Search code examples
mathsnmpramnagiosmib

Simple arithmetic on values retreived using OIDs


I am new to SNMP and Nagios, and would like to do some basic arithmetic on values retrieved using OIDs.

I need to monitor the used memory (RAM) on the servers on the University's network. They seem to be using UCD-SNMP-MIB. So far I have encountered memTotalReal.0 and memAvailReal.0, and no direct way to retrieve the used memory. Is there any specific reason for this?

Expected command for basic subtraction:

$USER1$/check_snmp -H $HOSTADDRESS$ -o memTotalReal.0-memAvailReal.0

What is the easiest way to retrieve the used memory? Do I need to resort to subtraction by possibly writing another script?


Solution

  • There is no simple way to do it. So you need to calculate it like this:

    (Used – buffers – cached) / Total * 100 = % memory used
    
    Used = total - available
    

    In terms of OIDs you'll need to use the following:

    • memTotalOID = '.1.3.6.1.4.1.2021.4.5.0'
    • memRealAvailOID = '.1.3.6.1.4.1.2021.4.6.0'
    • memRealBuffersOID = '.1.3.6.1.4.1.2021.4.14.0'
    • memRealCachedOID = '.1.3.6.1.4.1.2021.4.15.0'