fix parse oidname and santilize dimension name (#4498)
Dylan Wang committed
Oct 30, 2018 at 04:49 UTC
a35bd00fbf8f2578ec0c660b532e925911191b43
1 file changed
+4
-4
collectors/node.d.plugin/snmp/snmp.node.js
+4
-4
@@ -171,7 +171,7 @@ netdata.processors.snmp = {
171
172
var oid = this.fixoid(dim.oid);
173
var oidname = this.fixoid(dim.oidname);
174
-
174
+
175
if(__DEBUG === true)
176
netdata.debug(service.module.name + ': ' + service.name + ': indexing ' + this.name + ' chart: ' + c + ', dimension: ' + d + ', OID: ' + oid + ", OID name: " + oidname);
177
@@ -276,7 +276,7 @@ netdata.processors.snmp = {
276
277
switch(varbinds[i].type) {
278
case net_snmp.ObjectType.OctetString:
279
- if(service.snmp_oids_index[varbinds[i].oid].type !== 'title') {
279
+ if (service.snmp_oids_index[varbinds[i].oid].type !== 'title' && service.snmp_oids_index[varbinds[i].oid].type !== 'name') {
280
// parse floating point values, exposed as strings
281
value = parseFloat(varbinds[i].value) * 1000;
282
if (__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': found ' + service.module.name + ' value of OIDs ' + varbinds[i].oid + ", ObjectType " + net_snmp.ObjectType[varbinds[i].type] + " (" + netdata.stringify(varbinds[i].type) + "), typeof(" + typeof(varbinds[i].value) + "), in JSON: " + netdata.stringify(varbinds[i].value) + ", value = " + value.toString() + " (parsed as float in string)");
@@ -309,7 +309,7 @@ netdata.processors.snmp = {
309
if(value !== null) {
310
switch(service.snmp_oids_index[varbinds[i].oid].type) {
311
case 'title': service.snmp_oids_index[varbinds[i].oid].link.title += ' ' + value; break;
312
- case 'name' : service.snmp_oids_index[varbinds[i].oid].link.name = value; break;
312
+ case 'name' : service.snmp_oids_index[varbinds[i].oid].link.name = value.toString().replace(/\W/g, '_'); break;
313
case 'value': service.snmp_oids_index[varbinds[i].oid].link.value = value; break;
314
}
315
}
@@ -448,7 +448,7 @@ var snmp = {
448
var id = c + from.toString();
449
var chart = extend(true, {}, service_request_chart);
450
chart.title += from.toString();
451
-
451
+
452
if(typeof chart.titleoid !== 'undefined')
453
chart.titleoid += from.toString();
454