Nagios可以识别4种状态返回信息,即 0(OK)表示状态正常/绿色、1(WARNING)表示出现警告/黄色、2(CRITICAL)表示出现非常严重的错误/红色、3(UNKNOWN)表示未知错误/深黄色。Nagios根据插件返回来的值,来判断监控对象的状态,并通过web显示出来,以供管理员及时发现故障。
还有需要客户端增加sudo权限:
1)vim /usr/local/nagios/etc/nrpe.cfg
command_prefix=/usr/bin/sudo(取消注释)
2)visudo
nagios ALL=(ALL) NOPASSWD: ALL(增加一行)
注释Defaults requiretty
1)vim /usr/local/nagios/libexec/nh_check_users
#!/bin/bash
# for nrpe check user
U=`who | wc -l`
if [ $U -le 3 ];then
echo "OK,current user is.$U"
exit 0
elif [ $U -gt 6 ];then
echo "CRITICAL,current user is.$U"
exit 2
else
echo "WARNING,current user is.$U"
exit 1
fi
2)vim /usr/local/nagios/libexec/check_xxx_err.sh
FILE=/u03/log/xxx/xxx.log
WARNING1=ORA-01861
ERROR1=OutOfMemory
ERROR2=ORA-06508
if [ ! -f $FILE ];then
echo "log file is not exit!"
exit 2
fi
if [ `tail -1000 $FILE|egrep -i "$ERROR1|$ERROR2"|wc -l` -gt 0 ];then
echo "CRITICAL--Please restart Weblogc!"
exit 2
elif [ `tail -1000 $FILE|egrep -i "$WARNING1"|wc -l` -gt 0 ];then
echo "WARNING--Please check Weblogic!"
exit 1
else
echo OK
exit 0
fi
本文转自leonardos51CTO博客,原文链接: http://blog.51cto.com/leomars/1896088,如需转载请自行联系原作者