Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
while(len--)
service.snmp_oids_index[slice[len]].value = null;
}
else {
if(__DEBUG === true)
netdata.debug(service.module.name + ': ' + service.name + ': got valid ' + service.module.name + ' response: ' + netdata.stringify(varbinds));
var varbinds_len = varbinds.length;
for(var i = 0; i < varbinds_len ; i++) {
var value = null;
if(net_snmp.isVarbindError(varbinds[i])) {
if(__DEBUG === true)
netdata.debug(service.module.name + ': ' + service.name + ': failed ' + service.module.name + ' get for OIDs ' + varbinds[i].oid);
service.error('OID ' + varbinds[i].oid + ' gave error: ' + net_snmp.varbindError(varbinds[i]));
value = null;
failed++;
}
else {
// 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' && 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 {
function feedCb(varbinds) {
for (var i = 0; i < varbinds.length; i++) {
if (snmp.isVarbindError(varbinds[i])) {
node.error(snmp.varbindError(varbinds[i]), msg);
}
else {
//console.log(varbinds[i].oid + "|" + varbinds[i].value);
response.push({ oid: varbinds[i].oid, value: varbinds[i].value });
}
}
}
this.session.get (oids, function (error, varbinds) {
if (error) {
console.error (error);
} else {
for (var i = 0; i < varbinds.length; i++) {
if (snmp.isVarbindError(varbinds[i])) {
console.error (snmp.varbindError (varbinds[i]));
} else {
console.log (varbinds[i].oid + " = " + varbinds[i].value);
}
}
}
});