Monitor LuckFox Board Performance and Resources in Node-RED Dashboard

Monitor LuckFox Board Performance and Resources in Node-RED Dashboard

[{"id":"b1b645125e2d5bea","type":"tab","label":"Raspberry monitoring","disabled":false,"info":""},{"id":"7e5a3e1c05e07203","type":"inject","z":"b1b645125e2d5bea","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3","crontab":"","once":true,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":130,"y":120,"wires":[["6787d2979560c95d","473037b6b6712424"]]},{"id":"e9da887eeb64c43d","type":"ui_button","z":"b1b645125e2d5bea","name":"","group":"ca54f23962a86f89","order":1,"width":0,"height":0,"passthru":false,"label":"Reboot","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":140,"y":400,"wires":[["6bbf8e1a97a8f938"]]},{"id":"6bbf8e1a97a8f938","type":"exec","z":"b1b645125e2d5bea","command":"sudo reboot","addpay":false,"append":"","useSpawn":"","timer":"","name":"Reboot","x":320,"y":400,"wires":[[],[],[]]},{"id":"1ec2f6c7d29cb3d9","type":"ui_button","z":"b1b645125e2d5bea","name":"","group":"ca54f23962a86f89","order":2,"width":0,"height":0,"passthru":false,"label":"Shutdown","tooltip":"","color":"","bgcolor":"red","icon":"","payload":"","payloadType":"str","topic":"","x":140,"y":460,"wires":[["34827b3e175e97b2"]]},{"id":"34827b3e175e97b2","type":"exec","z":"b1b645125e2d5bea","command":"sudo shutdown -h now","addpay":false,"append":"","useSpawn":"","timer":"","name":"Shutdown","x":320,"y":460,"wires":[[],[],[]]},{"id":"6787d2979560c95d","type":"exec","z":"b1b645125e2d5bea","command":"top -d 0.5 -b -n2 | grep \"Cpu(s)\"|tail -n 1 | awk '{print $2 + $4}'","addpay":false,"append":"","useSpawn":"","timer":"","winHide":false,"name":"CPU Load","x":330,"y":100,"wires":[["bccfc85fa1b46bd0","0217ae8f96174401"],[],[]]},{"id":"bccfc85fa1b46bd0","type":"ui_gauge","z":"b1b645125e2d5bea","name":"","group":"1ce95ef59ad72d6d","order":4,"width":"4","height":"4","gtype":"gage","title":"CPU","label":"CPU%","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","diff":false,"className":"","x":510,"y":60,"wires":[]},{"id":"5a06a9cbdfc8b3b7","type":"exec","z":"b1b645125e2d5bea","command":"df -h","addpay":false,"append":"","useSpawn":"","timer":"","winHide":false,"name":"Disk Usage","x":330,"y":340,"wires":[["e2708e32b8b18644"],[],[]]},{"id":"3030ce1754ac3958","type":"inject","z":"b1b645125e2d5bea","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"600","crontab":"","once":true,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":130,"y":340,"wires":[["5a06a9cbdfc8b3b7"]]},{"id":"ad1877b7998445c9","type":"ui_text","z":"b1b645125e2d5bea","group":"ca54f23962a86f89","order":2,"width":"6","height":"2","name":"","label":"IP Address","format":"{{value.substring(0, value.indexOf(\" \"))}}","layout":"col-center","className":"","style":false,"font":"","fontSize":"","color":"#000000","x":510,"y":600,"wires":[]},{"id":"2e7b039bd6096604","type":"inject","z":"b1b645125e2d5bea","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":true,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":130,"y":600,"wires":[["c2e17d8d47eb18e6"]]},{"id":"c2e17d8d47eb18e6","type":"exec","z":"b1b645125e2d5bea","command":"hostname","addpay":false,"append":"-I","useSpawn":"","timer":"","winHide":false,"name":"Get Local IP","x":330,"y":600,"wires":[["ad1877b7998445c9"],[],[]]},{"id":"0217ae8f96174401","type":"ui_chart","z":"b1b645125e2d5bea","name":"","group":"1ce95ef59ad72d6d","order":5,"width":"8","height":"4","label":"CPU Load%","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"5","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":530,"y":100,"wires":[[]]},{"id":"473037b6b6712424","type":"exec","z":"b1b645125e2d5bea","command":"free | awk 'NR==2 {printf \"Total Memory: %.2f MB\\nUsed Memory: %.2f MB\\nFree Memory: %.2f MB\\nUtilized Memory: %.2f MB\\n\", $2/1024, $3/1024, $4/1024, ($2 - $4)/1024}'","addpay":false,"append":"","useSpawn":"","timer":"","winHide":false,"name":"Free Memory","x":330,"y":220,"wires":[["50b1e00fcb82e42c"],[],[]]},{"id":"50b1e00fcb82e42c","type":"function","z":"b1b645125e2d5bea","name":"function 1","func":"// Input payload as a string\nlet data = msg.payload;\n\n// Use regular expressions to extract values from the string\nlet totalMemory = parseFloat(data.match(/Total Memory:\\s*([\\d.]+)\\s*MB/)[1]);\nlet usedMemory = parseFloat(data.match(/Used Memory:\\s*([\\d.]+)\\s*MB/)[1]);\nlet freeMemory = parseFloat(data.match(/Free Memory:\\s*([\\d.]+)\\s*MB/)[1]);\nlet utilizedMemory = parseFloat(data.match(/Utilized Memory:\\s*([\\d.]+)\\s*MB/)[1]);\n\n// Create messages for each output with only the value\nlet msg1 = { payload: totalMemory };\nlet msg2 = { payload: usedMemory };\nlet msg3 = { payload: freeMemory };\nlet msg4 = { payload: utilizedMemory };\n\n// Return each message as a separate output\nreturn [msg1, msg2, msg3, msg4];\n","outputs":4,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":200,"wires":[["2141f449fbaf2eb1"],["27d7c42b5f899488"],["08af3ac3162b675f"],["626eb054ddc96c24"]]},{"id":"2141f449fbaf2eb1","type":"ui_gauge","z":"b1b645125e2d5bea","name":"Total Memory","group":"ef534acf744776de","order":2,"width":"3","height":"3","gtype":"donut","title":"Total Memory","label":"MB","format":"{{value}}","min":0,"max":"300","colors":["#ca3838","#e6e600","#00b500"],"seg1":"","seg2":"","diff":false,"className":"","x":720,"y":140,"wires":[]},{"id":"27d7c42b5f899488","type":"ui_gauge","z":"b1b645125e2d5bea","name":"Used Memory","group":"ef534acf744776de","order":2,"width":"3","height":"3","gtype":"donut","title":"Used Memory","label":"MB","format":"{{value}}","min":0,"max":"300","colors":["#ca3838","#e6e600","#00b500"],"seg1":"","seg2":"","diff":false,"className":"","x":720,"y":180,"wires":[]},{"id":"08af3ac3162b675f","type":"ui_gauge","z":"b1b645125e2d5bea","name":"Free Memory","group":"ef534acf744776de","order":2,"width":"3","height":"3","gtype":"donut","title":"Free Memory","label":" MB","format":"{{value}}","min":0,"max":"300","colors":["#ca3838","#e6e600","#00b500"],"seg1":"100","seg2":"200","diff":false,"className":"","x":710,"y":220,"wires":[]},{"id":"626eb054ddc96c24","type":"ui_gauge","z":"b1b645125e2d5bea","name":"Utilized Memory","group":"ef534acf744776de","order":2,"width":"3","height":"3","gtype":"donut","title":"Utilized Memory","label":"MB","format":"{{value}}","min":0,"max":"300","colors":["#ca3838","#e6e600","#00b500"],"seg1":"","seg2":"","diff":false,"className":"","x":720,"y":260,"wires":[]},{"id":"82f5ae13e0fd1dcc","type":"exec","z":"b1b645125e2d5bea","command":"sudo sh -c \"echo 3 > /proc/sys/vm/drop_caches\"","addpay":false,"append":"","useSpawn":"","timer":"","winHide":false,"name":"Clear Cached Memory","x":360,"y":520,"wires":[[],[],[]]},{"id":"93f7315f2cafb9f5","type":"ui_button","z":"b1b645125e2d5bea","name":"Clear Memory","group":"ca54f23962a86f89","order":1,"width":0,"height":0,"passthru":false,"label":"Clear Cached Memory","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"","topicType":"str","x":120,"y":520,"wires":[["82f5ae13e0fd1dcc"]]},{"id":"e2708e32b8b18644","type":"function","z":"b1b645125e2d5bea","name":"function 2","func":"// Input payload as a string\nlet data = msg.payload;\n\n// Split the input into lines\nlet lines = data.split('\\n');\n\n// Initialize variables\nlet totalSize = 0;       // Total space size in GB\nlet totalUsed = 0;       // Used space in GB\nlet totalAvailable = 0;   // Available space in GB\n\n// Regular expression to extract size, used, and available space from each line\nlet regex = /\\/dev\\/\\S+\\s+([\\d.]+)G\\s+([\\d.]+)G\\s+([\\d.]+)G\\s+\\d+%/;\n\n// Iterate through each line and sum the values\nfor (let line of lines) {\n    let match = line.match(regex);\n    if (match) {\n        // Extract the values in GB\n        totalSize += parseFloat(match[1]);       // Total Size\n        totalUsed += parseFloat(match[2]);        // Used\n        totalAvailable += parseFloat(match[3]);   // Available\n    }\n}\n\n// Format the results to two decimal places\ntotalSize = totalSize.toFixed(2);         \ntotalUsed = totalUsed.toFixed(2);       \ntotalAvailable = totalAvailable.toFixed(2);   \n\n// Calculate used and free percentages\nlet usedPercentage = ((totalUsed / totalSize) * 100).toFixed(2);\nlet freePercentage = ((totalAvailable / totalSize) * 100).toFixed(2);\n\n// Create different messages for each output\nlet output1 = { payload: totalSize };           // Total size in GB\nlet output2 = { payload: totalUsed };            // Used space in GB\nlet output3 = { payload: totalAvailable };       // Available space in GB\nlet output4 = { payload: usedPercentage };       // Used percentage\nlet output5 = { payload: freePercentage };       // Free percentage\n\n// Return all five outputs as an array\nreturn [output1, output2, output3, output4, output5];\n","outputs":5,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":420,"wires":[["d3111b2c6cb67fc4"],["155119b0b3debc14"],["ebd7b4fe6017af35"],["ed69e8512f023766"],["6f81093799de5d12"]]},{"id":"d3111b2c6cb67fc4","type":"ui_gauge","z":"b1b645125e2d5bea","name":"Total Memory","group":"c3e01724a5a1b3bf","order":2,"width":"3","height":"3","gtype":"donut","title":"Total Storage","label":"GB","format":"{{value}}","min":0,"max":"8","colors":["#ca3838","#e6e600","#00b500"],"seg1":"","seg2":"","diff":false,"className":"","x":740,"y":360,"wires":[]},{"id":"155119b0b3debc14","type":"ui_gauge","z":"b1b645125e2d5bea","name":"Used Memory","group":"c3e01724a5a1b3bf","order":2,"width":"3","height":"3","gtype":"donut","title":"Used Storage","label":"GB","format":"{{value}}","min":0,"max":"8","colors":["#ca3838","#e6e600","#00b500"],"seg1":"","seg2":"","diff":false,"className":"","x":740,"y":400,"wires":[]},{"id":"ebd7b4fe6017af35","type":"ui_gauge","z":"b1b645125e2d5bea","name":"Free Memory","group":"c3e01724a5a1b3bf","order":2,"width":"3","height":"3","gtype":"donut","title":"Free Storage","label":"GB","format":"{{value}}","min":0,"max":"8","colors":["#ca3838","#e6e600","#00b500"],"seg1":"","seg2":"","diff":false,"className":"","x":730,"y":440,"wires":[]},{"id":"6f81093799de5d12","type":"ui_gauge","z":"b1b645125e2d5bea","name":"Free Storage","group":"c3e01724a5a1b3bf","order":2,"width":"3","height":"3","gtype":"donut","title":"Free Storage","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#ca3838","#e6e600","#00b500"],"seg1":"33","seg2":"66","diff":false,"className":"","x":730,"y":520,"wires":[]},{"id":"ed69e8512f023766","type":"ui_gauge","z":"b1b645125e2d5bea","name":"Used Storage","group":"c3e01724a5a1b3bf","order":2,"width":"3","height":"3","gtype":"donut","title":"Used Storage","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#ca3838","#e6e600","#00b500"],"seg1":"33","seg2":"66","diff":false,"className":"","x":740,"y":480,"wires":[]},{"id":"ca54f23962a86f89","type":"ui_group","name":"OS","tab":"f806abdb1cb34130","order":5,"disp":true,"width":"6","collapse":false,"className":""},{"id":"1ce95ef59ad72d6d","type":"ui_group","name":"CPU","tab":"f806abdb1cb34130","order":4,"disp":true,"width":"12","collapse":false,"className":""},{"id":"ef534acf744776de","type":"ui_group","name":"Memory","tab":"f806abdb1cb34130","order":3,"disp":true,"width":"6","collapse":false,"className":""},{"id":"c3e01724a5a1b3bf","type":"ui_group","name":"Storage","tab":"f806abdb1cb34130","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"f806abdb1cb34130","type":"ui_tab","z":"b1b645125e2d5bea","name":"LuckFox Pico Pro/Max Control Panel","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Flow Info

Created 8 months, 2 weeks ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • exec (x7)
  • function (x2)
  • inject (x3)
Other
  • tab (x1)
  • ui_button (x3)
  • ui_chart (x1)
  • ui_gauge (x10)
  • ui_group (x4)
  • ui_tab (x1)
  • ui_text (x1)

Tags

  • LuckFox
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option