I've fixed many issues on servers which indicated errors on Nagios but for some reason the alert is still up even though the problem has been fixed. So i was wondering, is there a way to force check all hosts?
I've fixed many issues on servers which indicated errors on Nagios but for some reason the alert is still up even though the problem has been fixed. So i was wondering, is there a way to force check all hosts?
The easiest way by far is to simply restart Nagios. Upon a restart it will begin a new checking cycle.
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:
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
Here's a bash script based on Nagios' sample script and the external command "SCHEDULE_FORCED_HOST_SVC_CHECKS":
https://github.com/joshforcier/nagiosForceImmediateCheck
Here is a Nagios XI component to force an immediate check on multiple hosts/services.