Hello all!
Working with file storage now and seeking information about Erlang abilities.
Is there Erlang in-box-solution for getting info about physical disk and free space on it?
Is there Erlang in-box-solution for maintaining data when changing physical disks on-fly or need to develop by my own?
disksup:get_disk_data(). The result I got from asking AI.
nzok
October 27, 2025, 11:52pm
3
Setup: Erlang running in Ubuntu 24 WSL2 on Windows 11.
Eshell V13.2.2.5 (abort with ^G)
1> disksup:get_disk_data().
=WARNING REPORT==== 28-Oct-2025::12:46:56.523046 ===
OS_MON (disksup) called by <0.82.0>, not started
[{“none”,0,0}]
You have to ensure that os_mon is started. I haven’t used it myself,
so it’s not clear to me whether you can start it without setting a configuration
parameter.
nzok
October 29, 2025, 8:37pm
6
? I’m not the one who looked it up using an AI.
I’m the one who tried it and discovered that you have to set os_mon up first.
1 Like
Thx a lot. Appreciate it.
The image isn’t for you.
Using os_mon in some cases isn’t possible for me by some restrictions. Going to write out example of using “df“ within parsing reply soon.
hph
October 30, 2025, 6:22pm
8
maybe as a starter:
-record( dinf, {disk,
mountpoint,
totalBytes,
usedBytes,
freeBytes,
percentUsed
}
).
-spec diskinfo( string() ) -> #dinf{} | error.
diskinfo( Path ) ->
Df = os:cmd( lists:concat(["/usr/bin/df -h ",Path])),
Result = lists:nth( 2, string:split(Df,"\n",all) ),
case length(Result) > 0 of
true ->
[A,B,C,D,E,F] = string:lexemes(Result," "),
#dinf{disk=A, mountpoint=F, totalBytes=B, usedBytes=C, freeBytes=D, percentUsed=E};
false ->
error
end.
1 Like