The SnmpProxy object makes it possible to get the actual values requested by the manager from a MIB implemented in a remote SNMP subagent. The SnmpProxy objects are able to get values from SNMP agents implementing either of the SNMPv1 or SNMPv2 protocols. This makes it possible to get values from legacy SNMP agents in a way that is transparent to the manager.
The SnmpProxy object extends the SnmpMibAgent abstract class, and as such can be registered in the SnmpV3AdaptorServer just like a local MIB generated by the mibgen tool. In a master agent application, one SnmpProxy must be created per subagent. When creating the SnmpProxy object, you must provide it with the following parameters to enable it to access the underlying subagent:
Subagent's IP address
Subagent's port number
Security parameters, namely community strings, used for communicating with the subagent
Version of SNMP that must be used to access the subagent, namely either SNMPv1 or SNMPv2
Then you must register that proxy with the SnmpV3AdaptorServer, once for each MIB implemented by the subagent that you want to mirror in the master agent. This is demonstrated in Example 21–1.
A subagent implements the following three MIBs:
mib#1 (root OID=x.y.z.1)
mib#2 (root OID=x.y.z.2)
mib#3 (root OID=x.y.z.3)
If you want mib#1 and mib#3 to be accessible from the master agent managers, then you need to register your SnmpProxy object for both mib#1 and mib#3:
SnmpV3AdaptorServer snmpAdaptor = ....; SnmpProxy mySubAgentProxy = new SnmpProxy(....); SnmpOid oids = new SnmpOid(2); oids = new SnmpOid("x.y.z.1"); oids = new SnmpOid("x.y.z.3"); snmpAdaptor.addMib(mySubAgentProxy,oids);
Once you have done this, all varbinds contained in an SNMP request whose OIDs appear to be below x.y.z.1 or x.y.z.3 are passed to the registered mySubAgentProxy. The mySubAgentProxy proxy gets the actual values from the remote agent it is proxying. OIDs that appear to be contained below x.y.z.2 are not forwarded, and where applicable, are handled locally, because the SnmpProxy is not registered for those OIDs.