Here is a script I wrote which counts the number of rejected login attempts which occur on a daily basis and emails the details to a selected recipient. We have this running on HP-UX 11.11, but I think it should work for any Unix version, although might require a bit of tinkering. The idea behind it is that we wanted to see how many rejected logins occured each day so that we had a clearer idea of how many extra licenses we needed to buy...
Code:£!/bin/sh £ £ Rejected ServiceCenter Logins £ £ Setup Variables REPORT=/peregrine/logs/screject.log RECIPIENT=email.address@yourcompany.com OLDREP=/peregrine/logs/screject.old £ Setup Report Files rm $OLDREP touch $REPORT £ Filter today's SC.log file and pull out messages about rejected logins. awk -v "date=`date`" ' BEGIN { print date; print "------------------------------------------------------------------------- ------" ; c=0 } { if (match($0, "rejected") != 0) {print "Login for "$7" rejected at "$2" "subst r ($3, 1, 5) ;c++}} END { print;print "Total rejected logins: "c}' /peregrine/logs/sc.log > $REPORT 2>&1 sleep 5 £ Mail the output of the script to $RECIPIENT cat $REPORT | ux2dos | uuencode rejected_logins.txt | mailx -s "ServiceCenter Re jected Logins" $RECIPIENT sleep 5 mv $REPORT $OLDREP exit 0


Reply With Quote
?

Bookmarks