Hi Bill,

Thanks for your reply.


>then I recommend establishing the connection, sending the trap, and closing 
>the connection again, like the agentxtrap command does.

I have referred agentxtrap code and found "snmp_select_info" to be interesting. 
I have passed the resultant fds ( fd to connect to netsnmp ) + my fd ( fd to 
receive trap from ipmi daemon ), to select() and waiting on it.  I have tested 
this by making agent and snmpd idle for about an hour. So far so good. I have 
planned to let it be like this over night to see how well it goes.


How do you see this approach ?


If establishing the connection, sending trap and closing is the best way to do 
this, do you mean using following apis like agentxtrap ?

netsnmp_transport_open_client() , snmp_sess_add_ex, snmp_sess_close()   ?



Regards,

Mukunth


________________________________
From: Bill Fenner <fen...@gmail.com>
Sent: Thursday, October 25, 2018 1:33 AM
To: Rajaa, Mukuntha (Nokia - IN/Bangalore)
Cc: Net-snmp-users@lists.sourceforge.net
Subject: Re: Reconnect subagent automatically

On Mon, Oct 22, 2018 at 1:01 AM Rajaa, Mukuntha (Nokia - IN/Bangalore) 
<mukuntha.ra...@nokia.com<mailto:mukuntha.ra...@nokia.com>> wrote:

Hi,


I am using subagent mainly for "traps". So I am not using 
"agent_check_and_process". From what I understand, "agent_check_and_process" 
polls on to the connection between snmpd and subagent for any incoming request. 
My subagent is not serving any request at all. So I have skipped this function 
check at all.

The master agent will disconnect you regularly, then, if you're not responding 
to pings, because it will think that you've gone unresponsive.


So whenever master-agent (snmpd ) gets restarted, subagent isnt re-establishing 
the connection. My code snippet is something like this,


    while ( whatever )

    {

        wait_for_events_to_arrive_in_pipe(); // blocks on read-system call

    }


Currently I am hooking up netsnmp init script ( yes I am working on legacy 
system. No systemd ) to restart my subagent too. I am not too happy with this 
method. Is there an advisable way in doing so.

If you need to block until something happens, then I recommend establishing the 
connection, sending the trap, and closing the connection again, like the 
agentxtrap command does.

  Bill

_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to