![]() |
![]()
| ![]() |
![]()
NAMESyslogScan::Summary -- encapsulates a tally of how many bytes people have sent and received through sendmail SYNOPSISUse SyslogScan::Summary; Use SyslogScan::DeliveryIterator; my $iter = new SyslogScan::DeliveryIterator(syslogList => [/var/log/syslog]); my $summary; if (defined $DOING_IT_THE_HARD_WAY_FOR_NO_PARTICULAR_REASON) { # feed a series of SyslogScan::Delivery objects $summary = new SyslogScan::Summary(); my $delivery; while ($delivery = $iter -> next()) { $summary -> registerDelivery($delivery); # You would instead use: # $summary -> registerDelivery($delivery,'foo\.com\.$') # if you only cared to get statistics relating to how # much mail users at foo.com sent or received. } } else { # slurps up all deliveries in the iterator, # producing the same effect as the block above $summary = new SyslogScan::Summary($iter); } print $summary -> dump(); use SyslogScan::Usage; my $usage = $$summary{'john_doe@foo.com'}; if (defined $usage) { print "Here is the usage of John Doe at foo.com:\n"; print $usage -> dump(); } else { print "John Doe has neither sent nor received messages lately.\n"; } DESCRIPTIONA SyslogScan::Summary object will 'register' a series of SyslogScan::Delivery objects. All registered deliveries are grouped by sender and receiver e-mail addresses, and then added up. Three sums are kept: Total Bytes Recieved, Total Bytes Sent, and Total Bytes Broadcast. Methods
Example of useSuppose I have a function getTodaySummary() which gets a Summary of the last 24 hours of sendmail logging. my $summary = getTodaySummary(); open(SUMMARY1,">summary1.sav"); $summary -> persist(\*SUMMARY1); close(SUMMARY1); exit 0; # wait 24 hours my $summary = getTodaySummary(); open(SUMMARY2,">summary2.sav"); $summary -> persist(\*SUMMARY2); close(SUMMARY2); exit 0; # some time later, you decide you want a summary of the total # for both days. So, you write this program: open(INSUM1,"summary1.sav"); my $sum = SyslogScan::Summary -> restore(\*INSUM1); open(INSUM2,"summary2.sav"); my $sum2 = SyslogScan::Summary -> restore(\*INSUM2); $sum -> addSummary($sum2); print "Here is the grand total for both days:\n\n"; print $sum -> dump(); InternalsA SyslogScan::Summary object is a hash of SyslogScan::Usage objects, where the key is the e-mail address of the user in question. SyslogScan::Usage has its own man page which describes how to extract information without having to use the dump() method. AUTHOR and COPYRIGHTThe author (Rolf Harold Nelson) can currently be e-mailed as rolf@usa.healthnet.org. This code is Copyright (C) SatelLife, Inc. 1996. All rights reserved. This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself. In no event shall SatelLife be liable to any party for direct, indirect, special, incidental, or consequential damages arising out of the use of this software and its documentation (including, but not limited to, lost profits) even if the authors have been advised of the possibility of such damage. SEE ALSOSyslogScan::Usage, SyslogScan::DeliveryIterator, SyslogScan::Delivery, SyslogScan::ByGroup
|