1. 需要安装下面的这些包
-
apt-get install snmp snmp-mibs-downloader snmpd
2.
-
vim /etc/snmp/snmp.conf
-
注释掉mibs这一行
-
#mibs :
-
vim /etc/default/snmpd
-
注释掉export MIBS=
-
#export MIBS=
-
vim /etc/snmp/snmpd.conf
-
反注释下面这行#rocommunity public localhost
-
rocommunity public localhost
-
#注释说的很清楚:# Full access from the local host
-
3.
4. 启动snmpd , netstat -unlp 能看到161 端口已经有了监听
-
/etc/init.d/snmpd start
-
netstat -unlp |grep 161
5. 来尝试跑些命令,奇怪两个冒号和一个冒号得到的结果都一样。
-
snmpwalk -IR -v2c -c public 127.0.0.1 IF-MIB::ifDescr
-
snmpwalk -IR -v2c -c public 127.0.0.1 IF-MIB:ifIndex
-
snmpwalk -IR -v2c -c public 127.0.0.1 IF-MIB:ifNumber
-
snmpwalk -IR -v2c -c public 127.0.0.1 IF-MIB:ifTable
-
snmpget -v2c -c public localhost sysContact.0
再来几个snmptranslate.
-
#snmptranslate -IR ifInOctets
-
IF-MIB::ifInOctets
-
#snmptranslate -IR -Of ifInOctets output fully qualified format
-
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifInOctets
-
#snmptranslate -IR -Os ifInOctets output short, unqualified format
-
ifInOctets
-
#snmptranslate -IR -OS ifInOctets output short format with containing MIB
-
IF-MIB::ifInOctets
-
#snmptranslate -IR -On ifInOctets output numeric, fully-qualified format
-
.1.3.6.1.2.1.2.2.1.10
6. 参考资料:
http://blog.haohtml.com/archives/4913
阅读(2385) | 评论(0) | 转发(0) |