Page 1 of 1

host check_command

Posted: Fri Sep 30, 2016 7:56 am
by amprantino
A common scenario for hosts is to monitor the state based on ping using the check_command
However, some hosts doesn't reply to pings. So a more complex check command must be used.
define host {
host_name myhost
address 192.168.1.1
check_command check-host-alive-scenario
}
This check_command is also defined as a service, for various reasons.

define service{
use generic-service
host_name myhost
check_command check-host-alive-scenario
}

So it run twice for the same server, one as a service and one for the host check_command.

1) Is there a way to use the service sate to depict the same state as the service without running twice?

2) Is there a way to make server UP if at least on service is to non CRITICAL state ?

Re: host check_command

Posted: Fri Sep 30, 2016 12:54 pm
by lmiltchev
How is "check-host-alive-scenario" command defined?

If ICMP Ping requests are blocked on your host, you could define some alternative commands, using "check_http" or "check_tcp" (to check an open port).

Examples:

Code: Select all

$USER1$/check_http -H $HOSTADDRESS$
or

Code: Select all

$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$

Re: host check_command

Posted: Fri Sep 30, 2016 1:10 pm
by amprantino
Let me simplify:
myhost --> check_comamnd check_tcp
................. --> Service1 = check_tcp
This way "check_tcp" will run twice: one as myhost check_comamnd and one time as "Service1".

Is there a way to define "Service1" as the check_command of the host?

Re: host check_command

Posted: Fri Sep 30, 2016 2:00 pm
by mcapra
amprantino wrote: Is there a way to define "Service1" as the check_command of the host?
Not really. This is a limitation with how host objects are defined:
https://assets.nagios.com/downloads/nag ... tions.html

You could probably do something like call statusjson.cgi to get the plugin output and status code for Service1 then share that as output for your host's check command, but i'm not sure if that's any better than just running the check twice in terms of overhead. It's an option that comes to mind, though.

The JSON query generator is located at:
https://<nagios_host>/nagios/jsonquery.html