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

10,070

Solution 1

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.

Solution 2

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

Solution 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

Share:
10,070
Arkaitz Jimenez
Author by

Arkaitz Jimenez

Updated on July 02, 2022

Comments

  • Arkaitz Jimenez
    Arkaitz Jimenez almost 2 years

    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.

  • Arkaitz Jimenez
    Arkaitz Jimenez over 13 years
    Debians snmpd is based on net-snmp and the approaches I listed are the ones listed on net-snmp, unless I missed anything
  • Martin v. Löwis
    Martin v. Löwis over 13 years
    The snmpd he refers to likely originates from net-snmp.
  • Arkaitz Jimenez
    Arkaitz Jimenez over 13 years
    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.
  • Martin v. Löwis
    Martin v. Löwis over 13 years
    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.
  • Étienne
    Étienne almost 4 years
    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++.
  • Prof. Falken
    Prof. Falken almost 4 years
    @Étienne, thanks, I edited the answer and I hope it's accurate now.