Skip to content

Instantly share code, notes, and snippets.

@sergiogama
Created Jan 20, 2020
Embed
What would you like to do?
Raspberry System Monitoring

This flow show in a dashboard CPU, Memory loaded, Disk Usage and CPU Temperature. Also there are two buttons to Reboot and Shutdown the system. Is neessary install dashaboard.

[{"id":"9cf3a6d.1104258","type":"tab","label":"Raspberry monitoring","disabled":false,"info":""},{"id":"d4feb199.b898b","type":"ui_gauge","z":"9cf3a6d.1104258","name":"","group":"9cb4bc4d.96552","order":1,"width":"3","height":"3","gtype":"gage","title":"CPU Temperature","label":"C","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"35","seg2":"60","x":683,"y":33,"wires":[]},{"id":"c0682e5c.a4fc","type":"exec","z":"9cf3a6d.1104258","command":"vcgencmd measure_temp","addpay":false,"append":"","useSpawn":"","timer":"","name":"RPi Temp.","x":325.2221908569336,"y":46.33333683013916,"wires":[["95ae4c48.9f606"],[],[]]},{"id":"2be04c82.d0af74","type":"inject","z":"9cf3a6d.1104258","name":"","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":true,"onceDelay":"","x":107.49996185302734,"y":46.805556297302246,"wires":[["c0682e5c.a4fc","92285ea6.f97a7","c0ffe68.afd6e18"]]},{"id":"95ae4c48.9f606","type":"function","z":"9cf3a6d.1104258","name":"","func":"str = msg.payload\nmsg.payload = str.substring(5,9);\nreturn msg;","outputs":1,"noerr":0,"x":471.888858795166,"y":33.00000190734863,"wires":[["d4feb199.b898b","4bae8072.e81c2"]]},{"id":"f4592b30.2f0528","type":"ui_button","z":"9cf3a6d.1104258","name":"","group":"dd70abe0.14cb38","order":1,"width":0,"height":0,"passthru":false,"label":"Reboot","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":114.66669464111328,"y":330.0000696182251,"wires":[["cf3854e6.653878"]]},{"id":"cf3854e6.653878","type":"exec","z":"9cf3a6d.1104258","command":"sudo reboot","addpay":false,"append":"","useSpawn":"","timer":"","name":"Reboot","x":314.888916015625,"y":330.0000457763672,"wires":[[],[],[]]},{"id":"4b4a0861.092b28","type":"ui_button","z":"9cf3a6d.1104258","name":"","group":"dd70abe0.14cb38","order":2,"width":0,"height":0,"passthru":false,"label":"Shutdown","tooltip":"","color":"","bgcolor":"red","icon":"","payload":"","payloadType":"str","topic":"","x":104.27777099609375,"y":386.47229862213135,"wires":[["4de9dba1.ed7854"]]},{"id":"4de9dba1.ed7854","type":"exec","z":"9cf3a6d.1104258","command":"sudo shutdown -h now","addpay":false,"append":"","useSpawn":"","timer":"","name":"Shutdown","x":324.1666564941406,"y":386.6944923400879,"wires":[[],[],[]]},{"id":"4bae8072.e81c2","type":"ui_chart","z":"9cf3a6d.1104258","name":"","group":"9cb4bc4d.96552","order":5,"width":"6","height":"4","label":"CPU Temperature","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":true,"outputs":1,"x":683.9999389648438,"y":72.66667175292969,"wires":[[]]},{"id":"92285ea6.f97a7","type":"exec","z":"9cf3a6d.1104258","command":"top -d 0.5 -b -n2 | grep \"Cpu(s)\"|tail -n 1 | awk '{print $2 + $4}'","addpay":false,"append":"","useSpawn":"","timer":"","name":"CPU Load","x":325.2221908569336,"y":126.33333683013916,"wires":[["404f06.1e77b0fc"],[],[]]},{"id":"c0ffe68.afd6e18","type":"exec","z":"9cf3a6d.1104258","command":"free | grep Mem | awk '{print 100*($4+$6+$7)/$2}'","addpay":false,"append":"","useSpawn":"","timer":"","name":"Free Memory","x":325.2222099304199,"y":190.55557250976562,"wires":[["8cf70ed5.e49ec"],[],[]]},{"id":"404f06.1e77b0fc","type":"ui_gauge","z":"9cf3a6d.1104258","name":"","group":"9cb4bc4d.96552","order":4,"width":"3","height":"3","gtype":"gage","title":"CPU","label":"CPU","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":645.111083984375,"y":114.11111450195312,"wires":[]},{"id":"8cf70ed5.e49ec","type":"ui_gauge","z":"9cf3a6d.1104258","name":"","group":"9cb4bc4d.96552","order":2,"width":"3","height":"3","gtype":"gage","title":"Memory free","label":"%","format":"{{parseInt(value)}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":663.3333320617676,"y":176.55556392669678,"wires":[]},{"id":"a508a5b7.89a128","type":"exec","z":"9cf3a6d.1104258","command":"df -h","addpay":false,"append":"","useSpawn":"","timer":"","name":"Disk Usage","x":322.88884353637695,"y":258.2222442626953,"wires":[["a8dc2f34.5e32b"],[],[]]},{"id":"ad4498e0.e7c278","type":"ui_gauge","z":"9cf3a6d.1104258","name":"","group":"9cb4bc4d.96552","order":3,"width":"3","height":"3","gtype":"gage","title":"Disk Space","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":661.1110496520996,"y":244.88890743255615,"wires":[]},{"id":"a8dc2f34.5e32b","type":"function","z":"9cf3a6d.1104258","name":"","func":"var re = /([0-9]{2})%/\nvar idx = msg.payload.search(re);\nvar str = msg.payload;\nif (idx >=0) {\n str = msg.payload.substring(idx, idx + 2);\n}\nmsg.payload = str;\nreturn msg;","outputs":1,"noerr":0,"x":470.66661071777344,"y":244.88890171051025,"wires":[["ad4498e0.e7c278"]]},{"id":"5e6e69bb.0e1d38","type":"inject","z":"9cf3a6d.1104258","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":true,"x":122.88884353637695,"y":258.2222442626953,"wires":[["a508a5b7.89a128"]]},{"id":"620c2ccf.7c7584","type":"ui_text","z":"9cf3a6d.1104258","group":"dd70abe0.14cb38","order":2,"width":"6","height":"2","name":"","label":"IP Address","format":"{{value.substring(0, value.indexOf(\" \"))}}","layout":"col-center","x":661.555591583252,"y":430.8889102935791,"wires":[]},{"id":"19fadb42.3d0c25","type":"inject","z":"9cf3a6d.1104258","name":"","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":true,"onceDelay":"","x":118.90821075439453,"y":445.567081451416,"wires":[["9cce8e0f.766f7"]]},{"id":"9cce8e0f.766f7","type":"exec","z":"9cf3a6d.1104258","command":"hostname","addpay":false,"append":"-I","useSpawn":"","timer":"","name":"Get Local IP","x":323.4637641906738,"y":446.06709480285645,"wires":[["b1e5e669.f1fd48","620c2ccf.7c7584"],[],[]]},{"id":"b1e5e669.f1fd48","type":"mqtt out","z":"9cf3a6d.1104258","name":"Send IP thru MQTT","topic":"raspberrypi3_ip_gama","qos":"0","retain":"true","broker":"14bc5267.4d798e","x":680.6859703063965,"y":380.34489250183105,"wires":[]},{"id":"9cb4bc4d.96552","type":"ui_group","z":"","name":"System","tab":"ad4a1223.94ae8","order":1,"disp":true,"width":"6","collapse":false},{"id":"dd70abe0.14cb38","type":"ui_group","z":"","name":"OS","tab":"ad4a1223.94ae8","order":5,"disp":true,"width":"6","collapse":false},{"id":"14bc5267.4d798e","type":"mqtt-broker","z":"","name":"","broker":"test.mosquitto.org","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"raspberry_do_gama_alive","birthQos":"0","birthRetain":"true","birthPayload":"Raspberry ativo","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"ad4a1223.94ae8","type":"ui_tab","z":"9cf3a6d.1104258","name":"Raspbery PI (Control Panel)","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
@EDSTOBI
Copy link

EDSTOBI commented Oct 18, 2020

THX
Have made a small change for security
[{"id":"308e99ef.d3eb26","type":"tab","label":"Raspberry monitoring","disabled":false,"info":""},{"id":"7715cec0.85eb6","type":"ui_gauge","z":"308e99ef.d3eb26","name":"","group":"b7abe246.65d48","order":1,"width":"3","height":"3","gtype":"gage","title":"CPU Temperature","label":"C","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"35","seg2":"60","x":683,"y":33,"wires":[]},{"id":"41793972.ba0978","type":"exec","z":"308e99ef.d3eb26","command":"vcgencmd measure_temp","addpay":false,"append":"","useSpawn":"","timer":"","name":"RPi Temp.","x":325.2221908569336,"y":46.33333683013916,"wires":[["174a88cd.632777"],[],[]]},{"id":"300eb00d.94ab1","type":"inject","z":"308e99ef.d3eb26","name":"","repeat":"3","crontab":"","once":true,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":107.49996185302734,"y":46.805556297302246,"wires":[["41793972.ba0978","dfa17463.9df478","9446cca9.8323f"]]},{"id":"174a88cd.632777","type":"function","z":"308e99ef.d3eb26","name":"","func":"str = msg.payload\nmsg.payload = str.substring(5,9);\nreturn msg;","outputs":1,"noerr":0,"x":471.888858795166,"y":33.00000190734863,"wires":[["7715cec0.85eb6","1f6c6dff.42d792"]]},{"id":"63e0643.ee1c39c","type":"ui_button","z":"308e99ef.d3eb26","name":"","group":"d4cfd15.c63d03","order":1,"width":0,"height":0,"passthru":false,"label":"Reboot","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":114.66669464111328,"y":330.0000696182251,"wires":[["d6251f8e.cd0e5"]]},{"id":"d6251f8e.cd0e5","type":"exec","z":"308e99ef.d3eb26","command":"sudo reboot","addpay":false,"append":"","useSpawn":"","timer":"","name":"Reboot","x":314.888916015625,"y":330.0000457763672,"wires":[[],[],[]]},{"id":"112e9b83.5aa644","type":"ui_button","z":"308e99ef.d3eb26","name":"","group":"d4cfd15.c63d03","order":2,"width":0,"height":0,"passthru":false,"label":"Shutdown","tooltip":"","color":"","bgcolor":"red","icon":"","payload":"","payloadType":"str","topic":"","x":104.27777099609375,"y":386.47229862213135,"wires":[["f173a46c.ff1418"]]},{"id":"f173a46c.ff1418","type":"exec","z":"308e99ef.d3eb26","command":"sudo shutdown -h now","addpay":false,"append":"","useSpawn":"","timer":"","name":"Shutdown","x":324.1666564941406,"y":386.6944923400879,"wires":[[],[],[]]},{"id":"1f6c6dff.42d792","type":"ui_chart","z":"308e99ef.d3eb26","name":"","group":"b7abe246.65d48","order":5,"width":"6","height":"4","label":"CPU Temperature","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"1","removeOlderPoints":"","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":true,"outputs":1,"x":683.9999389648438,"y":72.66667175292969,"wires":[[]]},{"id":"dfa17463.9df478","type":"exec","z":"308e99ef.d3eb26","command":"top -d 0.5 -b -n2 | grep \"Cpu(s)\"|tail -n 1 | awk '{print $2 + $4}'","addpay":false,"append":"","useSpawn":"","timer":"","name":"CPU Load","x":325.2221908569336,"y":126.33333683013916,"wires":[["57cffc38.f8f244"],[],[]]},{"id":"9446cca9.8323f","type":"exec","z":"308e99ef.d3eb26","command":"free | grep Mem | awk '{print 100*($4+$6+$7)/$2}'","addpay":false,"append":"","useSpawn":"","timer":"","name":"Free Memory","x":325.2222099304199,"y":190.55557250976562,"wires":[["83406a82.0f3718"],[],[]]},{"id":"57cffc38.f8f244","type":"ui_gauge","z":"308e99ef.d3eb26","name":"","group":"b7abe246.65d48","order":4,"width":"3","height":"3","gtype":"gage","title":"CPU","label":"CPU","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":645.111083984375,"y":114.11111450195312,"wires":[]},{"id":"83406a82.0f3718","type":"ui_gauge","z":"308e99ef.d3eb26","name":"","group":"b7abe246.65d48","order":2,"width":"3","height":"3","gtype":"gage","title":"Memory free","label":"%","format":"{{parseInt(value)}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":663.3333320617676,"y":176.55556392669678,"wires":[]},{"id":"bccd5cd0.c872b","type":"exec","z":"308e99ef.d3eb26","command":"df -h","addpay":false,"append":"","useSpawn":"","timer":"","name":"Disk Usage","x":322.88884353637695,"y":258.2222442626953,"wires":[["cbf6b550.39e858"],[],[]]},{"id":"df3937c1.8903b8","type":"ui_gauge","z":"308e99ef.d3eb26","name":"","group":"b7abe246.65d48","order":3,"width":"3","height":"3","gtype":"gage","title":"Disk Space","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":661.1110496520996,"y":244.88890743255615,"wires":[]},{"id":"cbf6b550.39e858","type":"function","z":"308e99ef.d3eb26","name":"","func":"var re = /([0-9]{2})%/\nvar idx = msg.payload.search(re);\nvar str = msg.payload;\nif (idx >=0) {\n str = msg.payload.substring(idx, idx + 2);\n}\nmsg.payload = str;\nreturn msg;","outputs":1,"noerr":0,"x":470.66661071777344,"y":244.88890171051025,"wires":[["df3937c1.8903b8"]]},{"id":"5389de8f.3922b","type":"inject","z":"308e99ef.d3eb26","name":"","repeat":"60","crontab":"","once":true,"topic":"","payload":"","payloadType":"date","x":122.88884353637695,"y":258.2222442626953,"wires":[["bccd5cd0.c872b"]]},{"id":"d61dd89c.efe0f8","type":"ui_text","z":"308e99ef.d3eb26","group":"d4cfd15.c63d03","order":2,"width":"6","height":"2","name":"","label":"IP Address","format":"{{value.substring(0, value.indexOf(\" \"))}}","layout":"col-center","x":661.555591583252,"y":430.8889102935791,"wires":[]},{"id":"45662635.8a54e8","type":"inject","z":"308e99ef.d3eb26","name":"","repeat":"10","crontab":"","once":true,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":118.90821075439453,"y":445.567081451416,"wires":[["c806861e.cbcd58"]]},{"id":"c806861e.cbcd58","type":"exec","z":"308e99ef.d3eb26","command":"hostname","addpay":false,"append":"-I","useSpawn":"","timer":"","name":"Get Local IP","x":323.4637641906738,"y":446.06709480285645,"wires":[["8134a819.2768b8","d61dd89c.efe0f8"],[],[]]},{"id":"8134a819.2768b8","type":"mqtt out","z":"308e99ef.d3eb26","name":"Send IP thru MQTT","topic":"raspberrypi3_ip_gama","qos":"0","retain":"true","broker":"a67a1039.942a2","x":680.6859703063965,"y":380.34489250183105,"wires":[]},{"id":"b2827ed7.7bae6","type":"ui_switch","z":"308e99ef.d3eb26","name":"","label":"Freigabe zur Bearbeitung","tooltip":"","group":"d4cfd15.c63d03","order":6,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"create","oncolor":"green","offvalue":"false","offvalueType":"bool","officon":"lock","offcolor":"red","x":310,"y":580,"wires":[["3ee5ab11.500374"]]},{"id":"8aecb3f8.74df","type":"inject","z":"308e99ef.d3eb26","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"300","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":110,"y":580,"wires":[["b2827ed7.7bae6"]]},{"id":"3ee5ab11.500374","type":"function","z":"308e99ef.d3eb26","name":"Gate","func":"if (msg.payload === false)node.send({ui_control:{\"icon\":\"lock\"}});\nif (msg.payload === false){\n msg.enabled=false;\n msg.background=\"grey\";\n }\n if (msg.payload === true){\n msg.enabled=true;\n msg.background=\"green\";\n //msg.icon=\"mode_edit\";\n }\nif (msg.payload === true)node.send({ui_control:{\"icon\":\"lock_open\"}});\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":570,"y":580,"wires":[["112e9b83.5aa644","63e0643.ee1c39c"]]},{"id":"b7abe246.65d48","type":"ui_group","z":"","name":"System","tab":"8e914a4b.c15458","order":1,"disp":true,"width":"6","collapse":false},{"id":"d4cfd15.c63d03","type":"ui_group","z":"","name":"OS","tab":"8e914a4b.c15458","order":5,"disp":true,"width":"6","collapse":false},{"id":"a67a1039.942a2","type":"mqtt-broker","z":"","name":"","broker":"test.mosquitto.org","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"raspberry_do_gama_alive","birthQos":"0","birthRetain":"true","birthPayload":"Raspberry ativo","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"8e914a4b.c15458","type":"ui_tab","z":"308e99ef.d3eb26","name":"Raspbery PI (Control Panel)","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Copy link

ghost commented Mar 22, 2021

Hi Sergio,
my gauge Memory free is always red, fixed on 100%.
It's correct?

@Gun-neR
Copy link

Gun-neR commented Jul 3, 2021

@Giamma1963

I had to change the command in the Free Memory exec node to: free | grep Mem | awk '{printf("%.2f"), $4/$2 * 100.0}'

I also reversed the red and green gradient on the gauge to better caution me how little memory my RPi3 had left :P

@wolfgang1962
Copy link

wolfgang1962 commented Nov 30, 2021

Hi,

first of all - thanks a lot for this Flow and Dashboard.

I run this since I started with NodeRed in 2020. Its running as a instance of ioBroker on an RaspberryPi 4b with 8GB RAM. OS was Debian Buster. - Everything works good and I did some modifications to prevent unwanted shutdown/restart (I saw, you did something like that above in another way).

Now I had trouble during upgrading my system from Node.js 12 to 14. Something went wrong and I had to reinstall the whole system.
After restore the backup and reinstall all missing NodeRed-Nodes it runs nearly as known.
Only in your monitoring the CPU-Load and the Free Memory is not showing anything. CPU-Temperature and Used Disk-Space ist OK.
During the new installation I changed from Linux10/Debian Buster to Linux11/Debian Bullseye. Is it possible, that the commands you used in the exec-nodes are not running with bullseye?

Best regards
Wolfgang

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