Article
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);
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
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, test, test before you do anything drastic with it.
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 7400 reads


0