[SNMP4J] How to Remove an SNMP Community String.
Vivi Zhang
vzhang at anuesystems.com
Mon Dec 22 15:15:38 CET 2008
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
More information about the SNMP4J
mailing list