本文介绍如何在linux下配置snmp服务,供大家学习参考。
1.1 snmpd 服务安装
1.2 编辑snmpd.conf 配置文档
vim /etc/snmp/snmpd.conf
1.3 启动 snmpd 服务
1.4 验证snmpd 服务
//snmpd 使用 tcp/udp 161 端口
grep 'Simple Net Mgmt Proto' /etc/services
snmp 161/tcp # Simple Net Mgmt Proto
snmp 161/udp # Simple Net Mgmt Proto
lsof -i :161
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
snmpd 3734 root 11u IPv4 13174 UDP *:snmp
ps -ef | grep 'snmpd'
root 3734 1 0 09:34 ? 00:00:00 /usr/sbin/snmpd -Lsd -Lf /dev/null -p /var/run/snmpd.pid -a
1.5 修改snmpd 日志级别
//以上操作能够满足snmpd 服务正常使用,不过snmpd 默认日志级别将会在/var/log/message 写入大量snmp 信息,这样会影响我们察看系统日志,所以我们需要更改下!
Mar 1 09:55:01 monitor snmpd[3734]: Connection from UDP: [127.0.0.1]:37535
Mar 1 09:55:01 monitor snmpd[3734]: Received SNMP packet(s) from UDP: [127.0.0.1]:37535
Mar 1 09:55:01 monitor snmpd[3734]: Connection from UDP: [127.0.0.1]:47836
Mar 1 09:55:01 monitor snmpd[3734]: Received SNMP packet(s) from UDP: [127.0.0.1]:47836
//注释原有的OPTINOS,添加下面的一行,重启snmpd 服务即可。
vim /etc/init.d/snmpd
#OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd.pid -a"
OPTIONS="-LS 4 d -p /var/run/snmpd.pid -a"
/etc/init.d/snmpd restart
Stopping snmpd: [ OK ]
Starting snmpd: [ OK ]
1.6 使用snmpwalk 命令验证
-v是指版本,-c 是指密钥,获取到系统信息则正常!