[SNMP4J] How to Remove an SNMP Community String.
Frank Fock
fock at agentpp.com
Sun Dec 28 20:35:24 CET 2008
Hi Vivi,
I assume that you did not set the coexistence provider
at the CommandProcessor to your instance of the
SnmpCommunityMIB class.
The CommandProcessor then uses the SNMPv1/v2c community
as security name directly without mapping it to a
security name using the SNMP-COMMUNITY-MIB mapping.
Since you have an equal security name in your VACM
configuration, the request goes through.
For further questions read RFC 3414 and 3415.
Regards,
Frank
Vivi Zhang wrote:
> Let me resend the email.
>
> The previous email content was in an attachment. It did not show up in
> SNMP4j email archives.
>
> =============================================================================================
>
>
> Hi,
>
> I would really appreciate any help to find a way to remove an SNMP
> community string .
> I am using SNMP4j 1.9.3c, and SNMP4j agent 1.2.1d.
>
> I have no problem to add more community string to a running SNMP agent.
> But, when I have not been successfully remove a community string.
>
> Following is a section of code which initializes community mib and other
> mibs.
>
> vacmMIB = new VacmMIB(new MOServer[] { server });
> snmpTargetMIB = new SnmpTargetMIB(dispatcher);
> snmpNotificationMIB = new SnmpNotificationMIB();
> * snmpCommunityMIB = new SnmpCommunityMIB(snmpTargetMIB);*
> this.getServer().addContext(DEFAULTCONTEXT);
> initConfigMIB();
> notificationOriginator = new NotificationOriginatorImpl(session,
> vacmMIB,
>
> snmpv2MIB.getSysUpTime(),
>
> snmpTargetMIB,
>
> snmpNotificationMIB);
> snmpv2MIB.setNotificationOriginator(notificationOriginator);
>
> Following is a section of code which add a community string to community
> MIB
>
> Variable[] com2sec = new Variable[] {
> new OctetString(aCommunity), SECNAMEV1V2,
> getContextEngineID(), DEFAULTCONTEXT,
> new OctetString(), // transport tag
> new Integer32(StorageType.nonVolatile), // storage type
> new Integer32(RowStatus.active) // row status
> };
>
> MOTableRow row =
> communityMIB.getSnmpCommunityEntry().createRow(index,
>
> com2sec);
> communityMIB.getSnmpCommunityEntry().addRow(row);
>
> To remove all community strings, I tried following code:
> MOMutableTableModel comEntryModel =
> (MOMutableTableModel)communityMIB.getSnmpCommunityEntry().getModel();
> comEntryModel .clear();
>
> After this call, I expect all community rows are gone, and all SNMP
> queries should fail. But this does not happen.
>
> I also try to remove an individual community string using API call
> communityMIB.getSnmpCommunityEntry().removeRow(index); where index is a
> valid OID for a community string.
> In both cases, the row is removed, but the event did not fired since
> moTableModelListeners == null.
> public synchronized MOTableRow removeRow(OID index) {
> *MOTableRow row = (MOTableRow) rows.remove(index);*
> if ((row != null) && (moTableModelListeners != null)) {
> MOTableModelEvent event =
> new MOTableModelEvent(this, MOTableModelEvent.ROW_REMOVED, row);
> fireTableModelChanged(event);
> }
> return row;
> }
>
> After the calls, I am still able to query the snmp agent with "removed"
> community string.
>
> Wonder if it is expected behavior. Or I need config the
> TableModelListeners for SnmpCommunityEntry table.
> Please advise.
>
> Vivi
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
--
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com
More information about the SNMP4J
mailing list