Skip to content

Instantly share code, notes, and snippets.

@sergiogama
Created January 20, 2020 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergiogama/fa6e4749ff7f9067fd6b5330bc54f9e3 to your computer and use it in GitHub Desktop.
Save sergiogama/fa6e4749ff7f9067fd6b5330bc54f9e3 to your computer and use it in GitHub Desktop.
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}]
@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

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