EDIT. It seems that not every EPIC drive number is the same, please read this whole thread. You may have to do a raw ‘df’ command and look at your payload string to find out what your EPIC drive letter is.
Keep reading for how to use the same flow in your RIO.
A lot of people are using EPIC to do local data-logging, either to a file or often to a database.
When writing to the local disk, its a good idea to be aware of the space you have left.
Here is a quick flow that shows one way to keep an eye on your remaining disk space on your EPIC.
The core Linux command we are using is the ‘df’ or disk free command.
By issuing this command in an ‘Exec’ node we can look at the output and either display it as a string, or get the number and trend or alarm on it.
Here is what the flow looks like.
And here is the code to import.
[{"id":"e7412608.b001c","type":"inject","z":"b42e0f8.222b5f","name":"Repeat every 15 minutes","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"900","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":320,"wires":[["a8cc5a35.1d71b"]]},{"id":"9cc68d7c.a216c","type":"debug","z":"b42e0f8.222b5f","name":"space as string","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":760,"y":240,"wires":[]},{"id":"a8cc5a35.1d71b","type":"exec","z":"b42e0f8.222b5f","command":"df -h|grep /dev/sda5|awk '{print $4}'","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":480,"y":320,"wires":[["9cc68d7c.a216c","632e1b42.d5242c"],[],[]]},{"id":"632e1b42.d5242c","type":"function","z":"b42e0f8.222b5f","name":"string to float","func":"msg.payload = parseFloat(msg.payload);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":750,"y":320,"wires":[["8cb28bcb.fd37b"]]},{"id":"8cb28bcb.fd37b","type":"debug","z":"b42e0f8.222b5f","name":"space as float","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":940,"y":320,"wires":[]}]
If you want the result in bytes, just change the Exec node command to be;
df |grep /dev/sda5|awk '{print $4}'
This will give you a lot more resolution at the expense of ‘noise’.
Here is the Node-RED debug for each of the two options.
Firstly in gigs then in bytes.
Simply use which ever command makes sense for your application. For example, use the string to simply display the number for the end user, use bytes to alarm on.
Lastly, use a PAC Control node to move the data into your strategy if you need it there.
Or move it to a groov View data store node if you want to plot on a graph or email alert someone if the space drops below a threshold.