我使用 snmp 去收集 Linux 上的資訊,網卡、流量等等,
但 /var/log/messages 會有很多如下的記錄出現,它是 info,我也不需要這個東西的存在,也不會去看它,
Nov 9 04:05:12 st snmpd[3404]: Received SNMP packet(s) from UDP: [10.1.1.252]:55422 Nov 9 04:05:12 st snmpd[3404]: Connection from UDP: [10.1.1.252]:55422
所以要改變一下 snmpd 啟動方式,原本如下
root 3371 0.0 0.0 158268 8204 ? Sl Nov13 0:00 /usr/sbin/snmpd -Lsd -Lf /dev/null -p /var/run/snmpd.pid -a
就是 -Lsd 這個,-Ls 就是記錄到 syslog ,而 d 就是 LOG_DAEMON
所以我要換成 -LSwd 或者是 -LS4d,w 或 4 都是 warning 代表號
# more /etc/sysconfig/snmpd.options # snmpd command line options OPTIONS="-LS4d -Lf /dev/null -p /var/run/snmpd.pid -a"
不過為何有人要這麼設 -LS0-4d,它不會向下繼承嗎 ? 不會 -LS4d 就包含 0-4 ?? 我暫時無解
底下為 man 的說明
man snmpd
-L[efos] Specify where logging output should be directed (standard error or output, to a file or via syslog). See LOGGING OPTIONS in snmpcmd(5) for details.
man snmpcmd
-L [eEfFoOsS] Specifies output logging options. See LOGGING OPTIONS below. -Ls FACILITY Log messages via syslog, using the specified facility (’d’ for LOG_DAEMON, ’u’ for LOG_USER, or ’0’-’7’ for LOG_LOCAL0 through LOG_LOCAL7). There are also "upper case" versions of each of these options, which allow the corresponding logging mechanism to be restricted to certain priorities of message. Using standard error logging as an example: For -LF and -LS the priority specification comes before the file or facility token. The priorities recognised are: 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.
留言