Ping Network Devices From a List

Hey, I piosted the ARP trick.... where is it? Missing? Oh different thread! Well, since using the ARP cache can avoid statistic lists of devices, here is an example.

As for accessing the ARP cache, I just use an exec node to grab the ARP cache data from the Linux CLI., 'arp -a' will output device name (DNS resolved), device ip, and MAC address as well as the interface of the device that sees the other devices.

For example:

A.domain.org (192.168.1.161) at 50:02:91:d5:8d:95 [ether] on wlan0
B.domain.org (192.168.1.231) at 00:13:ef:60:08:ce [ether] on eth0
C.domain.org (192.168.1.137) at b8:27:eb:8a:b2:ff [ether] on eth0
D.domain.org (192.168.1.6) at on eth0
E.domain.org (192.168.1.168) at bc:dd:c2:53:e8:eb [ether] on eth0

Below is a simple flow using a persistent flow variable to maintain the device list, that is updated as the ARP cache changes, i.e. new devices added. Note my persistent flow variables are defined as 'persistent', any flow variable tagged with 'persistent' is such, and this environment specific, something you configure. See the end of this note for details on using persistent flow variables.

[{"id":"50ac89e1.0ecb","type":"inject","z":"cfa0d8c5.398578","name":"Make List","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":40,"wires":[["881e4330.695288"]]},{"id":"c506450a.dc169","type":"split","z":"cfa0d8c5.398578","name":"Split Lines","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":470,"y":40,"wires":[["d93f3fd9.e875a"]]},{"id":"aa6bb798.afacd","type":"debug","z":"cfa0d8c5.398578","name":"Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":260,"y":140,"wires":[]},{"id":"881e4330.695288","type":"exec","z":"cfa0d8c5.398578","command":"arp -a","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Get ARP Cache","x":280,"y":40,"wires":[["c506450a.dc169"],[],[]]},{"id":"d93f3fd9.e875a","type":"function","z":"cfa0d8c5.398578","name":"Add To Array","func":"// Just Device Name...\nvar theName = msg.payload.split(' ')[0];\n\nvar theDevices = flow.get('devices', 'persistent') || [],\n    theDevice = theDevices.map(theDevice => theDevice).indexOf(theName);\n\nif (theDevice != -1) {\n\n    // Update Existing Entry?  Not Really Needed Right?\n\n} else {\n    \n    // Add Entry...\n    theDevices.push(theName);\n    \n    flow.set('devices', theDevices, 'persistent');\n    \n}\n\n\nreturn msg;","outputs":0,"noerr":0,"initialize":"","finalize":"","x":650,"y":40,"wires":[]},{"id":"19bcf5ec.4323da","type":"inject","z":"cfa0d8c5.398578","name":"Show List","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"#:(persistent)::devices","payloadType":"flow","x":100,"y":140,"wires":[["aa6bb798.afacd"]]}]

If you need details on persistence of flow variables...
https://discourse.nodered.org/t/a-guide-to-understanding-persistent-context/4115