Novell Cool Solutions

GroupWise Mailbox Size Report



By:

November 10, 2009 2:24 pm

Reads:8,918

Comments:2

Score:4

Print/PDF

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);

1 vote, average: 4.00 out of 51 vote, average: 4.00 out of 51 vote, average: 4.00 out of 51 vote, average: 4.00 out of 51 vote, average: 4.00 out of 5 (1 votes, average: 4.00 out of 5)
You need to be a registered member to rate this post.
Loading...Loading...

Categories: Uncategorized

2

Disclaimer: This content is not supported by Novell. It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test it thoroughly before using it in a production environment.

2 Comments

  1. By:enevold

    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

  2. By:sp2490911

    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!!! ##
    ##################

Comment

RSS