1834253 Members
1955 Online
110066 Solutions
New Discussion

Script

 
SOLVED
Go to solution
sivakumar_11
Advisor

Script

Hi EB,

GM,
I need a exact script which should alert me when a f/s is full.

Urg. pls

tar
avis
6 REPLIES 6
Hoang Minh Tuan
Regular Advisor

Re: Script

Hi,

This is the script which alert you when file system is upper then 90% or full

bdf|grep -v File |awk '{ if ( $(NF-1) > 90 || $(NF-1) == "100%" ) print}'

you can make a script file then make it in cronjob to check it frequently.

HMT
Bus wait at bus station, Work wait at my work station
harry d brown jr
Honored Contributor

Re: Script

Waiting UNTIL a filesystem is full is Foolish and Dangerous. You need to be PRO-Active before a filesystem fills up, unless you enjoy potentially lost and corrupt data.

Change that script to alert when an FS reaches anywhere from 80%-94%, especially when an FS is SMALL. The larger the FS, then the more room to grow into, thus you might be able to increase the % to a larger number before alerting. There is NO magic bullet.

Additionally you need to PLOT your FS usage and be prepared to add additional storage if necessary.

live free or die
harry d brown jr
Live Free or Die
Muthukumar_5
Honored Contributor

Re: Script

You can use bdf and mailx command to do this. And as said by olympian have the upper limit of f/s in the range of 90-95%.

Make the Execution of this script with cron schedular.

#!/bin/ksh
# Alerter
for line in `bdf | awk '!/^Filesystem/ { print $5" "$6 }'`
do

per=$(echo $line | awk '{ print $1 }'
fs=$(echo $line | awk '{ print $1 }'

per1=$(echo $per | cut -d'%' -f1)

if [[ $per1 -gt 90 ]]
then

echo "$fs is greater than 90%" | mailx -s "Alert"

fi

done

HTH.
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor
Solution

Re: Script

Change
per=$(echo $line | awk '{ print $1 }'
fs=$(echo $line | awk '{ print $1 }'

to
per=$(echo $line | awk '{ print $1 }'
fs=$(echo $line | awk '{ print $2 }'

ok.
Easy to suggest when don't know about the problem!
Rory R Hammond
Trusted Contributor

Re: Script

I have two shell scripts. One returns free space percentage.

free.sh 5 will return filesystem that have less the 5% free space.
or
free.sh 20 will return filesystem that have less than 20% free space

The following snippet runs from cron,
you can easily modify to send page


SPACEWARN=20

for arg in $(free.sh ${SPACEWARN}|cut -f1 -d" ")
do
if
[ -n ${arg} ]
then
echo $(free.sh ${SPACEWARN}|grep ${arg}) | mailx -s "$arg low on space" root
fi
done
There are a 100 ways to do things and 97 of them are right
Marty Metras
Super Advisor

Re: Script

Attached is the Script I have been using for years.
I emails me when 80% of the space has been used.

Marty
The only thing that always remain the same are the changes.