Nagios报警状态有:ok WARNING WARNING UNKNOWN 四种状态。意思顾名思义,自己体会。
- vi check_backfiles
- #!/bin/bash
- # Author Steven
- # This scripts is used to monitor database back file.
- OK=0
- WARNING=1
- CRITICAL=2
- UNKNOWN=3
- #Yerterday
- date=`date +%Y-%m-%d -d "-1 day"`
- BACKFILE=/data/mysqlbak/operator$date.sql.gz
- #echo $size
- if [ -f ${BACKFILE} ];then
- size=`du -s $BACKFILE | awk '{print $1}'`
- if [ ${size} -lt 1000 ];then
- echo "Mysql back file size is error!!!"
- exit $WARNING
- fi
- echo "Mysql back file is exist!"
- exit $OK
- else
- echo "Mysql back file don't exist!"
- exit $CRITICAL
- fi
- define service{
- use mail-service
- host_name static
- service_description check_backfiles
- check_command check_nrpe!check_backfiles
- }