How to use the net-snmp.varbindError function in net-snmp

To help you get started, we’ve selected a few net-snmp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github netdata / netdata / collectors / node.d.plugin / snmp / snmp.node.js View on Github external
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 {
github node-red / node-red-nodes / io / snmp / snmp.js View on Github external
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 });
                }
            }
        }
github glenmurphy / route / modules / snmp_dev / snmp.js View on Github external
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);          
        }
      }
    }
  });

net-snmp

JavaScript implementation of the Simple Network Management Protocol (SNMP)

MIT
Latest version published 19 days ago

Package Health Score

82 / 100
Full package analysis