Pass several objects in one step to "Advanced Ping"

Hi,

I am using the "advanced ping" node to check if my network hardware is still up and running.
this node requires a msg.host value to ping to.
I would like to send him a list of msg.host value so that I do not have to handle them one by one.

Is there a possibility to return more than one object in a single step ?

Thats what I tried, but it does not work:

var x = {};
var y = [];

x.host = '10.0.0.21';
y[0] = x;

x.host = '10.0.0.40';
y[1] = x;

x.host = '10.0.0.160';
y[2] = x;

y.forEach(i,x)
{
    i++;
    return x;
}



Using the core node-red-node-ping you can ping 1 or multiple nodes...

from the built in help...

Triggered

In Triggered mode, you must connect an input wire and pass a msg in to trigger the ping operation.

If Target is populated, this will be used as the host/ip. The Target must be is a CSV list of hosts / IPs e.g. "192.168.0.1" or "192.168.0.1, www.google.com"

If Target is left empty, you can pass a CSV string or an array of hosts in msg.payload .

  • string - a CSV list of hosts / IPs e.g. "192.168.0.1" or "192.168.0.1, www.google.com"
  • array - an array of hosts as strings or objects. Note : The object must contain at minimum .host . Optionally, you can add a timeout property between 1000 & 30000 (default is 5000 / 5 seconds). Additionally, you can add whatever other properties you wish to this object and when the ping result is returned, it will be passed to the next node in msg.ping for use downstream

e.g...

[{"id":"76aa3560b32c2762","type":"ping","z":"1683bd9a.5e0a02","protocol":"Automatic","mode":"triggered","name":"","host":"","timer":"20","inputs":1,"x":1870,"y":1320,"wires":[["5cf32978c7d096fb"]]},{"id":"326dc067f7428bb2","type":"inject","z":"1683bd9a.5e0a02","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"192.168.1.38\",{\"host\":\"192.168.1.1\",\"name\":\"The router\"},{\"host\":\"myapiserver.com\",\"name\":\"external API\",\"timeout\":20000,\"support\":\"support@myapiserver.com\"}]","payloadType":"json","x":1870,"y":1260,"wires":[["76aa3560b32c2762"]]},{"id":"5cf32978c7d096fb","type":"debug","z":"1683bd9a.5e0a02","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1870,"y":1380,"wires":[]}]
1 Like

Or you could do something like this:

let y = [{ host: "10.0.0.21" }, { host: "10.0.0.40" }, { host: "10.0.0.160" }];

y.forEach(function (element) {
    node.send(element);
});
1 Like

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