Cybersecurity
DevOps Cloud (ADM)
IT Operations Cloud
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:
Here's how to do it:
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.
$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);