summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4161e32)
raw | patch | inline | side by side (parent: 4161e32)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Thu, 1 Jun 2017 07:39:24 +0000 (14:39 +0700) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Tue, 26 Sep 2017 19:13:09 +0000 (02:13 +0700) |
Collectd does not check for `res->errstat` value after
`snmp_sess_synch_response()` call. In case of error, there is no any data in
`res->variables` actually, but variables are tried to be processed as usual.
Suffix calculation will fail, so all subtrees will be marked as failed, not
only one subtree which caused an error.
The csnmp_instance_list_add() call will fail too, and, as result,
`csnmp_read_table` will finish it's work without any data submission.
The log message like
"snmp plugin: host HOSTNAME: csnmp_instance_list_add failed",
which is put into logs in this case, also has no enough diagnostic data.
Added code to proper check for `res->errstat` and to try to get available data.
Issue: #2291
`snmp_sess_synch_response()` call. In case of error, there is no any data in
`res->variables` actually, but variables are tried to be processed as usual.
Suffix calculation will fail, so all subtrees will be marked as failed, not
only one subtree which caused an error.
The csnmp_instance_list_add() call will fail too, and, as result,
`csnmp_read_table` will finish it's work without any data submission.
The log message like
"snmp plugin: host HOSTNAME: csnmp_instance_list_add failed",
which is put into logs in this case, also has no enough diagnostic data.
Added code to proper check for `res->errstat` and to try to get available data.
Issue: #2291
src/snmp.c | patch | blob | history |
diff --git a/src/snmp.c b/src/snmp.c
index aa3c9ddab38f59d14aca10ba7478e94cde7db9cf..2b1dd0446e690e0eac8856a1bb73d6947186697c 100644 (file)
--- a/src/snmp.c
+++ b/src/snmp.c
@@ -1388,6 +1388,38 @@ static int csnmp_read_table(host_definition_t *host, data_definition_t *data) {
break;
}
+ if (res->errstat != SNMP_ERR_NOERROR) {
+ if (res->errindex != 0 && res->errindex < oid_list_len) {
+ /* Find the OID which caused error */
+ for (i = 1, vb = res->variables; vb != NULL && i != res->errindex;
+ vb = vb->next_variable, i++)
+ /* do nothing */;
+
+ char oid_buffer[1024] = {0};
+ snprint_objid(oid_buffer, sizeof(oid_buffer) - 1, vb->name,
+ vb->name_length);
+ NOTICE("snmp plugin: host %s; data %s: OID `%s` failed: %s",
+ host->name, data->name, oid_buffer,
+ snmp_errstring(res->errstat));
+
+ /* Skip that OID */
+ i = res->errindex - 1;
+ while ((i < oid_list_len) && !oid_list_todo[i])
+ i++;
+
+ oid_list_todo[i] = 0;
+
+ snmp_free_pdu(res);
+ res = NULL;
+ continue;
+ }
+
+ ERROR("snmp plugin: host %s; data %s: response error: %s (%li) ",
+ host->name, data->name, snmp_errstring(res->errstat), res->errstat);
+ status = -1;
+ break;
+ }
+
for (vb = res->variables, i = 0; (vb != NULL);
vb = vb->next_variable, i++) {
/* Calculate value index from todo list */