diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-11-07 12:19:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-11-07 12:20:17 +0000 |
commit | a64a253794ac64cb40befee54db53bde17dd0d49 (patch) | |
tree | c1024acc5f6e508814b944d99f112259bb28b1be /collectors/node.d.plugin/snmp/snmp.node.js | |
parent | New upstream version 1.10.0+dfsg (diff) | |
download | netdata-upstream/1.11.0+dfsg.tar.xz netdata-upstream/1.11.0+dfsg.zip |
New upstream version 1.11.0+dfsgupstream/1.11.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | collectors/node.d.plugin/snmp/snmp.node.js (renamed from node.d/snmp.node.js) | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/node.d/snmp.node.js b/collectors/node.d.plugin/snmp/snmp.node.js index 3e7027958..a051d3d3a 100644 --- a/node.d/snmp.node.js +++ b/collectors/node.d.plugin/snmp/snmp.node.js @@ -1,4 +1,5 @@ 'use strict'; +// SPDX-License-Identifier: GPL-3.0-or-later // netdata snmp module // This program will connect to one or more SNMP Agents // @@ -170,7 +171,7 @@ netdata.processors.snmp = { var oid = this.fixoid(dim.oid); var oidname = this.fixoid(dim.oidname); - + if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': indexing ' + this.name + ' chart: ' + c + ', dimension: ' + d + ', OID: ' + oid + ", OID name: " + oidname); @@ -275,14 +276,16 @@ netdata.processors.snmp = { switch(varbinds[i].type) { case net_snmp.ObjectType.OctetString: - if(service.snmp_oids_index[varbinds[i].oid].type !== 'title') + if (service.snmp_oids_index[varbinds[i].oid].type !== 'title' && service.snmp_oids_index[varbinds[i].oid].type !== 'name') { // parse floating point values, exposed as strings value = parseFloat(varbinds[i].value) * 1000; - 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)"); - else + 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)"); + } + else { // just use the string value = varbinds[i].value; - 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 string)"); + 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 string)"); + } break; case net_snmp.ObjectType.Counter64: @@ -306,7 +309,7 @@ netdata.processors.snmp = { if(value !== null) { switch(service.snmp_oids_index[varbinds[i].oid].type) { case 'title': service.snmp_oids_index[varbinds[i].oid].link.title += ' ' + value; break; - case 'name' : service.snmp_oids_index[varbinds[i].oid].link.name = value; break; + case 'name' : service.snmp_oids_index[varbinds[i].oid].link.name = value.toString().replace(/\W/g, '_'); break; case 'value': service.snmp_oids_index[varbinds[i].oid].link.value = value; break; } } @@ -445,7 +448,7 @@ var snmp = { var id = c + from.toString(); var chart = extend(true, {}, service_request_chart); chart.title += from.toString(); - + if(typeof chart.titleoid !== 'undefined') chart.titleoid += from.toString(); |