mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Improved reference with examples and the list of possible values for $type.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@308444 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
7946764ba4
commit
30ecbf6808
1 changed files with 92 additions and 12 deletions
|
@ -3,13 +3,14 @@
|
|||
<refentry xml:id="function.snmpset" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>snmpset</refname>
|
||||
<refpurpose>Set an <acronym>SNMP</acronym> object</refpurpose>
|
||||
<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>hostname</parameter></methodparam>
|
||||
<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>
|
||||
|
@ -17,23 +18,23 @@
|
|||
<methodparam choice="opt"><type>int</type><parameter>timeout</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>int</type><parameter>retries</parameter></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>.
|
||||
specified by the <parameter>object_id</parameter>.
|
||||
</para>
|
||||
|
||||
|
||||
</refsect1>
|
||||
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>hostname</parameter></term>
|
||||
<term><parameter>host</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The <acronym>SNMP</acronym> agent.
|
||||
The hostname of the <acronym>SNMP</acronym> agent (server).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
@ -49,7 +50,7 @@
|
|||
<term><parameter>object_id</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The <acronym>SNMP</acronym> object.
|
||||
The <acronym>SNMP</acronym> object id.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
@ -57,13 +58,70 @@
|
|||
<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>
|
||||
|
@ -79,20 +137,41 @@
|
|||
<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>
|
||||
|
@ -101,7 +180,7 @@
|
|||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@ -124,3 +203,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
|
|||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
|
||||
|
|
Loading…
Reference in a new issue