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

snmp set Add check if varbinds field may be empty

This commit is contained in:
Dave Conway-Jones 2019-11-06 09:30:46 +00:00
parent 17853b772e
commit a146c8e28c
No known key found for this signature in database
GPG Key ID: 302A6725C594817F
3 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-snmp",
"version" : "0.0.22",
"version" : "0.0.23",
"description" : "A Node-RED node that looks for SNMP oids.",
"dependencies" : {
"net-snmp" : "1.2.4"

View File

@ -1,4 +1,4 @@
<script type="text/x-red" data-template-name="snmp">
<script type="text/html" 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="ip address(:optional port)">
@ -27,7 +27,7 @@
<div class="form-tips">Tip: Multiple OIDs can be separated by commas.</div>
</script>
<script type="text/x-red" data-help-name="snmp">
<script type="text/html" data-help-name="snmp">
<p>Simple SNMP oid or oid list fetcher. Triggered by any input.</p>
<p><code>msg.host</code> may contain the host.</p>
<p><code>msg.community</code> may contain the community.</p>

View File

@ -67,6 +67,7 @@ module.exports = function (RED) {
this.version = (n.version === "2c") ? snmp.Version2c : snmp.Version1;
this.varbinds = n.varbinds;
this.timeout = Number(n.timeout || 5) * 1000;
if (this.varbinds && this.varbinds.trim().length === 0) { delete this.varbinds; }
var node = this;
this.on("input", function (msg) {
var host = node.host || msg.host;