Scripts Required!

Taking care of your Linux box.
refra
Naik
Posts: 69
Joined: Wed Dec 06, 2006 3:51 pm

Scripts Required!

Postby refra » Thu Jan 07, 2010 12:36 pm

AOA,

I have a following file systems:

/dev/sda1 20G 8.1G 11G 43% /
/dev/sda3 40G 33G 5.3G 86% /d01
/dev/sdb 148G 113G 28G 81% /san
/dev/sdc 50G 84M 47G 1% /san01
/dev/sdd 403G 298G 85G 78% /san00

I need a script that if any file system exceed to 90% than email me.


Also if System load (w command) exceed to 5.00 then also mail me

ghulam yaseen
Naik
Posts: 68
Joined: Thu Aug 07, 2008 6:09 pm
Location: karachi

Re: Scripts Required!

Postby ghulam yaseen » Thu Jan 07, 2010 4:59 pm

Following script will send you an email once specified filesystems go over 90%



#!/bin/bash
output1=`df -lh | grep /dev/sda1 | awk '{print $5}' | sed 's/[!@#\$%^&*()]//g'`
output5=`df -lh | grep /dev/sda3 | awk '{print $5}' | sed 's/[!@#\$%^&*()]//g'`
output2=`df -lh | grep /dev/sdb | awk '{print $5}' | sed 's/[!@#\$%^&*()]//g'`
output3=`df -lh | grep /dev/sdc | awk '{print $5}' | sed 's/[!@#\$%^&*()]//g'`
output4=`df -lh | grep /dev/sdd | awk '{print $5}' | sed 's/[!@#\$%^&*()]//g'`
mail_address="your_mail_address"
function1(){
if [ $output1 -ge 90 ]
then
echo "filesystem Alert on "sda1"" | mail -s "filesystem alert" $mail_address
else
echo "nothing"
fi
}
function2(){
if [ $output2 -ge 90 ]
then
echo "filesystem Alert on sda3" | mail -s "filesystem alert" $mail_address
else
echo "nothing"
fi
}
function3() {
if [ $output3 -ge 90 ]
then
echo "filesystem Alert on sdc" | mail -s "filesystem alert" $mail_address
else
echo "nothing"
fi
}
function4() {
if [ $output4 -ge 90 ]
then
echo "filesystem Alert on sdd" | mail -s "filesystem alert" $mail_address
else
echo "nothing"
fi
}
function5() {
if [ $output5 -ge 90 ]
then
echo "filesystem Alert on sdb" | mail -s "filesystem alert" $mail_address
else
echo "nothing"
fi
}
function1
function2
function3
function4



Regards,
Ghulam Yaseen
http://friendspak.com

ghulam yaseen
Naik
Posts: 68
Joined: Thu Aug 07, 2008 6:09 pm
Location: karachi

Re: Scripts Required!

Postby ghulam yaseen » Thu Jan 07, 2010 5:13 pm

following script will send you email once the system load goes over 5


output1=`uptime | awk '{print $11}' | cut -c 1`
mail_address="your_mail_address"
if [ $output1 -ge 5 ]
then
echo "System load is gone over 5" | mail -s "system load warning" $mail_address
else
echo "nothing"
fi


Regards,
Ghulam Yaseen
http://friendspak.com

ghulam yaseen
Naik
Posts: 68
Joined: Thu Aug 07, 2008 6:09 pm
Location: karachi

regarding scripts

Postby ghulam yaseen » Thu Jan 07, 2010 5:17 pm

but do remember, more the scripts you run...more the system memory and cpu usage will happen.....

lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Postby lambda » Fri Jan 08, 2010 2:26 am

Watch out for the !
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?

ghulam yaseen
Naik
Posts: 68
Joined: Thu Aug 07, 2008 6:09 pm
Location: karachi

simplified script

Postby ghulam yaseen » Fri Jan 08, 2010 9:17 am



Return to “Administration”

Who is online

Users browsing this forum: No registered users and 1 guest