« Perl - Sorting multi-diminsional arraysForcing ARP table flush »

Zimbra Mailbox Size

03/02/09

Permalink 09:57:44 am, by admin Email , 148 words   English (US)
Categories: Project Gallery, Zimbra

Zimbra Mailbox Size

Here's a simple script that will provide a report on mailbox size for every mailbox on a Zimbra server. The report is sorted by box size in descending order:

#!/usr/bin/perl

my $all_accounts=`zmprov gaa`;
my @accounts = split(/\n/,$all_accounts);

my @sizes;
foreach $account (@accounts) {
my $mb_size=`zmmailbox -z -m $account gms`;
chomp($mb_size);
my $size;
if ($mb_size =~ /(.+)\ GB/) {
$size = $1 * 1024 * 1024;
} elsif ($mb_size =~ /(.+)\ MB/) {
$size = $1 * 1024;

} elsif ($mb_size =~ /(.+)\ KB/) {

$size = $1;
} elsif ($mb_size =~ /(.+)\ B/) {
$nsize = $1;
if ($nsize eq 0) {
$size = 0;
} else {
$size = abs(1024/$1);
};
};
$next = scalar(@sizes);
$sizes[$next][0] = $account;
$sizes[$next][1] = $size;
};

@sizes = sort { $a->[1] <=> $b->[1] } @sizes;

my $D=`date +'%m/%d/%y %H:%M'`; chomp($D);

print "==========================================================\n";
print " Zimbra Mailbox Report\n";
print " \n";
print " All sizes in KB.";
print " Generated on: $D\n";
print "==========================================================\n";

for (my $i = $#sizes-1; $i >= 0; $i--) {
printf ("%15.2f %s\n",$sizes[$i][1], $sizes[$i][0]);

};

Feedback awaiting moderation

This post has 1 feedback awaiting moderation...

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
PoorExcellent
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
July 2010
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Reliable Penguin offers Linux Server Migrations, Systems Administration & Programming. Visit our main website at:

http://www.reliablepenguin.com

Search

Bookmark and Share

XML Feeds

powered by b2evolution