It is currently Mon, 27 Jun 2022 11:36:27 GMT



 
Author Message
 monitoring disk space?
Is there a script that someone has written or is there a syslog facility
to monitor disk space for filesystems. What I need is someway for the
root account to be mailed or syslog to notify that a certain filesystem
is 95% + full etc. I've looked at several FAQs with no luck, but I am a
newbie so please excuse me if I've failed to look in the right places.

TIA. Andrew
--
 --------------------------------------------------------------------------
| Flatulence is a complex socio-psycho-biological phenomenon which may be  |
| viewed as a form of interpersonal communication or metacommunication     |
| (Cheese & Cutter, 1977)                                                  |
|                                                                          |
| email: andr...@smtpgate.chhlth.govt.nz                                   |
 --------------------------------------------------------------------------



 Fri, 02 Jan 1998 03:00:00 GMT   
 monitoring disk space?

    H> Is there a script that someone has written or is there a syslog
    H> facility to monitor disk space for filesystems. What I need is
    H> someway for the root account to be mailed or syslog to notify
    H> that a certain filesystem is 95% + full etc. I've looked at
    H> several FAQs with no luck, but I am a newbie so please excuse
    H> me if I've failed to look in the right places.

    H> TIA. Andrew --

Most systems will warn you when you go over 100% (there is normally a
10%-20% reserve of actual space that is not included in the
percentage).

Anyway, writing a script to do this wouldn't be very hard.
  === Al



 Sun, 04 Jan 1998 03:00:00 GMT   
 monitoring disk space?

The "df" (diskfree) command is provided just for monitoring drive space.
If you are working with a Sys-V-based system, or some Berkeley-based systems,
you have access to a script called "dfspace" that massages the output of df.
A sample of dfspace's output:

/                  :  Disk space:  836.00 MB of 1610.99 MB available (51.89%)
/stand             :  Disk space:    1.70 MB of    8.00 MB available (21.30%)
/usr/Xmore         :  Disk space:   27.85 MB of  300.00 MB available ( 9.29%)
/usr/mount1        :  Disk space:  146.61 MB of  437.50 MB available (33.51%)
/usr/mount2        :  Disk space:   75.65 MB of  379.39 MB available (19.94%)
/usr/mount3        :  Disk space:  160.68 MB of  903.32 MB available (17.79%)
/usr/mount4        :  Disk space:  661.09 MB of  830.07 MB available (79.64%)
/usr/mount5        :  Disk space:  313.73 MB of  610.35 MB available (51.40%)
/usr1              :  Disk space:   20.42 MB of  195.31 MB available (10.46%)

The simplest thing you can do is to run this as a cron job that will email
you the results to check manually.  As root, create a cron entry by running
"crontab", and add a line like:

        15 1,7,13,19 * * * '/sbin/dfspace |mailx -s "disk space report" root'

(this runs it at: 01:15, 07:15, 13:15 and 19:15 everyday)

What would be really nice is to notify youself if a disk is filling up
automatically.  Since dfspace is a shell script, you could copy it and modify
it to your own needs.  Or you could create a wrapper script like the following:

        # script to notify root if a disk (mounted system) is getting full

        THRESHOLD=10    # what integer percentage under which to notify
        TMPFILE=/tmp/{$0}_tmpfile

        OK_TST=true
        dfspace |while read LINE; do
                MNT_NM=`echo $LINE |cut -d\: -f1`
                if [ "$MNT_NM" = "" ]; then continue; fi
                PCT_FULL=`echo $LINE |cut -d\( -f2 |cut -c1-5`
                INT_FULL=`echo $PCT_FULL |cut -d. -f1`
                TST_VAL=`expr $INT_FULL - $THRESHOLD`
                if [ $TST_VAL -lt 0 ]; then
                        OK_TST=false
                        echo "$MNT_NM: $PCT_FULL is below $THRESHOLD.00%" >> $TMPFILE
                fi
        done

        if [ "$OK_TST" = "false" ]; then
                {
                echo "The following mounted filesystems are dangerously low on space:\n"
                cat $TMPFILE
                echo "\nA total space utilization report follows:\n"
                dfspace
                } | mailx -s "low filesystem report" root
        fi

        rm $TMPFILE 2>/dev/null
        exit 0

This generates an email message like the following:

+ From root Tue Aug 15 14:02 EDT 1995
+ Date: Tue, 15 Aug 95 14:02 EDT
+ From: Super User <r...@system.domain>
+ To: root
+ Subject: low filesystem report
+ Content-Length: 1416
+ Content-Type: text
+
+ The following mounted filesystems are dangerously low on space:
+
+ /usr/Xmore :  9.29 is below 10.00%
+ /usr/mount7 :  7.68 is below 10.00%
+
+ A total space utilization report follows:
+
+ /                  :  Disk space:  833.47 MB of 1610.99 MB available (51.74%)
+ /stand             :  Disk space:    1.70 MB of    8.00 MB available (21.30%)
+ /usr/Xmore         :  Disk space:   27.85 MB of  300.00 MB available ( 9.29%)
+ /usr/mount1        :  Disk space:  146.61 MB of  437.50 MB available (33.51%)
+ /usr/mount2        :  Disk space:   75.65 MB of  379.39 MB available (19.94%)
+ /usr/mount3        :  Disk space:  149.09 MB of  903.32 MB available (16.51%)
+ /usr/mount4        :  Disk space:  661.09 MB of  830.07 MB available (79.64%)
+ /usr/mount5        :  Disk space:  311.53 MB of  610.35 MB available (51.04%)
+ /usr1              :  Disk space:   20.42 MB of  195.31 MB available (10.46%)
+ /usr/mount6        :  Disk space:   73.97 MB of  601.37 MB available (12.30%)
+ /usr/mount7        :  Disk space:   26.49 MB of  345.00 MB available ( 7.68%)
+ /usr/add-on/pubtools:  Disk space:  153.93 MB of  470.53 MB available (32.72%)
+ /var/news          :  Disk space:   26.09 MB of   49.99 MB available (52.20%)
+ /usr/add-on/utils  :  Disk space:  153.93 MB of  470.53 MB available (32.72%)
+
+ Total Disk Space: 2661.91 MB of 7212.39 MB available (36.91%).

Then just run the new script from cron every so often.
I hope all of this helps...

--
- sgh     What are you doing, reading the words at the bottom?!?   Key Grip!?!
          What is a key grip anyway?!  I don't give credit to anybody -- it's
Scott G. Hall     (s...@cbgbcs.cb.att.com)              all my show!!  - Duckman
AT&T Bell Laboratories - GCBS, Columbus, OH, USA



 Sat, 31 Jan 1998 03:00:00 GMT   
 
   [ 3 post ] 

Similar Threads

1. How to monitor disk space usage and performance

2. snmp monitoring disk space ?

3. Monitoring disk space

4. How to monitor disk space -> send warning on beeper ?

5. monitoring free disk space

6. Utility to monitor free disk space..

7. Out of disk space though df/du show space available

8. Strange disk free space/used space...


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software