CentOS snmpd Logging

By | 24/09/2018

After setting up snmpd you may get a lot of messages in /var/log/messages:

Sep 24 04:04:04 hostname snmpd[3016]: Received SNMP packet(s) from UDP: [dot.quad.ip.address]:57229
Sep 24 04:04:04 hostname snmpd[3016]: Received SNMP packet(s) from UDP: [dot.quad.ip.address]:37295
Sep 24 04:04:04 hostname snmpd[3016]: Received SNMP packet(s) from UDP: [dot.quad.ip.address]:56589
Sep 24 04:04:04 hostname snmpd[3016]: Received SNMP packet(s) from UDP: [dot.quad.ip.address]:56472
Sep 24 04:04:04 hostname snmpd[3016]: Received SNMP packet(s) from UDP: [dot.quad.ip.address]:40939
Sep 24 04:04:04 hostname snmpd[3016]: Received SNMP packet(s) from UDP: [dot.quad.ip.address]:47488
Sep 24 04:04:04 hostname snmpd[3016]: Received SNMP packet(s) from UDP: [dot.quad.ip.address]:60910
Sep 24 04:04:04 hostname snmpd[3016]: Received SNMP packet(s) from UDP: [dot.quad.ip.address]:59905
Sep 24 04:04:04 hostname snmpd[3016]: Received SNMP packet(s) from UDP: [dot.quad.ip.address]:38448
Sep 24 04:04:04 hostname snmpd[3016]: Received SNMP packet(s) from UDP: [dot.quad.ip.address]:53977
Sep 24 04:04:04 hostname snmpd[3016]: Received SNMP packet(s) from UDP: [dot.quad.ip.address]:47916

To manage this you can adjust the snmpd logging levels. The man page for the logging options is part of the net-snmp-utils package. First install that package:

# yum install net-snmp-utils

Look in the man page for the -L option in the LOGGING OPTIONS section.

# man snmpcmd

Logging can be managed through setting the range of message levels you want reported:

0 or ! for LOG_EMERG,
1 or a for LOG_ALERT,
2 or c for LOG_CRIT,
3 or e for LOG_ERR,
4 or w for LOG_WARNING,
5 or n for LOG_NOTICE,
6 or i for LOG_INFO, and
7 or d for LOG_DEBUG.

Find the current process and check the passed options:

ps -elf | grep snmp
5 S root     30100     1  0  75   0 -  7108 stext  08:21 ?        00:00:03 /usr/sbin/snmpd -Lsd -Lf /dev/null -p /var/run/snmpd.pid -a
# cd /etc/sysconfig

# cat snmpd.options
# snmpd command line options

# OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd.pid -a"

I appears that the default logging range is 0-6 (i.e. -LS0-6d) which logs from Emergency through to Information levels. To log only up to Notice level edit and change OPTIONS in /etc/sysconfig/snmpd.options:

OPTIONS="-LS0-5d -Lf /dev/null -p /var/run/snmpd.pid -a"

Finally, restart the daemon and check status:

# service snmpd restart
# service snmpd status
#ps -elf | grep snmp
5 S root     31332     1  2  75   0 -  7105 stext  09:03 ?        00:00:00 /usr/sbin/snmpd -LS0-5d -Lf /dev/null -p /var/run/snmpd.pid -a

Leave a Reply