自己编写Nagios监控脚本
发表于:2024-11-27 作者:热门IT资讯网编辑
编辑最后更新 2024年11月27日,Nagios报警状态有:ok WARNING WARNING UNKNOWN 四种状态。意思顾名思义,自己体会。根据脚本的返回值 0 1 2 3 来给出nagios判断信息。 OK=0 WARNING
Nagios报警状态有:ok WARNING WARNING UNKNOWN 四种状态。意思顾名思义,自己体会。
根据脚本的返回值 0 1 2 3 来给出nagios判断信息。 OK=0 WARNING=1 CRITICAL=2 UNKNOWN=3 下面是监控mysql备份是否存在的例子:- 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
- }