mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-28 14:58:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@308496 c90b9560-bf6c-de11-be94-00142212c4b1
206 lines
6.7 KiB
XML
206 lines
6.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="function.snmpset" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>snmpset</refname>
|
|
<refpurpose>Set the value of an <acronym>SNMP</acronym> object</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>snmpset</methodname>
|
|
<methodparam><type>string</type><parameter>host</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>community</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>object_id</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>type</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>timeout</parameter><initializer>1000000</initializer></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>retries</parameter><initializer>5</initializer></methodparam>
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
<function>snmpset</function> is used to set the value of an <acronym>SNMP</acronym> object
|
|
specified by the <parameter>object_id</parameter>.
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>host</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The hostname of the <acronym>SNMP</acronym> agent (server).
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>community</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The write community.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>object_id</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The <acronym>SNMP</acronym> object id.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>type</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The <acronym>MIB</acronym> defines the type of each object id. It has to be specified as a single character from the below list.
|
|
</para>
|
|
<table>
|
|
<title>types</title>
|
|
<tgroup cols="2">
|
|
<tbody>
|
|
<row><entry>=</entry><entry>The type is taken from the MIB</entry></row>
|
|
<row><entry>i</entry><entry>INTEGER</entry> </row>
|
|
<row><entry>u</entry><entry>INTEGER</entry></row>
|
|
<row><entry>s</entry><entry>STRING</entry></row>
|
|
<row><entry>x</entry><entry>HEX STRING</entry></row>
|
|
<row><entry>d</entry><entry>DECIMAL STRING</entry></row>
|
|
<row><entry>n</entry><entry>NULLOBJ</entry></row>
|
|
<row><entry>o</entry><entry>OBJID</entry></row>
|
|
<row><entry>t</entry><entry>TIMETICKS</entry></row>
|
|
<row><entry>a</entry><entry>IPADDRESS</entry></row>
|
|
<row><entry>b</entry><entry>BITS</entry></row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
<para>
|
|
If OPAQUE_SPECIAL_TYPES was defined while compiling the SNMP library, the following are also valid:
|
|
</para>
|
|
<table>
|
|
<title>types</title>
|
|
<tgroup cols="2">
|
|
<tbody>
|
|
<row><entry>U</entry><entry>unsigned int64</entry></row>
|
|
<row><entry>I</entry><entry>signed int64</entry></row>
|
|
<row><entry>F</entry><entry>float</entry></row>
|
|
<row><entry>D</entry><entry>double</entry></row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
<para>
|
|
Most of these will use the obvious corresponding ASN.1 type. 's', 'x', 'd' and 'b' are all different ways of specifying an OCTET STRING value, and
|
|
the 'u' unsigned type is also used for handling Gauge32 values.
|
|
</para>
|
|
<para>
|
|
If the MIB-Files are loaded by into the MIB Tree with "snmp_read_mib" or by specifying it in the libsnmp config, '=' may be used as the <parameter>type</parameter> parameter
|
|
for all object ids as the type can then be automatically read from the MIB.
|
|
</para>
|
|
<para>
|
|
Note that there are two ways to set a variable of the type BITS like e.g. "SYNTAX BITS {telnet(0), ftp(1), http(2), icmp(3), snmp(4), ssh(5), https(6)}"
|
|
</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Using type "b" and a list of bit numbers like: <programlisting role="php">snmpset('FOO-MIB::bar.42', 'b', '0 1 2 3 4');</programlisting> with the disadvantage that the success is not easily verifyable as an snmpget() for the same OID would return e.g. 0xF8.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Using type "x" and a hex number but without(!) the usual "0x" prefix: <programlisting role="php">snmpset('FOO-MIB::bar.42', 'x', 'F0');</programlisting>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>value</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The new value.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>timeout</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The number of microseconds until the first timeout.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>retries</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The number of retries in case of timeouts.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
<para>
|
|
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".
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Using <function>snmpgetnext</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
snmpset("localhost", "public", "IF-MIB::ifAlias.3", "s", "foo");
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>snmpget</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|
|
|