/etc/snmp.conf
/etc/snmp/snmpd.conf
to allow connections by modifying agentAddress if it doesn’t already from the librenms lab./etc/snmp/snmpd.conf
to send the default set of traps to nmshost, creating internalUser for querying the data sources and specifying the default traps/lib/systemd/system/snmpd.service
by removing those options from the startup command in the service definition file, and reload the systemd daemonssh nmshost
sudo apt update
sudo apt install snmpd snmptrapd snmp-mibs-downloader
sudo sed -i -e 's/(^mibs :.*)/#\\1/' /etc/snmp/snmp.conf
sudo grep -i internaluser /etc/snmp/snmpd.conf || cat <<< "
#internal use user for querying trap data
createUser internalUser SHA fubar2snafu AES
rouser trapguy
iquerySecName trapguy
# Activate the standard monitoring entries
defaultMonitors yes
linkUpDownNotifications yes
# send traps to nmshost using community public
trap2sink nmshost public
# add an example custom trap to watch for high cpu usage
monitor -r 5 machineTooBusy hrProcessorLoad > 75
"| sudo tee -a /etc/snmp/snmpd.conf
sudo sed -i 's/-I -smux,mteTrigger,mteTriggerConf //' /lib/systemd/system/snmpd.service
sudo systemctl daemon-reload
sudo apt install postfix mailutils
ssh nmshost sudo tcpdump -v port 162
/etc/snmp/snmptrapd.conf
so that traps get logged and set up a traphandler to send email to yourself (make sure you change the email address in the example commands to be your email, not the professor’s)when you get a trap and restart the snmptrapd./lib/systemd/system/snmptrapd.service
and reload the systemd daemonsudo sed -i '$aauthCommunity log,execute public\ntraphandle default /usr/bin/traptoemail -s localhost dennis@nmshost.home.arpa' /etc/snmp/snmptrapd.conf
sudo sed -i 's/-LOw/-Lsd/' /lib/systemd/system/snmptrapd.service
sudo systemctl daemon-reload
sudo systemctl start snmptrapd
sudo ufw allow 162/udp
sudo ss -ulpn
snmptrap
command to send a trap message to nmshostsudo snmptrap -v 1 -c public nmshost '' '' 3 0 ''
sudo grep -i snmptrap /var/log/syslog |tail
mail
sudo systemctl restart snmpd
sudo grep -i internaluser /etc/snmp/snmpd.conf || cat <<< "
#internal use user for querying trap data
createUser internalUser SHA fubar2snafu AES
rouser trapguy
iquerySecName trapguy
# Activate the standard monitoring entries
defaultMonitors yes
linkUpDownNotifications yes
# send traps to nmshost using community public
trap2sink nmshost public
# add an example custom trap to watch for high cpu usage
monitor -r 5 machineTooBusy hrProcessorLoad > 75
"| sudo tee -a /etc/snmp/snmpd.conf
sudo sed -i 's/-I -smux,mteTrigger,mteTriggerConf //' /lib/systemd/system/snmpd.service
sudo systemctl daemon-reload
sudo systemctl restart snmpd
sudo grep -i snmptrap /var/log/syslog |tail
Services->SNMP
config page of the web interface, then check the end of /var/log/syslog
on nmshost which should show a cold start trap from pfsense.snmptrap
to test sending traps from loghost and webhost and verify you see them in the nmshost syslog file. Instead of trap 3, try using different trap codes to see what kinds of traps they can send.Librenms has an alerting capability that can use rules to match events that get recorded and then raise their visibility by putting them into an alert widget or by sending those alerts to a distribution mechanism. To demonstrate alerts, we will set up some simple ones to show in the standard alerts widget.
sudo grep -i librenms /etc/snmp/snmptrapd.conf || cat <<< "
traphandle default /opt/librenms/snmptrap.php
" | sudo tee -a /etc/snmp/snmptrapd.conf