Gathering Statistics from syslog
The logfiles that syslog creates provide a wealth of information that can be used to examine and tune the performance of sendmail. To illustrate, we will present a simple shell script for printing daily total message volume.
In the following discussion, we will assume that
sendmail logging is enabled
option, LogLevel on page 1040, is
nonzero) and that all syslog(8)
messages for the facility
Each mail message that sendmail receives for delivery (excluding those processed from the queue) causes sendmail to log a message such as this:
date host sendmail[pid]: quid: from=sender, size=bytes, ...
That is, for each
sender that is logged (the
sendmail also logs the total
received size of the message in
By summing all the
size= lines in a
/var/log/syslog file, we can
generate the total volume of all messages received
for the period represented by that file. One way
to generate such a total is shown in the following
Bourne shell script:
#!/bin/sh LOG=/var/log/syslog TOTAL=`(echo 0; sed -e '/size=/!d' -e 's/.*size=//' -e 's/,.*/+/' $LOG; echo p; ) | dc` echo Total characters sent: $TOTAL
The sed(1) selects only
the lines in /var/log/syslog
that contain the expression
size=. It then throws away all but the number
immediately following each
size= (the actual number
of bytes of each message), and appends a
+ to each.
The entire sequence ...