In an embedded linux application, I've successfully made a subagent that uses 
the 'Traditional API' in its servicing thread, rather than the 'Single API' 
(described in http://net-snmp.sourceforge.net/docs/README.thread.html).  That 
is, it uses register_readfd(), snmp_select_info(), 
netsnmp_external_event_info(), select(), netsnmp_dispatch_external_events(), 
snmp_read(), snmp_timeout(), run_alarms().  It uses AgentX to service SNMP 
operations from snmpd (running in a separate linux process).  The subagent 
successfully registers its handler callbacks (e.g. via netsnmp_register_scalar) 
and remote managers can perform GETs and SETs on the registered OIDs.

Now I need to make that subagent service traps.  I have the following questions:
1. Is there a Net-SNMP library API I can call to give it the trap OID plus a 
list of OIDs whose values should be sent in the trap, and have the library 
automatically GET the values, assemble the trap message and send it?

2. Or, do I need to write code myself to put the trap OID into a 
netsnmp_variable_list, then write code to GET the values and add them to that 
list, and then send the trap (e.g. send_v3trap) ?

3. If the answer to #2 is 'yes', should that be done by having the subagent 
send a GET to the snmpd agent?  If so, is this the correct way to do that?
    3.a. After the subagent's existing code to init_agent and init_snmp, create 
a session (snmp_sess_init) and open it (snmp_open)
    3.b. Call snmp_varlist_add_variable to add the trap OID to a 
netsnmp_variable_list
    3.c. GET the value needed for the trap by:
        3.c.i. Call snmp_pdu_create to create a GET PDU
        3.c.ii. Call snmp_add_null_var to add the OID for the needed value
        3.c.iii. Call snmp_synch_response to GET the value
    3.d. Call snmp_varlist_add_variable to add the retrieved value to the list
    3.e. Call send_v3trap to send the list in a trap

4. Am I correct in understanding that all the lib API in (3.c) - (3.e) calls 
must to be done within the subagent's servicing thread (since the lib is not 
thread-safe)?

5. Do I need to convert the servicing thread to use the 'Single API' calls in 
order for this to work (and thus use the 'Single API' calls in (3) above to GET 
the values needed for the trap)?  Or will the 'Traditional API' calls that I'm 
currently using work ok?



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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