ovedpo15 has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks!
I have a tool (written in Perl in Linux env) which keeps configurations in user's home directory (or a path that he provides). I noticed that users open a lot of tickets lately, complaining about different issues that caused by overfilled home directory (after some debugging).
I want to add some code which checks the size of used space, and if it's more than 90%, I want to print a warning to the stdout, saying that you might get different errors. I'm familiar with df and du, but I was wondering what would be the right way to do it (Maybe a basic Perl way, without installing additional modules)? As I understand, the pseudo code should look something like:
Also, please note that we provide an option to choose a specific path (and not use the default home directory), so the check should be performed on $path and not just ~/.
I have a tool (written in Perl in Linux env) which keeps configurations in user's home directory (or a path that he provides). I noticed that users open a lot of tickets lately, complaining about different issues that caused by overfilled home directory (after some debugging).
I want to add some code which checks the size of used space, and if it's more than 90%, I want to print a warning to the stdout, saying that you might get different errors. I'm familiar with df and du, but I was wondering what would be the right way to do it (Maybe a basic Perl way, without installing additional modules)? As I understand, the pseudo code should look something like:
I'm also opened to other suggestion on how to warn the user.my $used_space = get_used_space($path); if ($used_space >= 90) { print("Warning: please clean the directory: $path\n"); }
Also, please note that we provide an option to choose a specific path (and not use the default home directory), so the check should be performed on $path and not just ~/.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to know how much used space of a path?
by choroba (Cardinal) on Nov 19, 2021 at 23:03 UTC | |
Re: How to know how much used space of a path?
by NERDVANA (Deacon) on Nov 21, 2021 at 13:41 UTC | |
Re: How to know how much used space of a path?
by hanspr (Sexton) on Nov 20, 2021 at 05:20 UTC | |
by Fletch (Bishop) on Nov 20, 2021 at 05:48 UTC |
Back to
Seekers of Perl Wisdom