Operating System - HP-UX
1832880 Members
2331 Online
110048 Solutions
New Discussion

Re: How to get syslog statistics

 
Steven Chen_1
Super Advisor

How to get syslog statistics

I would like to make one command to get statistics of how many users sending mails within certain timing period.

the syslog looks like:
--------------
Mar 29 15:10:20 6C: sendmail[10960]: PAA10958: to=, delay=00:00:01, xdelay=00:00:01, mailer=forgnout, relay=mx.mail.rcn.net. stat=Sent (OK id=14iilq-0005sP-00@mx06.mrf.mail.rcn.net)

Mar 29 15:12:53 6C:IRIS sendmail[10962]: PAA10962: from=, size
=1297, class=0, pri=31297, nrcpts=1, msgid=ED98@iupuimbx04.uits.iupui.edu>, proto=ESMTP, relay=hermes.iupui.edu [134.68.220
-------------------

I can use 'grep -c username SYSLOG' to find out the total number, but don't know how to use the time periods, such within one day, last two hours, etc.

Your help is greatly appreciated.

Steven
Steve
3 REPLIES 3
Rajeev Tyagi
Valued Contributor

Re: How to get syslog statistics

Steven,

You can use both sed and awk for this pupose.

Eg. # grep username SYSLOG > /tmp/sendmail
# sed -n '/Mar 25/,/Mar 26/p' /tmp/sendmail | wc -l

I hope this will help.

Felix Maurer
Occasional Advisor

Re: How to get syslog statistics

You may use a perl script called ssl againt mail.log

Kind regards

Felix
Christopher Caldwell
Honored Contributor

Re: How to get syslog statistics

If you don't need per user statistics (just in bound/outbound statistics for a given time period), mailstats is an effective command. mailstats gives a count of outbound messages (and bytes transferred) and a count of inbound messages (and bytes transferred) for each mailer you have defined:

# mailstats
Statistics from Tue Sep 29 19:27:05 1998
M msgsfr bytes_from msgsto bytes_to Mailer
0 0 0K 261684 1050037K prog
1 0 0K 5301 18066K *file*
3 4161328 364780298K 13385581 240319945K local
5 14058647 318345719K 5313552 156255770K esmtp
9 8 77K 3 37K uucp-old
========================================
T 18219983 683126094K 18966121 397643855K

mailstats maintains statistics from the time the
/etc/mail/sendmail.st
is created.

You can
1) periodically truncate this file to see what happens in a given time period.
or
2) use a program like mrtg to plot the statistics over time. mrtg might be used to plot the difference between two consecutive executions of mailstats.

You might check www.sendmail.org, The "Bat book" (sendmail), and a search of the web for mailstats to get some examples/source scripts for folks maintaining mail statisics.