#!/bin/ksh # # written by Michael.Peters@Lazarusalliance.com as part of the # SafetyNET project. Use this to extract information from /var/adm/messages # and email the alert to the administrator. # # Usage: Execute from crontab every 5 minutes # # 4,9,14,19,24,29,34,39,44,49,54,59 * * * * /opt/alerts/auth-crit.sh > /dev/null # # PATH=/usr/bin:/usr/sbin:/usr/ucb:/bin SRVNM=`uname -n` DATE=`date '+%b %d'` DAY=`date '+%d'` HOUR=`date '+%H'` MONTH=`date '+%m'` MIN=`date '+%M'` LOGDIR=/var/adm/log/crit DATFILE=$LOGDIR/auth-crit.dat if [ ! -d $LOGDIR ] ; then mkdir -p $LOGDIR touch $DATFILE fi if [ $HOUR -eq "00" ]; then if [ $MIN -lt "05" ]; then > $DATFILE fi fi ### Add your email address below MAILADD=EMAIL_ADDRESS MAILFROM=auth_crit if [ `grep -c "$DATE $HOUR" $DATFILE` -eq 0 ] then ANSWER=`dmesg | grep -c "$DATE $HOUR.*auth.crit"` if [ $ANSWER -gt 0 ] then mail $MAILADD <> $DATFILE fi fi # Has a notice been sent this hour? if [ `grep -c "$DATE $HOUR" $DATFILE ` -lt 1 ] then if [ `grep "$DATE $HOUR" /var/adm/messages | grep -v auth.crit- | grep auth.crit | grep -c "+" ` -gt 0 ] then mail $MAILADD <> $DATFILE fi fi exit 0 ############################################################################## ### This script is submitted to BigAdmin by a user of the BigAdmin community. ### Sun Microsystems, Inc. is not responsible for the ### contents or the code enclosed. ### ### ### Copyright Sun Microsystems, Inc. ALL RIGHTS RESERVED ### Use of this software is authorized pursuant to the ### terms of the license found at ### http://www.sun.com/bigadmin/common/berkeley_license.jsp ##############################################################################