note 88349 added to function.snmpget
| From: | DouglasManley at osu1 dot php dot net | Date: | Tue, 20 Jan 2009 23:44:03 +0000 |
| Subject: | note 88349 added to function.snmpget | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149563@lists.php.net to get a copy of this message | ||
About the "timeout" and "retries" parameters (conveniently not documented):
From snmp_api.h (net-snmp):
170 struct snmp_session {
171 /*
172 * Protocol-version independent fields
173 */
174 long version;
175 int retries; /* Number of retries before timeout. */
176 long timeout; /* Number of uS until first timeout, then exponential backoff */
The important pieces here are "retries" and "timeout".
"retries": this number is the number of retries before timeout. If not specified, this
defaults to SNMP_DEFAULT_RETRIES--the C constant; there is no corresponding PHP constant.
"timeout": this is the number of MICRO-SECONDS (*not* nano-seconds; the "u" is
latin-character shorthand for a lowercase Greek "myu"). If not specified, this defaults
to SNMP_DEFAULT_TIMEOUT--the C constant; there is no corresponding PHP constant.
From snmp_api.h (net-snmp):
250 #define SNMP_DEFAULT_RETRIES -1
251 #define SNMP_DEFAULT_TIMEOUT -1
Now, if the default values (SNMP_DEFAULT_RETRIES or SNMP_DEFAULT_TIMEOUT) are used, then SNMP
defaults the values to--and again, these are internal constants--DEFAULT_RETRIES and
DEFAULT_TIMEOUT, respectively.
From snmp_api.c (net-snmp):
189 #define DEFAULT_RETRIES 5
190 #define DEFAULT_TIMEOUT 1000000L
This means:
1. SNMP tries 1 + 5 times to perform an action.
2. SNMP initially times out after 1 second.
After some testing against an agent that does not return a proper error code if an OID is not found,
I currently do not believe that "snmpget" only retries 5 times; using the default settings
for "snmpget", I've seen the following output from a script that simply performed one
snmpget with an IP, community string, and "ifName.1":
Performing snmpget...
Warning: snmpget(): Error in packet: (noSuchName) There is no such variable name in this MIB. in
/root/test.php on line 13
Warning: snmpget(): This name does not exist: in /root/test.php on line 13
[...]
[These two warning lines continued essentially forever--at least 10 minutes, which is definitely not
worth 5 retries.]
However, changing the retries value here had some effect; I am currently not sure why.
----
Server IP: 64.71.164.2
Probable Submitter: 216.158.20.130
----
Manual Page -- http://www.php.net/manual/en/function.snmpget.php
Edit -- https://master.php.net/note/edit/88349
Del: integrated -- https://master.php.net/note/delete/88349/integrated
Del: useless -- https://master.php.net/note/delete/88349/useless
Del: bad code -- https://master.php.net/note/delete/88349/bad+code
Del: spam -- https://master.php.net/note/delete/88349/spam
Del: non-english -- https://master.php.net/note/delete/88349/non-english
Del: in docs -- https://master.php.net/note/delete/88349/in+docs
Del: other reasons-- https://master.php.net/note/delete/88349
Reject -- https://master.php.net/note/reject/88349
Search -- https://master.php.net/manage/user-notes.php