Nearly Full Disks

In this example, we report when file systems are near capacity.

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

                                PIKT ALERT
                         Thu Jun 14 07:52:39 2007
                                  cadiz

EMERGENCY:
    DiskCap
        Report near-capacity filesystems

        Filesystem /storage2 on /dev/hda3 is 96% full, 29807256 KB capacity, 1375492 Kb left

The =diskcap() script macro follows.

diskcap(LIMDEFAULT, LIMWARN, LIMURGENT, LIMEMERG, BYPASS)

        init
                status =piktstatus
                level =piktlevel
                task "Report near-capacity filesystems"
                =dflinput
                =dffilter
                =dfdata
                keys $fsname

        begin
                if $alert() =~~ "warning|notice|info"
                        // run this only on sundays
                        if ! =sunday
                                quit
                        fi
                fi

        rule
                if $mount =~~ "^(BYPASS)$"
                        next
                fi

        rule
                set $capmsg = "Filesystem $mount on $fsname is $text(100*#cap,0)% full,
                               $text(#kbytes) KB capacity, $text(#avail) Kb left"

        rule    // consider adding a =dutop(10, $mount) call in each case
                if $alert() =~~ "emergency"
                        if    #cap >= (LIMEMERG)
                           && (! #defined(%cap) || (#cap > %cap))
                                output mail $capmsg
                        //      =page()
                        fi
                elsif $alert() =~~ "urgent"
                        if    #cap >= (LIMURGENT)
                           && (! #defined(%cap) || (#cap > %cap))
                                output mail $capmsg
                        fi
                elsif $alert() =~~ "warning"
                        if    #cap >= (LIMWARN)
                           && (! #defined(%cap) || (#cap > %cap))
#if missioncritical
                                output mail $capmsg
#else
                                =output_other_mail(DISKCAP,
                                                   'PIKT Alert on =pikthostname: WARNING',
                                                   =piktadmin, $capmsg)
#endif
                        fi
                else    // for interactive, command-line scripts
                        if    #cap >= (LIMDEFAULT)
                        // && (! #defined(%cap) || (#cap > %cap))
                                output $capmsg
                        fi
                fi

        end
                quit

You would invoke this macro in your alarms.cfg (or one of its #include files) like so:

DiskCap
        =diskcap(90%, 95%, 99%, 100%, )

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.

Open Hand For more examples, see Samples.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2008-03-27.   This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.   Copyright © 1998-2008 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
browser
cache clear
Pikt script