3

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.

Alireza
  • 563
  • 4
  • 8
  • 27
  • `refers to available space on the disk. How can get partition's free space?` Does the disk have more than one partition? – GregL Aug 25 '15 at 12:42
  • @GregL I have /var /boot /etc and etc partitions... I want to get free space of /var partition – Alireza Aug 27 '15 at 06:09
  • What's returned by an SNMP walk of `.1.3.6.1.4.1.2021.9`? – GregL Aug 27 '15 at 13:18
  • @GregL the command `snmpwalk -Os -c public -v 1 127.0.0.1 .1.3.6.1.4.1.2021.9` gives nothing but `End of MIB` – Alireza Aug 29 '15 at 06:31

1 Answers1

4

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

stimur
  • 894
  • 5
  • 11
  • 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. – Alireza Aug 30 '15 at 09:26
  • `.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. – stimur Aug 30 '15 at 12:17
  • 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. – galaxy Sep 01 '15 at 04:22
  • 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 Sep 01 '15 at 05:12
  • Do `snmpwalk -On -v 2c -c public localhost .1.3.6.1.4.1.2021.9` and see full output. – stimur Sep 01 '15 at 05:14