snmp3_set

(PHP 4, PHP 5, PHP 7)

snmp3_setSet the value of an SNMP object

Opis

snmp3_set ( string $host , string $sec_name , string $sec_level , string $auth_protocol , string $auth_passphrase , string $priv_protocol , string $priv_passphrase , string $object_id , string $type , string $value [, int $timeout = 1000000 [, int $retries = 5 ]] ) : bool

snmp3_set() is used to set the value of an SNMP object specified by the object_id.

Even if the security level does not use an auth or priv protocol/password valid values have to be specified.

Parametry

host

The hostname of the SNMP agent (server).

sec_name

the security name, usually some kind of username

sec_level

the security level (noAuthNoPriv|authNoPriv|authPriv)

auth_protocol

the authentication protocol (MD5 or SHA)

auth_passphrase

the authentication pass phrase

priv_protocol

the privacy protocol (DES or AES)

priv_passphrase

the privacy pass phrase

object_id

The SNMP object id.

type

MIB definiuje typ każdego id obiektu. Musi być podany jako pojedynczy znak z poniższej listy

types
=Typ pobrany z MIB
iINTEGER
uINTEGER
sSTRING
xHEX STRING
dDECIMAL STRING
nNULLOBJ
oOBJID
tTIMETICKS
aIPADDRESS
bBITS

Jeśli przy kompilacji biblioteki SNMP zdefiniowana została stała OPAQUE_SPECIAL_TYPES, dostępne są także poniższe wartości:

types
Uunsigned int64
Isigned int64
Ffloat
Ddouble

Większość z nich będzie w sposób oczywisty odpowiadać typowi ASN.1 's', 'x', 'd' i 'b' są różnymi sposobami na określenie wartości OCTET STRING, a typ 'u' - bez określania znaku - stosowany jest także dla obsługi wartości Gauge32.

Jeśli pliki MIB są ładowane do drzewa MIB poprzez "snmp_read_mib" lub przez podanie ich w konfiguracji libsnmp, '=' może być stosowane jako wartość parametru type dla wszystkich id obiektów, jako że typ może być automatycznie odczytany z MIB.

Istnieją dwa sposoby aby ustawić wartość zmiennej typu BITS, przykładowo "SYNTAX BITS {telnet(0), ftp(1), http(2), icmp(3), snmp(4), ssh(5), https(6)}":

  • Stosując typ "b" i listę wartości bitowych. Ta metoda nie jest zalecana ponieważ zapytanie GET dla dla tego samego OID zwróciłoby np. 0xF8.
  • Stosując typ "x" i wartość szesnastkową bez zwyczajowego prefiksu "0x".

Zobacz też sekcję z przykładami.

value

The new value

timeout

The number of microseconds until the first timeout.

retries

The number of times to retry if timeouts occur.

Zwracane wartości

Zwraca TRUE w przypadku powodzenia, FALSE w przypadku błędu.

If the SNMP host rejects the data type, an E_WARNING message like "Warning: Error in packet. Reason: (badValue) The value given has the wrong type or length." is shown. If an unknown or invalid OID is specified the warning probably reads "Could not add variable".

Przykłady

Przykład #1 Using snmp3_set()

<?php
  snmp3_set
('localhost''james''authPriv''SHA''secret007''AES''secret007''IF-MIB::ifAlias.3''s'"foo");
?>

Przykład #2 Using snmp3_set() for setting BITS SNMP object id

<?php
  snmp3_set
('localhost''james''authPriv''SHA''secret007''AES''secret007''FOO-MIB::bar.42''b''0 1 2 3 4');
// or
  
snmp3_set('localhost''james''authPriv''SHA''secret007''AES''secret007''FOO-MIB::bar.42''x''F0');
?>
add a note add a note

User Contributed Notes

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