SNMP Configuration (snmpd.conf) Cheat Sheet

A curated list of SNMP parameters for your /etc/snmp/snmpd.conf file

The article aims to highlight differences between Redhat (e.g. CentOS) based distributions and Debian (e.g. Ubuntu) based distributions.

Works with CentOS

With CentOS, you can get away with this line only `rocommunity your_secret_public_community` but here is a better template:

rocommunity your_secret_public_community

syslocation Rack, Room, Building, City, Country
syscontact Your Name <[email protected]>
sysDescr Hardware, Serial, Operating System, Platform

#Distro Detection
extend distro /usr/bin/distro

If you don’t have serial numbers for sysDescr, you could do something like:

sysDescr Guest, Host, Control Panel, Major Applications

E.g.:

sysDescr VM on SuperDaddy, Dedicated Machine at XYZ, Virtualmin, Email + Web

Distro detection script:

If you’re using LibreNMS or you want your SNMP program to automatically detect the distro, use this script:

curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro;
chmod +x /usr/bin/distro

 

Works with Ubuntu

Ubuntu needs more defaults to work than CentOS:

rocommunity your_secret_public_community
syslocation Rack, Room, Building, City, Country
syscontact Your Name <[email protected]>
com2sec readonly your_secret_public_community
agentaddress udp:161
sysservices 76
master yes

Other

A curated set of configuration commands and options that should work with any distribution

Allow Firewalld

If you’re using Firewalld, use these two commands to quickly allow SNMP through:

firewall-cmd --zone=public --permanent --add-service=snmp;
firewall-cmd --reload

Turn off Repetitive Logging

Is your syslog overrun with SNMP connect requests? Try this:

dontLogTCPWrappersConnects yes

Execute your own OID Script

Postfix

This parameter works in conjunction with another script to calculate Postfix queue size.

exec postqueue /etc/postfix/snmp_monitor_postqueue.sh

When you have this as the first “application” for SNMPD, the OID will be:

.1.3.6.1.4.1.2021.8.1.101.1

Monitoring Asterisk

When monitoring Asterisk, you might end with these four entries:

exec AsteriskExtensionInUse /usr/bin/sudo /etc/snmp/asterisk_extension_in_use.sh
exec AsteriskExtensionNotInUse /usr/bin/sudo /etc/snmp/asterisk_extension_not_in_use.sh
exec AsteriskExtensionUnavailable /usr/bin/sudo /etc/snmp/asterisk_extension_unavailable.sh
exec AsteriskExtensionRinging /usr/bin/sudo /etc/snmp/asterisk_extension_ringing.sh

Installation

Install on AlmaLinux

dnf install net-snmp

Install on CentOS

yum install net-tools

Automatic Start

Once the service is installed, verify that it is set to start at startup by running:

CentOS 6

chkconfig snmpd on

CentOS 7

systemctl enable snmpd
Result CentOS 7
Created symlink from /etc/systemd/system/multi-user.target.wants/snmpd.service to /usr/lib/systemd/system/snmpd.service.

Tip: If you do this again, you’ll have no output.

SNMPWalk

A beautiful elegant savvy way of testing your SNMP 😉

For CentOS, you need this:

yum install net-snmp-utils

Install on Ubuntu

sudo apt install snmpd

Then do this:

snmpwalk -c your_secret -v1 host.example.com

See Also

How to get SNMP daemon working on Ubuntu 18.04/20.04 LTS

How to set up SNMP for CentOS

How to monitor Postfix queue length using an SNMP monitor

Reference

https://docs.librenms.org/Support/SNMP-Configuration-Examples/#linux-snmpd-v2

 

 

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top