SNMP v3 node-red-node-snmp

Hi,
there is a PR still dangling in the pipeline since Oct 24 -> Added support for V3 . What a pitty that it is still unfinished.

I would also propose to not only add the additional parameters for SNMPv3 (user, password, authkey, privkey), but also to refactor the server parameters and credentials into a 'snmp config node'.

Unfortunately my personal skills will not be suffice to finish this. :slightly_frowning_face:

Yes - it was nearly completed and I don't think it was too far off - but I don't have any snmp skill or any devices to test it against (at least not knowingly) - so really does need someone to step up to complete it.

Not abandoned the project, work,family and COVID got in the way. I will see if I can rekindle this in the next few weeks.

2 Likes

I have installed the patched node of @AsHex_66 into a flow that monitors an enterprise switch.
Most of the changes that @dceejay requests in the comments to the PR are about the configuration fields in the UI.
But doing a request to a bigger snmp-table via SNMPv3 with 800+ entries crashes Node-RED :bomb:

 node-red[3532654]: 3 Feb 10:01:50 - [info] [snmp table:ipNetToMediaTable] [object Object]
 node-red[3532654]: 3 Feb 10:01:56 - [red] Uncaught Exception:
 node-red[3532337]: 2 Feb 17:53:58 - Error [ERR_SOCKET_DGRAM_NOT_RUNNING]: Not running
 node-red[3532337]:     at healthCheck (dgram.js:888:11)
 node-red[3532337]:     at Socket.close (dgram.js:710:3)
 node-red[3532337]:     at Session.close (/opt/node-red-nodes/io/snmp/node_modules/net-snmp/index.js:1813:13)
 node-red[3532337]:     at closeSession (/opt/node-red-nodes/io/snmp/snmp.js:49:29)
 node-red[3532337]:     at Req.responseCb (/opt/node-red-nodes/io/snmp/snmp.js:111:2
1)
 node-red[3532337]:     at Req.feedCb (/opt/node-red-nodes/io/snmp/node_modules/net-snmp/index.js:1855:8)
 node-red[3532337]:     at Req.Session.onSimpleGetResponse [as onResponse] (/opt/node-red-nodes/io/snmp/node>
 node-red[3532337]:     at Session.onMsg (/opt/node-red-nodes/io/snmp/node_modules/net-snmp/index.js:2177:7)
 node-red[3532337]:     at Socket.emit (events.js:315:20)
 node-red[3532337]:     at UDP.onMessage [as onmessage] (dgram.js:910:8)
 systemd[1]: node-red.service: Main process exited, code=exited, status=1/FAILURE
 systemd[1]: node-red.service: Failed with result 'exit-code'.

As it seems the bug is caused by the session.close() statement in the original code.
I don't fully understand this exception, but the UDP socket is closed to early during communication. In SNMPv2c is was not possible for me to trigger this bug.
Asking other, smaller SNMP tables with v3 works.

So, where to discuss this bug ?
Should I send a bug report to the fork of @AsHex_66 or should the cleaned and finished PR first merged ?

1 Like

I'd say discuss on the fork as that is where that code lies at present, and will need to be fixed there at some point.

X,

I have not tested with any requests >800 entries.
Is it node-Red that closes the session, or is this a driver request.
Have not jumped back into this, but will soon.
Remember, this has not released yet and is still under development.

AsHex

1 Like

Hello.

Just wondering if this is working yet or how I go about installing the fork?

1 Like

I dont know how to update this so it works.

But this is the thread that shows up when searching for v3 information so thought people looking may find this helpful.

This is what I got to work with a function node and net-snmp.

var user = {
name: "********",  // Add username
level: snmp.SecurityLevel.authPriv,  // Change based on security level
authProtocol: snmp.AuthProtocols.md5, // Change based on protocols
authKey: "**********", // Add auth key
privProtocol: snmp.PrivProtocols.aes, // Change based on ecryption
privKey: "********" // Add priv key
};

var session = snmp.createV3Session ("***.***.***.***", user);  // Add ip address of device

var oids = ["*.*.*.*.*.*.*.*.*", "*.*.*.*.*.*.*.*.*"];  // Add O.I.D's for readings

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 {
                msg.payload.temp = varbinds[0].value;
                msg.payload.current= varbinds[1].value
                msg.payload.voltage = varbinds[2].value
node.send(msg)
            }
        }
    }
    session.close ();
});

@AsHex_66 fyi

I have updated the node-red-node-snmp node to v1.0.0 complete with snmpv3 support. It is built upon the existing PR, resolving the outstanding points raised by Dave & has been published on the flows library.

2 Likes

V3 support now added.

You might want to give that a go?

I'd appreciate the feedback

Thanks.

1 Like

Well done, I have not checked this as I have been snowed under since Covid. I will give it a go and feed back what (if any) I find.

2 Likes

So I have tested the SNMP V3 and it worked, great! I was wondering if there is a way to set the AES encryption size. I believe it is using the default key size of 128 but I want to test devices at 192 and 256 bit key sizes. Any way I can set key size?