Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1306045
  • 博文数量: 416
  • 博客积分: 10495
  • 博客等级: 上将
  • 技术积分: 4258
  • 用 户 组: 普通用户
  • 注册时间: 2005-04-23 22:13
文章分类

全部博文(416)

文章存档

2015年(7)

2014年(42)

2013年(35)

2012年(14)

2011年(17)

2010年(10)

2009年(18)

2008年(127)

2007年(72)

2006年(23)

2005年(51)

分类: LINUX

2011-09-08 15:18:37

I, along with many of my peers, complain that snmpd (from ) writes too many messages to the log file.

Jan 8 13:45:02 example snmpd[2048]: Connection from UDP: [10.0.0.1]:51890 Jan 8 13:45:02 example snmpd[2048]: Received SNMP packet(s) from UDP: [10.0.0.1]:51890 Jan 8 13:45:02 example last message repeated 2 times

Now imagine that repeated in every server, every time your monitoring server polls your host. This is a major mess and fills up the logs with crap. (If you can't imagine, it's 1,440 messages per host, and I monitor 18 hosts, which is 25,920 messages a day.)

The fault lies with tcpwrappers support. The firewalls are configured so that only the monitoring host can connect to the snmpd port. If you're not supposed to connect to snmpd, you can't. Thus, every connection is legitimate and doesn't need to be logged.

But how does one stop the logging?

The man page refers to a configuration option, dontLogTCPWrappersConnects, however this doesn't actually work and just gives an error. Let's ignore that then.

Reading the source (for 5.3.2) we find that the errors are written as follows:

--- net-snmp-5.3.2/agent/snmp_agent.c 2007-08-17 01:31:40.000000000 +1200 if ((log_addresses && (1 == rc)) || netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_VERBOSE)) { snmp_log(LOG_INFO, "Received SNMP packet(s) from %s\n", addr); } ... if (hosts_ctl(name, STRING_UNKNOWN, sbuf, STRING_UNKNOWN)) { snmp_log(allow_severity, "Connection from %s\n", addr_string); } else { snmp_log(deny_severity, "Connection from %s REFUSED\n", addr_string);

As you can see, legitimate connections are logged at LOG_INFO and allow_severity (which is also set to LOG_INFO). Unfortunately, pretty much every other important message from snmpd is logged at this level, so if you're going to disable this silly chatter you have to disable almost every log message. If you're good at coding C, find the above blocks of code and comment out the snmp_log calls.

How? On Redhat Server 5 and Redhat Enterprise Linux 4 you simply create the file /etc/snmp/snmpd.options and put in there:

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

This is pretty much the default options (grep OPTIONS /etc/init.d/snmpd to compare) but with the removal of -Lsf, thus disabling logging.

For Fedora Core 10 and CentOS 5.2 the options file can be in /etc/sysconfig/snmpd.options, and if that file exists, use it instead.

Thank goodness for quiet log files!

Stephen Cope 2009-09-22
/net-snmp.html clickHeatSite = '';clickHeatGroup = 'net-snmp';clickHeatServer = '~kimihia/clickheat/click.php';initClickHeat();
阅读(1486) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~