diff --git a/functions/snmp.xml b/functions/snmp.xml index abc33f66f2..d3976f4927 100644 --- a/functions/snmp.xml +++ b/functions/snmp.xml @@ -1,5 +1,5 @@ - + SNMP functions SNMP @@ -7,13 +7,15 @@ In order to use the SNMP functions on Unix you need to install the UCD SNMP package. On Windows these functions - are only available on NT and not on Win95/98. + are only available on NT and not on Win95/98. + 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: + #define line. It should look like this afterwards: + @@ -27,7 +29,8 @@ 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. + will work around the misfeature. + @@ -48,14 +51,16 @@ - Returns SNMP object value on success and &false; on error. + Returns SNMP object value on success and &false; on error. + The snmpget function is used to read the value of an SNMP object specified by the object_id. SNMP agent is specified by the hostname and the read community is - specified by the community parameter. + specified by the community parameter. + @@ -90,14 +95,16 @@ $syscontact = snmpget("127.0.0.1", "public", "system.SysContact.0"); Sets the specified SNMP object value, returning &true; on success - and &false; on error. + and &false; on error. + The snmpset function is used to set the value of an SNMP object specified by the object_id. SNMP agent is specified by the hostname and the read community is specified - by the community parameter. + by the community parameter. + @@ -120,7 +127,8 @@ $syscontact = snmpget("127.0.0.1", "public", "system.SysContact.0"); Returns an array of SNMP object values starting from the - object_id as root and &false; on error. + object_id as root and &false; on error. + snmpwalk function is used to read all the @@ -139,7 +147,8 @@ $syscontact = snmpget("127.0.0.1", "public", "system.SysContact.0"); $a = snmpwalk("127.0.0.1", "public", ""); ]]> - + + Above function call would return all the SNMP objects from the @@ -154,7 +163,8 @@ for ($i=0; $i < count($a); $i++) { } ]]> - + + @@ -180,18 +190,20 @@ for ($i=0; $i < count($a); $i++) { Returns an associative array with object ids and their respective object value starting from the object_id - as root and &false; on error. + as root and &false; on error. + snmpwalkoid function is used to read all object ids and their respective values from an SNMP agent - specified by the hostname. Community specifies the read + specified by the hostname. Community specifies the read community for that agent. A &null; object_id is taken as the root of the SNMP objects tree and all objects under that tree are returned as an array. If object_id is specified, all the SNMP objects below that object_id are - returned. + returned. + The existence of snmpwalkoid and @@ -204,7 +216,8 @@ for ($i=0; $i < count($a); $i++) { $a = snmpwalkoid("127.0.0.1", "public", ""); ]]> - + + Above function call would return all the SNMP objects from the @@ -219,7 +232,8 @@ for (reset($a); $i = key($a); next($a)) { } ]]> - + + @@ -248,21 +262,25 @@ for (reset($a); $i = key($a); next($a)) { $quickprint = snmp_get_quick_print(); ]]> - + + Above function call would return &false; if quick_print is off, and &true; if quick_print - is on. + is on. + snmp_get_quick_print is only available when using the UCD SNMP library. This function is not available when using the - Windows SNMP library. + Windows SNMP library. + See: snmp_set_quick_print for a full description - of what quick_print does. + of what quick_print does. + @@ -287,7 +305,8 @@ $quickprint = snmp_get_quick_print(); 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. + for all strings of three characters or less. + Setting quick_print is often used when using the information returned @@ -304,24 +323,29 @@ $a = snmpget("127.0.0.1", "public", ".1.3.6.1.2.1.2.2.1.9.1"); echo "$a
\n"; ]]> -
+ + 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. + with quick_print enabled, just '0:00:00.00' would be printed. + By default the UCD SNMP library returns verbose values, quick_print is - used to return only the value. + used to return only the value. + Currently strings are still returned with extra quotes, this will be - corrected in a later release. + corrected in a later release. + snmp_set_quick_print is only available when using the UCD SNMP library. This function is not available when using - the Windows SNMP library. + the Windows SNMP library. +