CXXXVIII. SNMP 函數

需求

為了在 Unix 中使用 SNMP 函數,需要安裝 NET-SNMP 包。在 Windows 中,這些函數只能用於 NT,而不能用於 Win95/98。

安裝

重要提示:為了使用 UCD SNMP 包,需要在編譯之前將 NO_ZEROLENGTH_COMMUNITY 定義為 1。 在配置 UCD SNMP 之後,編輯 config.hacconfig.h,尋找 NO_ZEROLENGTH_COMMUNITY,將 #define 所在行的注解去掉。修改後應該類似這樣:
#define NO_ZEROLENGTH_COMMUNITY 1
然後使用 --with-snmp[=DIR] 選項編譯 PHP。

若果在組合 SNMP 指令時看到奇怪的欄位錯誤,那就是因為沒有遵從上述說明。若果不想重新編譯 UCD SNMP,可以使用 --enable-ucd-snmp-hack 開關編譯 PHP 以繞開上述錯誤。

Windows 版本在目錄 mibs 中包括了支援 SNMP 的檔案。此目錄應該移到 DRIVE:\usr\mibs,其中 DRIVE 是安裝 PHP 所在的盤符,例如 c:\usr\mibs

運行時配置

本增加模組在 php.ini 中未定義任何配置選項。

預定義常量

以下常量由本增加模組定義,因此只有在本增加模組被編譯到 PHP 中,或是在運行時被動態加載後才有效。

SNMP_VALUE_LIBRARY (integer)

SNMP_VALUE_PLAIN (integer)

SNMP_VALUE_OBJECT (integer)

SNMP_BIT_STR (integer)

SNMP_OCTET_STR (integer)

SNMP_OPAQUE (integer)

SNMP_NULL (integer)

SNMP_OBJECT_ID (integer)

SNMP_IPADDRESS (integer)

SNMP_COUNTER (integer)

SNMP_UNSIGNED (integer)

SNMP_TIMETICKS (integer)

SNMP_UINTEGER (integer)

SNMP_INTEGER (integer)

SNMP_COUNTER64 (integer)

目錄
snmp_get_quick_print --  返回 UCD 庫中 quick_print 設定的現用的值
snmp_get_valueretrieval --  Return the method how the SNMP values will be returned
snmp_read_mib --  Reads and parses a MIB file into the active MIB tree
snmp_set_enum_print --  Return all values that are enums with their enum value instead of the raw integer
snmp_set_oid_numeric_print --  Return all objects including their respective object id within the specified one
snmp_set_quick_print --  設定 UCD SNMP 庫中 quick_print 的值
snmp_set_valueretrieval --  Specify the method how the SNMP values will be returned
snmpget -- 取得一個 SNMP 物件
snmpgetnext --  Fetch a SNMP object
snmprealwalk --  返回特殊的所有對象,內含它們各自的對象 ID
snmpset -- 設定一個 SNMP 物件
snmpwalk -- 從代理返回所有的 SNMP 物件
snmpwalkoid -- 查詢關於網路實體的訊息樹