note 88349 deleted from function.snmpget by danbrown
| From: | danbrown@php.net | Date: | Wed, 21 Jan 2009 00:18:55 +0000 |
| Subject: | note 88349 deleted from function.snmpget by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149566@lists.php.net to get a copy of this message | ||
Note Submitter: Douglas Manley
----
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.