[Mimedefang] Tally script update

Cormack, Ken kcormack at acs.roadway.com
Wed Oct 22 16:36:38 EDT 2003


A couple weeks ago, at the request of several people, I sent along to the
list a little ksh script I run nightly, to count up some rough tallies of
sendmail and MIMEDefang rejections and the like.

If anyone's interested, I've just added the following output to that script.

AVERAGE RATE - MESSAGES PER MINUTE
  MIDNIGHT-8AM: 33
       8AM-5PM: 115
  5PM-MIDNIGHT: 48
       24 HOUR: 68

Like the rest of the script, it's a down-and-dirty (very dirty) function,
but it works.  It was a quick hack done with a lot of copy/paste, and the
amount of I/O seems absurd for what it's doing, but its fast enough for me,
so I've included it here for anyone that wants it.

##############################################
# grab each record recorded in each hour
grep "relay=" ${LOG} | awk '{ print $3 }' | cut -f1 -d":" >
/tmp/msg_rates.tmp

# count the number of records each hour, 00:00 to 07:59
CNT00=`cat /tmp/msg_rates.tmp | grep -c 00`
CNT01=`cat /tmp/msg_rates.tmp | grep -c 01`
CNT02=`cat /tmp/msg_rates.tmp | grep -c 02`
CNT03=`cat /tmp/msg_rates.tmp | grep -c 03`
CNT04=`cat /tmp/msg_rates.tmp | grep -c 04`
CNT05=`cat /tmp/msg_rates.tmp | grep -c 05`
CNT06=`cat /tmp/msg_rates.tmp | grep -c 06`
CNT07=`cat /tmp/msg_rates.tmp | grep -c 07`
# add up the totals for the 8 hours
let CNT0008="${CNT00} + ${CNT01} + ${CNT02} + ${CNT03} + ${CNT04} + ${CNT05}
+ ${CNT06} + ${CNT07}"
# divide by the number of minutes in 8 hours
let AVG0008="${CNT0008} / 480"

# count the number of records each hour, 08:00 to 16:59
CNT08=`cat /tmp/msg_rates.tmp | grep -c 08`
CNT09=`cat /tmp/msg_rates.tmp | grep -c 09`
CNT10=`cat /tmp/msg_rates.tmp | grep -c 10`
CNT11=`cat /tmp/msg_rates.tmp | grep -c 11`
CNT12=`cat /tmp/msg_rates.tmp | grep -c 12`
CNT13=`cat /tmp/msg_rates.tmp | grep -c 13`
CNT14=`cat /tmp/msg_rates.tmp | grep -c 14`
CNT15=`cat /tmp/msg_rates.tmp | grep -c 15`
CNT16=`cat /tmp/msg_rates.tmp | grep -c 16`
# add up the totals for the 9 hours
let CNT0817="${CNT08} + ${CNT09} + ${CNT10} + ${CNT11} + ${CNT12} + ${CNT13}
+ ${CNT14} + ${CNT15} + ${CNT16}"
# divide by the number of minutes in 9 hours
let AVG0817="${CNT0817} / 540"

# count the number of records each hour, 17:00 to 23:59
CNT17=`cat /tmp/msg_rates.tmp | grep -c 17`
CNT18=`cat /tmp/msg_rates.tmp | grep -c 18`
CNT19=`cat /tmp/msg_rates.tmp | grep -c 19`
CNT20=`cat /tmp/msg_rates.tmp | grep -c 20`
CNT21=`cat /tmp/msg_rates.tmp | grep -c 21`
CNT22=`cat /tmp/msg_rates.tmp | grep -c 22`
CNT23=`cat /tmp/msg_rates.tmp | grep -c 23`
# add up the totals for the 7 hours
let CNT1724="${CNT17} + ${CNT18} + ${CNT19} + ${CNT20} + ${CNT21} + ${CNT22}
+ ${CNT23}"
# divide by the number of minutes in 7 hours
let AVG1724="${CNT1724} / 420"

# count the 24-hour total (easier this way, than adding 24 seperate numbers)
CNT24=`cat /tmp/msg_rates.tmp | grep -c .`
# divide by the number of minutes
let AVG24="${CNT24} / 1440"

print "AVERAGE RATE - MESSAGES PER MINUTE"
print "  MIDNIGHT-8AM: ${AVG0008}"
print "       8AM-5PM: ${AVG0817}"
print "  5PM-MIDNIGHT: ${AVG1724}"
print "       24 HOUR: ${AVG24}\n\n"
###################################

Ken



More information about the MIMEDefang mailing list