System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Perl script to monitor filesystem?

dictum9
Super Advisor

Perl script to monitor filesystem?

Is there a Perl script that will monitor the filesystem and email if there is a full filesystem?

 

 

2 REPLIES
Bill Hassell
Honored Contributor

Re: Perl script to monitor filesystem?

Attached is a shell script called adminalert.sh
This script can monitor all the mounted filesystems for a maximum percentage, or you can list selected mountpoints and specify indivdual percentage limits in the config file. Unlike simple scripts that will create an email storm of messages until the problem is fixed, this script will report once and then wait for an hour (configurable) before reporting the same condition.

It is actually a series of monitors:
CPU Load Alert
Filesystem Limits
NFS mount failures
Ping Servers
User lockouts

Here's a sample of the config file:

    EMAILFREQ=60
    EMAIL=bhassell@sourcedirect.com
    EMAILFROM=root@billhassell.com
    LogFile=true
    LoadAlert=0
       LOADLIMIT=2.0
    DiskFull=1
      MOUNTS=/:95,/opt:85,/tmp:95,/var:95
    NFSalert=0
      NFSWAITSECS=3
      NFSMOUNTS=/mnt2
    PingTest=0
      PINGHOSTS=ftp:8:3:20:true,atl3:5,atl6:8:3:20,atl10:8:3:20,atl5par1
    ProcMon=0
      PROCS=swapper,nfsd:16,httpd:1:4
    UserLockCheck=1
      LOCKED=root,blh,sduser

Here's the usage:

   Usage: adminalert [-c] [-t]
   where -c = Just show the config file without comments
         -t = send test message to EMAIL from the config file

Requires /etc/adminalert.config to run.
The config file will have the name of the functions
  to invoke plus any variables for the functions.

This means that the conditions to check can be enabled
  or disabled in realtime by editing the config file.

To start, just run adminalert -c to see the default
  settings and to create the initial config file.
  Then edit the config file based on the comments.

Just add the script to cron and run it every few minutes.
You can select one or more monitor functions.



Bill Hassell, sysadmin
Steven Schweda
Honored Contributor

Re: Perl script to monitor filesystem?

> Is there a Perl script that will monitor the filesystem [...]

   Is Perl a requirement?  (Why?)  Define "monitor".  I know nothing,
but I seem to recall repeatedly seeing similar requests for shell
scripts which would do this job (usually with the help of "cron",
looking at "df" output).  Did your Web search for such scripts find
nothing?