首页 > 代码库 > Nagios监控LINUX /var/log/message脚本
Nagios监控LINUX /var/log/message脚本
写的不好轻喷
#! /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
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脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。