Mailing List CGatePro@mail.stalker.com Message #92844
From: Christian B. Ellsworth Capo <k@ellsworth.cl>
Subject: Re: User account disk usage
Date: Thu, 04 Oct 2007 15:56:16 -0400
To: CommuniGate Pro Discussions <CGatePro@mail.stalker.com>
Aaron wrote:
Is there a way to see the disk space usage for all accounts at once?  I
know you can select individual users and see what their usage is, but
am
I missing an obvious way of doing this for all the accounts across all
domains?
    


I'm sure someone has a handy CLI script that could generate that.

If I'm ever curious about stats like that, I just use some 3rd party
file-system based tools to report on the size of the actual user
directories, but maybe that's cheating. :)



#############################################################
This message is sent to you because you are subscribed to
  the mailing list <CGatePro@mail.stalker.com>.
To unsubscribe, E-mail to: <CGatePro-off@mail.stalker.com>
To switch to the DIGEST mode, E-mail to <CGatePro-digest@mail.stalker.com>
To switch to the INDEX mode, E-mail to <CGatePro-index@mail.stalker.com>
Send administrative queries to  <CGatePro-request@mail.stalker.com>
  
I have a Handy script that calculates mail usage and file usage per user, and has a review for the whole domain... if you have many users and domains, it's way better to >'ed to a file...

i hope it helps.

PS: Roman P. made most of this script, I added very little things.

#!/usr/bin/perl -w
#

use strict;
use CLI;  #get one from www.stalker.com/CGPerl



print "CommuniGate Main Domain postmaster password: ";
my $Password = <STDIN>;
chomp $Password;

####  YOU SHOLD REDEFINE THESE VARIABLES !!!

my $CGServerAddress='127.0.0.1';  #IP or domain name;
my $Login='postmaster';

# the end of the customizeable area



my ($sumAllMail,$sumAllWeb,$sumDomainMail,$sumDomainWeb)=(0,0,0,0);

my $cli = new CGP::CLI( { PeerAddr => $CGServerAddress,
                         PeerPort => 106,
                         login    => $Login,
                         password => $Password } )
  || die "*** Can't login to CGPro CLI: ".$CGP::ERR_STRING."\n";



processAllDomains();
$cli->Logout;
exit(0);

sub processAllDomains {
 my $DomainList = $cli->ListDomains()
              || die "*** Can't get the domain list: ".$cli->getErrMessage.", quitting";
 foreach(@$DomainList) {
   processDomain($_);
 }
 print sprintf("Total for all domains: mail %dK, files %dK\n",$sumAllMail/1024,$sumAllWeb/1024);
}         sub processDomain {
 my $domain=$_[0];
 print "Domain: $domain\n";
 $sumDomainMail=$sumDomainWeb=0;
 my $accountList = $cli->ListAccounts($domain)
   || die "*** Can't get accounts for $domain: ".$cli->getErrMessage."\n";

 foreach(keys %$accountList) {
   processAccount("$_\@$domain");
 }
 print sprintf("Total for domain $domain: mail %dK, files %dK\n",$sumDomainMail/1024,$sumDomainWeb/1024);
 print "---------------------------\n";
 $sumAllMail+=$sumDomainMail;  $sumAllWeb+=$sumDomainWeb;
}


sub processAccount {
 my $account=$_[0];
 #print "Account: $account\n";

 my $accMail = $cli->GetAccountInfo($account,'StorageUsed');
 $accMail=$1 if($accMail=~/(\d+)/);

 my $accInfo = $cli->GetWebFilesInfo($account) || die "*** GetWebFilesInfo failed for $account: ".$cli->getErrMessage."\n";
 my $accWeb=$accInfo->[0];
 $accWeb=$1 if($accWeb=~/(\d+)/);
 #my $quota = $cli->GetAccountSettings($account,'MaxAccountSize');
 print sprintf("$account: mail %dK, files %dK\n",$accMail/1024,$accWeb/1024);

 $sumDomainMail+=$accMail;
 $sumDomainWeb+=$accWeb;
}

__END__


Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster