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.
[FIX]:
You can fix this with ./scripts/github-remove
Modified Files:
LibreNMS/Snmptrap/Handlers/AuthenticationFailure.php
LibreNMS/Snmptrap/Handlers/JnxCmCfgChange.php