summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4300502)
raw | patch | inline | side by side (parent: 4300502)
author | Carlos Vicente <cvicente@gmail.com> | |
Tue, 17 Oct 2017 16:39:48 +0000 (16:39 +0000) | ||
committer | Carlos Vicente <cvicente@gmail.com> | |
Tue, 17 Oct 2017 16:39:48 +0000 (16:39 +0000) |
src/snmp.c | patch | blob | history |
diff --git a/src/snmp.c b/src/snmp.c
index 37ee86da06a5275c14e5c93530cb584454b48428..c74d76563166a5017f7730c722f2445d3159db2d 100644 (file)
--- a/src/snmp.c
+++ b/src/snmp.c
oconfig_item_t *ci) {
int timeout;
- if (ci->values[0].type != OCONFIG_TYPE_NUMBER) {
+ if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER)) {
WARNING("snmp plugin: `Timeout' must be a number");
return -1;
}
int retries;
- if (ci->values[0].type != OCONFIG_TYPE_NUMBER) {
+ if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER)) {
WARNING("snmp plugin: `Retries' must be a number");
return -1;
}
hd->sess_handle = NULL;
hd->interval = 0;
+ /* A negative value means that we have not set a timeout or retry value */
+ hd->timeout = -1;
+ hd->retries = -1;
+
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *option = ci->children + i;
status = 0;
sess.community_len = strlen(host->community);
}
- /* Set timeout & retries */
- sess.timeout = host->timeout;
- sess.retries = host->retries;
+ /* Set timeout & retries, if they have been changed from the default */
+ if (host->timeout >= 0) {
+ sess.timeout = host->timeout;
+ }
+ if (host->retries >= 0) {
+ sess.retries = host->retries;
+ }
/* snmp_sess_open will copy the `struct snmp_session *'. */
host->sess_handle = snmp_sess_open(&sess);