X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsnmp.c;h=8faccbe9548088a404eaabe97370027ac12aa5c2;hb=1eef4102557312f19400b8655f054c4fdb7311e4;hp=aa3c9ddab38f59d14aca10ba7478e94cde7db9cf;hpb=6d79874b8afa65cbb4a8e348caf37b8e60fbeded;p=collectd.git diff --git a/src/snmp.c b/src/snmp.c index aa3c9dda..8faccbe9 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -1388,6 +1388,50 @@ static int csnmp_read_table(host_definition_t *host, data_definition_t *data) { break; } + if (res->errstat != SNMP_ERR_NOERROR) { + if (res->errindex != 0) { + /* Find the OID which caused error */ + for (i = 1, vb = res->variables; vb != NULL && i != res->errindex; + vb = vb->next_variable, i++) + /* do nothing */; + } + + if ((res->errindex == 0) || (vb == NULL)) { + ERROR("snmp plugin: host %s; data %s: response error: %s (%li) ", + host->name, data->name, snmp_errstring(res->errstat), + res->errstat); + status = -1; + break; + } + + 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)); + + /* Calculate value index from todo list and skip OID found */ + i = 0; + size_t j = 1; + for (;;) { + while ((i < oid_list_len) && !oid_list_todo[i]) + i++; + + if (j == res->errindex) + break; + + i++; + j++; + } + + assert(i < oid_list_len); + oid_list_todo[i] = 0; + + snmp_free_pdu(res); + res = NULL; + continue; + } + for (vb = res->variables, i = 0; (vb != NULL); vb = vb->next_variable, i++) { /* Calculate value index from todo list */