2006
07.28

we just needed something on the fly to monitor /var/adm/messages for certain output in nagios. this does the trick rather nicely and its not that big of a script either.

tested with nagios versions 2.3 – 2.5

#!/bin/bash

TMPFILE=/tmp/tmpfile.$$
#GREP=/usr/bin/egrep

egrep "(ALERT|EMERG|ERR|WARN|NOTICE|panic|halt)" /var/adm/messages > $TMPFILE
egrep "\\(sd[0-9]+\\):" /var/adm/messages >> $TMPFILE
egrep "su:.*su\ root.*failed" /var/adm/messages >> $TMPFILE
egrep "cpumem-diagnosis" /var/adm/messages >> $TMPFILE

#if [ `cat $TMPFILE | wc -l` -ge 1 ]; then
if [ -s $TMPFILE ]; then
        cat $TMPFILE
        rm -f $TMPFILE
        exit 1
The following two tabs change content below.

charlie root

VP of keeping it real / HNIC at pissedoffadmins.com
I bring the cold coffee.

Latest posts by charlie root (see all)

No Comment.

Add Your Comment