projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ff7ec9f
)
snmp plugin: Replace reserved chars in hostname value
author
Pavel Rochnyack
<pavel2000@ngs.ru>
Fri, 15 Jun 2018 05:05:58 +0000
(12:05 +0700)
committer
Pavel Rochnyack
<pavel2000@ngs.ru>
Fri, 15 Jun 2018 05:05:58 +0000
(12:05 +0700)
src/snmp.c
patch
|
blob
|
history
diff --git
a/src/snmp.c
b/src/snmp.c
index
f591600
..
1bf6664
100644
(file)
--- a/
src/snmp.c
+++ b/
src/snmp.c
@@
-1193,6
+1193,15
@@
static bool csnmp_ignore_instance(csnmp_cell_char_t *cell,
return 0;
} /* bool csnmp_ignore_instance */
return 0;
} /* bool csnmp_ignore_instance */
+static void csnmp_cell_replace_reserved_chars(csnmp_cell_char_t *cell) {
+ for (char *ptr = cell->value; *ptr != '\0'; ptr++) {
+ if ((*ptr > 0) && (*ptr < 32))
+ *ptr = ' ';
+ else if (*ptr == '/')
+ *ptr = '_';
+ }
+}
+
static int csnmp_dispatch_table(host_definition_t *host,
data_definition_t *data,
csnmp_cell_char_t *instance_cells,
static int csnmp_dispatch_table(host_definition_t *host,
data_definition_t *data,
csnmp_cell_char_t *instance_cells,
@@
-1618,13
+1627,7
@@
static int csnmp_read_table(host_definition_t *host, data_definition_t *data) {
if (csnmp_ignore_instance(cell, data)) {
sfree(cell);
} else {
if (csnmp_ignore_instance(cell, data)) {
sfree(cell);
} else {
- /**/
- for (char *ptr = cell->value; *ptr != '\0'; ptr++) {
- if ((*ptr > 0) && (*ptr < 32))
- *ptr = ' ';
- else if (*ptr == '/')
- *ptr = '_';
- }
+ csnmp_cell_replace_reserved_chars(cell);
DEBUG("snmp plugin: il->instance = `%s';", cell->value);
csnmp_cells_append(&instance_cells_head, &instance_cells_tail, cell);
DEBUG("snmp plugin: il->instance = `%s';", cell->value);
csnmp_cells_append(&instance_cells_head, &instance_cells_tail, cell);
@@
-1651,6
+1654,8
@@
static int csnmp_read_table(host_definition_t *host, data_definition_t *data) {
break;
}
break;
}
+ csnmp_cell_replace_reserved_chars(cell);
+
DEBUG("snmp plugin: il->hostname = `%s';", cell->value);
csnmp_cells_append(&hostname_cells_head, &hostname_cells_tail, cell);
} else /* The variable we are processing is a normal value */
DEBUG("snmp plugin: il->hostname = `%s';", cell->value);
csnmp_cells_append(&hostname_cells_head, &hostname_cells_tail, cell);
} else /* The variable we are processing is a normal value */