Getting All Users Quota Data

Getting All User Quota Data With Zmsoap

   KB 21892        Last updated on 06/20/2016  




0.00
(0 votes)

Purpose

Getting All User Quota Data With Zmsoap.

Resolution

[zimbra@mail32 ~]$ zmsoap -z GetQuotaUsageRequest

<GetQuotaUsageResponse xmlns="urn:zimbraAdmin" more="0" searchTotal="6">
  <account limit="0" used="1775390" name="admin@mail32.zimbra.DOMAIN.com" id="fcdb6b46-f55a-4f60-8496-31e2e79f30d6"></account>
  <account used="9765" id="dc158043-4b02-4f85-9d8a-bf7446188117" limit="0" name="ajcody@mail32.zimbra.DOMAIN.com"></account>
  <account used="9146" name="wiki@mail32.zimbra.DOMAIN.com" id="ec49fa30-3ed9-4574-baf1-ad9efae23637" limit="0"></account>
  <account name="ham.kvttsx2i@mail32.zimbra.DOMAIN.com" id="9c2d21ef-57ea-412d-b848-3853b67df2d8" used="0" limit="0"></account>
  <account used="0" limit="0" id="70f29afa-2a5e-4bd1-922e-4df090a45348" name="spam.5jx1uzg_k@mail32.zimbra.DOMAIN.com"></account>
  <account id="a3d19006-44e0-4a9d-9ccd-297a7a70489c" limit="0" used="0" name="testlang@mail32.zimbra.DOMAIN.com"></account>
</GetQuotaUsageResponse>

Getting All User Quota Data With Zmprov

To get quota stats, run. The output is a little bit difficult to read since it's in bytes:

zmprov gqu `zmhostname`

This will display in bytes- first column is usage, second column is max quota (0=unlimited), third column will be the account :

zmprov gqu `zmhostname`|awk {'print " "$3" "$2" "$1'}

Here's a script to put into user readable format below [by Tony P.]. You'll need to modify the $hostname variable near the top:

#!/usr/bin/perl

my $hostname = localhost;

my @quotas = `zmprov gqu $hostname`;

foreach my $quotaline(@quotas)

{

chop($quotaline);

my ($email, $quota, $usage) = split(' ', $quotaline);

$quota=utils_convert_bytes_to_optimal_unit($quota);

$usage=utils_convert_bytes_to_optimal_unit($usage);

print "$email - $usage\n";

}

sub utils_convert_bytes_to_optimal_unit{

my($bytes) = @_;

return '' if $bytes eq '';

my $size;

$size = $bytes . ' Bytes' if $bytes < 1024;

$size = sprintf("%.2f", $bytes/1024) . ' KB' if $bytes >= 1024 && $bytes < 1048576;

$size = sprintf("%.2f", $bytes/1048576) . ' MB' if $bytes >= 1048576 && $bytes < 1073741824;

$size = sprintf("%.2f", $bytes/1073741824) . ' GB' if $bytes >= 1073741824 && $bytes < 1099511627776;

$size = sprintf("%.2f", $bytes/1099511627776) . ' TB' if $bytes >= 1099511627776;

return $size;

}

Additional Content

  • See the soap-admin.txt file in /opt/zimbra/docs/ and also Zmsoap for more zmsoap examples.
Verified Against: Zimbra Collaboration 8.6, 8.5, 8.0 Date Created: 04/26/2015
Article ID: https://wiki.zimbra.com/index.php?title=Getting_All_Users_Quota_Data Date Modified: 06/20/2016



Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »


Wiki/KB reviewed by SME1 SME2 Copyeditor Last edit by Jorge de la Cruz
Jump to: navigation, search