首先使用snmpwalk -v 1 localhost -c public测试snmp服务是否正常
Timeout: No Response from localhost
说明有问题
service snmpd status查看服务是否开启,关闭的话打开服务
服务开启之后还有timeout,查看vi /etc/snmp/snmpd.conf配置
在conf文件中添加下面两句见附一:
view all included .1
access notConfigGroup "" any noauth exact all none none
/usr/local/php/bin/php /usr/local/apache/htdocs/cacti/poller.php
/usr/bin/rrdtool fetch /usr/local/apache/htdocs/cacti/rra/localhost_load_1min_5.rrd AVERAGE
################################附一snmpd.conf文件########################################################
####
# First, map the community name "public" into a "security name"
# sec.name source community
com2sec notConfigUser default public #定义community名称为 public,映射到安全名 notConfigUser。
####
# Second, map the security name into a group name:
# groupName securityModel securityName
group notConfigGroup v1 notConfigUser #定义安全用户名notConfigUser映射到notConfigGroup组。
group notConfigGroup v2c notConfigUser
####
# Third, create a view for us to let the group have rights to: #定义一个view,来决定notConfigUser可以操作的范围。
# Make at least snmpwalk -v 1 localhost -c public system fast again. #定义可查看的snmp的范围。
# 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
view all included .1
####
# Finally, grant the group read-only access to the systemview view. #给notConfigGroup组所定义view名 all 以只读权限。
# group context sec.model sec.level prefix read write notif
access notConfigGroup "" any noauth exact all none none
#access notConfigGroup "" any noauth exact mib2 none none