1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

let snmp nodes specify optional :port

to close #462
This commit is contained in:
Dave Conway-Jones 2018-07-17 09:41:52 +01:00
parent 27a1038993
commit 8f83e471b8
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
3 changed files with 13 additions and 8 deletions

View File

@ -1,9 +1,9 @@
{
"name" : "node-red-node-snmp",
"version" : "0.0.18",
"version" : "0.0.19",
"description" : "A Node-RED node that looks for SNMP oids.",
"dependencies" : {
"net-snmp" : "1.1.19"
"net-snmp" : "1.2.4"
},
"repository" : {
"type":"git",

View File

@ -1,7 +1,7 @@
<script type="text/x-red" data-template-name="snmp">
<div class="form-row">
<label for="node-input-host"><i class="fa fa-globe"></i> Host</label>
<input type="text" id="node-input-host" placeholder="localhost">
<input type="text" id="node-input-host" placeholder="ip address(:optional port)">
</div>
<div class="form-row">
<label for="node-input-community"><i class="fa fa-user"></i> Community</label>
@ -62,7 +62,7 @@
<script type="text/x-red" data-template-name="snmp set">
<div class="form-row">
<label for="node-input-host"><i class="fa fa-globe"></i> Host</label>
<input type="text" id="node-input-host" placeholder="localhost">
<input type="text" id="node-input-host" placeholder="ip address(:optional port)">
</div>
<div class="form-row">
<label for="node-input-community"><i class="fa fa-user"></i> Community</label>
@ -131,7 +131,7 @@
<script type="text/x-red" data-template-name="snmp table">
<div class="form-row">
<label for="node-input-host"><i class="fa fa-globe"></i> Host</label>
<input type="text" id="node-input-host" placeholder="localhost">
<input type="text" id="node-input-host" placeholder="ip address(:optional port)">
</div>
<div class="form-row">
<label for="node-input-community"><i class="fa fa-user"></i> Community</label>
@ -192,7 +192,7 @@
<script type="text/x-red" data-template-name="snmp subtree">
<div class="form-row">
<label for="node-input-host"><i class="fa fa-globe"></i> Host</label>
<input type="text" id="node-input-host" placeholder="localhost">
<input type="text" id="node-input-host" placeholder="ip address(:optional port)">
</div>
<div class="form-row">
<label for="node-input-community"><i class="fa fa-user"></i> Community</label>
@ -254,7 +254,7 @@
<script type="text/x-red" data-template-name="snmp walker">
<div class="form-row">
<label for="node-input-host"><i class="fa fa-globe"></i> Host</label>
<input type="text" id="node-input-host" placeholder="localhost">
<input type="text" id="node-input-host" placeholder="ip address(:optional port)">
</div>
<div class="form-row">
<label for="node-input-community"><i class="fa fa-user"></i> Community</label>

View File

@ -7,8 +7,13 @@ module.exports = function (RED) {
function getSession(host, community, version, timeout) {
var sessionKey = host + ":" + community + ":" + version;
var port = 161;
if (host.indexOf(":") !== -1) {
port = host.split(":")[1];
host = host.split(":")[0];
}
if (!(sessionKey in sessions)) {
sessions[sessionKey] = snmp.createSession(host, community, { version:version, timeout:(timeout || 5000) });
sessions[sessionKey] = snmp.createSession(host, community, { port:port, version:version, timeout:(timeout || 5000) });
}
return sessions[sessionKey];
}