Node-RED as a SNMP Agent

3,155 views
Skip to first unread message

TridiumControls

unread,
Oct 11, 2016, 10:10:53 PM10/11/16
to Node-RED
Hi, 

Can node-red be configured as a SNMP agent? I do know there is this node http://flows.nodered.org/node/node-red-node-snmp 
from what I can tell it is only a fetcher, a snmp oid reader if you will. But I need values be available to SNMP managers from node-red. Possible?

Julian Knight

unread,
Oct 12, 2016, 7:56:09 AM10/12/16
to Node-RED
I don't think there is anything available as yet.

I note that there does seem to be at least one Node.JS module that could support this:


This could potentially be used to create a node.

You would also need to ensure that the server will receive UDP packets on port 161,

TridiumControls

unread,
Oct 12, 2016, 1:21:07 PM10/12/16
to Node-RED
Hmm. Very interesting. Nice part is that is available on npmjs.com and can be installed, to get it to work in node-red I can use this.

http://flows.nodered.org/node/node-red-contrib-npm

I got the npm node installed in node-red, but confused on how to pass the usage code to the npm node and get it to work.

has anyone used it before to explain what is required to get it to work?

SNMPJS gives me a usage code,

var os = require('os');
var snmp = require('snmpjs');

var agent = snmp.createAgent();

agent
.request({ oid: '.1.3.6.1.2.1.1.5', handler: function (prq) {
       
var nodename = os.hostname();
       
var val = snmp.data.createData({ type: 'OctetString',
            value
: nodename });

        snmp
.provider.readOnlyScalar(prq, val);
} });

agent
.bind({ family: 'udp4', port: 161 });

Does this need to be enclosed in a function and passed as a msg.payload to the npm node?

Ben Hardill

unread,
Oct 12, 2016, 5:37:11 PM10/12/16
to Node-RED
I wouldn't use the node-red-contrib-npm for something like this, it will be much better to actually create a fully fledged node to wrap the snmp npm.

Details of creating a Node-RED node are on the website here:

http://nodered.org/docs/creating-nodes/

It really isn't that tricky

TridiumControls

unread,
Oct 12, 2016, 11:31:25 PM10/12/16
to Node-RED
That's going to be little cumbersome for someone who has no prior java script experience.

Julian Knight

unread,
Oct 13, 2016, 2:00:11 AM10/13/16
to Node-RED
That's true of course, but then there isn't much call for creating SNMP agents!

Dave C-J

unread,
Oct 13, 2016, 2:55:48 AM10/13/16
to node...@googlegroups.com

Not quite clear to me what is required. Do you want Node-RED to be able to send traps to a server, or to be a "server" that SNMP can interrogate ?

In either case for now t may be easiest to set up snmpd  outside of Node-RED and then use an exec node to call out to a command line like snmptrap to set a trap in either the local snmpd or remotely.

TridiumControls

unread,
Oct 13, 2016, 11:06:56 AM10/13/16
to Node-RED
I already have a SNMP server. Here's what I'm looking for. 

I have a Honeywell Vista 15p panel which is a security system. Someone created a envisalink node for node-red, I am looking for a way to grab the status of the alarm panel and send the information via SNMP to my SNMP server which is managing other SNMP nodes. 

If Zone 1 door opens, etc, status of the alarm system, (armed, disarmed), any alarms. Like I said someone created a node for node-red to do that, but need a way to send it to my server over SNMP. 


 
In either case for now t may be easiest to set up snmpd  outside of Node-RED and then use an exec node to call out to a command line like snmptrap to set a trap in either the local snmpd or remotely.
 
How can this be done? You are talking to a greenhorn. I know few things about coding, but not enough to dive into the code and start writing it my self. 

Ben Hardill

unread,
Oct 13, 2016, 11:28:36 AM10/13/16
to Node-RED
The additional effort over getting it to work with the node-red-contrib-npm library would be relatively small, and good practice to get you started.


On Thursday, 13 October 2016 04:31:25 UTC+1, TridiumControls wrote:

TridiumControls

unread,
Oct 13, 2016, 11:35:54 AM10/13/16
to Node-RED
Ben, Do you think you can give me some insight on how to get started? I'm not familiar with java script. 

I know that SNMPJS gives me a usage code, 


var os = require('os');
var snmp = require('snmpjs');

var agent = snmp.createAgent();

agent
.request({ oid: '.1.3.6.1.2.1.1.5', handler: function (prq) {
       
var nodename = os.hostname();
       
var val = snmp.data.createData({ type: 'OctetString',
            value
: nodename });

        snmp
.provider.readOnlyScalar(prq, val);
} });

agent
.bind({ family: 'udp4', port: 161 });

What would the flow look like in node-red for example to inject the time stamp and use the NPM node with the above mentioned SNMPJS module available from NPM and be available with an OID that a SNMP server can read. I don't need to generate a MIB file, just have an OID available that I can read the time stamp fro node-red. 

DAVE C-J mentioned I can use exec node and use snmpd from linux to do what I want, I'm looking into that right now, and waiting for DAVE C-J's reply. 

Dave C-J

unread,
Oct 13, 2016, 7:20:44 PM10/13/16
to node...@googlegroups.com
What OS are you trying to run this on ? Are there any command line tools to send snmp traps to your server ? (eg like the snmptrap tool in Linux.) If so then try that first to see if it can be made to do what you want... - then use and exec node in Node-RED to call that same command - but this time with data you have got from the alarm box.
Reply all
Reply to author
Forward
0 new messages