Search code examples
javasnmpsnmp4j

Can't get any CPU or memory value with SNMP


I'm trying to get CPU and memory usage with SNMP. I have a Java code which takes the oid and runs the "get" command. I can reach the values with MIB-II. However when i import HOST-RESOURCES-MIB in the code i can't get CPU information it returns Null. But some oids work properly in HOST-RESOURCES-MIB.

For example:

hrSystemUpTime(.1.3.6.1.2.1.25.1.1.0)       gives me the value  3:51:15.07
hrProcessorLoad(.1.3.6.1.2.1.25.3.3.1.2.0)  gives me the value  Null

What is the problem?


Solution

  • I've solved the problem. In MIBs the information kept in indexes. Thus, in order to reach a particular information, you need to know which index it's kept.So, i did SNMPWalk on .1.3.6.1.2.1.25.3.3.1.2 for hrProcessorLoad (omit zero) and i got the values. We can also use getNext command to reach the correct index.