Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Unix disk space reports

by salvadors (Pilgrim)
on Dec 31, 2000 at 02:56 UTC ( #49030=note: print w/replies, xml ) Need Help??


in reply to Unix disk space reports

This seems much too complicated for my liking.

I really don't like the way it needs to create a temporary file, and that it writes it output out to a fixed file, rather than STDOUT, thus letting me redirect it, or play with it in some other way. I'd go for something more along the lines of:

use strict; my %space; while (<>) { next unless m#^/#; next if m#^/proc#; next unless m#^[^ ]* *([^ ]*) *[^ ]* *([^ ]*) *[^ ]*#; $space{$ARGV}{total} += $1; $space{$ARGV}{free} += $2; } foreach my $host (sort keys %space) { printf "%s: %dk free, out of %dk, (%.2f%%)\n", $host, $space{$host}{free}, $space{$host}{total}, $space{$host}{free} / $space{$host}{total} * 100; }
Then I'd call it as: perl ~/dfk hosts/* > report

Playing with the format of the output is then trivial.

If you really want to be able to view the intermediate 'space' file, then you could add a command line parameter for it (including the name of the output file?).

Tony

Replies are listed 'Best First'.
Re: Re: Unix disk space reports
by halxd2 (Monk) on Jan 02, 2001 at 19:43 UTC
    I agree my script does limit general usage; however, I was working to get a report that had the format I wanted for my boss. As for keeping the temp files I usualy keep them until I'm very sure I'm getting everything I what out of the script. I guess I just live in debugland.
      I want the same kind of report which has the capablity of showing the diskpace status for the past month. Can some help?

        You could start by showing us where in your code you have difficulties. As the program currently just displays the status quo, I imagine you have to collect the disk space report over time. Then, create your report from that.

        Personally, I would store that data in a database, for example DBD::SQLite, and then create the reports from that database using Querylet. But you can get by without a relational database if you hardcode the reporting logic into your script.

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://49030]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2019-10-18 21:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?