We have a script that disables host and service checks when we start or stop a server, and we don't have a way currently to do this for passive checks. The DISABLE_PASSIVE_SERVICE_CHECKS does not fit our need as it requires the service name, which varries based on the host.
Code: Select all
#!/bin/bash
# This is a sample shell script showing how you can submit the DISABLE_HOST_SVC_CHECKS command
# to Nagios. Adjust variables to fit your environment as necessary.
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
servers=(Nagios Services)
[ "$#" -lt 1 ]
for host do
/bin/printf "[%lu] DISABLE_HOST_SVC_CHECKS;${host%-*}\n" $now > $commandfile
/bin/printf "[%lu] DISABLE_HOST_CHECK;${host%-*}\n" $now > $commandfile
/bin/printf "[%lu] DISABLE_PASSIVE_HOST_CHECKS;${host%-*}\n" $now > $commandfile
done
for i in "${servers[@]}"; do
for host do
ssh -tt $(whoami)@$i 'bash -s' << EOF
/bin/printf "[%lu] DISABLE_HOST_SVC_CHECKS;${host%-*}\n" $now > $commandfile && \
/bin/printf "[%lu] DISABLE_HOST_CHECK;${host%-*}\n" $now > $commandfile && \
/bin/printf "[%lu] DISABLE_PASSIVE_HOST_CHECKS;${host%-*}\n" $now > $commandfile
exit
EOF
done
done