Which method is best to iterate keys in a snmpwalk? I need to find statistics for network in different boards in different PCs. Linux and Windows. I understand that the 1.3.1..... is different. How can I do something like "snmp fetch eth0 mrtu value" ? or "snmp fetch dsk "D" free%" ?
Should I open every mib under mibs directory and trackdown every meaningfull or meaningless key that is "dsk" or "net" and give it a try? And what value suits for me, keep it aside?
Or is there a 'rightful' method ? I need to make a code working on j开发者_开发技巧ava but yet I don't possess the knowledge yet.
Under MIBII you've got standard MIBs in which you can find useful informations about Disk an Interfaces. You can study these MIBS and write the code that get back just the necessaries counters. I think that it could be a bit different from Windows to Linux but not so. A "snmp fetch eth0 mrtu value" has sense if you are sure eth0 exists on the remote computer, so you'd better discover things and then poll them.
Remember that :
A SnmpWalk (as pointed by @bstPierre) is no more than multiple SNMP-GETNEXT/SNMP-RESPONSE so it as a cost on the bandwith, and the result is not so easy to compute.
With a simple SNMP-GET/SNMP-RESPONSE you can retreive multiple counters.
To walk the MIB, use the SNMP GETNEXT operation. Do it repeatedly to perform a MIB walk.
See this example for snmp4j.
精彩评论