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

参见

+添加备注

用户贡献的备注

此页面尚无用户贡献的备注。
To Top