need a unix script to let me know by email or pager when the filesystem is 80% full.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers need a unix script to let me know by email or pager when the filesystem is 80% full.
# 1  
Old 05-16-2002
need a unix script to let me know by email or pager when the filesystem is 80% full.

Does anyone have a script to check disk space usage.
My backup directory keeps filling up with archivelog files and
I need a script to let me know by email or pager when the filesystem is 80% full.


Thank you!
# 2  
Old 05-16-2002
If yo don't want to use percentage because you have large
filesystems. Correct and modify the following pseudo_coded_ksh:

#!/bin/ksh
#begin_of_MP_use.sh
fecha=`date +"%Y%m%d"`
LOG2=/tmp/"$fecha".txt
tty 1>/dev/null 2>&1
cod_ret=$?
if [ $cod_ret -eq 1 ]
then
VERBOSE="No"
fi

if [ "$VERBOSE" = "Yes" ]
then
set -x
TTY=`tty`
else
TTY=/dev/null
fi
dia=`date +"%Y%m%d"`
HOME=/usr/local/scripts/
LOG=$HOME/logs/"$dia"/"$fecha"_chequeo_MP.txt

if [ ! -d $HOME/logs/"$dia" ]
then
mkdir $HOME/logs/"$dia"
cod_ret=$?
if [ $cod_ret -ne 0 ]
then
LOG=$LOG2
echo "$fecha ERROR $cod_ret when creating $HOME/logs/$dia directory" |tee -a $LOG 1>>$TTY 2>&1
else
chmod 0750 $HOME/logs/"$dia"
cod_ret=$?
if [ $cod_ret -ne 0 ]
then
echo "$fecha ERROR $cod_ret when doing chmod 0750 $HOME/logs/$dia" |tee -a $LOG 1>>$TTY 2>&1
fi
fi
fi

function gen_std_DF {
case $1 in
AIX)
df -kMv /temp |awk '{print $1,$2,$5,$8}' |grep -v "Filesystem" > /tmp/my_df.txt
;;
SunOS)
df -F uMP -o i |awk '/\// {print $3 }' > /tmp/df_i.txt
df -l -F uMP -k |awk '/\//{print $1, $6, $4}' | paste - /tmp/df_i.txt > /tmp/my_df.txt
;;
Linux)
df -x iso9660 -x vfat -x proc -x devpts -i |awk '/\// {print $2}' > /tmp/df_i.txt
df -x iso9660 -x vfat -x proc -x devpts -k |awk '/\//{print $1,$6,$4}' |paste - /tmp/df_i.txt > /tmp/my_df.txt
;;
HP-UX)
bdf -il |awk '/\//{print $1, $9, $4, $6}' > /tmp/my_df.txt
;;
}


function notify_this {
case "$1" in
major) /usr/lpp/OV/OpC/opcmsg severity=$1 app=$2 obj=$3 msg_grp=$4 \
msg_text="$5";;
# opcmsg: HP Vantage Point Operations API
# PATH for AIX
# use the API for Tivoli or whatever
# replace with your emergency notification method

warning) uuencode /tmp/my_df.txt my_df.txt | mail -s "$5" <your_mail_account@your_domain> ;;

esac
}



# body of script

HOST=<hostname>
OS=`uname`
gen_std_DF "$OS"


cat /usr/local/scripts/varios/reportes/uso_MP/umbrales_"$servidor".txt |while read raw_dev SpaUmbMaj SpaUmbWar MP InoUmbMaj InoUmbWar
do

Free_Inodes=`cat /tmp/my_df.txt |grep -w $raw_dev |awk '{print $4'}`
if [ $Free_Inodes -ge $InoUmbWar ]
then
if [ $Free_Inodes -ge $InoUmbMaj ]
then
notify_this major df df OS "Free Inodes: $Free_Inodes $MP "
else
notify_this warning df df OS "Free Inodes: $Free_Inodes $MP "
fi
fi

FREE_SPACE=`cat /usr/local/scripts/varios/reportes/uso_MP/my_df.txt |grep -w $raw_dev |awk '{print $3}'|tail -1`
if [ $FREE_SPACE -lt $SpaUmbWar ]
then
if [ $FREE_SPACE -le $SpaUmbMaj ]
then
notify_this major df df OS "MR: Filesystem $MP $FREE_SPACE Kb libres"
else
notify_this warning df df OS "MR: Filesystem $MP $FREE_SPACE Kb libres"
fi
fi

done

exit 0

#end_of_MP_use.sh


# Example of umbrella_file for AIX
# Logical_Volume space_alarm_umb space_warning_umb Mount_point i-node_alarm_umb i-node_warning_umb
/dev/hd4 100000 200000 / 250 2500
/dev/hd2 1000 10000 /usr 2500 10000
/dev/hd9var 1200000 1500000 /var 3000 15000
/dev/hd3 5000 20000 /tmp 500 5000
/dev/hd1 5000 20000 /home 800 3600
/dev/mwa_raw_dev 5000 30000 /var/opt/perf 100 1000
/dev/ov_raw_dev 5000 30000 /var/lpp/OV 100 1000
/dev/recman_raw_dev 20000 50000 /rman 50 1000
/dev/oracle_raw_dev 20000 40000 /usr/lpp/oracle8i 100 1000
/dev/archiving_raw_dev 50000 100000 /usr/lpp/oracle8i/admin/<instance_name>/arch 90 9000
/dev/oraclebin_raw_dev 400000 200000 /usr/lpp/oracle8i/product/8.1.6 100 2000
/dev/backuprman_raw_dev 2000000 5000000 /home/backup 1000 10000
# end_of Example of umbrella_file for AIX

For the others OS Replace the Logical Volume with
partition_name, meta_device_name.
Examples:

HP-UX /dev/vg15/al_abd_p
Linux Redhat: /dev/sda1, /dev/md3
SunOs: /dev/dsk/c0t0d0s6


Good Luck. Hugo.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

[Solved] Filesystem getting full. Need a monitoring script

Hi, I am new to shell scripting in unix HP-UX. I need to determine how much a perticular file system is full and if it goes over 80% it should notify through mail about which are the files which are greater than 1 GB size. I used df -k command it is showing the alloocated KB and the %used... (14 Replies)
Discussion started by: Soma Das
14 Replies

2. Solaris

Filesystem Full

In our shop we have to run a batch cycle. Every so often while we are running batch we get a filesystem full situation that causes batch to stop or slow down. Anyway, the practiced procedure is to look for large files and zip them. This takes a lot of time. We are in a sun solaris environment. What... (1 Reply)
Discussion started by: Harleyrci
1 Replies

3. UNIX for Dummies Questions & Answers

filesystem is full

Hello everybody, a very basic question. Inspite of me deleting huge files in a filesystem(AIX 5.3) in oracle folder, the filesystem when i check using df -k still shows 100% full. Does that mean there is a process still pointing to the files which i deleted. how do i work around this. Thanks!... (3 Replies)
Discussion started by: karthikosu
3 Replies

4. Red Hat

/ filesystem getting full

Hi All, How do I increase the root filesystem? It's getting full. / 90% Here's the break down, below 232 dev 5624 tmp *6764 bin 16860 root *19680 sbin *20436 lib64 28329 boot *47992 etc 150012 var *254540 lib 651708 home *2445044 usr (5 Replies)
Discussion started by: itik
5 Replies

5. AIX

filesystem is full in AIX5.3

Hi, I am new to AIX 5.3.I want to work with it and when I check the space of AIX machine..its /usr is 99% full.So I am not able to add anything in that. filesystem is as below-- So can anyone tell me how can I resize it and increase the size of it. 2nd thing,when I am trying to... (6 Replies)
Discussion started by: smartgupta
6 Replies

6. UNIX for Dummies Questions & Answers

filesystem full

my root filesystem is eventually full "/dev/rdsk/c1d0s0" as a result i cannot boot to the operating system, i booted into the fail safe mode to check the space using df -h command i discover that it is eventually full. Also to my amazement i found that i cannot see the filesystem which mounted on... (1 Reply)
Discussion started by: seyiisq
1 Replies

7. Solaris

The filesystem is still full - Solaris 10!

Good morning, sir! I've a problem with FileSystem, the problem is FileSystem is full First time, I've already read carefully the sticky thread FileSystem full - What to lock for https://www.unix.com/sun-solaris/25840-filesystem-full-what-look.html And then, I will post some information of... (4 Replies)
Discussion started by: trantuananh24hg
4 Replies

8. UNIX for Dummies Questions & Answers

/tmp filesystem full

I am running AIX 3 4. When I do a df I get: Filesystem 512-blocks Free %Used Iused %Iused Mounted on /dev/hd4 32768 10232 69% 1309 16% / /dev/hd2 917504 86360 91% 19744 18% /usr /dev/hd9var 131072 67712 49% 617 ... (11 Replies)
Discussion started by: szodiac
11 Replies

9. UNIX for Dummies Questions & Answers

Filesystem Full

I noticed that whenever something is printed from my workstation, the available disk space in the /dev/dsk/c0t0d0s0 decreases considerably. Hence, after using my workstation for sometime, I encounter an error message: "Filesystem Full" that prevents me from printing any further. Is there a way to... (16 Replies)
Discussion started by: ilak1008
16 Replies

10. UNIX for Advanced & Expert Users

Pager message from UNIX

Hi, we have written an auto emailer script for some autosys jobs getting delayed using C-Shell. We would also like to enhance this by sending out a page to the support personnel. Is there any way in C-Shell or autosys wherein we have the facility to send these pager messages ? Please help !! (1 Reply)
Discussion started by: pavankri
1 Replies
Login or Register to Ask a Question