Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Simple server disk space display

by FoncÚ (Scribe)
on Apr 21, 2003 at 14:09 UTC ( #251998=perlquestion: print w/replies, xml ) Need Help??

FoncÚ has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I'd like to use Perl/CGI to include in a page a few little functions, the first of which would be a simple text display of how much space I've used on my webserver out of how much total there is. I.E., You have used 3333 Kb / 12.7 Gb. I'd very much like to include that in an HTML page, but I'm really not sure how I would go about doing that. What does the Collective Monk think?

FoncÚ

Replies are listed 'Best First'.
Re: Simple server disk space display
by Improv (Pilgrim) on Apr 21, 2003 at 14:30 UTC
    One solution would be to use FileSys::Diskspace
    Alternatively, you might try calling "df -k" or "dir" (depending on your OS) and parsing it itself, if you have problems getting FileSys::Diskspace to work on your platform (It hasn't been updated for awhile)
Re: Simple server disk space display
by TVSET (Chaplain) on Apr 21, 2003 at 14:42 UTC
    If you only need a disk space thingy, then just follow Improv's advice.

    If you need additional monitoring, then you might be better setting up an SNMP server on the machine and querying it all the values that you need. If you follow this path, then you can use Net::SNMP module to make your own scripts. You can also use a contrib collection from MRTG software distribution. MRTG is a something specifically design for monitoring, and (surprise, surprise!) is written in Perl. I'll also add a link to MRTG section on my site, in case you decide to look. :)

    Leonid Mamtchenkov

      Without going through the whole headache that SNMP can be (though it is well worth it where its possibilities are actually exploited), you can also benefit from various other very capable opensource monitoring packages like Nagios (formerly NetSaint), mon and Big Brother.

      Makeshifts last the longest.

Re: Simple server disk space display
by JamesNC (Chaplain) on Apr 21, 2003 at 14:42 UTC
    This was really simple to do... parsing out specifics from @rv is left up to you. (Win32/Perl 5.8)
    use CGI qw(:all); print header; #replace your dir here ... this is Win2K IIS my @rv = `dir /s c:\\Inetpub`; print "<pre>"; foreach(@rv){ s/[^\w\n \\]+//ig; } #Removes Win2K yuck # more sophisticated stuff left as exercise print @rv;
Re: Simple server disk space display
by nite_man (Deacon) on Apr 21, 2003 at 14:41 UTC
    You can try call
    system "du -sh <your dir>";
    This function show you summary size of <your dir>.
          
    --------------------------------
    SV* sv_bless(SV* sv, HV* stash);
    
Re: Simple server disk space display
by FoncÚ (Scribe) on Apr 21, 2003 at 16:00 UTC
    I think that MRTG might be the best way to go here, although the other suggestions work fine. Thanks, everyone.

    FoncÚ

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://251998]
Approved by Aristotle
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2023-03-31 00:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (74 votes). Check out past polls.

    Notices?