假如某个故障一时半会无法解决或计划停机维护,此时N多邮件看着心烦,要暂停报警一般会注释services.cfg相应的部分,很烦容易出错,现有nagios自带的方法如下:
- now=`date %s`
- commandfile='/var/spool/nagios/cmd/nagios.cmd'
- hosts="db01
- db02
- "
- services="MySQL_slave MySQL_slave_delay"
- message="Maintenance "
- #$ date -d 'Thu Jan 15 18:00:00 EST 2011' %s
- #1295132400
- #
- # date -d 'Thu Jan 16 00:00:00 EST 2011' %s
- #1295154000
- #
- # echo $((6*3600))
- #21600
- for host in $hosts; do
- printf "[%lu] SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME;${host};1295132400;1295154000;0;0;21600;user;${message}\n" $now > $commandfile
- done
/usr/bin/printf "[%lu] DISABLE_SVC_NOTIFICATIONS;${host};${service}\n" $now > $commandfile
万一某天你停掉了某个serices的监控,事后也忘了enable,很可能忽略这个services。无意中发现所有的监控情况都能在{nagios}/cache/nagios/status.dat,脚本分析一下,定期cron跑一下,发送那些services被disable了.
阅读(1248) | 评论(0) | 转发(0) |