Prev | Current Page 916 | Next

Bryan Costales, Claus Assmann, George Jansen, Gregory Shapiro

"sendmail, 4th Edition"


14.3.4.1 message_volume.sh
Eachmail 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 from=), sendmail also logs the total
received size of the message in bytes (the size=).
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 of processes is enclosed in parentheses. An echo statement first
prints a zero. Then the list of +-suffixed sizes is printed. Finally, another echo prints a
character p. The resulting combined output might look like this:
0
123+
456+
7890+
p
The leading 0, th e+ suffixes, and the final p are commands for the dc(1) program,
which adds up all the numbers (the + suffixes) and prints the total (the p).


Pages:
904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928
Okulary mieszkania dieta light katalog stron Altanki