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
- 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 =
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 - 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.
- nsExtendOutput1Table contains:
- NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.”program name” - First Line of the output
- NET-SNMP-EXTEND-MIB::nsExtendOutputFull.”program name” - FULL output
- NET-SNMP-EXTEND-MIB::nsExtendOutNumLines.”program name” - Total # of lines in the output
- NET-SNMP-EXTEND-MIB::nsExtendResult.”program name” - Exit Status
- 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 restartOn the fusion manager, run this snmpwalk command to ensure that the snmp extend functionality is working:
# snmpwalk -v1 -c public fusionmgr nsExtendOutput1TableNET-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!
- nsExtendOutput1Table contains: