Xref: utzoo comp.mail.sendmail:2779 comp.lang.perl:4310 Path: utzoo!censor!geac!torsqnt!hybrid!scifi!bywater!uunet!rbj From: rbj@uunet.UU.NET (Root Boy Jim) Newsgroups: comp.mail.sendmail,comp.lang.perl Subject: Re: Tools to analyze mail log Message-ID: <124175@uunet.UU.NET> Date: 27 Feb 91 00:26:42 GMT References: Followup-To: comp.mail.sendmail Organization: UUNET Communications Services, Falls Church, VA Lines: 37 In article ehrlich@cs.psu.edu (Dan Ehrlich) writes: >Does anyone have or know of any tools that will analyze a sendmail log? I >am looking for statistics like number of messages/bytes to/from by >host/user. If there is something out there that will do this (do not really >care if its C code, awk, perl, etc) I would appreciate hearing from you. Well, yes and no. Rick wants us to log downtime. Sometimes I forget the exact minute we go down and come back up. We have a slightly different perspective on mail than most people. If we aren't delivering mail, we're down! The following script checks for sendmail messages differing by more than one minute. Of course it barfs on 2359-0000, but who cares? I suppose it could be adapted to any similar log. #! /usr/local/bin/perl # # Scan sendmail log for missing intervals # This usually means downtime # `date`=~ /^....(...)/; $mon=$1; $old="0000"; $ARGV = shift || '/var/log/sendmail'; open(LOG,$ARGV) || die "can't open $ARGV"; while () { s/^$mon .. (..):(..):.*\n/$1$2/o; next if $_ eq $old; print "$old-$_\n" if $_ ne $new; $new = $old = $_; $new =~ s/(..)59/${1}99/; $new++; } -- [rbj@uunet 1] stty sane unknown mode: sane