[snmp] SNMP trap problem (thread count)

Birgit Arkesteijn birgit at westhawk.co.uk
Wed Oct 24 11:39:16 BST 2007


Hi Vijay,

First of all, try using the SnmpContextPool class.

Secondly, the thread will only be destroyed when you destroy the 
context. That isn't so straightforward with traps, because send() isn't 
synchronised, so you have to give the context a bit of time to actually 
send the PDU before you can destroy it. Try a few second sleep and then 
destroy the context.

Cheers, Birgit


Vijay Gholap wrote:
> Hi,
> 
>    I have an application in which i have implemented SNMP Trap sending
> functionality. My problem is that, i am able to send snmp trap(version 1/2)
> without any problem, but my applications thread count getting incremented on
> every send. So please help me to reduce this. Bellow is code snap of my
> application...
> 
> try {
> 
> 
> 	SnmpContext context = new SnmpContext(host, port, bindAddr, socketType);
>         context.setCommunity(community);
> 
>        TrapPduv1 pdu = new TrapPduv1(context);
>         pdu.setIpAddress(InetAddress.getLocalHost().getAddress());
>         pdu.setEnterprise("1.3.6.1.4.1.12.1");
>         pdu.setSpecificTrap(6);
>         pdu.setTimeTicks(10000);
> 
> 
>        pdu.addOid(sysUpTime, new AsnUnsInteger(5));
>        pdu.addOid(snmpTrapOID, new AsnObjectId("1.3.6.1.4.1.12.1"));
>  	 pdu.send();
> 
> 	} catch (java.io.IOException exc) {
> 	    System.out.println("IOException " + exc.getMessage());
> 	} catch (uk.co.westhawk.snmp.stack.PduException exc) {
> 	    System.out.println("PduException " + exc.getMessage());
> 	}
> 
> 
> 
> Regards,
> 
> Vijay Gholap.


More information about the snmp mailing list