Monitor disk usage

Can anyone recommend a port that I can use/install that will allow me to monitor the size of the directories I choose by going to a web page?

Basically I would like to list the size of users home directories and/or mailbox sizes but I would like to view all this info on a web page.

The other thing I would like to do is montior the status of my disk mirror (RAID 1) which uses gmirror (in a web page too).

Any suggestions? :e
 
I made one for myself.. quick and ugly.
Take a notice of text/plain. If you use text/html the output of all commands is put on one line, no separation.
Code:
#!/bin/sh

echo Content-type: text/plain
echo
df -h
echo
service -e
echo
mount
echo                                                      
sockstat -l4c
 
Maybe Nagios?

nagios-service-detail.gif
 
pbd said:
In a nutshell:

- install Apache
- write a cgi script, something like:

Code:
#!/bin/sh

du -sh /home/*
du -sh /var/mail/*

gmirror status

Thanks for that! I created it as follows:
Code:
#!/bin/sh

du -hs /home/*

gmirror status

When I run it manually, it runs fine. But since I have copied it into my cgi-bin directory, I get an Internal Server Error (when browsing it). Is there anything else I need to do?
 
After a bit more digging around in the logs I think its a permission error:
Code:
alpha# tail -F /var/log/httpd-error.log
[Fri May 20 12:26:10 2011] [error] [client 192.168.0.10] du: /home/test/Maildir: Permission denied
[Fri May 20 12:26:10 2011] [error] [client 192.168.0.10] du: /home/test/.ssh: Permission denied
[Fri May 20 12:26:10 2011] [error] [client 192.168.0.10] du: /home/test/.gnupg: Permission denied
[Fri May 20 12:26:10 2011] [error] [client 192.168.0.10] malformed header from script. Bad header= 20K\t/home/copy: monitor.cgi

So the question is, how do I get this script to execute with the correct permissions?
 
The reason it's giving a 500 server error is because the script needs to return
Code:
200 OK
After that it should supply a Content-type: header so the browser knows what to do with it. Then you can "print" any information to the client.
 
OK, so how do I get it to return a 200 OK? Sorry for the obvious questions but I have never used cgi scripts before...
 
Code:
#!/bin/sh

echo "200 OK"
echo
echo "Content-Type: text/plain"

du -hs /home/*

gmirror status
 
SirDice said:
Code:
#!/bin/sh

echo "200 OK"
echo
echo "Content-Type: text/plain"

du -hs /home/*

gmirror status

Tried that but I still have the "Internal Server Error". When I check the httpd-error.log theres many access denied messages. How can this script execute successfully when it is being run as the www user?
 
Quick and dirty: set up security/sudo so that the www user can perform this script (and only this script) as the root user and without a password.
 
DutchDaemon said:
Quick and dirty: set up security/sudo so that the www user can perform this script (and only this script) as the root user and without a password.

Great, I have sudo installed now. I have tried following some of the examples and added:
Code:
www localhost=NOPASSWD: /usr/local/www/apache22/cgi-bin/monitor.cgi

to the sudoers config file but no luck yet. I restarted Apache and also ran:
Code:
alpha# visudo -c
/usr/local/etc/sudoers: parsed OK

Still seem to be stuck with the dreaded "500 Internal Server error"!
 
Is your general cgi setup (in Apache's configuration files) ok, and is the script executable? Does it have a proper hashbang? Stuff like that.
 
DutchDaemon said:
Is your general cgi setup (in Apache's configuration files) ok, and is the script executable? Does it have a proper hashbang? Stuff like that.

I *assume* my cgi setup is ok as I am running "Mail Graph" currently which is cgi driven and it works great. The permissions on my cgi scripts are the same as the mail graph cgi script so I think the permissions are ok. Not sure what "hashbang" is?

Is my entry in the sudoers file ok?
 
Here's a perl CGI script I use, makes a table from df and refreshes every 45 seconds.

Code:
#!/usr/bin/perl
use CGI qw(:standard);
print STDOUT header;
print start_html(-head=>meta({-http_equiv => 'Refresh',
                                    -content    => '45'}));
print hr;


$| = 1;
@fields = map { td [split " ", $_, 6] } (qx/df -ch/);
print table({border => 1}, Tr(\@fields));
 
Is your script called .cgi? What directory is it in? Post the log of access denied, /var/log/http-error.log.

I would say, uncomment this in your httpd.conf:
Code:
Include etc/apache22/extra/httpd-userdir.conf
and then you can use ~/public_html directories

Also uncomment this:
Code:
Include etc/apache22/extra/httpd-manual.conf
and you will have the apache manual http://localhost/manual

And look at the UserDir directive.

Edit:
You will need this to for the userdir cgis:
Code:
AddHandler cgi-script .cgi

make changes and then sudo apachectl restart or (preferred?) sudo /usr/local/etc/apache22 restart.
 
xy16644 said:
Is my entry in the sudoers file ok?

I seem to be missing the actual elevation of privileges there.

It would normally look something like:

Code:
www     ALL=(root) NOPASSWD: /path/to/command
 
Back
Top