Centos

SNMP 遠端 PING

  • September 10, 2017

假設我們有 3 台伺服器 A、B 和 C。A 是我們的監控伺服器。我試圖在伺服器 B 上找到一個 OID 來 ping 伺服器 C,以從伺服器 B 的角度確定伺服器 C 是否可訪問。我在IBM Knowledge Center中找到了這個 OID 。在 LINUX 中是否有這樣做的 OID?

提前致謝

最後,我使用了 NET-SNMP-EXTEND-MIB,還編寫了一個以 IP 作為參數的 ping 腳本。

snmpset -v2c -c public  -m +NET-SNMP-EXTEND-MIB localhost 'nsExtendStatus."remotePing"'  = createAndGo 'nsExtendCommand."remotePing"' = /etc/snmp/scripts/pingScript.sh 'nsExtendArgs."remotePing"' = 'google.com'

不要忘記將 pingScript.sh 文件放在 /etc/snmp/scripts 下。在這裡,我預設輸入了 google.com,然後在我的程序中,我在執行時用適當的 IP 地址更改了這個文字。通過獲取 nsExtendOutput1Table.nsExtendOutputFull ,可以讀取 ping 時間或腳本返回的任何內容。

引用自:https://serverfault.com/questions/858566