Giter Club home page Giter Club logo

node-net-snmp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-net-snmp's Issues

MIB parser and MIB module store

npm release v2.3.0 implements a MIB parser and a MIB module store, created by new API call:

var store = snmp.createModuleStore ();

The idea is to parse MIB files into the "module store", where MIB module definitions are stored/retrieved as JSON objects. Also includes a one-liner to register the parsed MIBs for use in your SNMP agent. In three short commands, you're set up to write out to your agent's MIB:

store.loadFromFile ("/path/to/your/mibs/SNMPv2-MIB.mib");
var providers = store.getProvidersForModule ("SNMPv2-MIB");
agent.getMib ().registerProviders (providers);

From there, start cranking out your MIB:

var mib = agent.getMib ();
mib.setScalarValue ("sysDescr", "The most powerful system you can think of");
mib.setScalarValue ("sysName", "multiplied-by-six");
mib.addTableRow ("sysOREntry", [1, "1.3.6.1.4.1.47491.42.43.44.45", "I've dreamed up this MIB", 20]);

Pretty straight-forward. If you're into that sort of thing.

See the README.md docs for more info.

Session.createSession() seems to have wrong arguments.

Hi.

Session constructor has 3 arguments.

var Session = function (target, community, options) {
...
};

However, Session.createSession() has 4 arguments.

exports.createSession = function (target, community, version, options) {
  return new Session (target, community, version, options);
};

It is not so big problem, however I think it should be fixed some day.

Thank you.

The _generateId() function randomly returns negative ID's resulting in response parsing issues and timeouts

Hi, I just started trying to use node-net-snmp (and node-red-node-snmp, which uses node-net-snmp) and was surprised to encounter very basic problems, even with the sample .js on the node-net-snmp homepage. For example:

  • .get of 1 or 2 OID's would sometimes work, but often would timeout
  • .subtree would never work - always fails with timeout

When I reverted to index.js v. ecc688b, everything works fine - all .get's work reliably, and .subtree works fine.

I'm using node-net-snmp in Node.JS 8.9.3 in Windows 10 x64. I'm not sure if the changes to index.js are the problem or if there is some configuration issue, but for now I'm happy with the older version of index.js.

.subtree() returns correct results but times out repeatedly on Yocto

[email protected]
[email protected]
node.js: 6.10.3
yocto: 4.1.25

With the above installed versions, session.subtree() returns the correct results when I use either snmp.Version1 or snmp.Version2c.

However:

  • with snmp.Version1, it times out after returning every OID: 1 OID, then timeout, 1 OID, timeout, repeatedly until all OID's are returned.

  • with snmp.Version2c, it times out after returning every batch of OID's (= maxRepetitions). i.e., after returning the default of maxRepetitions = 20 OID's, it times out, then returns 20 more, then times out, repeatedly until all OID's are returned.

Obviously, I can reduce the timeout to something small, like 50ms instead of the default 5s. But this seems to me a workaround, and does not address the root cause of the problem.

Linux "snmpwalk" of the entire MIB works fine - no timeouts.

Any idea why I'm having this trouble in Yocto? I've used net-snmp successfully everywhere else (Windows 7 & 10, and other Linux distro's). Unfortunately, I'm stuck with node.js v 6.10.3 in this particular installation.

Example from README converted to Promise

Hi Stephen - this library is awesome! I am newish to Javascript and am curious on the smartest route to make your main example (session.get) from the README a Promise. I thought I would just ask you directly to see how you would go about it seeing how you build the thing and all.

Thanks again!

subtree no returns

The feedCb function is in an indefinite cycle

I am trying to get an array of the oid returned in the function and it does not finish executing even when there are no more children to read

unhandled error event with session.walk

I am using session.walk exactly as shown in the README and occasionally this will happen.

events.js:136
      throw er; // Unhandled 'error' event
      ^

InvalidAsn1Error: Expected 0x2: got 0x0
    at InvalidAsn1Error (/home/zip/gping/node_modules/asn1-ber/lib/ber/errors.js:4:11)
    at Reader._readTag (/home/zip/gping/node_modules/asn1-ber/lib/ber/reader.js:237:9)
    at Reader.readInt (/home/zip/gping/node_modules/asn1-ber/lib/ber/reader.js:147:14)
    at new ResponseMessage (/home/zip/gping/node_modules/net-snmp/index.js:531:24)
    at Session.onMsg (/home/zip/gping/node_modules/net-snmp/index.js:911:17)
    at Socket.emit (events.js:159:13)
    at UDP.onMessage [as onmessage] (dgram.js:658:8)

Can you fix that?

Integer value parsed incorrectly in some cases

Hi! Thanks for an awesome module!

I have a problem with a rather exotic device trying to read a temperature sensor value.
The code is simple:

var snmp = require('net-snmp');
var session = snmp.createSession('10.157.207.28', 'public', { version: snmp.Version1 });
session.get(['1.3.6.1.4.1.40418.2.4.4.1.0'], function (error, varbinds) {
    if (error) {
        throw error;
    }
    console.log('result>', varbinds);
    session.close();
});

What I get is an Integer too long (129) error. I drilled it down to the source and it looks like at this point an extra byte with value 129 is getting in the way for some reason. If I discard it prior to processing (i.e., add another buffer.readByte (); after this line, the value is parsed correctly. But I guess that'a a pretty bad hack.

I thought maybe the device is causing problems (I can read multiple other devices without issues), but both snmpget cli utility and the Free SNMP MIB Browser of ManageEngine seem to handle this OID of my device without any issues.

Maybe I will get down to the problem myself eventually, but some couple hours spent to this moment didn't bring me a solution.

snmpwalk do not stop

Hello,

I created the folowing code:

`
const snmp = require("net-snmp");

const options = {
port: 161,
retries: 1,
timeout: 5000,
transport: "udp4",
version: snmp.Version2c,
idBitsSize: 16
};

const session = snmp.createSession("10.200.36.18", "public", options);

console.log(session)

const oid = '1.3.6.1.4.1.6527.3.1.2.2.4.2.1.37';

function doneCb (error) {
if (error)
console.error (error.toString ());
}

function feedCb (varbinds) {
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);
}
}

var maxRepetitions = 1;

// The maxRepetitions argument is optional, and will be ignored unless using
// SNMP verison 2c
session.walk (oid, maxRepetitions, feedCb, doneCb);
`
The walk method do not stop, the method keeps running, not stop at the end of the mib, it simply goes to the next oid.

I just want to get the information of the specific oid.

Paulo

request fails due to community string

I using node-net-snmp for access SNMP v1, and receiving the following message
'Community 'public' in request does not match community '' in response' } varbinds = undefined
since "snmpget -v1 -c public" work successfully on the same OID, I'm wondering is this check is required. or is there a way to override it.

Thanks
Ilan

Not receiving error on bad trap

Hi there, I'm using v1.2.4 and even if I create a bogus session I'm not receiving errors either when I create the session, or send a trap. My code:

        this.session = snmp.createSession('127.0.0.1', 'public', {'version': snmp.Version2c});
        this.session.on('error', (error: Error) => {
            console.error(error.toString());
            this.close();
        });

there's nothing on 127.0.0.1 (or any other IP I try), and I send a trap with

            new Promise<void>((resolve, reject) =>
                this.session.trap(trapOid, varbinds, (error: Error) => {
                    if (error) {
                        reject(error);
                    }

                    resolve();
                }))

error always returns null. When I start my trap receiver everything works as expected but failure route is giving me no feedback.

Edit: looking at the code for session creation and trap (https://github.com/nospaceships/node-net-snmp/blob/master/index.js#L549 and https://github.com/nospaceships/node-net-snmp/blob/master/index.js#L1332) perhaps this is expected behaviour https://github.com/nospaceships/node-net-snmp/blob/master/index.js#L993. I'm new to SNMP so I'm not familiar if you can expect an error if the destination is wrong.

Some examples does not work

Hello.

I was tried to run examples snmp-table-columns.js and snmp-table.js, but it does not worked for me. It did not throw any error, it just did not print anything. At the same time I ran tcpdump and saw the SNMP traffic to and from my host. Other examples (snmp-get-bulk.js, snmp-get.js, snmp-subtree.js, etc.) works fine.

[root@localhost example]# node snmp-table.js MY_IP COMMUNITY 2c 1.3.6.1.2.1.2.2.1.2
[root@localhost example]#

But, for example, snmp-subtree.js works fine^

[root@localhost example]# node snmp-subtree.js MY_IP COMMUNITY 2c 1.3.6.1.2.1.2.2.1.2
1.3.6.1.2.1.2.2.1.2.1|InLoopBack0
1.3.6.1.2.1.2.2.1.2.2|NULL0
1.3.6.1.2.1.2.2.1.2.5|Ethernet0/0/1
1.3.6.1.2.1.2.2.1.2.6|Ethernet0/0/2
1.3.6.1.2.1.2.2.1.2.7|Ethernet0/0/3
1.3.6.1.2.1.2.2.1.2.8|Ethernet0/0/4
1.3.6.1.2.1.2.2.1.2.9|Ethernet0/0/5
1.3.6.1.2.1.2.2.1.2.10|Ethernet0/0/6
1.3.6.1.2.1.2.2.1.2.11|Ethernet0/0/7
1.3.6.1.2.1.2.2.1.2.12|Ethernet0/0/8
1.3.6.1.2.1.2.2.1.2.13|Ethernet0/0/9
1.3.6.1.2.1.2.2.1.2.14|Ethernet0/0/10
1.3.6.1.2.1.2.2.1.2.15|Ethernet0/0/11
1.3.6.1.2.1.2.2.1.2.16|Ethernet0/0/12
1.3.6.1.2.1.2.2.1.2.17|Ethernet0/0/13
1.3.6.1.2.1.2.2.1.2.18|Ethernet0/0/14
1.3.6.1.2.1.2.2.1.2.19|Ethernet0/0/15
1.3.6.1.2.1.2.2.1.2.20|Ethernet0/0/16
1.3.6.1.2.1.2.2.1.2.21|Ethernet0/0/17
1.3.6.1.2.1.2.2.1.2.22|Ethernet0/0/18
1.3.6.1.2.1.2.2.1.2.23|Ethernet0/0/19
1.3.6.1.2.1.2.2.1.2.24|Ethernet0/0/20
1.3.6.1.2.1.2.2.1.2.25|Ethernet0/0/21
1.3.6.1.2.1.2.2.1.2.26|Ethernet0/0/22
1.3.6.1.2.1.2.2.1.2.27|Ethernet0/0/23
1.3.6.1.2.1.2.2.1.2.28|Ethernet0/0/24
1.3.6.1.2.1.2.2.1.2.29|GigabitEthernet0/0/1
1.3.6.1.2.1.2.2.1.2.30|GigabitEthernet0/0/2
1.3.6.1.2.1.2.2.1.2.31|Vlanif1175

What am I doing wrong?

Incorrectly passing `req` object in call to `req.responseCb` when handling errors during response processing

Hi,

I noticed that when, within the callback function of session.get() there is a javascript error (e.g. an undefined variable), the module catches the error and calls again (!) the callback function, but this time its parameters are not (error, varbinds), but (varbinds, error).

I traced it in your code and found that it is called at the catch statement of Session.prototype.onMsg(). I added a console.log there, and yes, this is the place that it is being called.

There, you have a req.responseCb (req, error);, which is the inverse of what the callback function should accept.

Also, I am not sure if you should catch errors at the anonymous callback function.

InvalidAsn1Error: 'Expected 0x2: got 0x0'

How to solve this issue?

{ [InvalidAsn1Error: Expected 0x2: got 0x0] name: 'InvalidAsn1Error', message: 'Expected 0x2: got 0x0' }

/var/www/courious/node_modules/net-snmp/index.js:918
var req = this.unregisterRequest (message.pdu.id);
^
TypeError: Cannot read property 'pdu' of undefined
at Session.onMsg (/var/www/courious/node_modules/net-snmp/index.js:918:43)
at Socket.EventEmitter.emit (events.js:98:17)
at UDP.onMessage (dgram.js:440:8)

This error message is displayed in an attempt to capture SNMP information from a printer. It would be wrong of LIB ASN1 or LIB net-snmp that makes use of this?

error send response of walk to client

Hi , thank for the package.
I have problem send response of walk to client. I write simple code but i have this error:
NodeError:Cannot set headers after they are sent to the client

var snmp = require('net-snmp');
var express = require('express');
app.on('/api/snmp/', (req, res) => {
  const session = new snmp.createSession(req.query.IP, req.query.Community);
  session.walk(
    '1.3.6.1',
    20,
    function(varbinds) {
     let msg = [];
      for (var i = 0; i < varbinds.length; i++) {
        if (snmp.isVarbindError(varbinds[i])) {
          console.log('error1');
        } else {
          console.log('send');
          msg.push({ message: varbinds[i].oid + '|' + varbinds[i].value });
        }
      }
      console.log(res.getHeaders());
      // res.setHeader('Content-Type', 'application/json');
      // res.send(msg);
      res.end(msg);
      // resolve(resultStr);
    },
    function(error) {
      console.log('error2');
      console.log(error.toString()); // show error in console: Cannot set headers after they are sent to the client
    }
  );
});

I Fixed this convert type of "msg" varaible to string.

AES 128 option for privacy protocol

Hi Mark, congrats on taking over support for the repo (and thanks to Stephen for all the original work and years of support for it)! We've been using the v2c functionality of the library for a few years and it has been great.

Really excited to see support for v3, and traps / inform receivers, will probably be using both features quite soon.

Question - do you have any plans to support AES 128 bit encryption as specified in RFC 3826 https://tools.ietf.org/html/rfc3826 ?

thanks!

OctetString conversion to String

I want to do a generic SNMP Subtree, but I am having problems with OctetString conversion:

  • MAC Adresses are decoded with .toString('hex')
  • Text is decoded with .toString('utf8')

My code is the following:

this.connection.subtree(oid, (varbinds: Array<any>) => {
  varbinds.forEach(varbind => {
    if (snmp.isVarbindError(varbind))
      message.push({
        'oid': varbind.oid,
        'value': snmp.varbindError(varbind)
      })

    else {
      if (varbind['type'])
        varbind['type'] = snmp.ObjectType[varbind['type']]

      // How to make this statement generic?
      if (varbind['value'] instanceof Buffer)
        varbind['value'] = varbind['value'].toString("hex")

      message.push(varbind)
    }
  })
})

And my responses are:

[{
    oid: "1.3.6.1.2.1.2.2.1.2.2",
    type: "OctetString",
    value: "526564204861742c20496e63204465766963652030303031"
},
// [...]
{
    oid: "1.3.6.1.2.1.2.2.1.6.2",
    type: "OctetString",
    value: "82f8c67920e6"
}]

The expected snmpget responses are:

1.3.6.1.2.1.2.2.1.2.2 = STRING: Red Hat, Inc Device 0001
1.3.6.1.2.1.2.2.1.6.2 = STRING: 82:f8:c6:79:20:e6

How can I distinguish one from the other and create a generic subtree function with correct string conversion?

wrong data type in snmp table

Hello I'm using snmp v: 2c.

If I try to make a call on CMD with snmptable on my Switch the result is :

{
    "1": "1",
    "2": "Ethernet Interface",
    "3": "ethernetCsmacd",
    "4": "1500",
    "5": "1000000000",
    "6": "4c:60:de:62:ce:78",
    "7": "up",
    "8": "up",
    "9": "0:0:00:25.94",
    "10": "1043131113",
    "11": "2569070",
    "12": "89248",
    "13": "0",
    "14": "0",
    "15": "0",
    "16": "687409018",
    "17": "3980021",
    "18": "137561",
    "19": "0",
    "20": "0",
    "22": "? SNMPv2-SMI::zeroDotZero"
  }


But with the node script I receive:

{
    "1": "1",
    "2": "Ethernet Interface",
    "3": "6",
    "4": "1500",
    "5": "1000000000",
    "6": "4c60de62ce78",
    "7": "1",
    "8": "1",
    "9": "2594",
    "10": "3705478788",
    "11": "34357618",
    "12": "203684",
    "13": "0",
    "14": "0",
    "15": "0",
    "16": "713535",
    "17": "114687267",
    "18": "308945",
    "19": "0",
    "20": "0",
    "22": "0.0"
  }


snmp.createSession() should be where the callback is defined

Right now if I have an snmp session created for a host and run two unique oid walk requests, each walk request get's it's own feed callback and done callback.

The walk requests all call the done callback of the latest (in sequence of when the instances were created) walk request. That's fine but that means that the done callback or the data callback of things like a single oid request should be defined in snmp.createSession().

The same is true of the feed callback.

SNMP - AGENT & NMS

Dear @markabrahams , @rsolomo , @stephenwvickers , @dhillis-miovision , @mancku

My best wishes for 2020. You did a great job and I appreciate.

Now, Most of the time we found on github only repository regarding snmp for NMS to monitor an Agent in nodejs and javascript or C++ supporting snmp V1,2,3 with or without all securities for V3.

Questions

Topic : How to parse and verify the MIB file is compliant with RFC ?

Do you have the way to parse the MIB and verify no dependencies aren't missing ?

Topic : Do you have same repository for snmp Agent / NMS

I write a MIB file and I need an snmp agent

Topic : snmp trap from snmp agent

I don't need only to share linkdown, status of the device , ... but share some parameters through the traps.
How I can do it ?

Nodejs & javascript / typescript

We are looking to use libraries with nodejs and javascript /typescript ?

If you have any interesting links or you could share your knowledge it will be helpful and will be happy, I am not asking to make this only for me but to contribute for the open source community ;-)

Best Regards,
Youssef

Specifying Context name for snmp V3

I am trying out the new release to see if it will work for my use case. One issue I am encountering is the ability to specify the context name in the requests. As is, my requests all return NoSuchObject. I have been working with the net-snmp cmd line tools to communicate with my device so far, so I know the oid and credentials are correct. I am able to replicate the NoSuchObject error via cmd if I remove the context option (-n <context>) net-snmp docs

I've looked through the documentation and source code. In the code, I've found reference to contextName in terms of parsing the pdu, but haven't been able to discern a way of specifying the context.

Is there any examples or additional documentation I could be pointed to that would clear this up for me? Is it possible to set the context in this way?

Thank you

No way to convert Counter64 buffer

ok, I am struggling to find any reliable way to convert Counter64 type to string or number.
As mentioned here for that type of data this library utilizes Node's Buffer and returns a Buffer that I suppose to convert later by myself.

My problem is that example above produces zeros all the time even when I can see that there's no empty buffer returned by this library.

Metric that I try to parse is ifHCInOctets (its oid is 1.3.6.1.2.1.31.1.1.1.6). By using snmpget on this oid I can confirm that there's a value returned (not equal to 0). Using this package I can see that <Buffer 01 c9 5d> (which is something) which (according to straight snmpgeting the value) should give a value of 22860 (according to just snmpget for my given interface). This counter is frozen now because no traffic is flowing, but it is not 0 for sure.

I have tried int64-buffer package that always gives me 0, I have tried node-cint64 which gave me not 0, but some incorrect value either way.

So is it a bug? Or maybe any live example that shows correct value transformation can be given here?

Much appreciated! Thank you!

Value of OctetString in Varbind

I'm sending traps with several varbinds. One includes the text message for the trap. When monitoring the traffic with tcpdump, for certain (smaller?) text messages, the packet includes the plain text of the text message. For other (longer?) text messages, the value for the text message varbind appears as a "buffer" string which makes the packet nearly 3 times longer. Examples below:

"Short" trap:

console.log(varbinds)=[{"oid":"1.3.6.1.4.1.161.3.6.87.2.210.2.1.1.1","type":4,"value":"platstreampro-1"},{"oid":"1.3.6.1.4.1.161.3.6.87.2.210.2.1.5.1","type":66,"value":1027},{"oid":"1.3.6.1.4.1.161.3.6.87.2.210.2.1.6.1","type":4,"value":"Retries threshold reached for [consumer][platstreamproClient-10550]"},{"oid":"1.3.6.1.4.1.161.3.5.7.1.0","type":2,"value":1501093726},{"oid":"1.3.6.1.4.1.161.3.5.7.2.0","type":2,"value":0}]

tcpdump: C=D Trap(256)  E:161.3.4.87.2.210 192.168.161.85 enterpriseSpecific s=2 14435 E:161.3.6.87.2.210.2.1.1.1="platstreampro-1" E:161.3.6.87.2.210.2.1.5.1=1027 E:161.3.6.87.2.210.2.1.6.1="Retries threshold reached for [consumer][platstreamproClient-10550]" E:161.3.5.7.1.0=1501093726 E:161.3.5.7.2.0=0 E:161.3.6.87.2.210.2.1.100.1=1

"Long" trap:

console.log(varbinds)=[{"oid":"1.3.6.1.4.1.161.3.6.87.2.210.2.1.1.1","type":4,"value":"platstreampro-1"},{"oid":"1.3.6.1.4.1.161.3.6.87.2.210.2.1.5.1","type":66,"value":1028},{"oid":"1.3.6.1.4.1.161.3.6.87.2.210.2.1.6.1","type":4,"value":"[commonLogFunction][platstreamproClient-10550]:[Full rejoin attempt failed: KafkaError: NotCoordinatorForGroup: The broker returns this error code if it receives an offset fetch or commit request for a group that it is not a coordinator for.\n{ [KafkaError: The broker returns this error code if it receives an offset fetch or commit request for a group that it is not a coordinator for.]\n  name: 'KafkaError',\n  code: 'NotCoordinatorForGroup',\n  message: 'The broker returns this error code if it receives an offset fetch or commit request for a group that it is not a coordinator for.' } \n[at apply (/usr/src/app/node_modules/no-kafka/node_modules/lodash/lodash.js:482:27)]]"},{"oid":"1.3.6.1.4.1.161.3.5.7.1.0","type":2,"value":1501093726},{"oid":"1.3.6.1.4.1.161.3.5.7.2.0","type":2,"value":0}]

tcpdump: C=D Trap(869)  E:161.3.4.87.2.210 192.168.161.85 enterpriseSpecific s=2 14435 E:161.3.6.87.2.210.2.1.1.1="platstreampro-1" E:161.3.6.87.2.210.2.1.5.1=1028 E:161.3.6.87.2.210.2.1.6.1=5b_63_6f_6d_6d_6f_6e_4c_6f_67_46_75_6e_63_74_69_6f_6e_5d_5b_70_6c_61_74_73_74_72_65_61_6d_70_72_6f_43_6c_69_65_6e_74_2d_31_30_35_35_30_5d_3a_5b_46_75_6c_6c_20_72_65_6a_6f_69_6e_20_61_74_74_65_6d_70_74_20_66_61_69_6c_65_64_3a_20_4b_61_66_6b_61_45_72_72_6f_72_3a_20_4e_6f_74_43_6f_6f_72_64_69_6e_61_74_6f_72_46_6f_72_47_72_6f_75_70_3a_20_54_68_65_20_62_72_6f_6b_65_72_20_72_65_74_75_72_6e_73_20_74_68_69_73_20_65_72_72_6f_72_20_63_6f_64_65_20_69_66_20_69_74_20_72_65_63_65_69_76_65_73_20_61_6e_20_6f_66_66_73_65_74_20_66_65_74_63_68_20_6f_72_20_63_6f_6d_6d_69_74_20_72_65_71_75_65_73_74_20_66_6f_72_20_61_20_67_72_6f_75_70_20_74_68_61_74_20_69_74_20_69_73_20_6e_6f_74_20_61_20_63_6f_6f_72_64_69_6e_61_74_6f_72_20_66_6f_72_2e_0a_7b_20_5b_4b_61_66_6b_61_45_72_72_6f_72_3a_20_54_68_65_20_62_72_6f_6b_65_72_20_72_65_74_75_72_6e_73_20_74_68_69_73_20_65_72_72_6f_72_20_63_6f_64_65_20_69_66_20_69_74_20_72_65_63_65_69_76_65_73_20_61_6e_20_6f_66_66_73_65_74_20_66_65_74_63_68_20_6f_72_20_63_6f_6d_6d_69_74_20_72_65_71_75_65_73_74_20_66_6f_72_20_61_20_67_72_6f_75_70_20_74_68_61_74_20_69_74_20_69_73_20_6e_6f_74_20_61_20_63_6f_6f_72_64_69_6e_61_74_6f_72_20_66_6f_72_2e_5d_0a_20_20_6e_61_6d_65_3a_20_27_4b_61_66_6b_61_45_72_72_6f_72_27_2c_0a_20_20_63_6f_64_65_3a_20_27_4e_6f_74_43_6f_6f_72_64_69_6e_61_74_6f_72_46_6f_72_47_72_6f_75_70_27_2c_0a_20_20_6d_65_73_73_61_67_65_3a_20_27_54_68_65_20_62_72_6f_6b_65_72_20_72_65_74_75_72_6e_73_20_74_68_69_73_20_65_72_72_6f_72_20_63_6f_64_65_20_69_66_20_69_74_20_72_65_63_65_69_76_65_73_20_61_6e_20_6f_66_66_73_65_74_20_66_65_74_63_68_20_6f_72_20_63_6f_6d_6d_69_74_20_72_65_71_75_65_73_74_20_66_6f_72_20_61_20_67_72_6f_75_70_20_74_68_61_74_20_69_74_20_69_73_20_6e_6f_74_20_61_20_63_6f_6f_72_64_69_6e_61_74_6f_72_20_66_6f_72_2e_27_20_7d_20_0a_5b_61_74_20_61_70_70_6c_79_20_28_2f_75_73_72_2f_73_72_63_2f_61_70_70_2f_6e_6f_64_65_5f_6d_6f_64_75_6c_65_73_2f_6e_6f_2d_6b_61_66_6b_61_2f_6e_6f_64_65_5f_6d_6f_64_75_6c_65_73_2f_6c_6f_64_61_73_68_2f_6c_6f_64_61_73_68_2e_6a_73_3a_34_38_32_3a_32_37_29_5d_5d E:161.3.5.7.1.0=1501093726 E:161.3.5.7.2.0=0 E:161.3.6.87.2.210.2.1.100.1=1

Why is the format of the text varbind different between the two traps? How can I ensure that text varbind is always sent as plain text? Is there a particular length restriction?

Know when a session opens

Hi,

if my PDU is disconnected, then, when I close my session it breaks the program because i'm doing :

  process.on('SIGINT', this.session.close.bind(this.session));

But the session was not opened :

^Cdgram.js:638
    throw new errors.Error('ERR_SOCKET_DGRAM_NOT_RUNNING');
    ^

Error [ERR_SOCKET_DGRAM_NOT_RUNNING]: Not running
    at Socket._healthCheck (dgram.js:638:11)
    at Socket.close (dgram.js:516:8)
    at Session.close (/Users/xxx/Documents/xxx/projets/Kobalt/node_modules/net-snmp/index.js:602:13)
    at emitNone (events.js:105:13)
    at process.emit (events.js:207:7)
    at Signal.wrap.onsignal (internal/process.js:205:44)

Request ID size

I've noticed that the code is using a rather large number for the request id, and my device must be using a signed value to store the request id and the return request id is coming back negative. Could a lower number be used for the request-id or could we seed a number to ensure that the value isn't too large?

Cannot access to "private" oids

I am new at using SNMP protocol, so excuse me if i misspell technical details.

I am working with this this library to get some information from a "Rajant" antena (model)

When i attempt to get info from oids that i suppose are general, like sysDescr: [1.3.6.1.2.1.1.1.0] or sysObjectID: [1.3.6.1.2.1.1.2.0] i get the correct values from them

Nevertheless when i try to use some "private" Rajant oids like freeMemory: [1.3.6.1.4.1.34861.1.3] or uptime: [1.3.6.1.4.1.34861.1.5] I cannot access values from them. The only one i can get is serialNumber: [1.3.6.1.4.1.34861.1.1] = ME4-2450R-35483.

These oids are obtained from this rajant mib file

And my code is as follows:

var options = {
              port: 9002,
              retries: 1,
              timeout: 100000,
              version: snmp.Version1,
              idBitsSize: 16
            };

var session = snmp.createSession ("192.168.0.56", "public",options);

oids = ["1.3.6.1.4.1.34861.1.3]","1.3.6.1.4.1.34861.1.5]"];

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

  }
});

session.trap (snmp.TrapType.LinkDown, function (error) {
  if (error)
    console.error (error);
});

I get an error from these oids, i can't get their values

I am asking for support to understand what is happening,

Am I using the library incorrectly?
Do i have to make some kind of auth to get this information?
Does exist this difference between "private" and "general" oids or is it just my perception?
How can i get those values from private oids?

I would muchly appreciate if i get some explanation. Thanks in advance

Mac Address encodage ?

Hello,
I am a beginner in JS it's true,
But I can not understand the encoding of the string, finally how to recover it as a string.

My problem :
When I say this script:

var snmp = require("net-snmp");
var ip = "127.0.0.1"
var community = "public"

var session = snmp.createSession (ip, community);

var oids = ["1.3.6.1.2.1.2.2.1.6.5"];

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);
}}
session.close ();
});

session.trap (snmp.TrapType.LinkDown, function (error) {
if (error)
console.error (error);
});

He will ask the mac address of the 5th interface I should normally have this:

MacBook-Air:superviseur stagiaire$ snmpget -v1 -Ov -c public 127.0.0.1 1.3.6.1.2.1.2.2.1.6.5
STRING: 0:f0:ee:25:7c:14

But I get this:

MacBook-Air:superviseur stagiaire$ node test.js
1.3.6.1.2.1.2.2.1.6.5 = ��%|

Thanks for your help and I'm sorry for my English

PDU types mis-defined

The following is an excerpt from the current code-base for the PDU types.

var PduType = {
    160: "GetRequest",
    161: "GetNextRequest",
    162: "GetResponse",
    163: "SetRequest",
    164: "Trap",
    165: "GetBulkRequest",
    166: "InformRequest",
    167: "TrapV2",
    168: "Report"
};

According to the RFCs for SNMPv2, and the amendment released with SNMPv3, these values have been mis-defined.

Stephen, I can not currently create a pull request for this due to my current works with this project (ref. emails). The following is my suggestion:

var PduType = {
    0: "GetRequest",
    1: "GetNextRequest",
    2: "GetResponse",
    3: "SetRequest",
    4: "Trap",              // Obsoleted in SNMPv2 (by RFC 1448)
    5: "GetBulkRequest",
    6: "InformRequest",
    7: "TrapV2",
    8: "Report"
};

Simply reduce the index values of each by 160.

Using traps

Hi,

I am starting to use this node-net-snmp package to deal with a Remote I/O module that sends traps in case state of the inputs changes. I have been able so far to get the values of the digital inputs via get function and now I am tryng to collect the value of a particular DO and to respond to a TRAP . What must I do to listen to a particular trap emited by this device?

Need help with a NoSuchName error

When e.g. calling snmpget 192.168.10.123 1.3.6.1.2.1.2.2.1.16.1 I do get a response like IF-MIB::ifOutOctets.1 = Counter32: 1200267093.

However, when using node-net-snmp to retrieve exactly the same OID the response reports an error RequestFailedError: NoSuchName: 1.3.6.1.2.1.2.2.1.16.1

Any advise on what I'm doing wrong?

BitString support

hi!

Are you thinking of adding BitString support anytime soon?

Thanks!

global leak detected for value and signedBitSet when testing with Mocha

Mocha features a global leak detection mechanism which alerts and fails if your code under test introduces global variables.

What's happening is that somewhere in your code you're missing your var declaration. Mocha is smart enough to detect this in your entire project, not just your test files.

When you don't declare your variables they get attached to the global scope. In Node.js, that's global and in the browser that's window.

I have patched my local clone to fix this, and I'll look into creating a pull request (I'm a GitHub newby though, so it may take some time...)

Different responses from command line than from library

Hi.
I have some troubles trying to comunitate with some ComAp Controllers using this library.
We got 16 units, 6 AMF-25 and 10 PWR models. All same model units got the same firmware.
I always got an answer if I use snmpget from the command line but it fails randomly (independently of the model)
The response I got is the following:
{ ResponseInvalidError: OID '1.3.6.1.4.1.28634.6.3780509972.2.8198.0' in request at positiion '0' does not match OID '1.3.6.1.4.1.28634.6.-514457324.2.8198.0' in response at position '0'
at Object.feedCb (/home/mauricio/server/node_modules/net-snmp/index.js:626:22)
at Object.Session.onSimpleGetResponse [as onResponse] (/home/mauricio/server/node_modules/net-snmp/index.js:951:7)
at Session.onMsg (/home/mauricio/server/node_modules/net-snmp/index.js:920:9)
at emitTwo (events.js:126:13)
at Socket.emit (events.js:214:7)
at UDP.onMessage [as onmessage] (dgram.js:659:8)
name: 'ResponseInvalidError',
message: 'OID '1.3.6.1.4.1.28634.6.3780509972.2.8198.0' in request at positiion '0' does not match OID '1.3.6.1.4.1.28634.6.-514457324.2.8198.0' in response at position '0'' }
What would be the problem that fails using the library but it doesn't when using snmp from the command line.
Thanks!

Returning both and error and varbinds in the same .get() call

I am working on a project that remotely communicates with SNMP equipment using the session.get() function from this library. We're finding it very difficult to debug when a single point throws off the whole SNMP read, especially since equipment of the same model sometimes has that OID defined and sometimes doesn't.

We have error logs, but it's not very intuitive or user friendly for us to just fail the whole read if one point fails (aka on a NoSuchName exception), especially since our remote reads are on timers. It'd be great if we could still get a returned list of varbinds with values for those SNMP OIDs that did not cause an error, even when an error is present.

Is there a reason why the session.get() returns either an error or a list of varbinds, but not both? I've taken a look at the library and have a grasp on it (though I'm certainly not an expert), and I'd be willing to help work on this if it's viable.

Thanks!

convert float / opaque values

Hi,

I am trying to solve issue netdata/netdata#3703

net-snmp.js returns ObjectType.Opaque for Opaque:Float OIDs.

Any ideas how to convert the buffer into a number (in node or even in C - since this will be streamed to the netdata daemon)?

snmp.table not returning values for Counter64 entries

I am faced with an issue of reading large Counter64 values using snmp.table.
I found the following description in the documentation:
"Since JavaScript does not offer full 64 bit integer support objects with type Counter64 cannot be supported in the same way as other integer types, instead Node.js Buffer objects are used. Users are responsible for producing (i.e. for set() requests) and consuming (i.e. the varbinds passed to callback functions) Buffer objects. That is, this module does not work with 64 bit integers, it simply treats them as opaque Buffer objects."

Printing the table I receive after calling snmp.table I can see all the entries in the table other than the two I need.
That is, they are not represented as a Buffer like the documentation suggests rather they are missing altogether from the response.
using snmptable from a shell window I can see the entire table including the entries I need.
For reference, the values I am trying to read are 1730433156953 and 387069230443.

I am using an Ubuntu 16.04 LTS machine with node v4.4.7 and net-snmp package v1.1.19

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.