0
votes

I'm trying to get an nodejs app running, requesting the status of a printer with nodejs. I've tried so far to use "net-snmp" with no success.

The problems starts using the oid (iso.3.6.1.2.1.43.8.2.1.12.1.1).

If I use 'iso.3.6.1.2.1.43.8.2.1.12.1.1' or '.3.6.1.2.1.43.8.2.1.12.1.1' I will get "Error: argument is not a valid OID string".

If I use '3.6.1.2.1.43.8.2.1.12.1.1' I get "RequestFailedError: NoSuchName: 3.6.1.2.1.43.8.2.1.12.1.1".

var snmp = require('net-snmp');

var oids = [".3.6.1.2.1.43.8.2.1.12.1.1"];

var session = snmp.createSession ("w.x.y.z", "public");

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);
  }
});

snmpwalk will output: snmpget -v 2c -c public w.x.y.z iso.3.6.1.2.1.43.8.2.1.12.1.1 iso.3.6.1.2.1.43.8.2.1.12.1.1 = STRING: "24mm Dia / 0.94\" Dia"

Does anyone have an idea how to solve this, maybe also an workaround. I get simular errors if I use snmp-native.

1
Use correct OID 1.3.6.1.2.1.43.8.2.1.12.1.1 - Gambit Support

1 Answers

0
votes

Thanks a lot Gambit Support!

Just put "1" instead of "iso".

var snmp = require('net-snmp');
//wrong: var oids = ["iso.3.6.1.2.1.43.8.2.1.12.1.1"];

// correct

var oids = ["1.3.6.1.2.1.43.8.2.1.12.1.1"];

var session = snmp.createSession ("w.x.y.z", "public");

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);
  }
})