simple nagios script for exp match in solaris

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
«
»

    Leave a Reply

    Your email address will not be published. Required fields are marked *