#!perl # Many Thanks for # home777@mail.ru Ovseenko Andrey and # ######################################################################################## # Was originally prspoa.pl 1.0.0 25 OCT 2002 by # Koltogyan Sergey Rubenovich # skoltogyan@mail.ru # NPP AMI, Donetsk, ukraine ######################################################################################## # Rewritten-expanded by Rob Anderson (rob.anderson@americansouthwest.com) 24 MAR 2005 # Will run on NW5.0sp6A Perl + ActiveState PERL 5.8.4 for Windows at least. ######################################################################################## # Date Version Description ######################################################################################## # 03/24/05 1.00.01 Add FID to output & user/resource count # 03/30/05 1.00.02 Add Processed Date/Version, cleaned up FID and user name handling # 04/20/05 1.00.03 Add handling of GW6.5.4 at least # 05/19/05 1.01.00 Bug - not handling over threshold/limits users properly # Add red background for users over the size limit # Add orange background for users over the threshold size # Correct bug with processing time for job for 6.5 # 06/16/05 1.01.01 Bug fixes - Long mailbox ID's/Fid & MailboxID's with Spaces & add # version to footer ######################################################################################## ######################################################################################## ######################################################################################## ######################################################################################## ######################################################################################## ######################################################################################## ######################################################################################## # #Installation: # #Put the program somewhere accessable to your perl system. # #ex for Netware I've installed it in the sys:\perl\scripts directory # invoke from the NW5 command line: # load perl --noscreen sys:\perl\scripts\gwstats.pl # unload perl # ######################################################################################## ######################################################################################## ######################################################################################## ######################################################################################## ######################################################################################## ######################################################################################## sub doreport; #predeclaring the subroutine ### Below is code to get the current date and time ### ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); @nummonths = ("01","02","03","04","05","06","07","08","09","10","11","12"); @namemonths = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); @numyears = ("2002","2003","2004","2005"); if ($hour < 10) { $hour = "0$hour"; } if ($mday < 10) { $mday = "0$mday"; } if ($min < 10) { $min = "0$min"; } $year=$year+1900; $year_search = $year; $fmtdate = "@nummonths[$mon]/$mday/$year"; $sdate = "$year@nummonths[$mon]$mday"; $stime = "$hour\:$min"; ######################################################################################## ######################################################################################## #Change the below to your Company name if desired ######################################################################################## $coname = "Your Company Name Here"; ######################################################################################## ######################################################################################## # Enter your GW Domain and GW Po Information Below ######################################################################################## $gwdomain = "domain"; #enter the domain name for path purposes, and appearing on the report $gwpo = "po"; #enter the PO name for path purposes, and to appear on the report ######################################################################################## #Input and Ouptut Filenames here ######################################################################################### ## Note, unless you're using linux, you're going to want to use \ in your paths. Don't!# ## PERL doesn't like that very much. use /, eg f:/$gwpo/wpcsout/ofs/contents.log # ######################################################################################### my $TOSAVE = "sys:/novonyx/suitespot/docs/gwstats/$sdate-$gwdomain.html"; #puts into my novonyx webserver's directory my $FROMREAD = "mail:/$gwpo/wpcsout/ofs/contents.log"; #name of contents.log is set in during the GWCHECK run #my $INCLPUDB = -1; doreport; #actually executes the subroutine exit (0); #leave the program ######################################################################################## #No Changes below here unless you REALLY know what you're doing!!! ######################################################################################## sub doreport { @arr = (); open (FL, "<$FROMREAD") || die("Source File Error $!"); open (FL1, ">$TOSAVE") || die("Target File Error $!"); print FL1 "\n"; print FL1 "Groupwise Stats\n"; print FL1 "

$coname

\n"; print FL1 "

Groupwise System Statistics for $fmtdate

\n"; print FL1 "

For: ($gwdomain.$gwpo)

\n"; $progver='GWSTATS Version 01.01.01'; $BASESTR=' '; $user = ''; $size = ''; $inbox = ''; $outbox = ''; $trash = ''; $pousers = ''; $fid = ''; $processed = ''; $proctime = ''; $ver = ''; while () { if ($_ =~ /PROCESSING COMPLETED- total processing time:\s+(.{1,})/) { $proctime = $1; } if ($_ =~ /Accumulated task processing times spent on the job:\s+(.{1,})/) { #6.5 job time $proctime = $1; } if ($_ =~ /Processed on\s+(.{1,})/) { $processed = $1; } if ($_ =~ /Version\s+(.{1,})/) { $version = $1; } if ($_ =~ /Version\s+(\d+)/) { $ver = $1; } if ($_ =~ /Number of Users...............\s+(\w+)/) { $pousers = $1; } if ($_ =~ /Checking user =\s(.{1,14})\s*\(/) { $user = $1; } if ($_ =~ /Checking user =\s$user\s*\((\w+)\)/) { $fid = $1 } if ($_ =~ /Checking user =\s$user\s*\($fid\)\s+\d+\s+\w+\S\s+\S+\s\S+\s+\((.{1,}\s+)\[/) { $fullname = $1; } if ($_ =~ /(\d+) (\w+) in use by user's mail/) { $size = $1; $uom = $2; } if ($_ =~ /User stats: (\w+) InBox, (\w+) OutBox, (\w+) /) { $inbox = $1; $outbox = $2; $trash = $3; } if ($_ =~ /Disk space management values:\s+Size Limit - (\d+)(\w+),\s+Threshold -\s+(\S+)/) { $sizelim = $1; $uomthreshold = $2; $pctofthreshold = $3; } $exceedthreshold = -1; if ($_ =~ /Problem 90- Threshold limit exceeded\. Current size:\s+(\d+)(\w+)/) { $exceedthreshold = 1; $size = $1; $uom = $2; } $exceedlimit = -1; if ($_ =~ /Problem 89- Size Limit Exceeded\.\s+Current size:\s+(\d+)(\w+)/) { $exceedlimit = 1; $size = $1; $uom = $2; } # if ($user && $size && $fid) { ##This means there must be both a user name and the size > zeros and a FID if ($user && $size) { ##This means there must be both a user name and the size > zeros my %hash; $hash{'user'} = $user; $hash{'size'} = $size; $hash{'inbox'} = $inbox; $hash{'outbox'} = $outbox; $hash{'trash'} = $trash; $hash{'fid'} = $fid; $hash{'fullname'} = $fullname; $hash{'sizelim'} = $sizelim; $hash{'pctofthreshold'} = $pctofthreshold; $hash{'exceedthreshold'} = $exceedthreshold; $hash{'exceedlimit'} = $exceedlimit; push @arr, \%hash; $user = ''; $size = ''; $inbox = ''; $outbox = ''; $trash = ''; $fid = ''; $fullname = ''; $sizelim = ''; $pctofthreshold = ''; $exceedthreshold = -1; $exceedlimit = -1; } }; @arr = sort {$b->{'size'} <=> $a->{'size'}} @arr; print FL1 "
";
  print FL1 "
"; print FL1 ""; print FL1 "

Summary Information

\n"; print FL1 ""; print FL1 ""; print FL1 ""; print FL1 ""; print FL1 "
GroupWise Version:$version
Users/Resources in Post Office $gwpo:$pousers
Date GWCHECK Processed: $processed
GWCHECK Processing Time: $proctime
\n"; print FL1 "
";
  print FL1 "
"; print FL1 ""; if ($ver >= 6) { print FL1 ""; } print FL1 ""; if ($ver >= 6) { print FL1 ""; } print FL1 "\n"; foreach (@arr) { print FL1 ''; #white if ($_->{'exceedthreshold'} > 0) { print FL1 ''; #orange } if ($_->{'exceedlimit'} > 0) { print FL1 ''; #red } print FL1 '\n"; } print FL1 "
"; print FL1 "
Mailbox IDUser NameMailbox Size (in $uom)Inbox ItemsOutbox ItemsTrash ItemsFIDSize Limit (in $uomthreshold)% of Threshold
'; print FL1 $_->{'user'}; if ($ver >= 6) { print FL1 '
'; print FL1 $_->{'fullname'}; } print FL1 '
'; print FL1 $_->{'size'}; print FL1 '
'; print FL1 $_->{'inbox'}; print FL1 '
'; print FL1 $_->{'outbox'}; print FL1 '
'; print FL1 $_->{'trash'}; print FL1 '
'; print FL1 $_->{'fid'}; if ($ver >= 6) { print FL1 '
'; print FL1 $_->{'sizelim'}; print FL1 '
'; print FL1 $_->{'pctofthreshold'}; } print FL1 "
\n"; if ($ver >= 6) { print FL1 "
";
    print FL1 "
"; print FL1 ""; print FL1 "

Color Legend

\n"; print FL1 "\n"; print FL1 ""; print FL1 ""; print FL1 ""; print FL1 "
ColorDescription
Users Over Limit
Users Over Threshold
Users Under Quota
\n"; } print FL1 "



This page created at $fmtdate $stime
$progver
"; print FL1 "\© $year $coname
"; print FL1 ""; close(FL); close(FL1); }