Creating new and modifying existing SNMP trap handlers

I’m looking for a bit of help/education with trap handlers.

We adopted LibreNMS as a tool to manage SNMP traps, because we had no tool before this.

After onlining most of our infrastructure, we are receiving both:

  • traps that are not handled by a handler that we want translation for
  • traps that are being handled by an existing handler twhere we want to modify the handler.

I have a few questions about best practices with LibreNMS, so that I hopefully avoid causing myself pain down the road:

For now I am hoping to avoid ‘submitting code to the project’ to get the changes I want, though I’d like to contribute as I learn more, I’m just not there yet.

Question one: When creating a new handler, the documentation indicates I should add the handler to config/snmptraps.php … However at the top of this file I am met with a large friendly warning that states: “DO NOT EDIT THIS FILE! Change settings in the environment or .env”. My question is: if I should not edit this file – what should I change instead? This is unclear to me as I’m not sure what it wants when it refers to as the .env file/environment… What happens if I ignore this warning, and edit the file anyways? Will it work? Will it break upgrades down the road? Will my change eventually be over-written when this file changes as part of an update?

Question two: If I want to modify an existing trap handler (for example “JnxCmCfgChange.php” does not display the commit comment, but that information is included in the raw trap data, so I have modified the handler to also display the commit comment in the message) … What is the best/proper way to do this without breaking anything? Can I modify the handler in this way? Will I break auto-upgrades or perhaps my changes will be over-written if the maintainer updates this file some day? … My validate.php complains about the changes I had made to these files, and tells me I might be breaking things.

Appreciate any insight – I am new to LibreNMS and impressed - this is a wonderful NMS tool.

Component | Version
--------- | -------
LibreNMS  | 21.6.0
DB Schema | 2021_25_01_0127_create_isis_adjacencies_table (210)
PHP       | 7.3.28
Python    | 3.6.8
MySQL     | 10.5.10-MariaDB
RRDTool   | 1.4.8
SNMP      | NET-SNMP 5.7.2

[OK]    Composer Version: 2.1.3
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[OK]    Database schema correct
[WARN]  IPv6 is disabled on your server, you will not be able to add IPv6 devices.
[WARN]  Your local git contains modified files, this could prevent automatic updates.
        You can fix this with ./scripts/github-remove
        Modified Files:

Id suggest you look into other contributions in the same category for inspiration; Pull requests · librenms/librenms · GitHub

The auto update feature might stop working yes since you have modified files, it uses standards git for it. I would Setup a dev installation

@CJ04 Basically, for question 1, the big warning is there to tell you that the file is not modified by “users” but by “developpers”. But as soon as you start developping a new trap handler, this is the way to go. Traps handlers are not “user configurable”, only “devlopper writable”.
And yes it will break autoupdate if you changed a file. GIT will refuse to upgrade it (conflict) and your install will stay un-upgraded (with a warning every night) until you solve the conflict.
This is why you are invited to submit your contribution (even the smallest ones):

  • You help the community and
  • You help yourself keeping your install “up to date”, which is the community contribution to you

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.