#!/bin/ksh

# Public domain. Use as you wish.

EMAIL=nickus@gmail.com
TMPFILE=/tmp/svcs.output.$$

export PATH=/usr/bin

svcs -x >$TMPFILE

#
# check if the file size is greater than zero
# which means we got some output from svcs and
# therefore a service is bad
#
if [ -s $TMPFILE ]; then
	cat $TMPFILE | mailx -s "Service failed on `hostname`" $EMAIL
fi

rm -f $TMPFILE
