<span style="font-size:14px;">本文介紹怎樣在CentOS環境下配置一個簡單的SNMP服務</span>
切換到系統管理員賬戶工具
安裝snmp
確認snmp代理已安裝
rpm -q net-snmp
假設未安裝。安裝snmp
yum install net-snmppost
設置開機本身主動執行snmp
/sbin/chkconfig snmpd on配置snmp
spa
將原來的配置文件備份。編輯/etc/snmp/snmpd.conf,簡單配置例如如下.net
# First, map the community name "public" into a "security name" # sec.name source community com2sec notConfigUser default public #### # Second, map the security name into a group name: # groupName securityModel securityName group notConfigGroup v1 notConfigUser group notConfigGroup v2c notConfigUser #### # Third, create a view for us to let the group have rights to: # Make at least snmpwalk -v 1 localhost -c public system fast again. # name incl/excl subtree mask(optional) view systemview included .1.3.6.1.2.1.1 view systemview included .1.3.6.1.2.1.25.1.1 #### # Finally, grant the group read-only access to the systemview view. # group context sec.model sec.level prefix read write notif access notConfigGroup "" any noauth exact systemview none none
/etc/init.d/snmpd start
假設已啓動則從新啓動snmp服務
/etc/init.d/snmpd restartpwa
查看port是否打開
netstat -ln | grep 161
代理
安裝snmp測試工具
yum install net-snmp-utils
rest
本機測試snmp數據(改動monit爲配置的團體名)
snmpwalk -v 2c -c public localhost systemcode
snmpwalk -v3 -u username -l auth -a MD5 -A password localhostserver
建立SNMP(v3)用戶blog
net-snmp-config --create-snmpv3-user -ro -a MD5 lyceemsnmp lyceem.com
遠程測試snmp數據(改動ip爲serverip,snmpwalk命令需要安裝net-snmp)
snmpwalk -v 2c -c public ip system