2016-08-24 08:12:20 +01:00
|
|
|
source: Extensions/SNMP-Trap-Handler.md
|
2018-10-27 23:04:34 +01:00
|
|
|
path: blob/master/doc/
|
2019-09-09 05:48:35 -05:00
|
|
|
|
2016-03-04 17:13:03 -07:00
|
|
|
# SNMP trap handling
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
Currently, librenms only supports linkUp/linkDown (port up/down),
|
|
|
|
bgpEstablished/bgpBackwardTransition (BGP Sessions Up/Down) and
|
|
|
|
authenticationFailure SNMP traps. To add more see [Adding new SNMP Trap handlers](../Developing/SNMP-Traps.md)
|
2018-08-11 23:37:45 +02:00
|
|
|
|
|
|
|
Traps are handled via snmptrapd.
|
2016-03-04 17:13:03 -07:00
|
|
|
|
|
|
|
## Configure snmptrapd
|
|
|
|
|
|
|
|
Install snmptrapd via your package manager.
|
|
|
|
|
2019-01-17 15:48:04 -06:00
|
|
|
To enable snmptrapd to properly parse traps, we will need to add MIBs.
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
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. You may want to tweak to add vendor directories
|
|
|
|
for devices you care about (in addition to or instead of cisco).
|
2019-01-17 15:48:04 -06:00
|
|
|
|
|
|
|
```ini
|
|
|
|
[Service]
|
|
|
|
Environment=MIBDIRS=+/opt/librenms/mibs:/opt/librenms/mibs/cisco
|
|
|
|
Environment=MIBS=+ALL
|
|
|
|
```
|
|
|
|
|
|
|
|
For non-systemd systems, you can edit TRAPDOPTS in the init script in /etc/init.d/snmptrapd.
|
|
|
|
|
|
|
|
`TRAPDOPTS="-Lsd -M /opt/librenms/mibs -m ALL -f -p $TRAPD_PID"`
|
2018-08-11 23:37:45 +02:00
|
|
|
|
2016-03-04 17:13:03 -07:00
|
|
|
In `/etc/snmp/snmptrapd.conf`, add something like the following:
|
|
|
|
|
|
|
|
```text
|
|
|
|
traphandle default /opt/librenms/snmptrap.php
|
|
|
|
```
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
Along with any necessary configuration to receive the traps from your
|
|
|
|
devices (community, etc.)
|
2018-08-14 01:56:16 -05:00
|
|
|
|
2019-01-17 15:48:04 -06:00
|
|
|
Reload service files, enable, and start the snmptrapd service:
|
|
|
|
|
|
|
|
```
|
|
|
|
sudo systemctl daemon-reload
|
|
|
|
sudo systemctl enable snmptrapd
|
|
|
|
sudo systemctl restart snmptrapd
|
|
|
|
```
|
|
|
|
|
2018-08-14 01:56:16 -05:00
|
|
|
### Event logging
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
You can configure generic event logging for snmp traps. This will log
|
|
|
|
an event of the type trap for received traps. These events can be utilized for alerting.
|
2018-08-14 01:56:16 -05:00
|
|
|
|
|
|
|
In config.php
|
2019-09-09 05:48:35 -05:00
|
|
|
|
2018-08-14 01:56:16 -05:00
|
|
|
```php
|
|
|
|
$config['snmptraps']['eventlog'] = 'unhandled';
|
|
|
|
```
|
|
|
|
|
|
|
|
Valid options are:
|
2019-09-09 05:48:35 -05:00
|
|
|
|
|
|
|
- `unhandled` only unhandled traps will be logged
|
|
|
|
- `all` log all traps
|
|
|
|
- `none` no traps will create a generic event log (handled traps may still log events)
|