Flow to get free diskspace from EPIC or RIO

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.


Thanks for putting this out there. I copied the code directly into Node Red and ran it. Below is what I got from the debug node. image

Ok, that’s odd.
Change the Exec node to just be ‘df’ and see what the string debug shows. (You will have to click on the little arrow next to ‘payload’ to expand it so you can read all of it).
Please do a screen shot or a copy paste of the payload string.

You should see something like this.

1 Like

Here is what I get when the Exec is just ‘df’. image

use sda6 instead of sda5, that should fix it

1 Like

Yeah, @greichert is right… very odd, I thought all EPIC drives were mapped the same, but it seems not.
So @matthew.deluca your Exec node command needs to be df |grep /dev/sda6|awk '{print $4}'

1 Like

That did the trick, that you very much for helping out with this!

1 Like

You can use the same flow in your RIO.

You simply will need to run the flow with just ‘df’ in the exec node on the RIO to find out what the drive letter/number is.

Here is what I see when I run it on my RIO.

Once you know the mount point for the file system, you can then put the whole command into the exec node and get your free space from the flow.

So in my case, the exec node command would be df |grep /dev/mmcblk1p6 |awk '{print $4}'

1 Like

Note that you can also use this flow to check for space on a USB stick that you might have mounted on your EPIC or RIO… So if you are logging data to there, you can use this flow to monitor free space on a USB stick.

Once again, the best way to see what the USB drive number is is to do a ‘df’ and look at the mapping.
Here is my EPIC with a USB stick mounted.

You can get a hint on the USB stick drive number from groov Manage.
Navigate to your USB drive files and note the path…

This will show you the correct drive you want to add to the Node-RED exec node.

So in my case, the command to use is this df |grep /dev/sdb1|awk '{print $4}'

Remember, always use the ‘Filesystem’ mount point, not the ‘Mounted on’ path.

Also keep in mind that if you plug your memory stick into a different USB slot or use a USB hub and plug the stick into a different port, the drive mount point will change.

1 Like