Skip to content

Instantly share code, notes, and snippets.

@vaibhavarduino
Last active July 7, 2020 06:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaibhavarduino/ed47511832dfd79d6bf416f6a8a056da to your computer and use it in GitHub Desktop.
Save vaibhavarduino/ed47511832dfd79d6bf416f6a8a056da to your computer and use it in GitHub Desktop.
PING Network Monitoring / latency Dashboard

The flow checks whether the device answers to ping. If it does not, it will show a red indication in front of the device name. and in another group, the same devices show real-time latency. The default ping is every 5 seconds but can be configured.

tested on Centos7, windows and raspberry pi 3 mod-b devices

Pre-requisites

Node-RED version: v0.20.8

Node.js version: v10.16.3

Nodes install commands:

             npm install node-red-node-ping  (version 0.1.0)

             npm install node-red-dashboard  (version 2.19.4)

             npm install node-red-contrib-ui-led  (version 0.3.1)
[{"id":"975cc394.0dc9d","type":"tab","label":"Vaibhav","disabled":false,"info":""},{"id":"6b5e487.f8ab7b8","type":"ui_gauge","z":"975cc394.0dc9d","name":"","group":"a61c1d23.04fe3","order":2,"width":"2","height":"2","gtype":"gage","title":"FWALL 8.8.8.8","label":"ms","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":300,"y":100,"wires":[]},{"id":"4065334a.cd382c","type":"catch","z":"975cc394.0dc9d","name":"","scope":null,"uncaught":false,"x":2200,"y":3480,"wires":[[]]},{"id":"b890c1fc.c7d9d","type":"ui_gauge","z":"975cc394.0dc9d","name":"","group":"a61c1d23.04fe3","order":1,"width":"2","height":"2","gtype":"gage","title":"OpenDNS 4.2.2.2","label":"ms","format":"{{value}}","min":0,"max":"1000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":310,"y":40,"wires":[]},{"id":"245b55ba.395b5a","type":"function","z":"975cc394.0dc9d","name":"","func":"\nvar trueMsg = { payload: true };\nvar falseMsg = { payload: false };\n\n\nif(msg.payload===false)\n{\n return falseMsg; \n}\nelse{\n return trueMsg; \n\n}\n\n\n","outputs":1,"noerr":0,"x":290,"y":320,"wires":[["5bb29bd3.6d22f4"]]},{"id":"fe9fd4c4.a97df8","type":"function","z":"975cc394.0dc9d","name":"","func":"\nvar trueMsg = { payload: true };\nvar falseMsg = { payload: false };\n\n\nif(msg.payload===false)\n{\n return falseMsg; \n}\nelse{\n return trueMsg; \n\n}\n\n\n","outputs":1,"noerr":0,"x":290,"y":380,"wires":[["e072e428.bb8108"]]},{"id":"194fcb7e.1d3eb5","type":"ping","z":"975cc394.0dc9d","name":"FIREWALL","host":"8.8.8.8","timer":"5","x":80,"y":120,"wires":[["6b5e487.f8ab7b8","fe9fd4c4.a97df8"]]},{"id":"3b5466f7.65b8aa","type":"ping","z":"975cc394.0dc9d","name":"OpenDNS","host":"4.2.2.2","timer":"5","x":80,"y":60,"wires":[["b890c1fc.c7d9d","245b55ba.395b5a"]]},{"id":"ffbb13bb.41a35","type":"ui_gauge","z":"975cc394.0dc9d","name":"","group":"a61c1d23.04fe3","order":4,"width":"2","height":"2","gtype":"gage","title":"FWALL google","label":"ms","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":300,"y":220,"wires":[]},{"id":"10801da9.cd9532","type":"ui_gauge","z":"975cc394.0dc9d","name":"","group":"a61c1d23.04fe3","order":3,"width":"2","height":"2","gtype":"gage","title":"Local IP 192.168.15.1","label":"ms","format":"{{value}}","min":0,"max":"1000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":320,"y":160,"wires":[]},{"id":"7f853d21.fd0414","type":"function","z":"975cc394.0dc9d","name":"","func":"\nvar trueMsg = { payload: true };\nvar falseMsg = { payload: false };\n\n\nif(msg.payload===false)\n{\n return falseMsg; \n}\nelse{\n return trueMsg; \n\n}\n\n\n","outputs":1,"noerr":0,"x":290,"y":440,"wires":[["5c788d61.af2a44"]]},{"id":"ad6ffb85.286928","type":"function","z":"975cc394.0dc9d","name":"","func":"\nvar trueMsg = { payload: true };\nvar falseMsg = { payload: false };\n\n\nif(msg.payload===false)\n{\n return falseMsg; \n}\nelse{\n return trueMsg; \n\n}\n\n\n","outputs":1,"noerr":0,"x":290,"y":500,"wires":[["eeae252c.594298"]]},{"id":"fe6e4659.0b64f8","type":"ping","z":"975cc394.0dc9d","name":"FIREWALL2","host":"www.google.com","timer":"5","x":90,"y":240,"wires":[["ffbb13bb.41a35","ad6ffb85.286928"]]},{"id":"d38bccae.c1b68","type":"ping","z":"975cc394.0dc9d","name":"local IP","host":"192.168.15.1","timer":"5","x":70,"y":180,"wires":[["10801da9.cd9532","7f853d21.fd0414"]]},{"id":"5c788d61.af2a44","type":"ui_led","z":"975cc394.0dc9d","group":"5eaca1a3.15e28","order":3,"width":"4","height":"1","label":"Local IP 192.168.15.1","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"green","value":"true","valueType":"bool"},{"color":"red","value":"false","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"Local IP 192.168.15.1","x":500,"y":440,"wires":[],"info":"HELLO"},{"id":"eeae252c.594298","type":"ui_led","z":"975cc394.0dc9d","group":"5eaca1a3.15e28","order":4,"width":"4","height":"1","label":"FWALL google","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"green","value":"true","valueType":"bool"},{"color":"red","value":"false","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"FWALL google","x":480,"y":500,"wires":[],"info":"HELLO"},{"id":"5bb29bd3.6d22f4","type":"ui_led","z":"975cc394.0dc9d","group":"5eaca1a3.15e28","order":1,"width":"4","height":"1","label":"OpenDNS 4.2.2.2","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"green","value":"true","valueType":"bool"},{"color":"red","value":"false","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"OpenDNS 4.2.2.2","x":490,"y":320,"wires":[],"info":"HELLO"},{"id":"e072e428.bb8108","type":"ui_led","z":"975cc394.0dc9d","group":"5eaca1a3.15e28","order":2,"width":"4","height":"1","label":"FWALL 8.8.8.8","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"green","value":"true","valueType":"bool"},{"color":"red","value":"false","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"FWALL 8.8.8.8","x":480,"y":380,"wires":[],"info":"HELLO"},{"id":"a61c1d23.04fe3","type":"ui_group","z":"","name":"Latency Guage","tab":"2806402b.f11e7","order":2,"disp":true,"width":"4","collapse":true},{"id":"5eaca1a3.15e28","type":"ui_group","z":"","name":"SERVER RACK","tab":"2806402b.f11e7","order":1,"disp":true,"width":"4","collapse":true},{"id":"2806402b.f11e7","type":"ui_tab","z":"","name":"Quick Overview","icon":"dashboard","order":2,"disabled":false,"hidden":false}]
<style>
#btn2 {
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
display: inline;
}
</style>
<div id = "btn2" style="font-size:10px;width: 100px; margin:0 auto;height: 15px;padding-top:5px;"
ng-style="{'background-color': msg.payload === false ? 'red' : 'green'}">
<center>{{msg.payload === false ? 'DOWN' : '&nbsp;&nbsp;&nbsp;UP&nbsp;&nbsp;&nbsp;'}}</center>
</div>
@vaibhavarduino
Copy link
Author

PING_Network_Latency_Dashboard

@26tajeen
Copy link

26tajeen commented Jun 9, 2020

Thanks for this! I can get the UI to show the latency gauge but not the server rack LEDs - any ideas?

@vaibhavarduino
Copy link
Author

Thanks for this! I can get the UI to show the latency gauge but not the server rack LEDs - any ideas?

@lancelon Hi, ui led node package no more works with latest node.js version, you have to use Node.js version: v10.16.3

@26tajeen
Copy link

Thanks @vaibhavarduino - appreciate you replying so quickly! Is there a fix in the works do you know? :-D :-D or a thread I can monitor for changes?

@vaibhavarduino
Copy link
Author

vaibhavarduino commented Jun 12, 2020

@lancelon yes u can, but it will take some time until new ui led node package update gets available.
Or, you can use indicator created using CSS in ui-template instead of led. (attached template code file above)

Status

@26tajeen
Copy link

Thank you! I've implemented the CSS code in ui-template and it sort of works - I get the 'UP' message but it's not contained in a green 'button' style background

@vaibhavarduino
Copy link
Author

Thank you! I've implemented the CSS code in ui-template and it sort of works - I get the 'UP' message but it's not contained in a green 'button' style background

Hi @lancelon, have a look at new flow uploaded today (https://flows.nodered.org/flow/e937dd9ddf50342d5f8813f7d2dff610)

@26tajeen
Copy link

That works! Thanks! :-)

@26tajeen
Copy link

Actually - comparing it to your JPG - I get the UP in a green box [but I don't get the individual LEDs](new-led
image share
) - despite updating to the new LED fork. Weird. Anyway I'm not expecting you to do anything just for interest's sake! Thanks again

@vaibhavarduino
Copy link
Author

vaibhavarduino commented Jun 16, 2020 via email

@26tajeen
Copy link

I've imported your flow and updated LED fork. I removed the previous (not forked) package beforehand too.
I'm not actually sure there's a difference between the -fork and the not forked packages because they both point at the same GitHub repo?

@26tajeen
Copy link

aha. Sorry. Restarting node-red sorted it...

@vaibhavarduino
Copy link
Author

aha. Sorry. Restarting node-red sorted it...

Perfect..!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment