Posted 21 February, 2016
librenms, my hero monitor!
In this guide I just install configure SNMP daemon on Centos 8.2 (latest at this writing). SNMP is used to read out the state of the machine, this includes CPU, network (-traffic, -settings,…), memory, … I can suggest LibreNMS, for the monitor. Back to setting SNMP daemon up !
Install
Install the service using our loved yum.
yum install net-snmp net-snmp-utils
Config
To the configuration; which can be found here : /etc/snmp/snmpd.conf
I however remove the original one -most of the time- and just copy/paste the one I use on all servers; Keep the original for reference, although its very verbose (IMHO)
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.ori
This is the config I use and why in the comments :
# this create a SNMPv1/SNMPv2c community named "my_servers" # and restricts access to LAN adresses 192.168.0.0/16 (last two 0's are ranges) rocommunity my_servers 192.168.0.0/16 # setup info syslocation "rack 1, room 3, Antwerpen serverrroom" syscontact "Svenn" # open up agentAddress udp:161 # run as agentuser root # dont log connection from UDP: dontLogTCPWrappersConnects yes # fix for larger then 2TB disks (raid!) realStorageUnits 0
Network security
Since this is a network tool, we need to allow incoming connections through the firewall; For Centos 6-7 this is mostly IPTABLES, if you are using Centos 8 then FirewallD is the one to config;
IPTABLES
iptables -A INPUT -s 192.168.0.0/16 -p udp --dport 161 -j ACCEPT
Be sure to change the ip range!
FirewallD
firewall-cmd --permanent --add-service=snmp firewall-cmd --reload
Note I did not add the range here (you could add a zone).
Starting the daemon
systemctl start snmpd systemctl enable snmpd
Reduce verbose
In older versions, snmpd was really verbose. By default EVERY connection is logged in rsyslog. Considering I poll every 5 minutes, this adds up in /var/log/messages. So lets down it a bit, this can be done in /etc/sysconfig/snmpd add the following, to reduce the verbosity :
OPTIONS=”-Ls3d”
Extending snmp
Librenms can track multiple snmp extends, most relevant for me are zfs, apc ups, nfs server (my own creation), these can generally be added using a small executable script adding this in snmp.conf
extend nfs-server /etc/snmp/nfs-server.sh extend zfs /etc/snmp/zfs-linux extend ups-apcups /etc/snmp/ups-apcups.sh
For more info on these, I would refer to the documentation of LibreNMS.
Testing … 123
On the machine you are installing LibreNMS or any other NMS package try :
snmpwalk -c my_servers -v1 servername SNMPv2-MIB::sysDescr.0
This should return the system description. (only change -c COMMUNITY and -v1 SERVERNAME/IP)
Happy monitoring!
changes :
If you enjoyed this article, please consider buying me a Dr Pepper.
Fuel the beast!
Buy me a Dr Pepper
Perfect! Thanks