SNMP Traps are now supported! (Finally)

Tags: #<Tag:0x00007f84b164f6d0>

Hi all!

Traps are here! You were waiting for this and now is released!

linkUp/Down, bgpUp/Down and authentication failure are the currently supported traps.

Want them working? https://docs.librenms.org/Extensions/SNMP-Trap-Handler/

Have an issue? Please, reply this post instead opening a new one!

4 Likes

Great! thanks for your work will definitely be checking this out :slight_smile:

Hi, thank you for this feauture, but I need help. Where can I see that traps ? and what you mean with this

Modify startup options to include -M /opt/librenms/mibs -m ALL

where can I edit this. I am using UBUNTU 16.0.4

Thank you

@jozefrebjak What you mean with where you will see the traps?

For example, a linkDown trap (port down) your database will be updated with that and you will see in the event log the trap like this: Interface went Down : GigabitEthernet0/5 (TRAP)

If you have a port up/down alert, you will recieve it as soon as alerts.php is ran (every 1 minute in cron).

Same for BGP sessions.

For where to put startup options, I dont really know in Ubuntu but, if you are using systemd, do systemctl status snmptrapd and you will see an output with this line:

Loaded: loaded (/usr/lib/systemd/system/snmptrapd.service; enabled; vendor preset: disabled)
You need to edit the snmptrapd.service file (in the location you have) and add the startup options to the ExecStart.

At least is how I have it.

Hmm I’ve done the following so far but no success, can you see anything I’m doing wrong?

Updated to latest LibreNMS on master.
su librenms
sudo vim /etc/snmp/snmptrapd.conf

ADD

disableAuthorization yes
authCommunity log,execute,net COMMUNITYSTRING
traphandle default /opt/librenms/snmptrap.php

sudo vim /usr/lib/systemd/system/snmptrapd.service

ADD to ExecStart

ExecStart=/usr/sbin/snmptrapd $OPTIONS -f -M /opt/librenms/mibs -m ALL

sudo systemctl daemon-reload
sudo systemctl enable snmptrapd
sudo systemctl restart snmptrapd
sudo systemctl status snmptrapd

It is active running, with Started Simple Network Management Protocol (SNMP) Trap Daemon…

Then i added to LibreNMS config.php

$config['snmptraps']['eventlog'] = 'all';

So this means I should see eventlogs for that device when interfaces are shut no shut?
How can you test recieval of trap messages without LibreNMS , do they come into journalctl or possible to add a seperate logfile like -Lf /tmp/all_traps ? (logoption doesn’t work in snmptrapd for me)

On the router i have all traps enabled and my snmp-server host libreip communitystring line.

and I wasn’t sure if you need udp,tcp 162 opened on the server? I have anyway.

You dont need $config['snmptraps']['eventlog'] = 'all'; To be honest, dont know for what is that :stuck_out_tongue:

In your router, assuming it is Cisco, you should also enable traps:

This is my config (for a edge bgp router)

snmp-server enable traps snmp authentication linkdown linkup coldstart warmstart
snmp-server enable traps bgp
snmp-server host LIBREHOST version 2c COMMUNITYSTRING

UDP 162 is the used port by snmptrap daemon

Recieved traps are found in /var/log/messages iirc

Got it working! thanks for the help.

(Had to allow UDP 162 on a hardware fw i forgot about)

@TheGreatDoc - Hi I’m trying to make SNMP traps work with some Secomea Trustgates - I have the MIB file but I find it hard to code the SNMP trap handlers - Can you perhaps help me out?

HI,

I am quite a new to LibreNMS and trying to get SNMP traps to work with Dell Servers.

Component Version
LibreNMS 1.59-58-g71ccb6a15
DB Schema 2019_12_05_164700_alerts_disable_on_update_current_timestamp (155)
PHP 7.2.24-0ubuntu0.18.04.2
MySQL 10.1.43-MariaDB-0ubuntu0.18.04.1
RRDTool 1.7.0
SNMP NET-SNMP 5.7.3

====================================

I have made the following changes please let me know what I am missing.

  1. Sudo vim /etc/snmp/snmptrapd.conf
    Add
    disableAuthorization yes
    authCommunity log,execute,net “CommunityString”
    traphandle default /opt/librenms/snmptrap.php

Make the folder /etc/systemd/system/snmptrapd.service.d/ and edit the file /etc/systemd/system/snmptrapd.service.d/mibs.conf and add the following content.

[Service]
Environment=MIBDIRS=+/opt/librenms/mibs:/opt/librenms/mibs/dell
Environment=MIBS=+ALL

LibreNMS SNMP Traps Intergration