Nagios - Is it possible to force check of all hosts by using a command in any given moment?

The easiest way by far is to simply restart Nagios. Upon a restart it will begin a new checking cycle.


So i was wondering, is there a way to force check all hosts?

SCHEDULE_FORCED_HOST_SVC_CHECKS external command is what you're looking for.

To get all of your hosts, take a look at the MK Livestatus:

# echo -e 'GET hosts\nColumns: host_name' | unixcat /usr/local/nagios/var/rw/live

then pipe to the SCHEDULE_FORCED_HOST_SVC_CHECKS command:

echo -e 'GET hosts\nColumns: host_name' | unixcat /usr/local/nagios/var/rw/live | while read host; do echo "[$(date +%s)] SCHEDULE_FORCED_HOST_SVC_CHECKS;$host;$(date +%s)\n" $(date +%s) >> /usr/local/nagios/var/rw/nagios.cmd; done

Tags:

Centos

Nagios