File System exceed Alert Script!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File System exceed Alert Script!
# 8  
Old 03-15-2010
I have tried executing your script (with the df-h o/p you provided).

Code:
###########################################
ALERT="50"
ALERT1="85"
DFH=dfh.$$
#DFH=df.$$
DFM=mail.$$
CHK=chk.$$
###########################################
EMAIL=anchal.khare@xyz.com
SUBJECT="WARNING! Disk Usage of $(uname -n)"
MAILPROG=mailx
###########################################

rm -f $DFM
clear
echo
echo `date` | tee $DFM
echo | tee -a $DFM
#df -h > $DFH
cat $DFH | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $6 }' | while read output;
do
  echo "OP is $output"
  USEP=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
  FS=$(echo $output | awk '{ print $2 }' )
  echo "USEP is $USEP, FS is $FS"
  if [ $USEP -gt $ALERT ]
  then
  echo "Running out of space \"$FS - ($USEP%)\"" | tee -a $DFM
  fi
done
if test -f $CHK
then
echo "Not Sending an Email"
exit
else
echo Sending an Email
$MAILPROG -s "$SUBJECT" "$EMAIL" < $DFM
echo Creating Tmp File
touch $CHK
fi


## USEP is null here. because of different subshell
## syntx error for if
echo "USEP is $USEP, ALERT1 is $ALERT1"
if [ $USEP -lt $ALERT1 ]
then
echo Removing Tmp File
rm -f $CHK

fi


this is what I am getting in the mail,

Code:
Mon Mar 15 12:17:58 MET 2010

Running out of space "/d01 - (87%)"
Running out of space "/san - (81%)"
Running out of space "/san00 - (79%)"


if this is not working for you, try to debug with echoing and check your DFM file. and if DFM file is OK, try to send mail explicitly with that file and see what happens.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to monitor diskspace of /home/ not to exceed 80%

I want to monitor the diskspace of the /home/ directory NOT to exceed 80%. I want a script_file.sh for this. I am trying "df -h" command and I am stuck unable to extract the percentage. 1. HOW TO extract the percentage (I believe 5th column)? 2. IF we were able to extract the column,... (8 Replies)
Discussion started by: Shreyas N
8 Replies

2. Shell Programming and Scripting

shell script to alert if a file has been modified

Hi , I want a script who will send alert the moment someone edit any file in a directory in LINUX. Can some one throw some light on this please.!! (4 Replies)
Discussion started by: d8011
4 Replies

3. Shell Programming and Scripting

Looking for shell script to monitor CPU utilization and send mail once exceed 75%

Dear Group, I'm look for shell script to Monitor CPU usage and send mail once it exceed 75% I'm running Suse10.4. (3 Replies)
Discussion started by: clfever
3 Replies

4. Shell Programming and Scripting

Script to Alert a file and sends an email

Hello All, I need a script which alerts me when a files arrive in a directory. I don't need every file. but i need some specific pattern file. And i need to get automatic email gettin as an alert For Example: /a/b/c/ : directory format of file should take regualr expression or manually... (2 Replies)
Discussion started by: krux_rap
2 Replies

5. Shell Programming and Scripting

Script check for file, alert if not there, and continue checking until file arrives

All, Is there a way to keep checking for a file over and over again in the same script for an interval of time? Ie If { mail -user continue checking until file arrives file arrives tasks exit I don't want the script to run each time and email the user each time a file... (4 Replies)
Discussion started by: markdjones82
4 Replies

6. Infrastructure Monitoring

Monitoring and Alert System

hi, i serarch monitoring and alert system. when HDD and services are down. Send email and sms alert to me and help desk. but i don't find any program. Can you help me ? Thanks. (1 Reply)
Discussion started by: oulutas
1 Replies

7. Shell Programming and Scripting

File system backup alert

Hi All, OS: AIX 5.3 64 bits Could anyone please share unix File system backup alert shell script which sends an alert message upon failure.. Thanks for your time! Regards, (0 Replies)
Discussion started by: a1_win
0 Replies

8. Post Here to Contact Site Administrators and Moderators

Alert system

Do you have an alert system? meaning when your question has been answer, could be u guys send an email, informing the question has been answer, of someone did post a reply? Thanks (2 Replies)
Discussion started by: owange_county
2 Replies

9. Shell Programming and Scripting

Shel Script doesn't work from Exceed

Hi, I am using this script to load up my Oracle Databases, but when I log in through Exceed, it hangs. Can anyone tell me what else I need to add to make this work?? Details ****************************************************************************************************... (11 Replies)
Discussion started by: dnkansah
11 Replies

10. Programming

Max file size can't exceed 2 GB

We have Sun OS 5.9 we are doing a backup process (ProC program) that uses the function... fprintf(fp,"%s;%s;%s;%s;%s;%ld;%ld;%ld;%ld;%s;%s;%s;%d;%s;%s;%s;%ld;%s;%s;%s;%ld;%ld;%s;%ld;%s;%ld;%s;%s;%c%c",x_contrno, x_subno, x_b_subno,x_transdate,x_last_traffic_date,BillAmt_s, x_billamount_int,... (10 Replies)
Discussion started by: atiato
10 Replies
Login or Register to Ask a Question