[{"id":"83a23089.dc697","type":"tab","label":"Network Ping","disabled":false,"info":""},{"id":"e80b494.9f3ffb8","type":"exec","z":"83a23089.dc697","command":"ping -c 1","addpay":true,"append":"","useSpawn":"false","timer":"5","oldrc":false,"name":"","x":340,"y":540,"wires":[["dcebcf2c.162d9"],["87273839.35aad8"],["f37c6d51.6df29"]]},{"id":"4792d396.188f5c","type":"split","z":"83a23089.dc697","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":550,"y":400,"wires":[["4faf6278.986aac"]]},{"id":"dcebcf2c.162d9","type":"function","z":"83a23089.dc697","name":"update thisPing","func":"\nmsg.thisPing.timestamp = new Date();\nmsg.thisPing.message = msg.payload;\n\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":500,"wires":[["cf63f56.6746e08","bae00ed9.43d8e"]]},{"id":"87273839.35aad8","type":"function","z":"83a23089.dc697","name":"update thisPing","func":"\nmsg.thisPing.timestamp = new Date();\nmsg.thisPing.message = msg.payload;\nmsg.thisPing.error = true;\nmsg.thisPing.state = 'ng'\n\n\n\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":540,"wires":[["caef9860.2a9ab8","bae00ed9.43d8e"]]},{"id":"f37c6d51.6df29","type":"function","z":"83a23089.dc697","name":"update thisPing","func":"msg.thisPing.timestamp = new Date();\nmsg.thisPing.result = msg.payload;\nmsg.thisPing.error = msg.payload.code !== 0;\nmsg.thisPing.state = msg.thisPing.error === false ? \"ok\" : \"ng\";\n\n\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":580,"wires":[["1c70a1b5.b65a5e","bae00ed9.43d8e"]]},{"id":"4faf6278.986aac","type":"function","z":"83a23089.dc697","name":"Init thisPing","func":"let pingResults = flow.get(\"pingResults\") || {}\nmsg.thisPing = pingResults[msg.topic] || {};\n\nmsg.thisPing.name = msg.payload.name;\nmsg.thisPing.ip = msg.payload.ip;\nmsg.thisPing.timestamp = new Date();\nmsg.thisPing.result = '';\nmsg.thisPing.error = null;\nmsg.thisPing.state = 'pinging';\n\nmsg.topic = msg.thisPing.name;\nmsg.payload = msg.thisPing.ip;\n\npingResults[msg.topic] = msg.thisPing;//store ping obj in pingResults\nflow.set(\"pingResults\",pingResults);//save pingResults in flow context\n\nreturn msg;","outputs":1,"noerr":0,"x":710,"y":400,"wires":[["e80b494.9f3ffb8","e9e310aa.76a0d"]]},{"id":"e9e310aa.76a0d","type":"debug","z":"83a23089.dc697","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":930,"y":400,"wires":[]},{"id":"cf63f56.6746e08","type":"debug","z":"83a23089.dc697","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":930,"y":500,"wires":[]},{"id":"caef9860.2a9ab8","type":"debug","z":"83a23089.dc697","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":930,"y":540,"wires":[]},{"id":"1c70a1b5.b65a5e","type":"debug","z":"83a23089.dc697","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":930,"y":580,"wires":[]},{"id":"bae00ed9.43d8e","type":"function","z":"83a23089.dc697","name":"Update flow context","func":"let pingResults = flow.get(\"pingResults\") || {}\nlet thisPing = msg.thisPing;\n\n//store ping item\npingResults[thisPing.name] = thisPing;\n\n//save pingResults in flow context\nflow.set(\"pingResults\",pingResults);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":890,"y":640,"wires":[["3945775b.f70428"]]},{"id":"ee978690.205da8","type":"template","z":"83a23089.dc697","name":"build html table","field":"html","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"\n<table width=\"100%\">\n <tr>\n <th>Name</th>\n <th>IP</th> \n <th>Status</th> \n </tr>\n {{#tableData}}\n <tr class='{{rowclass}}'>\n <td>{{{name}}}</td>\n <td>{{ip}}</td> \n <td>{{{stateInfo}}}</i></td> \n </tr>\n {{/tableData}}\n</table>","x":720,"y":760,"wires":[["7960265a.b5a7f8","3bd11951.e1ee46"]]},{"id":"7960265a.b5a7f8","type":"debug","z":"83a23089.dc697","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":930,"y":720,"wires":[]},{"id":"d038da8f.ce2a68","type":"inject","z":"83a23089.dc697","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"30","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"name\":\"router\",\"ip\":\"192.168.1.1\"},{\"name\":\"nvr\",\"ip\":\"192.168.1.30\"},{\"name\":\"cam1\",\"ip\":\"192.168.1.31\"},{\"name\":\"bad device\",\"ip\":\"192.168.2.99\"}]","payloadType":"json","x":270,"y":760,"wires":[["436755d5.3c93dc"]]},{"id":"436755d5.3c93dc","type":"function","z":"83a23089.dc697","name":"convert pingResults to array","func":"let pingResults = flow.get(\"pingResults\") || {}\n\nlet tableData = [];\nfor (let k in pingResults) {\n let r = pingResults[k];\n if(r.state == \"ok\"){\n r.rowclass = \"good\";\n r.stateInfo = '<i class=\"fa fa-thumbs-up\" aria-hidden=\"true\"></i> OK'\n } else if(r.state == \"ng\") {\n r.rowclass = \"bad\";\n r.stateInfo = '<i class=\"fa fa-thumbs-down\" aria-hidden=\"true\"></i> NG'\n } else {\n r.rowclass = \"unknown\";\n r.stateInfo = '<i class=\"fa question\" aria-hidden=\"true\"></i> Unknown'\n }\n tableData.push(r);\n}\n\nmsg.tableData = tableData\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":760,"wires":[["ee978690.205da8"]]},{"id":"3bd11951.e1ee46","type":"ui_template","z":"83a23089.dc697","group":"94ef3efa.b0b16","name":"","order":3,"width":"6","height":"5","format":"<style>\ntable {\n color: #333;\n font-family: Helvetica, Arial, sans-serif;\n width: 100%;\n border-collapse: collapse;\n border-spacing: 0;\n}\ntd, th {\n border: 1px solid transparent;\n /* No more visible border */\n height: 30px;\n transition: all 0.3s;\n /* Simple transition for hover effect */\n}\nth {\n background: #DFDFDF;\n /* Darken header a bit */\n font-weight: bold;\n}\ntd {\n background: #FAFAFA;\n text-align: center;\n}\n\n/* Cells in even rows (2,4,6...) are one color */\n\ntr:nth-child(even) td {\n background: #F1F1F1;\n}\n\n/* Cells in odd rows (1,3,5...) are another (excludes header cells) */\n\ntr:nth-child(odd) td {\n background: #FEFEFE;\n}\ntr td:hover {\n background: #666;\n color: #FFF;\n}\n\n/* Hover cell effect! */ \n\ntr.good {\n color: green;\n}\n\ntr.bad {\n color: red;\n}\n\ntr.unknown {\n color: orange;\n}\n\n \n</style>\n<div ng-bind-html=\"msg.html\"></div>\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":940,"y":760,"wires":[[]]},{"id":"8614c5fd.bf5588","type":"inject","z":"83a23089.dc697","name":"*** Setup devices to ping here ***","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"name\":\"router\",\"ip\":\"192.168.1.1\"},{\"name\":\"nvr\",\"ip\":\"192.168.1.30\"},{\"name\":\"cam1\",\"ip\":\"192.168.1.31\"},{\"name\":\"bad device\",\"ip\":\"192.168.2.99\"}]","payloadType":"json","x":270,"y":360,"wires":[["4792d396.188f5c"]]},{"id":"b70e1388.f2246","type":"telegram sender","z":"83a23089.dc697","name":"","bot":"","haserroroutput":false,"outputs":1,"x":1270,"y":640,"wires":[[]]},{"id":"3945775b.f70428","type":"rbe","z":"83a23089.dc697","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload.content","x":1090,"y":640,"wires":[["b70e1388.f2246"]]},{"id":"94ef3efa.b0b16","type":"ui_group","name":"Default","tab":"6cc8c50b.445afc","order":1,"disp":true,"width":"6","collapse":false},{"id":"6cc8c50b.445afc","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]