Community "community_string"
Collect "std_traffic"
Interval 120
+ Timeout 10
+ Retries 1
</Host>
<Host "some.server.mydomain.org">
Address "192.168.0.42"
Community "more_communities"
Collect "powerplus_voltge_input"
Interval 300
+ Timeout 5
+ Retries 5
</Host>
</Plugin>
=head1 CONFIGURATION
Since the aim of the C<snmp plugin> is to provide a generic interface to SNMP,
-it's configuration is not trivial and may take some time.
+its configuration is not trivial and may take some time.
Since the C<Net-SNMP> library is used you can use all the environment variables
that are interpreted by that package. See L<snmpcmd(1)> for more details.
B<Step> of generated RRD files depends on this setting it's wise to select a
reasonable value once and never change it.
+=item B<Timeout> I<Seconds>
+
+How long to wait for a response. The C<Net-SNMP> library default is 1 second.
+
+=item B<Retries> I<Integer>
+
+The number of times that a query should be retried after the Timeout expires.
+The C<Net-SNMP> library default is 5.
+
=back
=head1 SEE ALSO
char *name;
char *address;
int version;
- int timeout;
+ cdtime_t timeout;
int retries;
/* snmpv1/2 options */
return 0;
} /* int csnmp_config_add_host_address */
-static int csnmp_config_add_host_timeout(host_definition_t *hd,
- oconfig_item_t *ci) {
- int timeout;
-
- if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER)) {
- WARNING("snmp plugin: `Timeout' must be a number");
- return -1;
- }
-
- timeout = (int)ci->values[0].value.number;
- if (timeout < 0) {
- WARNING("snmp plugin: `Timeout' must not be negative");
- return -1;
- }
-
- /* net-snmp library timeout is in microseconds */
- hd->timeout = timeout * 1000000;
-
- return 0;
-} /* int csnmp_config_add_host_timeout */
-
-static int csnmp_config_add_host_retries(host_definition_t *hd,
- oconfig_item_t *ci) {
- int retries;
-
-
- if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER)) {
- WARNING("snmp plugin: `Retries' must be a number");
- return -1;
- }
-
- retries = (int)ci->values[0].value.number;
- if (retries < 0) {
- WARNING("snmp plugin: `Retries' must not be negative");
- return -1;
- }
-
- hd->retries = retries;
-
- return 0;
-} /* int csnmp_config_add_host_retries */
-
static int csnmp_config_add_host_collect(host_definition_t *host,
oconfig_item_t *ci) {
data_definition_t *data;
hd->sess_handle = NULL;
hd->interval = 0;
- /* A negative value means that we have not set a timeout or retry value */
- hd->timeout = -1;
+ /* These mean that we have not set a timeout or retry value */
+ hd->timeout = 0xFFFFFFFFFFFFFFFF;
hd->retries = -1;
for (int i = 0; i < ci->children_num; i++) {
else if (strcasecmp("Version", option->key) == 0)
status = csnmp_config_add_host_version(hd, option);
else if (strcasecmp("Timeout", option->key) == 0)
- status = csnmp_config_add_host_timeout(hd, option);
+ cf_util_get_cdtime(option, &hd->timeout);
else if (strcasecmp("Retries", option->key) == 0)
- status = csnmp_config_add_host_retries(hd, option);
+ cf_util_get_int(option, &hd->retries);
else if (strcasecmp("Collect", option->key) == 0)
csnmp_config_add_host_collect(hd, option);
else if (strcasecmp("Interval", option->key) == 0)
}
/* Set timeout & retries, if they have been changed from the default */
- if (host->timeout >= 0) {
- sess.timeout = host->timeout;
+ if (host->timeout != 0xFFFFFFFFFFFFFFFF) {
+ /* net-snmp expects microseconds */
+ sess.timeout = CDTIME_T_TO_US(host->timeout);
}
if (host->retries >= 0) {
sess.retries = host->retries;