You can think of a separate standalone agentx based subagent process. I am
doing the same for my work. The master agent will monitor and response to
GET/SET. The device sends async msgs which will be listened by this subagent
and throught net-snmp trap API you can send them to the managers via master
agent. In this way you can also have snmpd.conf for reading trap-dest
systems.

just a suggestion, do your full study based on your platform and need.



On Mon, Feb 28, 2011 at 6:51 PM, Giuseppe Modugno
<[email protected]>wrote:

>   Dear list,
>
>    I have an electronic device I want to control by SNMP SET/GET requests.
> This device communicates through a serial (RS232) port with a specific
> protocol.
>
>    I'm going to connect a board running Linux and Net-SNMP agent to the
> serial device. The connection will be made through RS232.
>
>    Usually the serial device monitor incoming GET/SET requests (with a
> custom format) from the serial port and answer with the value requested or
> ACK/NAK.
>
>    I already extended the main Net-SNMP agent with a dynamic loadable
> module. In the init() function of the module, I register the private OIDs
> related to the serial device and the handler function. I also open the
> serial port.
>   For SET and GET SNMP requests, I convert them into GET/SET serial
> commands and send them to the serial port, waiting for the answer. Depending
> on the answer, I send back to SNMP manager the value requested or an error.
>   This system works very well and I'm satisfied with it.
>
>    Now I need another feature: traps.
>   The serial device can send asynchronous (unsolicited) messages that
> should be converted in SNMP notifications.
>
>    The first approach I considered was to create an indipendent process (a
> serial bridge process) that would be stay between the serial port and the
> agent. This bridge monitors the serial port for asynchronous messages
> (sending notifications when necessary) and the agent (through a local domain
> socket) for GET/SET requests. These requests are transparently routed to the
> serial port, and also the answers are routed back to the agent (the bridge
> can simply distinguish asyncronous messages that creates notifications and
> answer messages that must be routed to the agent).
>
>    After some coding, I think this approach is not good. Indeed the serial
> bridge will not run inside the agent, so it couldn't know details about
> sending traps (i.e., it can't use send_v2trap() function). I should use a
> system() call to "snmptrap" command, loosing many benefits of send_v2trap()
> function (as Dave pointed me in a previous post).
>
>    So I'm looking for a better approach. As the serial device can send
> messages at any time (asyncronously) I need to call a select() on the serial
> port file descriptor, waiting for some activities on it.
>
>    But I have some difficulties to find a good point where to call the
> select(), considering that the init() function must return and the
> registered handler is called only for SET/GET requests from the network.
>
>    Is it possible to create and launch (fork?) a new process (the serial
> bridge) from the init() function of the dynamic loadable module? I never
> used fork in the past, but I know the child process will start again from
> main() function. What happens if I fork from a shared object module? Does
> the snmpd main() function start again?
>
>    Any help will be appreciated.
>
>
>
> ------------------------------------------------------------------------------
> Free Software Download: Index, Search & Analyze Logs and other IT data in
> Real-Time with Splunk. Collect, index and harness all the fast moving IT
> data
> generated by your applications, servers and devices whether physical,
> virtual
> or in the cloud. Deliver compliance at lower cost and gain new business
> insights. http://p.sf.net/sfu/splunk-dev2dev
> _______________________________________________
> Net-snmp-coders mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
>
>


-- 
Rakesh P. Zingade
+919420626099
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to