[SNMP4J] Traps for running-config change

Tomas, Gregg (Mission Systems) Gregg.Tomas at ngc.com
Wed Oct 3 19:03:06 CEST 2007


Frank or All,

Are there any ways to listen for traps when any field of a cisco's
running-config has been modified?

My router is configured as follow:

snmp-server enable traps config
snmp-server enable traps syslog
snmp-server host <myIpAddress> version 3 noauth <myUserName>
snmp-server host <myIpAddress> version 2c noauth

My code snippet:
		TransportMapping transport;
		Address address = new UdpAddress(host + "/" + port);
		try {
			transport = new
DefaultUdpTransportMapping((UdpAddress) address);
		} catch(IOException ioex) {
			System.out.println("Unable to bind to local IP
and port: " + ioex);
			System.exit(-1);
		}

		threadPool =
ThreadPool.create(this.getClass().getName(), numThreads);

		MessageDispatcher mtDispatcher =
			new MultiThreadedMessageDispatcher(threadPool,
new MessageDispatcherImpl());

		// add message processing models
		mtDispatcher.addMessageProcessingModel(new MPv1());
		mtDispatcher.addMessageProcessingModel(new MPv2c());
		mtDispatcher.addMessageProcessingModel(new MPv3());

		// add all security protocols
		SecurityProtocols.getInstance().addDefaultProtocols();

		snmp = new Snmp(mtDispatcher, transport);
		if(snmp != null){
			snmp.addCommandResponder(this);
		} else {
			System.out.println("Unable to create Target
object");
			System.exit(-1);
		}

		if(version == SnmpConstants.version3) {
			mtDispatcher.addMessageProcessingModel(new
MPv3());

			MPv3 mpv3 =
	
(MPv3)snmp.getMessageProcessingModel(MessageProcessingModel.MPv3);

			USM usm = new
USM(SecurityProtocols.getInstance(),
				new
OctetString(mpv3.createLocalEngineID()), 0);

	
SecurityModels.getInstance().addSecurityModel(usm);

			if (authoritativeEngineID != null) {
	
snmp.setLocalEngine(authoritativeEngineID.getValue(), 0, 0);
			}

			this.addUsmUser(snmp);
		}

Thanks in advance.

Gregg




More information about the SNMP4J mailing list