snmp3_set
(PHP 4, PHP 5, PHP 7, PHP 8)
Set the value of an SNMP object
Description
snmp3_set() is used to set the value of an SNMP object specified by the object_id.
The authentication and privacy arguments must always be passed, but their values are ignored when security_level does not use them.
Parameters
hostnameThe hostname of the SNMP agent (server).
security_nameSecurity-name
security_levelSecurity-level
auth_protocolAuth-protocol
auth_passphraseAuth-passphrase
privacy_protocolPrivacy-protocol
privacy_passphrasePrivacy-passphrase
object_idThe SNMP object id.
typeValues Mapping Note Note
valueThe new value
timeoutThe number of microseconds until the first timeout.
retriesThe number of times to retry if timeouts occur.
Return Values
Success
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".
Changelog
| Version | Description |
|---|---|
| 8.5.0 | Now throws a ValueError when the hostname length is equal to or greater than 128 bytes, when the port is negative or greater than 65535, or when the timeout or retries values are lower than -1 or too large. |
Examples
Using snmp3_set()
<?php
snmp3_set('localhost', 'james', 'authPriv', 'SHA', 'secret007', 'AES', 'secret007', 'IF-MIB::ifAlias.3', 's', "foo");
?>
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');
?>