phpday 2027 - Call for Papers

snmp_set_output_option

(PHP 8 >= 8.6.0)

snmp_set_output_option — Set an option for formatting the returned values

Descrição

function snmp_set_output_option(Snmp\Output $option, bool $enable): void

Enables or disables an option that controls how the Net-SNMP library formats the values and OIDs returned by the SNMP functions, such as snmp2_get() or snmp2_real_walk().

A new SNMP object takes its initial output options from the values set with this function. To change an option for a single session, set the corresponding property of the SNMP object instead.

Parâmetros

option

The option to set. See Snmp\Output for the available options.

enable

Whether to enable the option.

Valor Retornado

Nenhum valor é retornado.

Exemplos

Exemplo #1 Formatting TimeTicks and table indexes

<?php

var_dump(snmp2_get('localhost', 'public', 'SNMPv2-MIB::sysUpTime.0'));

snmp_set_output_option(Snmp\Output::NumericTimeticks, true);
var_dump(snmp2_get('localhost', 'public', 'SNMPv2-MIB::sysUpTime.0'));

snmp_set_output_option(Snmp\Output::ExtendedIndex, true);
var_dump(snmp2_real_walk('localhost', 'public', 'IF-MIB::ifDescr'));

?>

O exemplo acima produzirá algo semelhante a:

string(40) "Timeticks: (14096763) 1 day, 15:09:27.63"
string(8) "14096763"
array(2) {
  ["IF-MIB::ifDescr[1]"]=>
  string(10) "STRING: lo"
  ["IF-MIB::ifDescr[2]"]=>
  string(12) "STRING: eth0"
}

Veja também

+adicionar nota

Notas de Usuários

Não há notas de usuários para esta página.
To Top