chkuser 2.0 - logging summary

Here included is a small and simple shell script, tailored for my needs. It would be very simple to adapt it to your system and have a good report of your chkuser activity.

NOTE:

  • command [-yesterday] [service] is the complete command line
  • -yesterday is the optional parameter for yesterday log summary
  • optional service name is used to select which SMTP service must be shown. This is the name used by splogger. No name means ALL SMTP services.
  • zfile=/tmp/maillog.tmp.$$ is the location of a temporary file
  • zcat /var/log/maillog.0.gz is needed to display yesterday logging. Point it to your current yesterday file.
  • cat /var/log/maillog is needed for your today logs. Point it to your current today file.

 

 

#!/bin/sh
zfile=/tmp/maillog.tmp.$$
mygrep="grep" mygrepc="grep -c"
if [ "$1" = "-yesterday" ]
then shift;
command="zcat /var/log/maillog.0.gz"
else
command="cat /var/log/maillog"
fi
if [ "$1" = "" ]
then
stringtmp=""
else stringtmp=" $1: "
fi
$command | grep "$stringtmp" > $zfile
echo -n "CHKUSER entries "; $mygrepc CHKUSER $zfile
echo -n "CHKUSER accepted null senders "; $mygrepc \
"CHKUSER accepted null sender" $zfile
echo -n "CHKUSER rejected senders "; $mygrepc "CHKUSER rejected sender" $zfile
echo -n "CHKUSER accepted senders "; $mygrepc "CHKUSER accepted sender" $zfile
echo -n "CHKUSER rejected rcpts "; $mygrepc "CHKUSER rejected rcpt" $zfile
echo -n "CHKUSER accepted rcpts "; $mygrepc "CHKUSER accepted rcpt" $zfile
echo -n "CHKUSER rejected relaying "; $mygrepc "CHKUSER rejected relaying" $zfile
echo -n "CHKUSER accepted relaying "; $mygrepc "CHKUSER relaying rcpt" $zfile
echo -n "CHKUSER mbx overquota "; $mygrepc "CHKUSER mbx overquota" $zfile
echo -n "CHKUSER max rcpt intrusion triggers "; $mygrep \
"CHKUSER intrusion threshold" $zfile | $mygrepc "allowed rcpt"
echo -n "CHKUSER max wrong rcpt intrusion triggers "; $mygrep \
"CHKUSER intrusion threshold" $zfile | $mygrepc "allowed invalid rcpt"
echo -n "CHKUSER rejected intrusions "; $mygrepc "CHKUSER rejected intrusion" $zfile
rm -f $zfile