1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.21 $ -->
<reference id="ref.snmp">
<title>SNMP functions</title>
<titleabbrev>SNMP</titleabbrev>
<partintro>
<simpara>
In order to use the SNMP functions on Unix you need to install the <ulink url="&url.ucd-snmp;">UCD SNMP</ulink> package. On Windows these functions
are only available on NT and not on Win95/98.</simpara>
<simpara>
Important: In order to use the UCD SNMP package, you need to define
NO_ZEROLENGTH_COMMUNITY to 1 before compiling it. After configuring UCD
SNMP, edit config.h and search for NO_ZEROLENGTH_COMMUNITY. Uncomment the
#define line. It should look like this afterwards:</simpara>
<para>
<programlisting role="c">
<![CDATA[
#define NO_ZEROLENGTH_COMMUNITY 1
]]>
</programlisting>
</para>
<simpara>
If you see strange segmentation faults in combination with SNMP commands,
you did not follow the above instructions. If you do not want to recompile
UCD SNMP, you can compile PHP with the --enable-ucd-snmp-hack switch which
will work around the misfeature.</simpara>
</partintro>
<refentry id="function.snmpget">
<refnamediv>
<refname>snmpget</refname>
<refpurpose>Fetch an SNMP object</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>snmpget</methodname>
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
<methodparam><type>string</type><parameter>community</parameter></methodparam>
<methodparam><type>string</type><parameter>object_id</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>timeout</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>retries</parameter></methodparam>
</methodsynopsis>
<para>
Returns SNMP object value on success and &false; on error.</para>
<para>
The <function>snmpget</function> function is used to read the
value of an SNMP object specified by the
<parameter>object_id</parameter>. SNMP agent is specified by the
<parameter>hostname</parameter> and the read community is
specified by the <parameter>community</parameter> parameter.</para>
<para>
<informalexample>
<programlisting role="php">
<![CDATA[
$syscontact = snmpget("127.0.0.1", "public", "system.SysContact.0");
]]>
</programlisting>
</informalexample>
</para>
</refsect1>
</refentry>
<refentry id="function.snmpset">
<refnamediv>
<refname>snmpset</refname>
<refpurpose>Set an SNMP object</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>snmpset</methodname>
<methodparam><type>string</type><parameter>hostname</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></methodparam>
<methodparam choice="opt"><type>int</type><parameter>retries</parameter></methodparam>
</methodsynopsis>
<para>
Sets the specified SNMP object value, returning &true; on success
and &false; on error.</para>
<para>
The <function>snmpset</function> function is used
to set the value of an SNMP object specified by the
<parameter>object_id</parameter>. SNMP agent is specified by the
<parameter>hostname</parameter> and the read community is specified
by the <parameter>community</parameter> parameter.</para>
</refsect1>
</refentry>
<refentry id="function.snmpwalk">
<refnamediv>
<refname>snmpwalk</refname>
<refpurpose>Fetch all the SNMP objects from an agent</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>snmpwalk</methodname>
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
<methodparam><type>string</type><parameter>community</parameter></methodparam>
<methodparam><type>string</type><parameter>object_id</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>timeout</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>retries</parameter></methodparam>
</methodsynopsis>
<para>
Returns an array of SNMP object values starting from the
<function>object_id</function> as root and &false; on error.</para>
<para>
<function>snmpwalk</function> function is used to read all the
values from an SNMP agent specified by the
<parameter>hostname</parameter>. <parameter>Community</parameter>
specifies the read community for that agent. A &null;
<parameter>object_id</parameter> is taken as the root of the SNMP
objects tree and all objects under that tree are returned as an
array. If <parameter>object_id</parameter> is specified, all the
SNMP objects below that <parameter>object_id</parameter> are
returned.
<informalexample>
<programlisting role="php">
<![CDATA[
$a = snmpwalk("127.0.0.1", "public", "");
]]>
</programlisting>
</informalexample></para>
<para>
Above function call would return all the SNMP objects from the
SNMP agent running on localhost. One can step through the values
with a loop
<informalexample>
<programlisting role="php">
<![CDATA[
for ($i=0; $i < count($a); $i++) {
echo $a[$i];
}
]]>
</programlisting>
</informalexample></para>
</refsect1>
</refentry>
<refentry id="function.snmpwalkoid">
<refnamediv>
<refname>snmpwalkoid</refname>
<refpurpose>Query for a tree of information about a network entity
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>snmpwalkoid</methodname>
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
<methodparam><type>string</type><parameter>community</parameter></methodparam>
<methodparam><type>string</type><parameter>object_id</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>timeout</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>retries</parameter></methodparam>
</methodsynopsis>
<para>
Returns an associative array with object ids and their respective
object value starting from the <parameter>object_id</parameter>
as root and &false; on error.</para>
<para>
<function>snmpwalkoid</function> function is used to read all
object ids and their respective values from an SNMP agent
specified by the hostname. Community specifies the read
<parameter>community</parameter> for that agent. A &null;
<parameter>object_id</parameter> is taken as the root of the SNMP
objects tree and all objects under that tree are returned as an
array. If <parameter>object_id</parameter> is specified, all the
SNMP objects below that <parameter>object_id</parameter> are
returned.</para>
<para>
The existence of <function>snmpwalkoid</function> and
<function>snmpwalk</function> has historical reasons. Both
functions are provided for backward compatibility.
<informalexample>
<programlisting role="php">
<![CDATA[
$a = snmpwalkoid("127.0.0.1", "public", "");
]]>
</programlisting>
</informalexample></para>
<para>
Above function call would return all the SNMP objects from the
SNMP agent running on localhost. One can step through the values
with a loop
<informalexample>
<programlisting role="php">
<![CDATA[
for (reset($a); $i = key($a); next($a)) {
echo "$i: $a[$i]<br>\n";
}
]]>
</programlisting>
</informalexample></para>
</refsect1>
</refentry>
<refentry id="function.snmp-get-quick-print">
<refnamediv>
<refname>snmp_get_quick_print</refname>
<refpurpose>Fetch the current value of the UCD library's quick_print setting
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>snmp_get_quick_print</methodname>
<void/>
</methodsynopsis>
<para>
Returns the current value stored in the UCD Library for quick_print.
quick_print is off by default.
<informalexample>
<programlisting role="php">
<![CDATA[
$quickprint = snmp_get_quick_print();
]]>
</programlisting>
</informalexample></para>
<para>
Above function call would return &false; if
quick_print is off, and &true; if quick_print
is on.</para>
<para>
<function>snmp_get_quick_print</function> is only available when using
the UCD SNMP library. This function is not available when using the
Windows SNMP library.</para>
<para>
See: <function>snmp_set_quick_print</function> for a full description
of what quick_print does.</para>
</refsect1>
</refentry>
<refentry id="function.snmp-set-quick-print">
<refnamediv>
<refname>snmp_set_quick_print</refname>
<refpurpose>Set the value of quick_print within the UCD SNMP library.
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>void</type><methodname>snmp_set_quick_print</methodname>
<methodparam><type>bool</type><parameter>quick_print</parameter></methodparam>
</methodsynopsis>
<para>
Sets the value of quick_print within the UCD SNMP library. When this
is set (1), the SNMP library will return 'quick printed' values. This
means that just the value will be printed. When quick_print is not
enabled (default) the UCD SNMP library prints extra information
including the type of the value (i.e. IpAddress or OID). Additionally,
if quick_print is not enabled, the library prints additional hex values
for all strings of three characters or less.</para>
<para>
Setting quick_print is often used when using the information returned
rather then displaying it.
<informalexample>
<programlisting role="php">
<![CDATA[
snmp_set_quick_print(0);
$a = snmpget("127.0.0.1", "public", ".1.3.6.1.2.1.2.2.1.9.1");
echo "$a<BR>\n";
snmp_set_quick_print(1);
$a = snmpget("127.0.0.1", "public", ".1.3.6.1.2.1.2.2.1.9.1");
echo "$a<BR>\n";
]]>
</programlisting>
</informalexample></para>
<para>
The first value printed might be: 'Timeticks: (0) 0:00:00.00', whereas
with quick_print enabled, just '0:00:00.00' would be printed.</para>
<para>
By default the UCD SNMP library returns verbose values, quick_print is
used to return only the value.</para>
<para>
Currently strings are still returned with extra quotes, this will be
corrected in a later release.</para>
<para>
<function>snmp_set_quick_print</function> is only available when using
the UCD SNMP library. This function is not available when using
the Windows SNMP library.</para>
</refsect1>
</refentry>
<refentry id='function.snmprealwalk'>
<refnamediv>
<refname>snmprealwalk</refname>
<refpurpose>
Return all objects including their respective object id withing the specified one
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>snmprealwalk</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 choice="opt"><type>int</type><parameter>timeout</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>retries</parameter></methodparam>
</methodsynopsis>
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
</reference>
<!-- 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:"../../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
-->
|