Script bash per acknowledge di Host e services Nagios
Jump to navigation
Jump to search
- Per effettuare l'ACK di host:
#!/bin/sh # This is a sample shell script showing how you can submit the ACKNOWLEDGE_HOST_PROBLEM command # to Nagios. Adjust variables to fit your environment as necessary. hosttoack=$1 now=`date +%s` commandfile="/var/nagios/rw/nagios.cmd" if [ "a$hosttoack" = "a" ]; then echo ERROR: Need Nagios Host name to use in Ack exit 1 fi /usr/bin/printf "[%lu] ACKNOWLEDGE_HOST_PROBLEM;$hosttoack;1;1;1;nagiosadmin;Down I know\n" $now > $commandfile
- Per effettuare l'ACK di services:
#!/bin/sh # This is a sample shell script showing how you can submit the ACKNOWLEDGE_SVC_PROBLEM command # to Nagios. Adjust variables to fit your environment as necessary. now=`date +%s` commandfile='/var/lib/nagios3/rw/nagios.cmd' echo ACKNOWLEDGE_SVC_PROBLEM $1 $2 /usr/bin/printf "[%lu] ACKNOWLEDGE_SVC_PROBLEM;$1;$2;2;1;1;nagiosadmin;$3\n" $now > $commandfile
- Esempio di esecuzione:
for SRV in SERVICE1 SERVICE2 SERVICE3; do ./nagios-ack-service hostname.example.com $SRV "This is the ACK comment"; done