[SNMP4J] Re: unable to add community name to SampleAgent
Jeff Ramin
ramin at berbee.com
Thu Jan 22 22:56:09 CET 2009
Can anybody help me? Am I completely off the mark? Missing one
critical step? If I'm unable to do this, I may have to choose
another package entirely.
Thanks.
Jeff Ramin wrote:
>
> Hi folks.
>
> I'm using the latest snmp4jagent library (1.2.2), and I have the
> SampleAgent running.
>
> I want to add another community name that the agent will accept
> from a v2c client. I've stolen some code from the
> TestAgent.addCommunities()
> method and added it to the SampleAgent. These are the changes I've made:
>
> I save the engine context id when creating the AgentConfigManager for
> later use:
> 106c115,116
> < agent = new AgentConfigManager(new
> OctetString(MPv3.createLocalEngineID()),
> ---
> > engineContextID = new OctetString(MPv3.createLocalEngineID());
> > agent = new AgentConfigManager(engineContextID,
>
> I create and save an SnmpCommunityMIB object in the constructor for
> later use:
> 115c125,133
> < }
> ---
> >
> > SnmpTargetMIB targetMIB = new SnmpTargetMIB(messageDispatcher);
> > communityMIB = new SnmpCommunityMIB(targetMIB);
> > }
>
> In main(), right after the sampleAgent.run() call, I try to add a
> community name by calling the new method:
> 387a406,407
> >
> > addCommunity("test");
>
> and here is my addCommunity() method, stolen from TestAgent:
> private static void addCommunity(String community) {
>
> // add row to SnmpCommunityMIB table
> Variable[] com2sec = new Variable[] {
> new OctetString(community), // community name
> new OctetString("cpublic"), // security name
> engineContextID, // local engine ID
> new OctetString("public"), // default context name
> new OctetString(), // transport tag
> new Integer32(StorageType.nonVolatile), // storage type
> new Integer32(RowStatus.active) // row status
> };
> MOTableRow row =
> communityMIB.getSnmpCommunityEntry().createRow(new
> OctetString("public2public").toSubIndex(true), com2sec);
> communityMIB.getSnmpCommunityEntry().addRow(row);
> }
>
>
>
>
> I don't see any errors, but the agent rejects requests that use
> the community name "test".
>
> Could somebody explain what I'm doing wrong? Thanks!
>
>
>
--
Jeffrey Ramin
Berbee
ramin at berbee.com
608.298.1024
More information about the SNMP4J
mailing list