码迷,mamicode.com
首页 > 移动开发 > 详细

Nagios监控LINUX /var/log/message脚本

时间:2015-01-27 15:05:34      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:nagios

写的不好轻喷
#! /bin/sh
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
currdate=`date | awk ‘{print $2,"*",$3}‘`

if [ `/usr/bin/sudo tail -20 /var/log/messages | grep "$currdate" | grep -i -E ‘error|fail|offline|suspending‘ | grep -v -E ‘nfs|ftp|sshd|telnet|login|timeout|authentication|cdrom|channel_handler|segfault|rip|rsp‘ |grep -v ‘(No output on stdout) stderr:‘| wc -l` -gt 0 ];then
dmsgtmp=`/usr/bin/sudo tail -20 /var/log/messages | grep "$currdate" | grep -i -E ‘error|fail|offline|suspending‘ | grep -v -E ‘nfs|ftp|sshd|telnet|login|timeout|authentication|cdrom|channel_handler|segfault|rip|rsp‘`
echo "============`date +%Y-%m-%d-%H:%M:%S`==============" >> /home/nagios/sys_error.log
echo "Linux OS log result:" >> /home/nagios/sys_error.log
echo "CRITICAL-$dmsgtmp" >> /home/nagios/sys_error.log
exit $STATE_CRITICAL
fi
if [ `/usr/bin/sudo tail -20 /var/log/messages | grep "$currdate" | grep -i -E ‘error|fail|offline|suspending‘ | grep -v -E ‘nfs|ftp|sshd|telnet|login|timeout|authentication|cdrom|channel_handler|segfault|rip|rsp‘ |grep -v ‘(No output on stdout) stderr:‘| wc -l` -eq 0 ];then
echo "OK"
exit $STATE_OK
fi

Nagios监控LINUX /var/log/message脚本

标签:nagios

原文地址:http://blog.csdn.net/ashic/article/details/43193765

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!