script to monitor mount points on linux box

Hi,

the following shell script is not working on linux box
sugeestions appreciated.

FILE1=/tmp/check1.txt
FILE2=/tmp/check2.txt
df -k | awk '{if (NR != 1)
print $5 $6}' > ${FILE1}
awk -F"%" '{if ($1 > 90) print "Warning: Filesystem " $2 " over 90% threshold (" $1 "%)"}' ${FILE1} > ${FILE2}
if [ -s ${FILE2} ]; then
mail -s "Filesystem threshold reached" prakash.gr@youtelecom.com < ${FILE2}
fi
rm ${FILE1}
rm ${FILE2}

Thanks

Prakash GR

What is not working ie. what is the error output?
Is this written for a df -k on your Linux box?
Some Unix'es/Linux'es have different positions for their Used%.

Hi,

mail service is enabled in that linux box but i am not getting mail.

is this script is fine .

Thanks

Prakash GR

Please tell exactly what the problem is - do you get garbled output? Maybe comment out the line where it is sent as mail and redirect to a file or check your output on the screen.

sorry zaxxon,

could you give me hint how to redirect the things

Thanks

Prakash GR

What you can do is remove few lines from code. and type on shell set -x on.
when you run it ... you will see what is the script in action ...

if [ -s ${FILE2} ]; then
mail -s "Filesystem threshold reached" prakash.gr@youtelecom.com < ${FILE2}
fi
rm ${FILE1}
rm ${FILE2}

Hi pani,

[ideasdb@voipdb2 ~]$ set -x
[ideasdb@voipdb2 ~]$ sh  mountpoint1.sh
+ sh mountpoint1.sh
/tmp/check1.txt
++ echo -ne '\033]0;ideasdb@voipdb2:~\007'

Thanks

Prakash GR

Give me output of the command :

df -k 

And also which mount point are you interested in monitoring..

---------- Post updated at 04:44 AM ---------- Previous update was at 04:36 AM ----------

Your script says no Mount point is above 90% .. if you need a mail to check ... change the 90% in your script to 1% or less :slight_smile: ... You will get a alert email ...