PIKT

Samples: Full Disks

PIKT Logo
Home FAQ News Intro Samples Tutorial Reference Software Authors Licensing SiteSearch


In this example, we report when file systems are full.

The DiskCapEmergency script might send an alert message like the following:

-------------------------------------------------------------------------------

                                PIKT ALERT
                         Wed Oct  3 04:30:06 2002
                                 athens4

EMERGENCY:
    DiskCapEmergency
        Report emergency full disk situations

        Filesystem /ckp on /dev/md/dsk/d10 is 100% full, 0 Kb left

        17370930        /ckp/ingres
        8               /ckp/lost+found

-------------------------------------------------------------------------------
The DiskCapEmergency script makes reference to the DiskCaps.obj file.  The script follows.

///////////////////////////////////////////////////////////////////////////////
//
// disks_alarms.cfg
//
///////////////////////////////////////////////////////////////////////////////

[other alarms omitted...]

///////////////////////////////////////////////////////////////////////////////

DiskCapEmergency        // report, possibly take action, and possibly page if
                        // capacity threshold exceeded (typically 100%--i.e.,
                        // the file system is full)

        init
                status active
                level emergency
                task "Report emergency full disk situations"
                =dflinput
                =dffilter
                =dfdata
                keys $fsname

        begin
                =readvals(=objdir/DiskCaps.obj, diskcapval, ":", 6)

        rule    // every $mount has its own #hr value
                set #hr = #hour()

        rule
                // the 1st val (2nd field) in DiskCaps.obj is the emergency field
                if $diskcapval["$mount 1"] ne $err()
                        set #caplim = #val($diskcapval["$mount 1"])
                        set $execcmd = $diskcapval["$mount 6"]
                else
                        set #caplim = #val($diskcapval["DEFAULT 1"])
                        set $execcmd = $diskcapval["DEFAULT 6"]
                endif

#ifdef debug
        rule
                output "$mount $text(#hr) $text(#cap*100)%
                        $text(#caplim*100)% $execcmd"
#endifdef

        rule    // report, possibly take action, and possibly page if
                // capacity threshold exceeded
                if    #cap >= #caplim
                   && =increased(cap, #caplim, 0%)
                        // report
                        output mail "Filesystem $mount on $fsname is
                                     $text(100*#cap,0)% full,
                                     $text(#avail) Kb left"
                        =dutop(10, $mount)
                        // possibly take action
                        if $execcmd ne ""
                                =exec $execcmd
                        endif
                        // possibly page
#ifdef page
                        if    #hr > %hr         // no repeats within the hour
#  if misscritsys
                           && #hr % 1 == 0      // page hourly
                                =page($hostname() $mount is full,
                                      =pagesysadmins, =allhours(#now()))
#    if db
                                =page($hostname() $mount is full,
                                      =pagedbadmins, =allhours(#now()))
#    endif
#  else
                           && #hr % 2 == 0      // page every two hours
                                =page($hostname() $mount is full,
                                      =pagesysadmins, ! =offhours(#now()))
#  endif
                        endif
#endifdef
                endif

///////////////////////////////////////////////////////////////////////////////

[other alarms omitted...]

///////////////////////////////////////////////////////////////////////////////
This is just one program example.  You could add rules, or write new scripts, for example to:  report hardware failures, report network cross-mounted disks going off-line, report problems with the RAID setup, clear /tmp files, log I/O stats, etc.

[For more examples, see Samples.]


Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software | Authors | Licensing | SiteSearch
Links | SiteIndex | Pikt-Users | Pikt-Workers | Contribute | ContactUs | Top of Page
Page best viewed at 1024x768.   Page last updated 2005-06-22.
This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.
Copyright © 1998-2005 Robert Osterlund.  All rights reserved.

Computer Books at Amazon.com

Performance Tuning for Linux Servers
Performance Tuning for Linux Servers

Managing Linux Systems with Webmin
Managing Linux Systems with Webmin

Running Linux
Running Linux

Red Hat Enterprise Linux & Fedora Edition
Red Hat Enterprise Linux & Fedora Edition

UNIX CD Bookshelf
UNIX CD Bookshelf