summaryrefslogtreecommitdiffstats
path: root/node.d/snmp.node.js
diff options
context:
space:
mode:
authorLennart Weller <lhw@ring0.de>2017-09-17 22:17:45 +0000
committerLennart Weller <lhw@ring0.de>2017-09-17 22:17:45 +0000
commit7ee3962eaca4214264964ae32c86de457a90e382 (patch)
tree5a784485351593ac6d74fa9fd9bbd8fe7c9c3fe0 /node.d/snmp.node.js
parentmaintscript eludes me (diff)
parentNew upstream version 1.8.0+dfsg (diff)
downloadnetdata-7ee3962eaca4214264964ae32c86de457a90e382.tar.xz
netdata-7ee3962eaca4214264964ae32c86de457a90e382.zip
Updated version 1.8.0+dfsg from 'upstream/1.8.0+dfsg'
with Debian dir 412de09d9bca38fe00146ef090f9e53f76493882
Diffstat (limited to 'node.d/snmp.node.js')
-rw-r--r--node.d/snmp.node.js37
1 files changed, 30 insertions, 7 deletions
diff --git a/node.d/snmp.node.js b/node.d/snmp.node.js
index 57b37ffa0..3e7027958 100644
--- a/node.d/snmp.node.js
+++ b/node.d/snmp.node.js
@@ -269,13 +269,36 @@ netdata.processors.snmp = {
failed++;
}
else {
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': found ' + service.module.name + ' value of OIDs ' + varbinds[i].oid + " = " + varbinds[i].value);
-
- if(varbinds[i].type === net_snmp.ObjectType.OctetString && service.snmp_oids_index[varbinds[i].oid].type !== 'title')
- value = parseFloat(varbinds[i].value) * 1000;
- else
- value = varbinds[i].value;
+ // test fom Counter64
+ // varbinds[i].type = net_snmp.ObjectType.Counter64;
+ // varbinds[i].value = new Buffer([0x34, 0x49, 0x2e, 0xdc, 0xd1]);
+
+ switch(varbinds[i].type) {
+ case net_snmp.ObjectType.OctetString:
+ if(service.snmp_oids_index[varbinds[i].oid].type !== 'title')
+ // 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
+ // 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)");
+ break;
+
+ case net_snmp.ObjectType.Counter64:
+ // copy the buffer
+ value = '0x' + varbinds[i].value.toString('hex');
+ 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 buffer)");
+ break;
+
+ case net_snmp.ObjectType.Integer:
+ case net_snmp.ObjectType.Counter:
+ case net_snmp.ObjectType.Gauge:
+ default:
+ 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 number)");
+ break;
+ }
ok++;
}