Disk Space Graph

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
banaan
Posts: 6
Joined: Thu Nov 21, 2002 3:29 pm

Disk Space Graph

Post by banaan »

Hi, i've been experimenting with the diskfree.pl script, but i can not get it working.. i`m trying to make a graph like this. Is there a tutorial for graphs like these?


Regards

Jan Peter 'Banaan' Balkenende
gregm
Posts: 38
Joined: Mon Oct 21, 2002 4:19 pm

Post by gregm »

If you run "perl diskspace.pl /" (or /usr etc) from a shell does it show the proper values?

I collect disk space information on my system as well, but I show individual usage for web, mail and database on the file system

http://status.digitalorphans.org/graphs.php/disk

There's two pieces to this: I run cmd.php as a non-root user, which doesn't have access to all of the directories. So, I have a root cronjob setup to get the sizes, using du:

Code: Select all

*/5 * * * * du -sb /var/lib/mysql | awk '{print $1 }' > /var/stats/size_db
*/5 * * * * du -sb /home/httpd/vhosts | awk '{print $1 }' > /var/stats/size_web
*/5 * * * * du -sb /var/qmail/mailnames | awk '{print $1 }' > /var/stats/size_mail
Each file just simple contains a number, which is the number of bytes.

Then, in cacti, i have a data input called "get file contents", using:

Code: Select all

Input string: cat <file>
Output string: <data>
And for each data source, I'll specify "file" as "/var/stats/size_db" etc.

If you run cmd.php as root, then you could just make the data input string:

Code: Select all

du -sb <file> | awk '{print $1 }' 
The difference with my script though, is it shows bytes used, not bytes free, but it's handy because it shows exactly how much space everything is using.
Guest

Post by Guest »

Hi GregM,

Your graph looks fabulous. I would really want to setup the same on my SME linux box (www.e-smith.org).

I have installed Cacti and find it immensely useful. I need more graphs than are standard though.

How do I collect the data-input 'how much usage each user's html-folder structure is', and showing it in Cacti?

I have an SME-Server 5.6 (Linux) downloaded from www.e-smith.org and set-up cacti from this How-to: http://www.speedfactor.ath.cx/howto/
And have tried to setup additional graphs according to this How-to: http://www.speedfactor.ath.cx/howto/snmp.html

On the SME-Server you divide the different websites hosted up into Information-bays. I would like to view graphically how much each I-bay takes up. Is there a way to do this in Cacti?

BR

Morten
gregm
Posts: 38
Joined: Mon Oct 21, 2002 4:19 pm

Post by gregm »

It really depends on the method your server uses to store everything for users. Just check the disk space for that directory:

Code: Select all

du -sb /home/vhosts/username | awk '{print $1 }'
Set it up as a shell script that accepts a parameter for username, and then just make a data input for each user using the parameter to select which user.

Alternatively, you could probably automate it a bit by going around cacti, and just use rrdtool directly, using your actual list of users to generate everything, but that could be a lot more work depending if you can program or not.
ifsnop

diskfree.pl issue

Post by ifsnop »

i have a lvm array on /dev/anthl_vg/anthl_lv.

# df
S.ficheros Bloques de 1K Usado Dispon Uso% Montado en
/dev/hda1 9646700 8608512 1038188 90% /
/dev/anthl_vg/anthl_lv
234423304 119496092 114927212 51% /mnt/raid

the carriage return is caused by default on df. You should run df -P (stands for Posix'ly Correct) so output is on the same line an the diskfree.pl script parses it correctly.

# df -P
S.ficheros Bloques de 1024 Usado Dispon Ocupado Montado en
/dev/hda1 9646700 8608528 1038172 90% /
/dev/anthl_vg/anthl_lv 234423304 119496548 114926756 51% /mnt/raid
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest