[SNMP4J] Help for setting up OIDs that change values
Andrew Samuels
drewsamuels13 at gmail.com
Wed Sep 9 15:04:03 CEST 2015
All,
I have been looking at using SNMP4J for a while and finally started to get
to grips with it, however setting up OIDs that can return changing values
is proving more challenging than I anticipated and I am looking for
pointers. I have read the instrumentation guide and pulled various pieces
of code together from searching.
So far I have the basics working, various examples show these
// Set up a new agent
this.myAgent = new SNMPAgent("udp:10.0.0.5/161");
// Start the agent
this.myAgent.start();
// Remove all the default MIBs so I can see any additions/changes I am
making more easily.
myAgent.unregisterManagedObject(myAgent.getSnmpv2MIB());
myAgent.unregisterManagedObject(myAgent.getSnmp4jLogMIB());
myAgent.unregisterManagedObject(myAgent.getSnmpCommunityMIB());
myAgent.unregisterManagedObject(myAgent.getSnmp4jConfigMIB());
myAgent.unregisterManagedObject(myAgent.getSnmpFrameworkMIB());
myAgent.unregisterManagedObject(myAgent.getSnmpNotificationMIB());
myAgent.unregisterManagedObject(myAgent.getUsmMIB());
myAgent.unregisterManagedObject(myAgent.getVacmMIB());
myAgent.unregisterManagedObject(myAgent.getSnmpProxyMIB());
myAgent.unregisterManagedObject(myAgent.getSnmpTargetMIB());
//Add a simple OID with string
OID mo1= new OID("1.3.6.1.2.1.1.1");
myAgent.registerManagedObject(MOCreator.createReadOnly(mo1,"this is my
test"));
If I start the agent and then do a walk
snmpwalk -v 2c -c public 10.0.0.5 .1
iso.3.6.1.2.1.1.1 = STRING: "this is my test"
iso.3.6.1.2.1.1.1 = No more variables left in this MIB View (It is past the
end of the MIB tree)
I get back what I expected and everything is good, so I know the agent
starts, community is working etc.
The next step I unfortunately do not seem to be able to get working at all.
Lets say I have a class call Kitchen and an instance of the class called
ThisKitchen. It has the following return methods
getStaffOnDuty() - returns string
getSpoonCount() - returns int
getKnifeCount() - returns int
getForkCount() - returns int
These values can be updated in the ThisKitchen instance with comparable set
calls ,so setStaffOnDuty, setSpoonCount etc
I have tried using a MOServerLookupListener and MOTable and also the
class UpdatableManagedObject,
however the MOTable I obviously do not yet understand fully and the
UpdateableManagedObject always returns null for the oid I set up.
A simple oid structure (fake prefix) I am looking for would be
1.8.8.8.1 = staffonduty - string
1.8.8.8.2 = spooncount - int
1.8.8.8.3 = knifecount - int
1.8.8.8.4 = forkcount - int
Can any one provide some pointers, not looking for complete code (although
very welcome), but some basic framework pointers that aligns with what I am
trying to do ? as I believe my current approach is missing some
fundamentals for OIDs that change values and how the structures work.
Andrew.
More information about the SNMP4J
mailing list