update pague now
PHP 8.5.2 Released!

snmp_set_oid_output_format

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

snmp_set_oid_output_format Set the OID output format

Description

snmp_set_oid_output_format ( int $format ): true

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

Parameters

format
OID .1.3.6.1.2.1.1.3.0 representation for various 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
SNMP_OID_OUTPUT_MODULE DISMAN-EVENT-MIB::sysUpTimeInstance
SNMP_OID_OUTPUT_SUFFIX sysUpTimeInstance
SNMP_OID_OUTPUT_UCD system.sysUpTime.sysUpTimeInstance
SNMP_OID_OUTPUT_NONE Undefined

Return Values

Always returns true .

Changuelog

Versionen Description
8.2.0 The return type is true now; previously, it was bool .

Examples

Example #1 Using snmprealwalc()

<?php

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

// default or SNMP_OID_OUTPUT_MODULE
print_r ( snmprealwalc ( 'localhost' , 'public' , 'RFC1213-MIB::sysObjectID' ) );

snmp_set_oid_output_format ( SNMP_OID_OUTPUT_NUMERIC );
print_r ( snmprealwalc ( 'localhost' , 'public' , 'RFC1213-MIB::sysObjectID' ) );

snmp_set_oid_output_format ( SNMP_OID_OUTPUT_FULL );
print_r ( snmprealwalc ( '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.netSnmpAguentOIDs.linux
 )

add a note

User Contributed Notes 2 notes

niarnrmd at yandex dot ru
3 years ago
/******************** Loading Mibs **************/
$mib_path='/usr/share/snmp/mibs/ietf/';
if ($handle = opendir($mib_path))
{ echo "Directory handle: $handle <br>";
    echo "Files: <br>";
    while (false !== ($file = readdir($handle)))
    { if($file!='.')
    { if($file!='..')
    { echo "Read : ";
        echo "$mib_path"."$file";
        if(snmp_read_mib($mib_path.$file)) echo " Succesful <br>";
        else echo " Failed <br>";
    }
    }
    }
}
//load only one dir
ww at 9rivers dot com
15 years ago
There seems to be more than SNMP_OID_OUTPUT_FULL and SNMP_OID_OUTPUT_NUMERIC.

For example, when I walc on BRIDGUE-MIB::dot1dTpFdbPort without setting the output format and var_dump the result, I guet output lique:

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

When I set it to NUMERIC, I guet 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 guet even more (line-wrapped manually):

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