[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mailbox count and average size



I am not sure if anyone can use since most of the people on this list are technical. But just in case I thought I would share this very simple perl script that will give you:

number of mailboxes on a message store
average Mailbox size in MB
GeoMeans of Mailbox sizes in KB.

This scripts was written on a RHEL 6 box with perl, v5.10.1
This will require an install of a perl module. 

yum install perl-Statistics-Descriptive

Happy Hunting. 



Regards,
Pablo Garaitonandia
Penn State University
ITS, Applied Information Technologies
(814) 865-6385
pablo@psu.edu


[root@tcs9 scripts]# cat mailboxes.pl



#!/usr/bin/env perl
#
use strict;
use warnings;
use Statistics::Descriptive;
use integer;


my @quota;
my @numbers;
my @geomeans;
my $sum;
my $product = "1";


my $id=getpwuid($<);
#Esnure that zimbra user is being used
chomp $id;
if ($id ne "zimbra")
    {
        print STDERR "Error: must be run as zimbra user\n";
        exit (1);
    }

my $count = `zmprov gqu \`zmhostname\` | wc -l`;
my $stat0 = Statistics::Descriptive::Full->new();
my $stat1 = Statistics::Descriptive::Full->new();


open(QUO,"zmprov gqu `zmhostname` |") || die "Failed: $!\n";


while ( <QUO> )
    {
        push(@quota, $_);
    }


foreach my $quota (@quota)
    {
        chomp $quota;
        my ($user, $limit, $actual) = split(/ /, $quota);
        push (@numbers, $actual);
        $sum += $actual;

    }


my $arrSize = @quota;

foreach my $numbers(@numbers)
    {
        if ($numbers == 0)
            {
                push (@geomeans, "1");
            }
        else
        {
            push (@geomeans, $numbers);
        }
    }



$stat0->add_data(@numbers); my $mean = $stat0->mean();
$stat1->add_data(@geomeans); my $geo = $stat1->geometric_mean();

$mean = int($mean);
$geo = int($geo);

$mean = ($mean / 1024 ) / 1024;
$geo = $geo / 1024;

chomp $count;

print "Mailboxes: " . $count . "\n";
print "Means: " . $mean . " MB\n";
print "Geomeans: " . $geo . " KB\n";


__END__