February 4, 2012

SNMP Quota from NetApp Filers

I had written a shell script to query the NetApp filers for user and qtree quota about 4+ years ago. Its been in production at work since then and has found immense use. I finally efforted a modified and generalized version of that utilitiy and ported it to perl, now that I have the net-snmp perl module installed.

Download the perl script here

Read the mage page here

The script will allow your users to obtain user and qtree quota related information without gaining access to the filer console. It uses the SNMP MIB from NetApp and the perl Net::SNMP module.

Usage:

rajeev@box% ./getquota.pl -help

Options:
   -help   Print usage info and exit.

  -man    Print the manual page and exist. 

  -home   Query and print the user quota information. If no username is
                 passed, then the quota information for the running user is
                 provided. Optionally, a username and the hosting filer name can
                 be passed to query the usage information of that user. See
                 EXAMPLES below.

   -filer     Filer name where the resource is exported from

   -volume Volume name. Requires -f.

    -qtree  Qtree name. Requires -f and -v.

Obtaining user quota information

Most places I know use the NetApp user quotas for the home directories and mount them at /home/username. As a normal user, you can get the home directory usage information with this script as follows:

rajeev@box% ./getquota.pl -home

Home Area quota for: rajeev

Current Usage: 1.3 GB
Current Limit: 2 GB


To obtain quota information for a specific qtree in a given volume:

rajeev@box% ./getquota.pl -f toaster -v projects -q ABC

Quota for: /vol/projects/ABC

Current Usage: 1 GB
Current Limit: 1.6 GB
# of Files Used: 64105

In addition to reporting the space consumption, the script will also spit out the # of files being used.

To obtain a volume specific information:

rajeev@box% ./getquota.pl -f toaster -v projecta

Quota for: /vol/projecta/

Current Usage: 725.9 GB
Current Limit: 794.6 GB
# of Files Used: 24791968

From the above info, I can also infer that my average file size is around 30KB – and also there are lots of them. This might help in designing your backup environments, snapmirror etc. as well.

Comments

  1. unixfoo says:

    Good and useful tool. Thanks

  2. Nice script.
    I’ve got a feature request: could you add an integer percentage output of quota so it can be incorporated into Nagios?(Unfortunatly I can’t program in Perl myself). Would be great!
    I’m not sure if the next is possible: another nice feature would be to know whichs qtree’s are over an certain percentage of quota (e.g. 90%), without having to specify the qtree’s.
    Keep up the good work.

  3. ron says:

    When running the script I’m getting an error…
    Can’t locate Net/SNMP.pm in @INC (@INC contains: /usr/opt/perl5/lib/5.8.0/aix-thread-multi /usr/opt/perl5/lib/5.8.0 /usr/opt/perl5/lib/site_perl/5.8.0/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.0 /usr/opt/perl5/lib/site_perl .) at ./getquota.pl line 21.
    BEGIN failed–compilation aborted at ./getquota.pl line 21.

  4. @Ron

    It appears that your system’s perl installation does not have net-snmp module installed. You need that for this perl script to work (since it makes SNMP calls)

Speak Your Mind

*