Hi,
I am an absolute beginner of Icinga. I have a Linux server running Icinga2 and a Windows server for testing. So far I have only operated Icinga2 via the GUI. So far it works well with existing checks. Now I would like to install my own script and this dont work with the instructions found on the net.
e.g.
I have the file on the Linux server first:
/etc/icinga2/conf.d/commands.conf edited.
I simply copied the part from the link above and appended it to the end of the existing commands.conf.
object CheckCommand "powershell_check" {
import "plugin-check-command"
command = [ "C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe" ]
arguments = {
"-command" = {
value = "$ps_command$"
order = -1
}
"-warn" = {
value = "$ps_warn$"
}
"-crit" = {
value = "$ps_crit$"
}
";exit" = {
value = "$LastExitCode"
}
}
}
then I have the file on the Linux server
/etc/icinga2/conf.d/services.conf edited. Again, I simply copied the part from the example and appended it to services.conf.
Now I would have expected to see the service somewhere in the GUI. The following parameters are also not entirely clear to me:
command_endpoint = host.address
assign where host.vars.os == “windows”
Do I have to set the variable beforehand or is this an example and individual?
How can I simply assign the service to my test server?
The Powershell script (plugin) must be on my test server. If it is not there I should at least get an error message in my gui?
When you put your check command in this file, you would have to do this on every Windows machine as well. Best practice is to put all new Windows command objects in a global zone that is also existing at your Windows machines. We are using windows-commands as global zones to achieve this.
assign where host.vars.os == “windows”
This just one example to assign a service to many hosts (which have definied `vars.os = “windows”)
For tests you can simply assign a service to test server with e.g.:
ok, i thought i just have to configure on the server. Now I have entered the entries in the commands.conf and in the Services.conf on the Windows test server. In the GUI I see neither the service nor the command. Should I see them in the GUI?
Yes, there is a way to configure it only on the server (which I’ve described). No seeing it in the GUI is most properly because your assign rule does not fit. After changing you conf-files run icinga2 daemon -C and check with icinga2 object list if your service object has been generated.
Don’t mind, newbies questions are welcome. First you need to add such a section to every zones.conf:
object Zone "windows-commands" {
global = true
}
Second, you need to create the according directory /etc/icinga2/zones.d/windows-commands/ at your master only. Third, place every command object that shall be executed on your Windows agent in that directory only. Every time icinga2 gets a reload trigger this directory incl. every sub directory is sychronized to all nodes that have windows-commands as global zone defined.
in the zones.conf of my Agent and in the /etc/icinga2/zones.conf from my Server.
I have create a folder /etc/icinga2/Zones.d/windows-commands/
In this folder I create a file “win_powershellcheck_x86.conf”
After a deploy from my Icinga2 GU I was hoping to find the win_powershell_x86.conf file on the agent. But it is not there. In the GUI cannot find the zone windows-command.
Now I have the zone “windows-commands” on the server deleted. Then created the zone “windows commands” via the director. Now I see the following output on the agent:
c:\Program Files\ICINGA2\sbin>icinga2.exe object list -n windows-commands
Object 'windows-commands' of type 'Zone':
% declared in 'C:/ProgramData/icinga2/var/lib/icinga2/api/zones/director-global/director/zones.conf', lines 1:0-1:29
* __name = "windows-commands"
* endpoints = null
* global = true
% = modified in 'C:/ProgramData/icinga2/var/lib/icinga2/api/zones/director-global/director/zones.conf', lines 2:5-2:17
* name = "windows-commands"
* package = "_cluster"
* parent = ""
* source_location
* first_column = 0
* first_line = 1
* last_column = 29
* last_line = 1
* path = "C:/ProgramData/icinga2/var/lib/icinga2/api/zones/director-global/director/zones.conf"
* templates = [ "windows-commands" ]
% = modified in 'C:/ProgramData/icinga2/var/lib/icinga2/api/zones/director-global/director/zones.conf', lines 1:0-1:29
* type = "Zone"
* zone = "director-global"
On The Server I get now a warning by the command icinga daemon -C
[2020-07-10 09:52:57 +0200] warning/config: Ignoring directory ‘/etc/icinga2/zones.d/windows-commands’ for unknown zone ‘windows-commands’.
Now I have run the kickstart and I see the zone “windows-commands” in the Director. The output from the command “icinga2.exe object list -n windows-commands” is empty.