Raspberry Pi status data


#1

Here in the USA, its Pi day! 3.14. Yah!
As you can probably imagine, we love the Raspberry Pi here at Opto… We have a blog on how to how to get your Pi up and running with the latest Node-RED and our starter kit. (The blog is peppered with lots of great links, be sure and check it out).

Since its Pi day and we are all really loving Node-RED, I thought we should combine the two with groov and show some Pi love.

Here is a simple flow that gets the Pi CPU temperature, CPU load, free memory and free disk space. It sends these 4 bits of data to a groov Data Store and I plot them on a week long graph.
(As usual, I have borrowed heavily from the great resource of flows.nodered.org, all credit should go to those that have done the heavy lifting for us all).

Here is what the flow looks like in Node-RED.

As you can see, we use the Exec Node to do the system calls to get the data. The Function Nodes clean things up as needed.

Here is a few days of data in groov.

You can clearly see my garage air temperature go up and down on the day/night cycle, and the times I have opened the garage door and let in the cool night air. For now, the CPU load and memory are pretty stable, once we start developing on this Pi it will be interesting to see how this changes.

Since everything is accessible as a groov tag, you could even have groov send you an event email if any of these parameters goes above a limit, how handy would it be to get an email saying you are low on SD card space!!!

Here is the flow;

[{“id”:“f6cb5b8d.ec83a8”,“type”:“exec”,“z”:“e6f98917.e7896”,“command”:“cat /sys/class/thermal/thermal_zone0/temp”,“addpay”:false,“append”:"",“useSpawn”:"",“timer”:"",“name”:“RPi Temp.”,“x”:410,“y”:180,“wires”:[[“e01da776.275cc8”],[],[]]},{“id”:“e8e209b6.961cf”,“type”:“inject”,“z”:“e6f98917.e7896”,“name”:“10 seconds”,“topic”:"",“payload”:"",“payloadType”:“date”,“repeat”:“10”,“crontab”:"",“once”:false,“x”:170,“y”:260,“wires”:[[“f6cb5b8d.ec83a8”,“e045e15a.cc23e8”,“c6dc60f7.e0736”]]},{“id”:“e01da776.275cc8”,“type”:“function”,“z”:“e6f98917.e7896”,“name”:“string to float”,“func”:“str = msg.payload\nmsg.payload = parseFloat(str)/1000;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:610,“y”:180,“wires”:[[“b0661593.156bc”]]},{“id”:“e045e15a.cc23e8”,“type”:“exec”,“z”:“e6f98917.e7896”,“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”:410,“y”:260,“wires”:[[“2213d1b7.69f0ee”],[],[]]},{“id”:“c6dc60f7.e0736”,“type”:“exec”,“z”:“e6f98917.e7896”,“command”:“free | grep Mem | awk ‘{print 100*($4+$6+$7)/$2}’”,“addpay”:false,“append”:"",“useSpawn”:"",“timer”:"",“name”:“Free Memory”,“x”:410,“y”:340,“wires”:[[“dbec2728.f2bbd”],[],[]]},{“id”:“b9b80334.07464”,“type”:“exec”,“z”:“e6f98917.e7896”,“command”:“df -h”,“addpay”:false,“append”:"",“useSpawn”:"",“timer”:"",“name”:“Disk Usage”,“x”:410,“y”:420,“wires”:[[“6e64a3df.8dbab4”],[],[]]},{“id”:“6e64a3df.8dbab4”,“type”:“function”,“z”:“e6f98917.e7896”,“name”:“extract free space”,“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”:610,“y”:420,“wires”:[[“11799f08.108529”]]},{“id”:“dd4efdcb.7863”,“type”:“inject”,“z”:“e6f98917.e7896”,“name”:“1 minute”,“topic”:"",“payload”:"",“payloadType”:“date”,“repeat”:“60”,“crontab”:"",“once”:false,“x”:160,“y”:420,“wires”:[[“b9b80334.07464”]]},{“id”:“b0661593.156bc”,“type”:“groov-write-ds”,“z”:“e6f98917.e7896”,“dataStore”:"",“tagName”:"",“tableStartIndex”:null,“value”:"",“valueType”:“msg.payload”,“name”:"",“x”:810,“y”:180,“wires”:[[]]},{“id”:“2213d1b7.69f0ee”,“type”:“groov-write-ds”,“z”:“e6f98917.e7896”,“dataStore”:"",“tagName”:"",“tableStartIndex”:null,“value”:"",“valueType”:“msg.payload”,“name”:"",“x”:810,“y”:260,“wires”:[[]]},{“id”:“dbec2728.f2bbd”,“type”:“groov-write-ds”,“z”:“e6f98917.e7896”,“dataStore”:"",“tagName”:"",“tableStartIndex”:null,“value”:"",“valueType”:“msg.payload”,“name”:"",“x”:810,“y”:340,“wires”:[[]]},{“id”:“11799f08.108529”,“type”:“groov-write-ds”,“z”:“e6f98917.e7896”,“dataStore”:"",“tagName”:"",“tableStartIndex”:null,“value”:"",“valueType”:“msg.payload”,“name”:"",“x”:810,“y”:420,“wires”:[[]]}]

Happy Pi day!