[rrd-users] Re: Need a disk space usage rrdtool

Watkins, K (Kobe) Kobe.Watkins at rabobank.com
Wed Nov 9 03:00:32 MET 2005


Hi Eddy,
I've found the best way to graph disk space is to graph the percentage
used, and then specify the size of each partition/drive in the legend.

I graph Windows disk usage from a Unix box (strange, I know), but here's
an example where the drives are C, D & E and the server name is
mailhost. I use RRDTool v1.2.11.

Create the RRD with data sources/variables C D E (which are gauges).
Minimum value 0 and max 100 because we're getting percentages.

$ rrdtool create /usr/local/rrdtool/rrds/mailhost-disk.rrd
DS:C:GAUGE:600:0:100 DS:D:GAUGE:600:0:100 DS:E:GAUGE:600:0:100
RRA:AVERAGE:0.5:1:2000 RRA:AVERAGE:0.5:6:2000 RRA:AVERAGE:0.5:24:4000
RRA:AVERAGE:0.5:288:1000 RRA:MIN:0.5:1:2000 RRA:MIN:0.5:6:2000
RRA:MIN:0.5:24:4000 RRA:MIN:0.5:288:1000 RRA:MAX:0.5:1:2000
RRA:MAX:0.5:6:2000 RRA:MAX:0.5:24:4000 RRA:MAX:0.5:288:1000

http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/doc/rrdcreate.en.html

The variables should be specified in the order they are outputted in
your collection command. For example, you'll probably be using "df -k",
so you variables will be something like "root", "var" and "usr" (in that
order):

$ df -k
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/md/dsk/d0       1487790 1156577  271702    81%    /
/dev/md/dsk/d1       1487790  835851  592428    59%    /var
/dev/md/dsk/d2       1487790 1327549  100730    93%    /usr

So substitute with the following in your "rrdtool create" command:

DS:root:GAUGE:600:0:100 DS:var:GAUGE:600:0:100 DS:usr:GAUGE:600:0:100

Then run a script every 5 minutes to get the disk usage and update the
RRD. I threw this together quickly, so there's probably a much more
efficient way of doing this:

#!/bin/sh
# Get the disk stats
DISKCOMMAND="df -k | awk '{print $5}' | grep -v capacity | sed -e
's/\%//'"
DISKRRD="rrdtool update /usr/local/rrdtool/rrds/mailhost-disk.rrd N"
for DISK in `${DISKCOMMAND}`
do
        if [ -z "${DISK}" ]
        then
                DISK=U
        fi
        DISKRRD=${DISKRRD}:${DISK}
done
# Update the RRD
${DISKRRD}

DISKRRD results in a command like:

rrdtool update /usr/local/rrdtool/rrds/mailhost-disk.rrd N:81:59:93

http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/doc/rrdupdate.en.html

Now you've collected your data, you need to put it in a graph. I use
"rrdcgi" to generate the graphs dynamically, based on specified time
periods.

http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/doc/rrdcgi.en.html

Below is my embedded graph command, where the CV variables are received
as CGI parameters, and in this case equal:

END = "now"
LENGTH = "end-1m" (start is one month before now)
PERIOD = "Monthly"

<RRD::GRAPH
/usr/local/rrdtool/www/graphs/mailhost-disk-<RRD::CV END>-<RRD::CV
LENGTH>.png
--imginfo '<IMG SRC="/graphs/%s" WIDTH="%lu" HEIGHT="%lu" alt="<RRD::CV
PERIOD> mailhost Disk Space Used">'
--start <RRD::CV LENGTH> --end <RRD::CV END> --width 600 --height 200
--imgformat PNG
--lazy --vertical-label "% Disk Space Used" --upper-limit 100
--lower-limit 0 --rigid --title "<RRD::CV PERIOD> mailhost Disk Space
Used"
--font TITLE:10:/usr/lib/font/verdanab.ttf --font
AXIS:7.5:/usr/lib/font/verdana.ttf --font
LEGEND:7.5:/usr/lib/font/lucon.ttf --font
UNIT:7.5:/usr/lib/font/verdana.ttf
DEF:C=/usr/local/rrdtool/rrds/mailhost-disk.rrd:C:AVERAGE
DEF:D=/usr/local/rrdtool/rrds/mailhost-disk.rrd:D:AVERAGE
DEF:E=/usr/local/rrdtool/rrds/mailhost-disk.rrd:E:AVERAGE
HRULE:100#FF0000
COMMENT:" \s" COMMENT:" \s"
LINE2:C#FF0000:"C\:SYSTEMDISK"
GPRINT:C:LAST:"  Size\: 33.9 GB   Current\: %3.0lf %%"
GPRINT:C:AVERAGE:"    Average\: %3.0lf %%"
GPRINT:C:MIN:"    Min\: %3.0lf %%" GPRINT:C:MAX:"    Max\: %3.0lf %%"
COMMENT:" \s" COMMENT:" \s" COMMENT:" \s"
LINE2:D#00FF00:"D\:DATA"
GPRINT:D:LAST:"        Size\: 29.3 GB   Current\: %3.0lf %%"
GPRINT:D:AVERAGE:"    Average\: %3.0lf %%"
GPRINT:D:MIN:"    Min\: %3.0lf %%" GPRINT:D:MAX:"    Max\: %3.0lf %%"
COMMENT:" \s" COMMENT:" \s" COMMENT:" \s"
LINE2:E#0000FF:"E\:LOGS"
GPRINT:E:LAST:"        Size\: 38.5 GB   Current\: %3.0lf %%"
GPRINT:E:AVERAGE:"    Average\: %3.0lf %%"
GPRINT:E:MIN:"    Min\: %3.0lf %%" GPRINT:E:MAX:"    Max\: %3.0lf %%"
COMMENT:" \s" COMMENT:" \s" COMMENT:" \s" COMMENT:" \s"
COMMENT:"Data graphed from <RRD::TIME::STRFTIME START <RRD::CV LENGTH>
<RRD::CV END> '%H\:%M %e/%b/%Y'> to <RRD::TIME::STRFTIME END <RRD::CV
LENGTH> <RRD::CV END> '%H\:%M %e/%b/%Y'>"
>

http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/doc/rrdgraph.en.html
http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/doc/rrdgraph_examples
.en.html
http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/doc/rrdgraph_data.en.
html
http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/doc/rrdgraph_graph.en
.html

The result is the attached graph.

You'll probably have to take out or change the font parameters. Also, if
you want to generate the graph from the command line using "rrdtool
graph" instead of using rrdcgi, then there are a few things like
STRFTIME that won't work.

I hope this helps to a certain extent. I know I spent months refining my
collection techniques and resulting graphs, so I hope someone else can
benefit from my trial and error.

Also, in my examples I replaced a whole bunch of variables with
pathnames, server names etc., so if there are inconsistencies they'll
probably be typos on my part.

Cheers,
Kobe

-----Original Message-----
From: rrd-users-bounce at list.ee.ethz.ch
[mailto:rrd-users-bounce at list.ee.ethz.ch] On Behalf Of Eddy Beliveau
Sent: Wednesday, 9 November 2005 12:54 AM
To: rrd-users at list.ee.ethz.ch
Subject: [rrd-users] Need a disk space usage rrdtool


Hi!

I'm not familiar with rrd tools

I'm currently using mailgraph and queuegraph and my users loved them

Now, In would like to generate a graph about my disc space usage on my
RedHat 9 server

I do not want to reinvent the wheel.  Has it been done previously ?

Thanks,
Eddy
--

Eddy.Beliveau at hec.ca

Analyste - Applications Reseau
HEC Montreal
3000 Chemin de la Cote Sainte-Catherine
Montreal  (Quebec)
Canada H3T 2A7

Any horizontal surface soon tends to be piled up

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi


If this e-Mail contains marketing material and you do not wish to receive such material by e-Mail in future, please reply to this e-Mail and place the words "Remove My Details - Electronic Messages" in the Subject Header.  

The Rabobank Group 
Australia: 1800 025 484
New Zealand: 0800 500 933

-- Attached file removed by Ecartis and put at URL below --
-- Type: image/png
-- Desc: mailhost-disk-now-end-1m.png
-- Size: 38k (39198 bytes)
-- URL : http://lists.ee.ethz.ch/p/mailhost-disk-now-end-1m.png


--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the rrd-users mailing list