mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
slight edits to snmp to pass jslint-ing
This commit is contained in:
parent
163345cf5c
commit
d087281a11
@ -36,3 +36,7 @@ want to use `msg.oid` to provide input.
|
|||||||
|
|
||||||
Outputs `msg.payload` containing the table of objects, and the requested `msg.oid`.
|
Outputs `msg.payload` containing the table of objects, and the requested `msg.oid`.
|
||||||
Values depends on the oids being requested.
|
Values depends on the oids being requested.
|
||||||
|
|
||||||
|
### snmp-walker
|
||||||
|
|
||||||
|
### snmp-subtree
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-snmp",
|
"name" : "node-red-node-snmp",
|
||||||
"version" : "0.0.6",
|
"version" : "0.0.7",
|
||||||
"description" : "A Node-RED node that looks for SNMP oids.",
|
"description" : "A Node-RED node that looks for SNMP oids.",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"net-snmp" : "1.1.13"
|
"net-snmp" : "1.1.13"
|
||||||
@ -20,5 +20,8 @@
|
|||||||
"name": "Dave Conway-Jones",
|
"name": "Dave Conway-Jones",
|
||||||
"email": "ceejay@vnet.ibm.com",
|
"email": "ceejay@vnet.ibm.com",
|
||||||
"url": "http://nodered.org"
|
"url": "http://nodered.org"
|
||||||
}
|
},
|
||||||
|
"contributors": [
|
||||||
|
{ "name": "Mika Karalia" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2014 IBM Corp.
|
* Copyright 2014,2016 IBM Corp.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -32,11 +32,11 @@ module.exports = function(RED) {
|
|||||||
if (oids) {
|
if (oids) {
|
||||||
node.session.get(oids.split(","), function(error, varbinds) {
|
node.session.get(oids.split(","), function(error, varbinds) {
|
||||||
if (error) {
|
if (error) {
|
||||||
node.error(error.toString());
|
node.error(error.toString(),msg);
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < varbinds.length; i++) {
|
for (var i = 0; i < varbinds.length; i++) {
|
||||||
if (snmp.isVarbindError(varbinds[i])) {
|
if (snmp.isVarbindError(varbinds[i])) {
|
||||||
node.error(snmp.varbindError (varbinds[i]));
|
node.error(snmp.varbindError(varbinds[i]),msg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (varbinds[i].type == 4) { varbinds[i].value = varbinds[i].value.toString(); }
|
if (varbinds[i].type == 4) { varbinds[i].value = varbinds[i].value.toString(); }
|
||||||
@ -102,6 +102,7 @@ module.exports = function(RED) {
|
|||||||
node.send(msg);
|
node.send(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.on("input",function(m) {
|
this.on("input",function(m) {
|
||||||
msg = m;
|
msg = m;
|
||||||
var oids = node.oids || msg.oid;
|
var oids = node.oids || msg.oid;
|
||||||
@ -125,7 +126,7 @@ module.exports = function(RED) {
|
|||||||
this.session = snmp.createSession(this.host, this.community, {version: this.version});
|
this.session = snmp.createSession(this.host, this.community, {version: this.version});
|
||||||
var node = this;
|
var node = this;
|
||||||
var maxRepetitions = 20;
|
var maxRepetitions = 20;
|
||||||
var response = new Array();
|
var response = [];
|
||||||
|
|
||||||
function doneCb(error) {
|
function doneCb(error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
@ -141,8 +142,9 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
function feedCb(varbinds) {
|
function feedCb(varbinds) {
|
||||||
for (var i = 0; i < varbinds.length; i++) {
|
for (var i = 0; i < varbinds.length; i++) {
|
||||||
if (snmp.isVarbindError (varbinds[i]))
|
if (snmp.isVarbindError(varbinds[i])) {
|
||||||
console.error (snmp.varbindError (varbinds[i]));
|
node.error(snmp.varbindError(varbinds[i]));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
console.log(varbinds[i].oid + "|" + varbinds[i].value);
|
console.log(varbinds[i].oid + "|" + varbinds[i].value);
|
||||||
response.add({oid: varbinds[i].oid, value: varbinds[i].value});
|
response.add({oid: varbinds[i].oid, value: varbinds[i].value});
|
||||||
@ -162,7 +164,6 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType("snmp subtree",SnmpSubtreeNode);
|
RED.nodes.registerType("snmp subtree",SnmpSubtreeNode);
|
||||||
|
|
||||||
function SnmpWalkerNode(n) {
|
function SnmpWalkerNode(n) {
|
||||||
@ -174,11 +175,11 @@ module.exports = function(RED) {
|
|||||||
this.session = snmp.createSession(this.host, this.community, {version: this.version});
|
this.session = snmp.createSession(this.host, this.community, {version: this.version});
|
||||||
var node = this;
|
var node = this;
|
||||||
var maxRepetitions = 20;
|
var maxRepetitions = 20;
|
||||||
var response=new Array();
|
var response = [];
|
||||||
|
|
||||||
function doneCb(error) {
|
function doneCb(error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error (error.toString ());
|
node.error(error.toString());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var msg = {};
|
var msg = {};
|
||||||
@ -190,8 +191,9 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
function feedCb(varbinds) {
|
function feedCb(varbinds) {
|
||||||
for (var i = 0; i < varbinds.length; i++) {
|
for (var i = 0; i < varbinds.length; i++) {
|
||||||
if (snmp.isVarbindError (varbinds[i]))
|
if (snmp.isVarbindError(varbinds[i])) {
|
||||||
console.error (snmp.varbindError (varbinds[i]));
|
node.error(snmp.varbindError(varbinds[i]));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
console.log(varbinds[i].oid + "|" + varbinds[i].value);
|
console.log(varbinds[i].oid + "|" + varbinds[i].value);
|
||||||
response.add({oid: varbinds[i].oid, value: varbinds[i].value});
|
response.add({oid: varbinds[i].oid, value: varbinds[i].value});
|
||||||
@ -211,4 +213,4 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("snmp walker",SnmpWalkerNode);
|
RED.nodes.registerType("snmp walker",SnmpWalkerNode);
|
||||||
}
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user