Jon A
Jon A

Reputation: 372

Check if a device has an snmp object without waiting for a timeout?

I'm using snmp4j to collect power consumption on POE (power over ethernet) ports. But some devices don't support POE. When I go to ask those devices for the power consumption, they eventually time out.

Waiting for the time out imposes an undesirable delay on displaying information on a web page.

I don't think there's a universally available object that will tell you if the device supports POE, so I'm wondering if there's a way to ask a device if an object exists without actually requesting the object and then waiting for the time out.

Upvotes: 2

Views: 417

Answers (1)

k1eran
k1eran

Reputation: 4970

1) Some devices will support the SNMPv2-MIB::sysORTable; possibly you could retrieve it and see if the MIB with POE present before trying to retrieve the POE data (Assuming here it is POE retrieval that is slow not the SNMP round-trip!)

Quoting How can I get MIBs list from a remote server by using PHP? sysORTable is:

"The (conceptual) table listing the capabilities of the local SNMP application acting as a command responder with respect to various MIB modules. SNMP entities having dynamically-configurable support of MIB modules will have a dynamically-varying number of conceptual rows."

Here is what I get for a standard Linux host :

snmptable -M +.  -m +ALL -v 2c -c public -Pu -Ci  <some ipaddr>  SNMPv2-MIB::sysORTable
SNMP table: SNMPv2-MIB::sysORTable

 index                                        sysORID                                              sysORDescr  sysORUpTime
     1          SNMP-MPD-MIB::snmpMPDMIBObjects.3.1.1         The MIB for Message Processing and Dispatching. 0:0:00:00.30
      // SNIP
     6                                     IP-MIB::ip The MIB module for managing IP and ICMP implementations 0:0:00:00.30
     7                                UDP-MIB::udpMIB         The MIB module for managing UDP implementations 0:0:00:00.30
     8        SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup               View-based Access Control Model for SNMP. 0:0:00:00.30

2) Alternatively could you use current approach except with a shorter (non-default) SNMP retrieval timeout ?

Upvotes: 2

Related Questions