Created
September 30, 2013 14:46
-
-
Save adamrb/6764862 to your computer and use it in GitHub Desktop.
Remove anything still acknowledged after the previous run.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
livestatus="/usr/local/nagios/var/rw/live" | |
acked_services="/usr/local/nagios/var/ack_services" | |
acked_hosts="/usr/local/nagios/var/ack_hosts" | |
now=`date +%s` | |
commandfile='/usr/local/nagios/var/rw/nagios.cmd' | |
# Clear acks on any currently acked service | |
while read sline; do | |
host=$(echo $sline | cut -d ";" -f 1) | |
service=$(echo $sline | cut -d ";" -f 2) | |
echo "Removing ack for $service on $host" | |
/usr/bin/printf "[%lu] REMOVE_SVC_ACKNOWLEDGEMENT;${host};${service}\n" $now > $commandfile | |
done < $acked_services | |
# Clear acks on any currently acked host | |
while read host; do | |
echo "Removing ack for $host" | |
/usr/bin/printf "[%lu] REMOVE_HOST_ACKNOWLEDGEMENT;${host}\n" $now > $commandfile | |
done < $acked_hosts | |
sleep 5 | |
# Make a list of anything that's still acknowledged. | |
services_filter="GET services\nColumns: host_name description\nFilter: acknowledged = 1" | |
hosts_filter="GET hosts\nColumns: host_name\nFilter: acknowledged = 1" | |
echo -e $services_filter | /usr/local/bin/unixcat $livestatus > $acked_services | |
echo -e $hosts_filter | /usr/local/bin/unixcat $livestatus > $acked_hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment