Script won't be executed on remote host

Hi everybody,

I stuck on a strange problem and I hope to find help here:
We want to monitor if a system requires a reboot. So I downloaded check_reboot.sh from the icinga exchange and put the script on the server (and also on the icinga node), like I did it hundred times before. In commands.conf I added the check command:

object CheckCommand “check_restart” {
import “plugin-check-command”
command = [ PluginDir + “/check_reboot.sh” ]
}

For testing purposes I’ve had limit the check on two machines in my services template:

apply Service “Reboot Required” {
import “generic-service”
check_command = “check_restart”
command_endpoint = host.vars.remote_client
enable_notifications = false
enable_perfdata = false
check_interval = 120
assign where host.name == “REMOTEHOST”
assign where host.name == “ICINGAHOST”
}

The icinga client is installed on the remote host an I told Icinga to run the script on the remote host.
Icinga tells me for the remote host “Check command ‘check_restart’ does not exist.” and remains in unknown state.
If I enter the check command in the commands.conf on the remote host, everything is fine and the script is working fine. I’ve never added any commands to the commands.conf on the remote hosts and I was able to monitor disk states, cpu, memory, etc. on the same way via the agent, but this script drives me crazy.
I’ve no clue what’s the problem … has somebody had an likely problem with this script?
We’re on Icinga2 r2.11.2-1 on Ubuntu 16.04.

I don’t really understand your description. In general, you need to have the object definition on all hosts. You could verify this via:

icinga2 object list -n check_restart

A common way to achieve this, is to put the object definition into the global-templates folder. For disk states, cpu, memory, etc. it’s already done by the ITL.

Hi,
I’ve a global templates, I didn’t write it extra, sorry.
If I fire up the command icinga2 object list -n check_restart, there is no listing on the remote host. The same command on the icinga node gives me the answer where the command is declared. But why not on the remote host?

Is global-templates defined in zones.conf on your remote hosts?

Did you check the logs, you should find something like

Copying 2 zone configuration files for zone ‘global-templates’

after you have initiated a reload.

Global Templates are defined on remote hosts:

object Zone “global-templates” {
global = true
}

I cannot find any lines matching your suggest. There are entries for syncing runtime objects to master, but not for copying config file for global-templates.