(PHP 4, PHP 5, PHP 7)
snmp3_set — Set the value of an SNMP object
$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.
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 锟斤拷锟斤拷锟剿革拷锟斤拷锟斤拷锟斤拷 id 锟斤拷锟斤拷锟酵★拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫筹拷锟侥碉拷锟斤拷锟街凤拷之一锟斤拷
= | MIB锟斤拷锟斤拷 |
i | INTEGER |
u | INTEGER |
s | STRING |
x | HEX STRING |
d | DECIMAL STRING |
n | NULLOBJ |
o | OBJID |
t | TIMETICKS |
a | IPADDRESS |
b | BITS |
锟斤拷锟斤拷诒锟斤拷锟� SNMP 锟斤拷时锟斤拷锟斤拷锟斤拷 OPAQUE_SPECIAL_TYPES
锟斤拷锟斤拷么锟斤拷锟斤拷值锟角合凤拷锟侥o拷
U | unsigned int64 |
I | signed int64 |
F | float |
D | double |
锟斤拷些值锟襟都伙拷使锟斤拷锟斤拷 ASN.1 锟斤拷锟斤拷锟斤拷锟斤拷汀锟�'s'锟斤拷'x'锟斤拷'd' 锟皆硷拷 'b' 锟斤拷锟斤拷指锟斤拷一锟斤拷锟斤拷锟街斤拷锟街凤拷锟斤拷值锟侥凤拷式锟斤拷锟斤拷锟斤拷 'u' 锟睫凤拷锟斤拷锟斤拷锟斤拷也锟斤拷锟斤拷锟节达拷锟斤拷 Gauge32 值锟斤拷
锟斤拷锟� MIB 锟侥硷拷锟斤拷锟斤拷 "snmp_read_mib" 锟斤拷锟斤拷通锟斤拷锟斤拷 libsnmp config 锟斤拷指锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 MIB 锟斤拷时锟斤拷
'=' 锟斤拷锟皆憋拷锟斤拷锟斤拷为锟斤拷锟叫讹拷锟斤拷锟� type
锟斤拷锟斤拷锟斤拷锟斤拷为 type 锟斤拷锟皆憋拷锟皆讹拷锟斤拷 MIB 锟叫讹拷取锟斤拷
注锟斤拷锟斤拷锟斤拷锟街凤拷式锟斤拷锟斤拷锟借定 BITS 锟斤拷锟酵的憋拷锟斤拷锟斤拷锟斤拷锟斤拷 "SYNTAX BITS {telnet(0), ftp(1), http(2), icmp(3), snmp(4), ssh(5), https(6)}":
锟斤拷锟斤拷细锟节硷拷锟斤拷锟斤拷锟斤拷锟街★拷
value
The new value
timeout
The number of microseconds until the first timeout.
retries
The number of times to retry if timeouts occur.
锟缴癸拷时锟斤拷锟斤拷 TRUE
锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE
锟斤拷
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".
Example #1 Using snmp3_set()
<?php
snmp3_set('localhost', 'james', 'authPriv', 'SHA', 'secret007', 'AES', 'secret007', 'IF-MIB::ifAlias.3', 's', "foo");
?>
Example #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');
?>