php教程

snmp_set_oid_output_format

(PHP 5 >= 5.2.0, PHP 7)

snmp_set_oid_output_format Set the OID output format

说明

snmp_set_oid_output_format ( int $oid_format = SNMP_OID_OUTPUT_MODULE ) : bool

snmp_set_oid_output_format() sets the output format to be full or numeric.

参数

oid_format
OID .1.3.6.1.2.1.1.3.0 representation for various oid_format values
SNMP_OID_OUTPUT_FULL.iso.org.dod.internet.mgmt.mib-2.system.sysUpTime.sysUpTimeInstance
SNMP_OID_OUTPUT_NUMERIC.1.3.6.1.2.1.1.3.0

Begining from PHP 5.4.0 four additional constants available:

SNMP_OID_OUTPUT_MODULEDISMAN-EVENT-MIB::sysUpTimeInstance
SNMP_OID_OUTPUT_SUFFIXsysUpTimeInstance
SNMP_OID_OUTPUT_UCDsystem.sysUpTime.sysUpTimeInstance
SNMP_OID_OUTPUT_NONEUndefined

返回值

没有返回值。

注释

Note:

snmp_set_oid_output_format() is only available when using the UCD SNMP library. This function is not available when using the Windows SNMP library.

范例

Example #1 Using snmprealwalk()

<?php

 snmp_read_mib
("/usr/share/mibs/netsnmp/NET-SNMP-TC");

 
// default or SNMP_OID_OUTPUT_MODULE in PHP >= 5.3.6
 
print_rsnmprealwalk('localhost''public''RFC1213-MIB::sysObjectID') );

 
snmp_set_oid_output_format(SNMP_OID_OUTPUT_NUMERIC);
 
print_rsnmprealwalk('localhost''public''RFC1213-MIB::sysObjectID') );

 
snmp_set_oid_output_format(SNMP_OID_OUTPUT_FULL);
 
print_rsnmprealwalk('localhost''public''RFC1213-MIB::sysObjectID') );
?>

The above would output:

 Array
 (
    [RFC1213-MIB::sysObjectID.0] => OID: NET-SNMP-TC::linux
 )
 Array
 (
    [.1.3.6.1.2.1.1.2.0] => OID: .1.3.6.1.4.1.8072.3.2.10
 )
 Array
 (
    [.iso.org.dod.internet.mgmt.mib-2.system.sysObjectID.0] => OID: .iso.org.dod.internet.private.enterprises.netSnmp.netSnmpEnumerations.netSnmpAgentOIDs.linux
 )

User Contributed Notes

ww at 9rivers dot com 30-Dec-2010 08:43
There seems to be more than SNMP_OID_OUTPUT_FULL and SNMP_OID_OUTPUT_NUMERIC.

For example, when I walk on BRIDGE-MIB::dot1dTpFdbPort without setting the output format and var_dump the result, I get output like:

  ["BRIDGE-MIB::dot1dTpFdbPort.'..F8.7'"]=>
  string(2) "52"

When I set it to NUMERIC, I get what I expected:

  [".1.3.6.1.2.1.17.4.3.1.2.244.206.70.56.24.55"]=>
  string(2) "52"

When I set it to FULL, I get even more (line-wrapped manually):

  [".iso.org.dod.internet.mgmt.mib-2 .dot1dBridge.dot1dTp .dot1dTpFdbTable .dot1dTpFdbEntry .dot1dTpFdbPort. '..F8.7'"]=>
  string(2) "52"

CopyRight © 2008-2022 verySource.Com All Rights reserved. 京ICP备17048824号-1 京公网安备:11010502034788