SNMP 函数
简介
需求
为了在 Unix 中使用 SNMP 函数,需要安装 » NET-SNMP 包。在 Windows 中,这些函数只能用于 NT,而不能用于 Win95/98。
安装
重要提示:为了使用 UCD SNMP 包,需要在编译之前将 NO_ZEROLENGTH_COMMUNITY 定义为 1。 在配置 UCD SNMP 之后,编辑 config.h 或 acconfig.h,查找 NO_ZEROLENGTH_COMMUNITY,将 #define 所在行的注释去掉。修改后应该类似这样:
#define NO_ZEROLENGTH_COMMUNITY 1
如果在组合 SNMP 命令时看到奇怪的字段错误,那就是因为没有遵从上述说明。如果不想重新编译 UCD SNMP,可以使用 --enable-ucd-snmp-hack 开关编译 PHP 以绕开上述错误。
Windows 版本在目录 mibs 中包含了支持 SNMP 的文件。此目录应该移到 DRIVE:\usr\mibs,其中 DRIVE 是安装 PHP 所在的盘符,例如 c:\usr\mibs。
运行时配置
本扩展模块在 php.ini 中未定义任何配置选项。
资源类型
预定义常量
以下常量由本扩展模块定义,因此只有在本扩展模块被编译到 PHP 中,或者在运行时被动态加载后才有效。
- SNMP_OID_OUTPUT_FULL (integer)
- As of 5.2.0
- SNMP_OID_OUTPUT_NUMERIC (integer)
- As of 5.2.0
- 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)
Table of Contents
- 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_oid_output_format — Set the OID output format
- 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 — 查询关于网络实体的信息树