Nagios monitoring LINUX/var/log/message script
Not easy to write #! /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