Is there an OID to retrieve specific HDD partition on SNMP?

11,620

Depending on your case, partition layout and mount points your indexes can vary: but here is example of reporting free disk space on partitions

two mounted partitions: df | grep mnt /dev/xvdz1 5160576 10236 4888196 1% /mnt /dev/xvdz2 36123264 49032 34239276 1% /mnt/test

getting indexes for them from snmpwalk: snmpwalk -On -v 2c -c public localhost .1.3.6.1.4.1.2021.9 | grep /dev/xvdz .1.3.6.1.4.1.2021.9.1.3.8 = STRING: "/dev/xvdz1" .1.3.6.1.4.1.2021.9.1.3.9 = STRING: "/dev/xvdz2"

8 and 9 for xvdz1 and xvdz2 accordingly

so querying for free disk these indexes:

for xvdz1
# snmpwalk -On -v 2c -c public localhost .1.3.6.1.4.1.2021.9.1.7.8 .1.3.6.1.4.1.2021.9.1.7.8 = INTEGER: 4888196

for xvdz2
# snmpwalk -On -v 2c -c public localhost .1.3.6.1.4.1.2021.9.1.7.9 .1.3.6.1.4.1.2021.9.1.7.9 = INTEGER: 34239276

Compare it to output of df

Share:
11,620

Related videos on Youtube

Pavel
Author by

Pavel

Updated on September 18, 2022

Comments

  • Pavel
    Pavel over 1 year

    I want to get hard disk free space of a specific partition, is there a way to retrieve this with SNMP OID? Is there any special OID for this?


    EDIT:
    the OID .1.3.6.1.4.1.2021.9.1.7.1 refers to available space on the disk. How can get partition's free space? This is what I want.

  • Pavel
    Pavel over 8 years
    Thank you very much for the response. At first snmpwalk shows OID .1.3.6.1.4.1.2021.9.1.3.8 and .1.3.6.1.4.1.2021.9.1.3.9. But for xvdz1 you have used .1.3.6.1.4.1.2021.9.1.7.8 is this a typo? or I don't get something very well. Tnx again.
  • stimur
    stimur over 8 years
    .8 and .9 are just particular values for my example. xvdX is disk naming scheme for Xen (Amazon) replace it with sda or sdb or whatever you want to monitor.
  • galaxy
    galaxy over 8 years
    Areza, yes it seems to be a typo -- by the common sense they they should match. Possibly, @stimur copy pasted the first command but for some reason was typing the OIDs for the free disk query and unintentionally typed .1.7.8 instead of .1.3.8 at the end of the command. In the last command it's likely that he just replaced the last digit without even verifying that the OID string points to a different location.
  • stimur
    stimur over 8 years
    It is not a typo, 3.8 is of type string and shows the name of device mounted. While 1.8 is for free space on that partition.
  • stimur
    stimur over 8 years
    Do snmpwalk -On -v 2c -c public localhost .1.3.6.1.4.1.2021.9 and see full output.