snmpwalk command allows us to perform SNMP queries to recover a single or multiple values (depending on the OID we use). I find it very useful in shellscripts, and then configured as Nagios custom service check or plugin.

There are lots of options (this post is a very basic howto. You can read the manpage for further information), but basically I use snmpwalk this way depending on the SNMP version:

snmpwalk -v1 -c <COMMUNITY> <HOST> <OID>
snmpwalk -v2c -c <COMMUNITY> <HOST> <OID>
snmpwalk -v3 -l authNoPriv -u <USER> -A <PASSWORD> <HOST> <OID>

Examples of snmpwalk usage:

Ironport queued mails (query with single value return):

# snmpwalk -v1 -c public IRONPORT1
SNMPv2-SMI::enterprises.15497. = Gauge32: 0

GSA Google Search Appliance disk health (query with single value return):

# /usr/bin/snmpwalk -v1 -c public GSA1 system.gsaDisk.diskHealth
GSA-MIB::diskHealth.0 = INTEGER: green(0)

Checkpoint VSX fans status (query with single value return):

# snmpwalk -v3 -l authNoPriv -u fwadmin -A ******** VSX1 .

CHECKPOINT-MIB::fanSpeedSensorStatus.1.0 = INTEGER: 0
CHECKPOINT-MIB::fanSpeedSensorStatus.2.0 = INTEGER: 0
CHECKPOINT-MIB::fanSpeedSensorStatus.3.0 = INTEGER: 0
CHECKPOINT-MIB::fanSpeedSensorStatus.4.0 = INTEGER: 0

Note in this case we can get one of the fans status value by appending the fan ID to the OID…

Checkpoint VSX fan 3 status (query with single value return):

# snmpwalk -v3 -l authNoPriv -u fwadmin -A ******** VSX1 .
CHECKPOINT-MIB::fanSpeedSensorStatus.3.0 = INTEGER: 0

UPS Output powers in watts (Query with multiple value return):

# snmpwalk -v1 -c public SA1
SNMPv2-SMI::enterprises.534. = INTEGER: 1956
SNMPv2-SMI::enterprises.534. = INTEGER: 1567
SNMPv2-SMI::enterprises.534. = INTEGER: 1675

UPS Output power 2 in watts (Query with single value return):

# snmpwalk -v1 -c public SAI1
SNMPv2-SMI::enterprises.534. = INTEGER: 1567

Every solution has its own OIDs but they are easily searchable on the web.

In future posts, i'll show how to:

  • Parse the snmpwalk output to get only the value we want
  • Develop a simple shellscript that returns a value (ready to be used by Nagios) depending on the output of the snmpwalk command
  • Configure Nagios to perform checks based on the developed script