#!/bin/sh ################################################################ # # showblock # # a script that lists who has been blocked by our filters in the # current /var/log/maillog # # Must be run with log access privilege (sudo or root will do :) # # Chuck Geigner # # Future Mods # 1) show blocking stats # # 11 Jul 2003 re-write! all the commented code below was disposed of, # being that, by jove, it was suck-city. I am embarassed to have # authored it that way. awk (or perl) was obviously the tool for this, # not "cut" - so see below for a sed/awk one-line pipe that does what # previously took 20 lines of other shell code... # #date|cut -c 9-10 > /tmp/dtest.tmp #sed 's/^ //g' /tmp/dtest.tmp > /tmp/dtest1.tmp #DTEST=`cat /tmp/dtest1.tmp` #if [ $DTEST -ge 10 ]; then # grep 'reject=550' /var/log/maillog |\ # cut -d" " -f 1-3,10- |\ # sed 's/(may be forged)//g'|\ # sed 's/reject=550 //g'|\ # sed 's/relay=//g' > /tmp/shblk.tmp #elif [ $DTEST -ge 1 -a $DTEST -le 9 ]; then # grep 'reject=550' /var/log/maillog |\ # cut -d" " -f 1-4,10- |\ # sed 's/(may be forged)//g'|\ # sed 's/reject=550 //g'|\ # sed 's/relay=//g' > /tmp/shblk.tmp #else # echo "\$DTEST has invalid value of $DTEST. quitting." # exit 1 #fi #more /tmp/shblk.tmp #rm /tmp/dtest*.tmp #rm /tmp/shblk.tmp awk -F, '/reject=550/ {print $1 $2 $5}' /var/log/maillog|\ awk '{print $1" "$2" "$3" ["$7"] "$10" "$11}'|\ sed 's/arg1=//'|less exit