[mrtg] Re: Monitoring disk space

Jeff Liebermann jeffl at comix.santa-cruz.ca.us
Wed Oct 24 23:26:37 MEST 2001


On Wed, Oct 24, 2001 at 02:37:34PM +0100, Wagner Garcia Campagner wrote:
> Is there a way for me to monitor the disk usage in a server???

Since you didn't specify any particular operating systems, I'll
assume that you're using my favorite; SCO Unix OSR5 3.2v5.0.5.
You could use "hostmib" for your unspecified operating system,
but that's no fun.  I'm partial to shell scripts this week.

---------------------  cut here -----------------------------
(...)
The trick below is using the shell "set" command to break
apart the output into fields that conveniently also removes
any leading spaces.  Although leading spaces are NOT a problem
in the current version MRTG, it was a problem in the past.
This method can be used to graph anything that can be belched
to a single line of output.  I have graphed the output of
df, uptime, netstat, llistat, sar, and various database
utilities.  The only requirement is that the shell script can
reduce the desired program output to a single line and that
it be consistant.  Beware of trying to graph anything that takes
more than 5 minutes to process (i.e. uutraf).  Also, beware
of trying to graph Linux ping which returns values in usec,
msec, and seconds which makes graphing an adventure.

In the diskspace example below, I added an inode count because
one of my news filesystems is currently stuck at 65,000 inodes
max per filesystem and I'm constantly running out of inodes.
Since there is always more than one line of output, the tail -1
command is necessary to extract the desired line.

==============================================================
#!/bin/sh
# Get diskspace and inode consumption for MRTG.
# by Jeff Liebermann  04/15/98
#
# usage: script_name Filesystem
# i.e.   script_name /dev/root
#
# The format belched by df -v -i
# Mount Dir  Filesystem           blocks   used   free %used iused ifree %iused
# /          /dev/root           1050000 972132  77868  93%  59872 71384   46%
# /stand     /dev/boot             30000  16414  13586  55%     14  3746    1%
# /u         /dev/u               600000 252560 347440  43%   4259 70741    6%
# /usr/spool /dev/news            184492   5830 178662   4%      8 23056    1%
#
#	Grab last line of df -v -i and remove percent signs
drivel=`df -v -i $1 | tail -1 | tr -d %`   # just one Filesystem
#	Break apart into fields using IFS seperators
set $drivel
#	Print % diskspace used, percent % used, filler, filler.
#	The $6 and $9 are the 6th and 9th fields of the df output.
echo "$6\n$9\n0\n0"

---------------------  cut here -----------------------------

# Part of mrtg.cfg
Target[rdf.1]: `dff.sh /dev/root`
Title[rdf.1]: Comix Disk Useage /dev/root
PageTop[rdf.1]: <H1>Comix Disk Useage /dev/root</H1>
Options[rdf.1]: growright, gauge, nopercent
MaxBytes[rdf.1]:100
Unscaled[rdf.1]: dwmy
YLegend[rdf.1]: % Used
ShortLegend[rdf.1]: %
Legend1[rdf.1]: Avg Percent Diskspace Used
Legend2[rdf.1]: Avg Percent Inodes Used
LegendI[rdf.1]: Diskspace
LegendO[rdf.1]: Inodes


-- 
# Jeff Liebermann  Liebermann Design  150 Felker St #D  Santa Cruz  CA  95060
# 831.336.2558 voice   831.426.1240 fax   831.421.6491 digital_pager
# jeffl at comix.santa-cruz.ca.us  http://www.cruzio.com/~jeffl

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list