phpday 2027 - Call for Papers

SNMP::setOidOutputFormat

(PHP 8 >= 8.6.0)

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

説明

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.

パラメータ

format

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

戻り値

常に true を返します。

例

例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'));

?>

上の例の出力は、 たとえば以下のようになります。

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"
}

参考

+add a note

User Contributed Notes

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