Hire me if you like: blake.irvin@gmail.com

Tuesday, February 16, 2010

Automatically Reporting Service Failures in OpenSolaris

Slap this in a cronjob and fill in the email addresses as you see fit:

#!/bin/bash

##
## Written by Blake Irvin - bcirvin@opensolaris.org
##

PATH=/usr/gnu/bin:/usr/bin:/usr/X11/bin:/usr/sbin:/sbin/

SERVICEISSUES=`svcs -H | grep -v "online\|legacy_run" | wc -l`
MAILTO=user@domain.com
RETURNADDRESS=user@domain.com

if [ $SERVICEISSUES != 0 ]
   then
      svcs -xv | mailx -r $RETURNADDRESS -s "$SERVICEISSUES services issues on $HOSTNAME" $MAILTO
else
   exit 0
fi

No comments:

Archive