phpday 2027 - Call for Papers

SNMP::setOidOutputFormat

(PHP 8 >= 8.6.0)

SNMP::setOidOutputFormat — Set the OID output format of the session

Description

public function SNMP::setOidOutputFormat(Snmp\OidOutput $format): bool

Sets the format in which the OIDs returned by the requests of this session are printed, for instance in the keys of the array returned by SNMP::walk().

This is the same as setting the SNMP::$oid_output_format property to the corresponding SNMP_OID_OUTPUT_* constant. It does not change the format used by the other sessions, nor by functions such as snmp2_real_walk(); use snmp_set_oid_output_format() for those.

Parameters

format

The format to use. See Snmp\OidOutput for the available formats.

Return Values

Always returns true.

Examples

Example #1 Walking with numeric OIDs

<?php

$session = new SNMP(SNMP::VERSION_2c, 'localhost', 'public');
$session->setOidOutputFormat(Snmp\OidOutput::Numeric);

var_dump($session->walk('IF-MIB::ifDescr'));

?>

The above example will output something similar to:

array(2) {
  [".1.3.6.1.2.1.2.2.1.2.1"]=>
  string(10) "STRING: lo"
  [".1.3.6.1.2.1.2.2.1.2.2"]=>
  string(12) "STRING: eth0"
}

See Also

+add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top