snmp问题,请高手指点
snmp.conf文件内容如下(这台主机的ip为192.168.0.9):
# First, map the community name "public" into a "security name"
# sec.name source community
#com2sec notConfigUser default public
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
view all included .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
access notConfigGroup "" any noauth exact all none none
access notConfigGroup "" any noauth exact mib2 none none
exec .1.3.6.1.4.1.2021.56 mem /bin/bash /tmp/memtest.sh
exec .1.3.6.1.4.1.2021.57 cpu /bin/bash /tmp/cpustat.sh
我在192.168.0.15主机上测试,输入命令snmpwalk -v 1 192.168.0.9 -c public .1.3.6.1.4.1.2021.57,怎么提示END MIB.
cat memtest.sh
#!/bin/bash
free -m|grep -i mem|awk '{print $3}'
free -m|grep -i mem|awk '{print $2}'
cat cpustat.sh
#!/bin/bash
idle=`sar -u 1 3|grep -i average|awk '{print $7}'`
used=`echo "100 - $idle"|bc -l -s`
echo $idle
echo $used
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在顶一下,cu没人了吗???
那位大哥知道,赐教一下.