16.1 Setting an SNMP Object


You want to set the value of an SNMP object.

Technique

Use the snmpset() function:

 <?php snmpset("localhost", "public",         "system.SysContact.0", "s", "sterling@designmultimedia.com")              or die("Cannot Set SNMP object"); ?> 

Comments

The snmpset() function sets an SNMP object (in this case, "system.SysContact.0" ) of a certain type (in this case, a string "s" ) on a server ( "localhost" ) with a specified community (in this case, "public" ) to a certain value (in this case, "sterling@ _designmultimedia.com" ). Because the snmpset() function returns true on success and false on failure, we can then check the return value with the die() function.

The snmpset() function has two optional arguments: the timeout argument and the retry argument. Their meanings are the same as for the snmpwalk () function.



PHP Developer's Cookbook
PHP Developers Cookbook (2nd Edition)
ISBN: 0672323257
EAN: 2147483647
Year: 2000
Pages: 351

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net