Monday, June 05, 2017

Re: SNMP OID for free memory

On 2017-06-04, mabi <mabi@protonmail.ch> wrote:
> Hi,
>
> I am using OpenBSD 6.1 the the Net-SNMP port in order to monitor the system resources. I don't seem to find any OID for the free memory and was wondering if this information is simply not made available in SNMP. Doing an snmpwalk on the HOST-RESOURCES MIB for memory shows the following avaialble OIDs related to memory:

Don't use net-snmp's snmpd on OpenBSD without a very good reason,
use snmpd from the base OS.

> HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Physical memory
> HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: Real memory
> HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Virtual memory
> HOST-RESOURCES-MIB::hrStorageDescr.8 = STRING: Shared virtual memory
> HOST-RESOURCES-MIB::hrStorageDescr.9 = STRING: Shared real memory
> HOST-RESOURCES-MIB::hrStorageDescr.10 = STRING: Swap space
> HOST-RESOURCES-MIB::hrStorageDescr.31 = STRING: /
>
> Any idea where the the free memory info would be hiding?

Whichever of the hrStorageUsed oids that relates to the memory you're
interested in, e.g. given the list above it would be hrStorageUsed.1 for
physical memory. Multiply it by the same-numbered hrStorageSize.

Here's an example from the base OS's snmpd, using snmptable to pull in
the relevant oids for the whole table and format the display.

$ snmptable -v2c -c public 127.0.0.1 hrStorageTable
SNMP table: HOST-RESOURCES-MIB::hrStorageTable

hrStorageIndex hrStorageType hrStorageDescr hrStorageAllocationUnits hrStorageSize hrStorageUsed hrStorageAllocationFailures
1 HOST-RESOURCES-MIB::hrStorageTypes.2 Physical memory 4096 Bytes 2069645 1468114 0
2 HOST-RESOURCES-MIB::hrStorageTypes.2 Real memory 4096 Bytes 2082986 1481455 0
10 HOST-RESOURCES-MIB::hrStorageTypes.3 Swap space 4096 Bytes 1572863 0 0
31 HOST-RESOURCES-MIB::hrStorageTypes.4 / 4096 Bytes 520119 37923 0
32 HOST-RESOURCES-MIB::hrStorageTypes.4 /data 4096 Bytes 8254103 2292580 0
33 HOST-RESOURCES-MIB::hrStorageTypes.4 /home 4096 Bytes 31930799 10749150 0
34 HOST-RESOURCES-MIB::hrStorageTypes.4 /usr 4096 Bytes 1546599 132582 0
35 HOST-RESOURCES-MIB::hrStorageTypes.4 /usr/X11R6 4096 Bytes 1028871 48383 0
36 HOST-RESOURCES-MIB::hrStorageTypes.4 /usr/local 4096 Bytes 8254103 4240627 0
37 HOST-RESOURCES-MIB::hrStorageTypes.4 /usr/src 4096 Bytes 1028871 271331 0
38 HOST-RESOURCES-MIB::hrStorageTypes.4 /usr/ports 4096 Bytes 2061047 523465 0
39 HOST-RESOURCES-MIB::hrStorageTypes.4 /usr/obj 4096 Bytes 12382807 1816114 0
40 HOST-RESOURCES-MIB::hrStorageTypes.4 /usr/xenocara 4096 Bytes 516007 179230 0
41 HOST-RESOURCES-MIB::hrStorageTypes.4 /var 4096 Bytes 8254103 879286 0
42 HOST-RESOURCES-MIB::hrStorageTypes.4 /distsrc 4096 Bytes 38701655 28351200 0
43 HOST-RESOURCES-MIB::hrStorageTypes.4 /var/www 4096 Bytes 4125399 660222 0
44 HOST-RESOURCES-MIB::hrStorageTypes.4 /var/www/htdocs/pub 512 Bytes 2097669360 3955189904 0
45 HOST-RESOURCES-MIB::hrStorageTypes.4 /y/Multimedia 512 Bytes 2097669360 3955189904 0
46 HOST-RESOURCES-MIB::hrStorageTypes.4 /y/Download 512 Bytes 2097669360 3955189904 0
47 HOST-RESOURCES-MIB::hrStorageTypes.4 /y/homes 512 Bytes 2097669360 3955189904 0

> I found a script called check_snmp_openbsd.py (https://github.com/alexander-naumov/nagios-plugins/blob/master/check_snmp_openbsd.py) where the OID .1.3.6.1.4.1.11.2.3.1.1.7.0 is used for getting the free memory but when I do an snmpget on my OpenBSD box this OID is not available.

I might have missed something but I don't see it actually using that
mem_free definition.

No comments:

Post a Comment