On sön, 2007-02-04 at 23:57 +0530, bhushan wrote:
> Hello Friends,
> I am using netsnmp 5.1.2 , i have written a code that will send trap
> to main agent i.e. snmpd, for this i have return a module that have
> follwing function i.e.
>
> 1 ) initialize()
> doing snmp initalization in this function i.e
> snmp_disable_log();
> if (netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
> NETSNMP_DS_AGENT_ROLE, 1) !=
> 0)
> return ERROR;
> // for this i also modified snmpd.conf so that main agent
> // listen on correct port
> if (netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
> NETSNMP_DS_AGENT_X_SOCKET, "udp:localhost:705") !=0 )
This looks seriously confused - AgentX usually listens to
unix:/var/agentx/master or occationally to tcp:localhost:705. In any
case is it a connection oriented protocol, so udp: is wrong.
> return ERR_NETSNMP;
> while(i< 4) {
> ret_val = init_agent("subagent");
> if(ret_val == 0)
> break;
> sleep(2);
> i++;
> }
> if(ret_val != 0)
> return ERR_NETSNMP;
> init_snmp("subagent");
>
> 2) trap_send
> send trap to main agent i.e. snmpd
> using following api
> snmp_varlist_add_variable
> sendv2_trap
> snmp_free_varbind
> 3) destroy
> snmp_shutdown("sub-agent");
> shutdown_agent();
>
>
> so my main program call this function when it starts i.e.
> when it starts it call initialize then for sending trap it call
> trap_send function. when main program dont want to send trap
> it call destroy &
> problem occurs when main program want to send
> trap again then it again call initalization function & when it call
> initialization funcion it fails in init_agent function it fails
> i.e it exit
> so my main from get exited.
> what may be the problem I have seen simmilar post on mailing
> list of netsnmp but don't get help from thouse mails.
> I think when main program call destroy, & after that call init_agent
> then at that time some thing went wrong i also don't know weather
> i correct or not. Please help me in this friends
If it hurts when you do that, then don't do that.
You should execute the initialize part on program startup, then you can
run the trap_send part multiple times during the lifetime of the program
and finally you call the destroy part during program shutdown.
Of course in an ideal world the shutdown code would clean up enough to
make it possible to reinit but as you have seen that isn't the case.
/MF
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders