February 4, 2012

ibrix user quotas

If you are an ibrix customer, you probably know that you while you can configure an ibrix file system with user quotas, there are no userland tools available to actually check for those quotas. Using Net-SNMP package, however, we can overcome this shortcoming. Extend, to the rescue!

IBRIX user quotas are managed on the fusion manager server.


[root@fusionmgr]# /usr/local/ibrix/bin/ibrix_edquota -h

[ ibrix_edquota -h ]
Usage: ibrix_edquota
-? : Display the command usage
-G : All groups
-I : Soft limits (files)
-M : Soft limits (MB)
-U : All users
-f : Name of filesystem
-g : Group ID or Name
-i : Hard limits (files)
-l : list quota limits
-m : Hard limits (MB)
-s : Set quota limits
-u : User ID or Name

ibrix_edquota: Usage Patterns

=======================================

ibrix_edquota -s -g GROUP -f FSNAME -M SOFT_MEGABYTES -m HARD_MEGABYTES -I SOFT_FILES -i HARD_FILES
: set the specified usage limits on FSNAME for group GID
ibrix_edquota -s -u USER -f FSNAME -M SOFT_MEGABYTES -m HARD_MEGABYTES -I SOFT_FILES -i HARD_FILES
: set the specified usage limits on FSNAME for user UID
ibrix_edquota -l -u UID [-f FSNAME]
: list the usage limits for user UID
ibrix_edquota -l -g GID [-f FSNAME]
: list the usage limits for group GID
ibrix_edquota -l -U [-f FSNAME]
: list the usage limits for all USERS
ibrix_edquota -l -G [-f FSNAME]
: list the usage limits for all GROUPS
ibrix_edquota -?

COMMAND LINE: ibrix_edquota -h IS INVALID

The user quotas are setup using the ibrix_edquota -s ... command. The listing of user quotas is also done using the ibrix_edquota -l command. Since this command is not available on any other server, there is no direct way for a normal user to get quota information.

I used the Net-SNMP package and its ability to extend the functionality of the agent. In theory, it is very simple. Configure SNMP to run ibrix_edquota command everytime an a preset OID is queried. I used the extend directive, since it has performance improvements over the older directives, exec, pass and pass_persist.

Setting up SNMP

  1. First, we need a script that will run the ibrix_edquota command for a given file system.

    #!/usr/bin/perl

    #
    # ibrix_quota.pl
    #
    $|=1;

    #======================================#
    # Process args #
    #======================================#

    $req = $ARGV[0];

    if (!$req) {
    exit 1;
    }

    open (OUTPUT, "/usr/local/ibrix/bin/ibrix_edquota -f $req -l -U | grep -v 'Filesystem' |");
    while ($line = ) {
    print $line;
    }
    close (OUTPUT);
    exit 0;

    I saved this as /usr/local/scripts/ibrix_quota.pl
    Let’s make sure this script actually produces something…


    # [root@fusionmgr# /usr/local/scripts/ibrix_quota.pl ibrixfs1
    ibrixfs1 34518 0 930816 930816 none 0 122945536 122945536 none
    ibrixfs1 34630 102993 930816 930816 none 76309 122945536 122945536 none
    ibrixfs1 34851 0 930816 930816 none 0 122945536 122945536 none
    ibrixfs1 34152 146926 930816 930816 none 14997 122945536 122945536 none
    ibrixfs1 34215 0 930816 930816 none 0 122945536 122945536 none
    ibrixfs1 34234 1055 930816 930816 none 164 122945536 122945536 none
    ibrixfs1 34290 10879 930816 930816 none 10998 122945536 122945536 none
    ibrixfs1 34358 0 930816 930816 none 0 122945536 122945536 none

  2. Edit the snmpd.conf file and configure the extend functionality. If your organization/company has a reserved OID, then you can use an open child of that OID, or else, snmp will use the preset MIB tables (nsExtendConfigTable) to store the output.

    There are TWO result tables, in either case.

    1. nsExtendOutput1Table contains:
      1. NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.”program name” – First Line of the output
      2. NET-SNMP-EXTEND-MIB::nsExtendOutputFull.”program name” – FULL output
      3. NET-SNMP-EXTEND-MIB::nsExtendOutNumLines.”program name” – Total # of lines in the output
      4. NET-SNMP-EXTEND-MIB::nsExtendResult.”program name” – Exit Status

    2. nsExtendOutput2Table contains the output as a series of separate lines

    In this case, we will not specify an OID and used the nsExtendOutput tables


    # echo "extend ibrix_quota.pl /usr/local/scripts/ibrix_quota.pl ibrixfs1" >> /etc/snmp/snmpd.conf
    # /etc/init.d/snmpd restart

    On the fusion manager, run this snmpwalk command to ensure that the snmp extend functionality is working:


    # snmpwalk -v1 -c public fusionmgr nsExtendOutput1Table

    NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."ibrix_quota.pl" = STRING: ibrixfs1 34518 0 930816 930816 none 0 122945536 122945536 none
    NET-SNMP-EXTEND-MIB::nsExtendOutputFull."ibrix_quota.pl" = STRING: ibrixfs1 34518 0 930816 930816 none 0 122945536 122945536 none
    ibrixfs1 34630 102993 930816 930816 none 76309 122945536 122945536 none
    ibrixfs1 34851 0 930816 930816 none 0 122945536 122945536 none
    ibrixfs1 34152 146926 930816 930816 none 14997 122945536 122945536 none
    ibrixfs1 34215 0 930816 930816 none 0 122945536 122945536 none
    ibrixfs1 34234 1055 930816 930816 none 164 122945536 122945536 none
    ibrixfs1 34290 10879 930816 930816 none 10998 122945536 122945536 none
    ibrixfs1 34358 0 930816 930816 none 0 122945536 122945536 none
    NET-SNMP-EXTEND-MIB::nsExtendOutNumLines."ibrix_quota.pl" = INTEGER: 8
    NET-SNMP-EXTEND-MIB::nsExtendResult."ibrix_quota.pl" = INTEGER: 0

    Let’s look at the other output table as well. This time, I am doing it from a remote host also..

    dude@remotehost % snmpwalk -v 1 -c public fusionmgr nsExtendOutput2Table
    NET-SNMP-EXTEND-MIB::nsExtendOutLine."ibrix_quota.pl".1 = STRING: ibrixfs1 34518 0 930816 930816 none 0 122945536 122945536 none
    NET-SNMP-EXTEND-MIB::nsExtendOutLine."ibrix_quota.pl".2 = STRING: ibrixfs1 34630 102993 930816 930816 none 76309 122945536 122945536 none
    NET-SNMP-EXTEND-MIB::nsExtendOutLine."ibrix_quota.pl".3 = STRING: ibrixfs1 34851 0 930816 930816 none 0 122945536 122945536 none
    NET-SNMP-EXTEND-MIB::nsExtendOutLine."ibrix_quota.pl".4 = STRING: ibrixfs1 34152 146926 930816 930816 none 14997 122945536 122945536 none
    NET-SNMP-EXTEND-MIB::nsExtendOutLine."ibrix_quota.pl".5 = STRING: ibrixfs1 34215 0 930816 930816 none 0 122945536 122945536 none
    NET-SNMP-EXTEND-MIB::nsExtendOutLine."ibrix_quota.pl".6 = STRING: ibrixfs1 34234 1055 930816 930816 none 164 122945536 122945536 none
    NET-SNMP-EXTEND-MIB::nsExtendOutLine."ibrix_quota.pl".7 = STRING: ibrixfs1 34290 10879 930816 930816 none 10998 122945536 122945536 none
    NET-SNMP-EXTEND-MIB::nsExtendOutLine."ibrix_quota.pl".8 = STRING: ibrixfs1 34358 0 930816 930816 none 0 122945536 122945536 none


    yay!

    Now you can wrap this snmp command in any script/utility and allow your users lookup their user quota information!

Comments

  1. akshar says:

    Dear Sir,

    thank you for providing the solution but unfortunately above perl script is throwing an error. Can you kindly suggest something on this?

  2. Well – post the errors you are receiving.

  3. akshar says:

    Hello Sir,

    Thanks for kind reply..In the above perl script, while ($line= ) is the error line.

    -> perl /tmp/mf1 home
    syntax error at /tmp/mf1 line 19, near “= ) ”
    Execution of /tmp/mf1 aborted due to compilation errors.

    Also sir, even if this script executes and generates the output as mentioned above,
    when executed snmpwalk “snmpwalk -v1 -c public fusionmgr nsExtendOutput1Table” line,
    i am getting no output.
    I have added this line as you suggested.
    echo “extend ibrix_quota.pl /usr/local/scripts/ibrix_quota.pl ibrixfs1″ >> /etc/snmp/snmpd.conf
    my snmpd.conf file is as as below: (ibrix version 5.6)
    ##entered only non commented lines
    com2sec notConfigUser default public
    group notConfigGroup v1 notConfigUser
    group notConfigGroup v2c notConfigUser
    view systemview included .1.3.6.1.2.1.1
    view systemview included .1.3.6.1.2.1.25.1.1
    access notConfigGroup “” any noauth exact systemview none none
    syslocation Unknown (edit /etc/snmp/snmpd.conf)
    syscontact Root (configure /etc/snmp/snmp.local.conf)
    pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat
    pass .1.3.6.1.2.1.10.7.11.1 /usr/bin/nx_snmp.pl

    Kindly help me sir.

  4. akshar says:

    Dear Sir,

    Could you guide me regarding the same.

    -Akshar

Trackbacks

  1. [...] while ago, I had a write up on using the net-snmp project’s extend configuration option to get IBRIX user quota reports [...]

Speak Your Mind

*