2013-10-25 36 views
1

我有麻煩的設置,甚至從我的設備本身獲取SNMP值,但我可以從遠程位置。SNMP命令不適用於設備本身。從不同的位置正常工作

這是我的snmpd.conf文件。正如你所看到的,這個測試只有,我有兩個我授予完全訪問權限的社區。 (我會改變我的公共社區閱讀後,不必擔心)

com2sec rw default public 
com2sec rw localhost private 
group public v1 rw 
group public v2c rw 
group public usm rw 
group private v1 rw 
group private v2c rw 
group private usm rw 
view all included .1 
access public "" any noauth exact all all all 
access private "" any noauth exact all all all 

在這裏,我可以設置並從遠程位置獲取我的SNMP值。

$ snmpget -v2c -c public x.x.x.x SNMPv2-MIB::sysName.0 
SNMPv2-MIB::sysName.0 = STRING: default 
$ snmpset -v2c -c public x.x.x.x SNMPv2-MIB::sysName.0 s "TEST_TEST" 
SNMPv2-MIB::sysName.0 = STRING: TEST_TEST 
$ snmpget -v2c -c public x.x.x.x SNMPv2-MIB::sysName.0 
SNMPv2-MIB::sysName.0 = STRING: TEST_TEST 
$ 

現在,當我從設備本身嘗試它...這就是我得到的。我不能snmpwalk它或任何東西。爲什麼?

$ snmpget -v2c -c private localhost SNMPv2-MIB::sysName.0 
Cannot find module (SNMP-VIEW-BASED-ACM-MIB): At line 0 in (none) 
Cannot find module (SNMP-COMMUNITY-MIB): At line 0 in (none) 
Cannot find module (SNMP-FRAMEWORK-MIB): At line 0 in (none) 
Cannot find module (SNMP-MPD-MIB): At line 0 in (none) 
Cannot find module (SNMP-USER-BASED-SM-MIB): At line 0 in (none) 
Cannot find module (TUNNEL-MIB): At line 0 in (none) 
Cannot find module (IPV6-FLOW-LABEL-MIB): At line 0 in (none) 
Cannot find module (UCD-DLMOD-MIB): At line 0 in (none) 
Cannot find module (IP-MIB): At line 0 in (none) 
Cannot find module (IF-MIB): At line 0 in (none) 
Cannot find module (TCP-MIB): At line 0 in (none) 
Cannot find module (UDP-MIB): At line 0 in (none) 
Cannot find module (HOST-RESOURCES-MIB): At line 0 in (none) 
Cannot find module (SNMPv2-MIB): At line 0 in (none) 
Cannot find module (SNMPv2-SMI): At line 0 in (none) 
Cannot find module (NOTIFICATION-LOG-MIB): At line 0 in (none) 
Cannot find module (DISMAN-EVENT-MIB): At line 0 in (none) 
Cannot find module (DISMAN-SCHEDULE-MIB): At line 0 in (none) 
getaddrinfo: localhost Name or service not known 
snmpget: Unknown host (localhost) (No such file or directory) 

我希望能夠從我的設備中更改一些值,以便我可以snmpwalk它並獲取值。所有幫助表示讚賞!

回答

0

顯然localhost不能正確解析,

getaddrinfo: localhost Name or service not known

你嘗試127.0.0.1對於IP V4,或::1爲IP v6的?

+0

我做到了。之後我仍然會得到所有「無法找到模塊」和「SNMPv2-MIB :: sysName.0:未知對象標識符」。我嘗試了所有這些。 – user2537383

+0

@ user2537383,使用IP地址時,getaddrinfo:localhost名稱或服務未知的行會消失嗎?如果是這樣,那麼您可以檢查是否有適當的net-snmp安裝,其中包含默認的MIB文檔,http://net-snmp.sourceforge.net/tutorial/tutorial-5/commands/mib-options.html沒有這些文檔,'snmpget'不能理解什麼是'SNMPv2-MIB :: sysName.0' –

0

運行snmpwalk/snmpget命令的機器似乎沒有它需要的所有MIB。或者可能不知道他們在哪裏。

無論如何,我在Docker容器中的Ubuntu 12機器上收到類似的錯誤。修正了「apt-get install snmp-mibs-downloader」,但該軟件包僅在將其添加到/etc/apt/sources.list(不要忘記「apt-get update」)時纔可用:

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu 
## security team. 
deb http://us.archive.ubuntu.com/ubuntu/ precise multiverse" >> /etc/apt/sources.list 
deb-src http://us.archive.ubuntu.com/ubuntu/ precise multiverse" >> /etc/apt/sources.list 
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse" >> /etc/apt/sources.list 
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse" >> /etc/apt/sources.list