Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
SyslogScan::Summary(3)User Contributed Perl DocumentatioSyslogScan::Summary(3)

       SyslogScan::Summary -- encapsulates a tally of how many bytes people
       have sent and received through sendmail

	   Use SyslogScan::Summary;
	   Use SyslogScan::DeliveryIterator;

	   my $iter = new SyslogScan::DeliveryIterator(syslogList =>
	   my $summary;
	       # 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	sent or	received.
	       # 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{''};
	   if (defined $usage)
	       print "Here is the usage	of John	Doe at\n";
	       print $usage -> dump();
	       print "John Doe has neither sent	nor received messages lately.\n";

       A 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

       static new() method
	   new takes as	arguments a (possibly null) list of
	   SyslogScan::DeliveryIterator	objects, from which it extracts	and
	   registers all queued	deliveries.

       registerDelivery() method
	   registerDelivery takes as its first argument	a SyslogScan::Delivery
	   object followed by up to two	optional patterns.  If the first
	   pattern is specified, only those e-mail addresses which match the
	   pattern are tallied.	 This enables you to create an accounting
	   summary for only those users	at your	site.

	   If the second pattern is also specified, then deliveries will only
	   be registered to the	person matched by the first pattern if the
	   second pattern matches the address at 'the other end	of the pipe'.

	   Pattern-matches are case-insensitive.  Remember the '(?!regexp)'
	   operation if	you want only addresses	which do _not_ match the
	   pattern to get passed through the filter.  For example, if mail to
	   or from 'support' is	exempt from billing charges, note that the


	   does	_not_ match '' but _does_ match

       registerAllInIterators()	method
	   Takes as parameters two patterns and	a list of iterators, then
	   feeds deliveries in the iterators and the patterns to

	   For example:

	       $sum -> registerAllInIterators('foo\.com$','^(?!.*bar\.com$)',@iterList)

	   will	bill users at for all mail extracted from @iterList
	   which was sent from to somewhere besides, or	sent
	   to from somewhere besides

       dump() method
	   dump	returns	a string containing address lines alternating with
	   usage reports.  Usage reports are in	the form:

		   B#,Bb	S#,Sb	     R#,Rb


	   B# is the number of messages	broadcast B# is	the total number of
	   bytes broadcast

	   S# is the number of messages	sent S#	is the total number of bytes

	   R# is the number of messages	received R# is the total number	of
	   bytes received

       persist() method
	   persist takes as its	single argument	an output file-handle, and
	   then	persists the state of the summary to the file.

       static restore()	method
	   restore takes as its	single argument	an input file-handle which
	   stores the results of a previous persist() command, and then
	   returns a copy of the object	in the state in	which it was
	   originally persisted.

       addSummary() method
	   addSummary takes as its single argument a second
	   SyslogScan::Summary object, and then	adds this second summary to
	   the $self object.

   Example of use
       Suppose I have a	function getTodaySummary() which gets a	Summary	of the
       last 24 hours of	sendmail logging.

	   my $summary = getTodaySummary();
	   $summary -> persist(\*SUMMARY1);
	   exit	0;

	   # wait 24 hours

	   my $summary = getTodaySummary();
	   $summary -> persist(\*SUMMARY2);
	   exit	0;

	   # some time later, you decide you want a summary of the total
	   # for both days.  So, you write this	program:

	   my $sum = SyslogScan::Summary -> restore(\*INSUM1);

	   my $sum2 = SyslogScan::Summary -> restore(\*INSUM2);

	   $sum	-> addSummary($sum2);
	   print "Here is the grand total for both days:\n\n";
	   print $sum -> dump();

       A 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.

       The author (Rolf	Harold Nelson) can currently be	e-mailed as

       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.

       SyslogScan::Usage, SyslogScan::DeliveryIterator,	SyslogScan::Delivery,

perl v5.32.0			  1997-11-24		SyslogScan::Summary(3)


Want to link to this manual page? Use this URL:

home | help