-
Notifications
You must be signed in to change notification settings - Fork 214
There's no mention of kilobytes in the command documentation below:
I was trying to convert the result wih Number::Bytes::Human, and my assumption was the result will be in bytes. It seems to follow du, but explicit mention of the unit size would help many Perl users.
du($path)
Returns the disk usage of $path.
task "du", "server01", sub { say "size of /var/www: " . du("/var/www"); };
This command will not be reported.
All reactions
Replies: 1 comment
There's no mention of kilobytes in the command documentation below:
I believe Rex docs doesn't mention the measurement unit of the value because Rex itself doesn't do any conversions itself or make any guarantees/assumptions about the unit.
[...] my assumption was the result will be in bytes.
I'd like to better understand what made you assume the value would be in bytes. Does the du command return the size in bytes on the systems you manage?
It seems to follow
du
Yes, Rex::Commands::Fs::du() does exactly that: calls the du command on the managed system (more precisely, it calls du -s).
but explicit mention of the unit size would help many Perl users.
I'm afraid that guaranteeing uniform reporting units could quickly get out of hand, because du on Linux, *BSD, Solaris, Mac OS X, etc. have different command line flags, and/or configured via different environment variables. Not sure if there's a different pre-existing solution for getting disk usage in a uniform way (or whether we would still want to to call that du) 🤔
Currently I don't think it would be responsible to promise that Rex core will become that uniform frontend to masks all those differences (though I'm open to discuss ideas about how it would be possible in a sustainable way).
What might make more sense for Rex core is to clarify that Rex::Commands::Fs::du() is a pass-through for du on the managed system by stating something like:
du($path)Returns the disk usage of
$pathas given by theducommand on the target system.
And perhaps even in the module description:
DESCRIPTION
With this module you can do file system tasks like creating directories, deleting or moving files, and more. The functions are often named and behave similarly as the well-known Linux commands.
What do you think? Would something like that have helped you better understand what the du() function and/or the Rex::Commands::Fs module does?