Check disk space inside elixir

Hi @here, i have a problem to check my disk space using elixir. I have found out in erlang i can use –diskup, my question is how can i measure disk size of my os/system ?

1 Like

You can use the erlang module in elixir.

iex(1)> :disksup.start_link()
{:ok, #PID<0.194.0>}
iex(2)> :disksup.get_disk_data()
[{'/', 244810132, 64}, {'/private/var/vm', 244810132, 11}]
8 Likes

Although if you do make use of disksup make sure you understand the difference between binaries and charlists: https://elixir-lang.org/getting-started/binaries-strings-and-char-lists.html

thank you, it works

Putting this out there for anyone having issues with :disksup.get_disk_data() returning an empty list:
disksup relies on df under linux, if your Linux distro is using the BusyBox provided df it will fail silently.
This can be fixed by installing GNU core utilities (coreutils).

5 Likes