Nagios监控LINUX /var/log/message脚本
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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。