Best way of adding SNMP support to your own application on Debian
Asked Answered
D

4

6

I am working on Debian and I have this server we want to monitor.
The application is ours and there are around a hundred real-time counters we want to export for monitoring purposes, graphs and alarms.

I've been looking at the Debian way of doing this because we do use Debian packaging to install the app, and Debian uses snmpd daemon, based on net-snmp, to export SNMP. So far every approach I've seen looks very complicated, from recompiling snmpd to load a dynamic library into it, and compiling a form of subagent that replicates what snmpd does.

While all of those options make me think I should go for something else than SNMP I don't want to give up that early and I was wondering if anybody has found a feasible implementation.

Ideally it should be coded in C or C++ as the app is in C++, but I'm open to wrappers or other kind of suggestions.

Dustheap answered 14/12, 2010 at 21:57 Comment(0)
P
6

net-snmp supports both the smux and agentx agent extension protocols, allowing sub-agents to live in different processes. They also have a tutorial on writing AgentX subagents in C.

Pericardium answered 14/12, 2010 at 22:13 Comment(2)
So, would you add a separate process as a subagent or directly make your own process a subagent? On one side I don't like the idea of the agent polling my process 100 times for 100 values when it could be done on one go, but creating another process for this and the comms looks a little too much.Dustheap
With proper multiprocessing/asynchronous processing, it shouldn't matter that your process gets 100 requests. So I'd definitely try to put the subagent into the application process.Prairie
P
6

An often overlooked solution is Agent++ API, which to me looks pretty nice and is under the Apache license. As far as I understand, you can modify that agent to answer to your own MIBs.

That said, doing a subagent isn't such a bad choice. You start the standard unpatched snmpd (from net-snmp). Then you connect to it with your subagent, which only adds those OIDs you want it to add. The net-snmp kit for coding AgentX (as the protocol is called) sub-agents is not dead simple to use, but not very hard either. There is also a Perl module for sub-agent development: https://metacpan.org/pod/NetSNMP::agent

Postimpressionism answered 14/12, 2010 at 22:14 Comment(2)
Maybe this was correct in the past, but as of today AgentX++ is available with a commercial license (see agentpp.com/doc/agentpp_pricelist.pdf ). Agent++ itself is available under Apache license, but not AgentX++.Springhalt
@Étienne, thanks, I edited the answer and I hope it's accurate now.Postimpressionism
N
3

The traditional way to do this in linux is to use the net-snmp package. Make sure you write the MIB first. Everything is based on the MIB and changes to the MIB usually results in lots of changes in the code. Coding for net-snmp is not difficult and there is lots of documentation to get you started, eg: http://www.net-snmp.org/wiki/index.php/Tutorials#Coding_Tutorials

Neap answered 14/12, 2010 at 22:19 Comment(0)
W
-1

Have you tried net-snmp?

Weis answered 14/12, 2010 at 22:5 Comment(2)
Debians snmpd is based on net-snmp and the approaches I listed are the ones listed on net-snmp, unless I missed anythingDustheap
The snmpd he refers to likely originates from net-snmp.Prairie

© 2022 - 2024 — McMap. All rights reserved.