projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #3339 from jkohen/patch-1
[collectd.git]
/
src
/
snmp.c
diff --git
a/src/snmp.c
b/src/snmp.c
index
361a140
..
98da2b8
100644
(file)
--- a/
src/snmp.c
+++ b/
src/snmp.c
@@
-99,7
+99,6
@@
struct host_definition_s {
c_complain_t complaint;
data_definition_t **data_list;
int data_list_len;
c_complain_t complaint;
data_definition_t **data_list;
int data_list_len;
-
int bulk_size;
};
typedef struct host_definition_s host_definition_t;
int bulk_size;
};
typedef struct host_definition_s host_definition_t;
@@
-764,7
+763,7
@@
static int csnmp_config_add_host(oconfig_item_t *ci) {
/* These mean that we have not set a timeout or retry value */
hd->timeout = 0;
hd->retries = -1;
/* These mean that we have not set a timeout or retry value */
hd->timeout = 0;
hd->retries = -1;
- hd->bu
ild
_size = 0;
+ hd->bu
lk
_size = 0;
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *option = ci->children + i;
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *option = ci->children + i;
@@
-821,6
+820,11
@@
static int csnmp_config_add_host(oconfig_item_t *ci) {
status = -1;
break;
}
status = -1;
break;
}
+ if (hd->bulk_size > 0 && hd->version < 2) {
+ WARNING("snmp plugin: Bulk transfers is only available for SNMP v2 and "
+ "later, host '%s' is configured as version '%d'",
+ hd->name, hd->version);
+ }
if (hd->version == 3) {
if (hd->username == NULL) {
WARNING("snmp plugin: `Username' not given for host `%s'", hd->name);
if (hd->version == 3) {
if (hd->username == NULL) {
WARNING("snmp plugin: `Username' not given for host `%s'", hd->name);
@@
-1577,7
+1581,7
@@
static int csnmp_read_table(host_definition_t *host, data_definition_t *data) {
csnmp_oid_type_t oid_list_todo[oid_list_len];
int status;
csnmp_oid_type_t oid_list_todo[oid_list_len];
int status;
- size_t i
, j
;
+ size_t i;
/* `value_list_head' and `value_cells_tail' implement a linked list for each
* value. `instance_cells_head' and `instance_cells_tail' implement a linked
/* `value_list_head' and `value_cells_tail' implement a linked list for each
* value. `instance_cells_head' and `instance_cells_tail' implement a linked
@@
-1593,8
+1597,8
@@
static int csnmp_read_table(host_definition_t *host, data_definition_t *data) {
csnmp_cell_value_t **value_cells_head;
csnmp_cell_value_t **value_cells_tail;
csnmp_cell_value_t **value_cells_head;
csnmp_cell_value_t **value_cells_tail;
- DEBUG("snmp plugin: csnmp_read_table (host = %s, data = %s
(%ld))"
,
-
host->name, data->name, data->values_len
);
+ DEBUG("snmp plugin: csnmp_read_table (host = %s, data = %s
)", host->name
,
+
data->name
);
if (host->sess_handle == NULL) {
DEBUG("snmp plugin: csnmp_read_table: host->sess_handle == NULL");
if (host->sess_handle == NULL) {
DEBUG("snmp plugin: csnmp_read_table: host->sess_handle == NULL");
@@
-1660,7
+1664,7
@@
static int csnmp_read_table(host_definition_t *host, data_definition_t *data) {
status = 0;
while (status == 0) {
status = 0;
while (status == 0) {
- /* If SNMP v2 and later and bulk transfer
t
enabled, use GETBULK PDU */
+ /* If SNMP v2 and later and bulk transfer
s
enabled, use GETBULK PDU */
if (host->version > 1 && host->bulk_size > 0) {
req = snmp_pdu_create(SNMP_MSG_GETBULK);
req->non_repeaters = 0;
if (host->version > 1 && host->bulk_size > 0) {
req = snmp_pdu_create(SNMP_MSG_GETBULK);
req->non_repeaters = 0;
@@
-1773,13
+1777,13
@@
static int csnmp_read_table(host_definition_t *host, data_definition_t *data) {
continue;
}
continue;
}
+ size_t j;
for (vb = res->variables, j = 0; (vb != NULL);
vb = vb->next_variable, j++) {
for (vb = res->variables, j = 0; (vb != NULL);
vb = vb->next_variable, j++) {
+ i = j;
/* If bulk request is active convert value index of the extra value */
if (host->version > 1 && host->bulk_size > 0) {
/* If bulk request is active convert value index of the extra value */
if (host->version > 1 && host->bulk_size > 0) {
- i = j % oid_list_todo_num;
- } else {
- i = j;
+ i %= oid_list_todo_num;
}
/* Calculate value index from todo list */
while ((i < oid_list_len) && !oid_list_todo[i]) {
}
/* Calculate value index from todo list */
while ((i < oid_list_len) && !oid_list_todo[i]) {