是否有迴應表明該OID沒有價值,還是應該只是不返回?SNMP代理如何響應對它沒有任何價值的OID的獲取請求?
回答
這取決於。
例如,從Debian的SNMP軟件包安裝的snmpget
工具都以某種方式抱怨缺少OID並且沒有。
舉個例子,一些基本的SNMP的OID:
[email protected]:~# snmpwalk -v2c -cpublic localhost
...
iso.3.6.1.2.1.1.5.0 = STRING: "debian"
iso.3.6.1.2.1.1.6.0 = STRING: "Sitting on the Dock of the Bay"
使用snmpget
,當你給它一個丟失的OID會抱怨:
[email protected]:~# snmpget -v2c -cpublic localhost iso.3.6.1.2.1.1.6.1
iso.3.6.1.2.1.1.6.1 = No Such Instance currently exists at this OID
然而,它會返回一個零代碼,信令它是「好的」,它不存在:
[email protected]:~# echo $?
0
如果你正在寫g從SNMP讀取自己的工具或腳本,這實際上取決於您知道OID丟失/無效的重要性。 I'd recommend checking out the net-snmp documentation/coding tutorials如果你正在尋找權威的例子。
編輯:這裏有一些的RFC如果這是你的東西排序(鏈接從萊克斯李的回答被盜)
RFC 3416, 4.2.1爲SNMP v2c的以上GET請求處理
4.2.1。 GetRequest-PDU
GetRequest-PDU是應 應用程序的請求生成和發送的。
收到GetRequest-PDU後,接收SNMP實體會在變量綁定列表中處理 中的每個變量綁定,以產生一個 Response-PDU。響應PDU的所有字段具有與接收到的請求的相應字段相同的值,除了下面指示的 。每個變量綁定如下處理:
(1)如果變量綁定的名稱完全匹配一個 變量此請求訪問,則變量 結合的值字段被設置爲指定 變量的值的名稱。 (2)否則,如果變量綁定的名稱沒有與此請求可訪問的任何(潛在)變量的對象IDENTIFIER前綴匹配的OBJECT IDENTIFIER前綴 ,則其值域設置爲「noSuchObject」。
(3)否則,變量綁定的值字段被設置爲 「noSuchInstance」。
如果任何變量綁定的處理是有原因的其他 比上面列出,則響應-PDU重新格式化其請求-id和變量綁定字段 相同的值 接收的GetRequest失敗-PDU,其錯誤狀態字段的值設置爲 爲「genErr」,並且其錯誤索引字段的值設置爲失敗變量綁定的 索引。
否則,Response-PDU的錯誤狀態字段的值將 設置爲「noError」,並且其錯誤索引字段的值爲零。
然後將生成的Response-PDU封裝到消息中。如果 結果消息的大小小於或等於 本地約束和發起者的最大消息大小,則將其 發送到GetRequest-PDU的發起者。
否則,會生成一個備用Response-PDU。該備選的 響應PDU在其請求標識字段 中與接收到的GetRequest-PDU格式相同,其錯誤狀態 字段的值設置爲「tooBig」,其錯誤索引字段的值設置爲 零,以及一個空的變量綁定字段。這個備用的 響應PDU然後被封裝到消息中。如果 結果消息的大小小於或等於本地約束 和發起者的最大消息大小,則將其發送到GetRequest-PDU的發起者 。否則,snmpSilentDrops [RFC3418]計數器遞增,結果消息爲 丟棄。
RFC 1157, 4.1.2爲SNMP V1 GET請求處理
4.1.2。所述的GetRequest-PDU
The form of the GetRequest-PDU is:
GetRequest-PDU ::=
[0]
IMPLICIT SEQUENCE {
request-id
RequestID,
error-status -- always 0
ErrorStatus,
error-index -- always 0
ErrorIndex,
variable-bindings
VarBindList
}
所述的GetRequest-PDU是由協議實體僅在其SNMP應用實體的 請求而生成。
在接收到的GetRequest-PDU,根據在下面的列表中的任何適用的規則 響應接收協議實體的:
(1) If, for any object named in the variable-bindings field,
the object's name does not exactly match the name of some
object available for get operations in the relevant MIB
view, then the receiving entity sends to the originator
of the received message the GetResponse-PDU of identical
form, except that the value of the error-status field is
noSuchName, and the value of the error-index field is the
index of said object name component in the received
message.
(2) If, for any object named in the variable-bindings field,
the object is an aggregate type (as defined in the SMI),
then the receiving entity sends to the originator of the
received message the GetResponse-PDU of identical form,
except that the value of the error-status field is
noSuchName, and the value of the error-index field is the
index of said object name component in the received
message.
(3) If the size of the GetResponse-PDU generated as described
below would exceed a local limitation, then the receiving
entity sends to the originator of the received message
the GetResponse-PDU of identical form, except that the
value of the error-status field is tooBig, and the value
of the error-index field is zero.
(4) If, for any object named in the variable-bindings field,
the value of the object cannot be retrieved for reasons
not covered by any of the foregoing rules, then the
receiving entity sends to the originator of the received
message the GetResponse-PDU of identical form, except
that the value of the error-status field is genErr and
the value of the error-index field is the index of said
object name component in the received message.
如果沒有上述規則適用,則接收協議 實體發送給接收到的消息的發起者 GetResponse-PDU,使得對於接收到的消息的變量- 綁定字段中命名的每個對象,GetResponse-PDU的對應組件 表示該變量的名稱和值。 GetResponse- PDU的錯誤狀態字段的值爲noError,錯誤索引字段的值爲零。 GetResponse-PDU的request-id字段的值爲 收到的消息的值。
行爲遵循標準RFC文檔,就像
- RFC 3416, 4.2.1爲SNMP v2c的和上面GET請求處理
- RFC 1157, 4.1.2對於SNMP V1 GET請求處理
- 1. VBScript獲取SNMP OID值
- 2. SNMP OUTPUT OPTIONS - 如何獲得OID響應值?
- 3. 如何獲取Oid(#Snmp)的名稱?
- 4. 如何在nodejs代理請求中獲取響應對象
- 5. 如何獲取java http請求中的代理響應?
- 6. 獲取OID的描述 - SNMP
- 7. 如何使用SNMP代理回覆snmp請求?
- 8. 如何從Ajax請求獲取響應?
- 9. 如何POST請求獲取jSON響應
- 10. 處理遞增的SNMP OID?
- 11. 如何僅從Ruby中的HTTP請求獲取響應代碼
- 12. jQuery .ajax請求沒有任何影響
- 13. 如何處理:此請求沒有可用的響應數據
- 14. 如何獲取會議響應響應的會議請求?
- 15. JMX對象如何映射到SNMP OID?
- 16. 如何在Jmeter中獲取JSON響應JSON請求的值
- 17. 如何讀取SNMP OID輸出
- 18. SNMP AgentX:如何註冊OID?
- 19. 如何在SNMP中走OID
- 20. 具有多個OID的SNMP getBulkRequest - 哪個返回的響應OID順序?
- 21. SNMP如何獲取並設置代理的值
- 22. snmpd如何處理SNMP請求?
- 23. 如何在GETBULK請求時更新我的snmp代理表?
- 24. 如何使用net-snmp將請求特定的數據設置爲SNMP代理?
- 25. 獲取沒有內容長度的http請求的響應?
- 26. PHP對AJAX請求沒有響應
- 27. 如何在任何jsp/servlet上使用正常的ajax請求獲取響應
- 28. cefsharp如何攔截xhr請求獲取響應體值?
- 29. 如何在LoopbackJS中獲取ExpressJS請求和響應對象?
- 30. 如何從Python請求「響應」對象獲取HTTP VERB?
注意的問題說:「怎麼樣是一個SNMP代理應該回應「,但你似乎已經回答」SNMP命令行工具應該如何響應「。萊克斯李的答案是正確的。 – Jolta 2014-11-17 10:33:09
我使用了命令行實用程序,因爲它們實際上是標準的,並且提供了立即可用的響應。編輯帖子以添加RFC。 – 2014-11-20 15:36:31