summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d3abd8f)
raw | patch | inline | side by side (parent: d3abd8f)
author | Carlos Vicente <cvicente@gmail.com> | |
Wed, 18 Oct 2017 14:21:56 +0000 (14:21 +0000) | ||
committer | Carlos Vicente <cvicente@gmail.com> | |
Wed, 18 Oct 2017 14:21:56 +0000 (14:21 +0000) |
src/collectd-snmp.pod | patch | blob | history | |
src/collectd.conf.in | patch | blob | history | |
src/snmp.c | patch | blob | history |
diff --git a/src/collectd-snmp.pod b/src/collectd-snmp.pod
index edb95060f2baea9015056a038901d06f6a79cd81..d615088e5afdc77fd34c5e64b2a18f13eb389391 100644 (file)
--- a/src/collectd-snmp.pod
+++ b/src/collectd-snmp.pod
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
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 5f58a6e97d9f11a1b022bb60bdaa970bef107559..425f1ddf9a7ace66e2ec80698505ebc75f56a0b9 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# 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>
diff --git a/src/snmp.c b/src/snmp.c
index c74d76563166a5017f7730c722f2445d3159db2d..f27e64ff98b9446a542bb72cd7a800e41a0edae2 100644 (file)
--- a/src/snmp.c
+++ b/src/snmp.c
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;