GroupWise Mailbox Size Report

0 Likes

Here's a simple script for parsing through a directory full of gwcheck logs and creating a .csv file which lists the postoffice, username, and mailbox size in KB for easy sorting. This is very useful for determining who would be impacted by a quota implementation.



Prerequisites:



  • Perl (I used Active Perl on my desktop computer)

  • GWCheck logs



Here's how to do it:


Run a GWCheck for each postoffice you want in the report, with the following options:

Analyze/Fix Databases
Structure
Contents
Fix Problems
Update user disk space totals



Save each of the log files as POname.log (where POname is the name of the postoffice) and put them all in a single directory. I used c:\gw stats in my example below.



Update the script to reflect your own pathnames for the folder where the log files are, and the resulting .csv file.



Run the script. It will parse through all the log files, and create a single .csv file listing the postoffice, username, and mailbox size in KB.



mailhogs.pl



$inpath = "c:/gw stats/";
open (OUT, ">c:/gw stats/gwdata.csv") || die "Cannot open csv file for write: $!";
print STDOUT "Parsing gwcheck output into csv\n";
opendir(DIR, $inpath);
@files = grep { /\.log/ } readdir(DIR);
closedir(DIR);
foreach $logfile (@files){
$infile = "$inpath$logfile";
open(IN, "< $infile") or die "can't open $infile: $!";
while (<IN>) {
if (/Post Office= ([a-z|A-Z] )\s/) {
$postoffice = $1;
print "$postoffice ";
}
if (/Checking user = (\w )\s/){
$username = $1;
print "$username ";
}
if (/([0-9] ) kbytes in use/){
$size = $1;
print "$size\n";
if ($username) {
print OUT "$postoffice,$username,$size\n";
$username = "";
}
}
}
close(IN);
}
close(OUT);


Labels:

How To-Best Practice
Comment List
  • Does it work on GW 12.0.4?
  • Hiya all...

    First of all let me say cheers to "alvaradc". Nice script, mate. I've used your script as a template and have created an updated version, if you don't mind:

    This version includes the reading and outputting of the Mailbox Size Limits as well, and also support PO names with a "-" in them, as a lot of people seem to think this is necessary in naming PO's...lol...

    Also cleaned up the layout a bit (and used my own naming for the variables), just so it was easier for me to read, and added some "Descriptions" in as well. Next version might even include additional fields - will cross that bridge when the need arises.

    Hope you like what I've done with it:

    ####################################
    ## Mail Usage script for GW7/8 by ##
    ## Tobie Steyn - 08 May 2014. ##
    ## Adapted from log parser script ##
    ## found on Cool Solutions with ##
    ## added field to include Limits. ##
    ## Also made layout friendlier & ##
    ## Post Office names support "-". ##
    ## ##
    ## -------:||:------- ##
    ## Thanks go to "alvaradc" for ##
    ## original script. ##
    ## CHEERS MATE!!! ##
    ## -------:||:------- ##
    ####################################

    ## Change locations below to reflect your file locations: ##

    $location = "c:/temp/gw_stats/";
    open (OUT, ">c:/temp/gw_stats/GW_PO_Output.csv") || die "Cannot open csv file for write: $!";

    ## Display what's happening.... ##

    print STDOUT "Extracting GWCheck output file into new csv...\n";

    ## Working... ##

    opendir(DIR, $location);

    @files = grep { /\.log/ } readdir(DIR);
    closedir(DIR);

    foreach $logfile (@files){
    $sourcefile = "$location$logfile";
    open(IN, "< $sourcefile") or die "can't open $sourcefile: $!";

    while () {
    if (/Post Office= ([a-z|A-Z|-]+)\s/){
    $postoffice = $1;
    print "$postoffice ";
    }

    if (/Checking user = (\w+)\s/){
    $username = $1;
    print "$username ";
    }

    if (/Disk space management values: Size Limit - ([0-9]+)/){
    $sizelimit = $1;
    print "$sizelimit ";
    }

    if (/([0-9]+) kbytes in use/){
    $mailsize = $1;
    print "$mailsize\n";
    if ($username) {
    print OUT "$postoffice,$username,$mailsize,$sizelimit\n";
    $username = "";
    }

    }
    }
    close(IN);
    }
    close(OUT);

    ##################
    ## That's it... ##
    ## Enjoy!!! ##
    ##################
  • I changed this line in your script, because of PO's starting with a number.

    Org line
    if (/Post Office= ([a-z|A-Z]+)\s/)

    Newline
    if (/Post Office= ([0-9|a-z|A-Z]+)\s/)

    Thanks
    - Michael Enevold
Related
Recommended