Node-red-node-snmp dynamic host?

I'm trying to find documentation on how to dynamically set the 'Host' parameter of the SNMP node.

Use case:
Http://server:1880/ip?ip=ip.to.check >>> SNMP host <ip.to.check>

Screen Shot 2020-04-10 at 4.11.22 PM

I think if you leave it blank in the node then msg.host can be used to set it.

Leaving the SNMP node's host parameter empty returns:
"TypeError: Cannot read property 'indexOf' of undefined"

Using Set msg.payload to msg.host has also been unsuccessful.

Ok - will have a look over the weekend

If it helps..., I have the node-red-node-snmp (0.0.24) installed.

Also as a test I've tied Injecting {"host":"10.128.135.20"} directly into the SNMP node with no luck.

hi
it needs to be msg.host node msg.payload.host

The SNMP Node does not seem to be unwrapping the variable in the host field BEFORE triggering the SNMP call.

I have also tried {{req.params.host}} as outlined here without any luck...

The Template and HTTP out page load as expected...

I have also been looking at using a sub-flow with an environmental variable.... so far without luck.

The top screenshot still shows msg.payload.host.... it must be msg.host - you need a change node after the inject to move it.

Success!

When I had initially worked with the change node, it failed. I now see that it was because the default 'Set' was not changing the payload as expected. Swapping 'Set' to 'Move' resolved the issue. With additional tinkering I found hat 'Set' could be made to work, however the fields have to be flipped when using 'Set'.

Change > Move: msg.req.params.host To: msg.host
Change > Set: msg.host To: msg.req.params.host

Thanks!

Screen Shot 2020-04-14 at 11.05.46 AM

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.