Traps and agent in separate threads (v2c)

"Mattias Jansson" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
I know (from FAQ and mailing-list etc) that Net-SNMP isn't thread-safe by
itself.

I've also read this post
<http://sourceforge.net/mailarchive/message.php?msg_id=27115676>
http://sourceforge.net/mailarchive/message.php?msg_id=27115676 regarding
sending notifications from "outside the agent", but I have some unanswered
questions left.

 

My scenario is the following:

I have a multi-threaded (pthread) application, which embed an agent using
code generated by mib2c. I don't run agentX, instead my app acts as master
agent (for my enterprise MIB only). I have no problems running *all* snmp
related stuff in one thread so far, it handles requests using a cache, and
the cache is reloaded within that same thread with locking (mutex's)
provided by me to acquire data from global variables shared with the other
threads (who actually change the data). This entire setup is used for
statistics, monitored by another process GET'ing the data at certain
interval.

 

Now my question/problem is the following:

I also want my app to send notifications (v2c TRAP), in case something
urgent happens in the app. But I want the TRAP-sending to be the
responsibility of a different thread, I don't want it to have anything to do
with the agent thread/code. From the other thread (linked above), I know I
can't use send_v2trap, as it depends on stuff in the agent. But as I
understand it, I could implement something like "net-snmp/apps/snmptrap.c",
which isn't depending on an agent, and use that to send TRAP. Only one
thread will do the sending (I won't have multiple threads sending TRAP); the
thread will pop "messages" of a queue and send them. No need to worry about
synchronization/thread-safety between multiple "TRAP-senders".

 

I need to know though, if this is a (thread-)safe approach?? Or is there any
chance the "agent-thread" and the "TRAP-sender-thread" will conflict in
using any global variables? I'm using v2c only, no need for v3 (although, if
the same scenario using v3 poses a problem, I'd like to know)

 

How else can I accomplish what I want?

 

Regards

MJ

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.