host check_command

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
amprantino
Posts: 140
Joined: Thu Apr 18, 2013 8:25 am
Location: libexec

host check_command

Post 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 ?
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: host check_command

Post 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$
Be sure to check out our Knowledgebase for helpful articles and solutions!
amprantino
Posts: 140
Joined: Thu Apr 18, 2013 8:25 am
Location: libexec

Re: host check_command

Post 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?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: host check_command

Post 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
Former Nagios employee
https://www.mcapra.com/
Locked