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:
my $used_space = get_used_space($path);
if ($used_space >= 90) {
print("Warning: please clean the directory: $path\n");
}
I'm also opened to other suggestion on how to warn the user.
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
~/.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.