- 论坛徽章:
- 0
|
PRODUCT DB2 SPACE MONITOR SHELL
#! /bin/sh
Month=`date "+%m"`
Day=`date "+%d"`
Year=`date "+%y"`
YEAR=`date "+%Y"`
LogDir=/tmp/sysmonitor
DISK=$LogDir/FILESYSTEM_$YEAR$Month$Day.txt
Temp_file1=$LogDir/temp1.log
Temp_file2=$LogDir/temp2.log
#####Monitor FileSpace#####
date>> $DISK
df -m >> $DISK
CNT1=`grep dev $DISK|grep -E -w "hd4|var|maestro"|awk '{if($3/$2> $CRITICAL
date >> $CRITICAL
grep -w Free $DISK >> $CRITICAL
grep dev $DISK|grep -E -w "hd4|var|maestro"|awk '{if($3/$2> $CRITICAL
grep dev $DISK|grep -E -w -v "hd4|var|hd3|usr|maestro|hd1|opt|fix|proc"|awk '{if($3/$2> $CRITICAL
grep dev $DISK|grep -E -w "hd3"|awk '{if($3> $CRITICAL
fi
CNT1=`grep dev $DISK|grep -E -w "hd4|var|maestro"|awk '{if($3/$2> $WARNING
date >> $WARNING
grep -w Free $DISK >> $WARNING
grep dev $DISK|grep -E -w "hd4|var|maestro"|awk '{if($3/$2> $WARNING
grep dev $DISK|grep -E -w -v "hd4|var|hd3|usr|maestro|hd1|opt|fix|proc"|awk '{if($3/$2> $WARNING
grep dev $DISK|grep -E -w "hd3"|awk '{if($3> $WARNING
fi
####Monitor TableSpace####
CRITICAL=$LogDir/CRITICAL_TABLESPACE_$YEAR$Month$Day.txt
TABLE=$LogDir/TABLESPACE_GPCDB_$YEAR$Month$Day.txt
su - gpcp /dev/null
db2 list tablespaces show detail >> $TABLE
db2 connect reset > /dev/null
exit
!!
grep -E -w "Name|Useable pages|Used pages" $TABLE > $Temp_file1
awk '{if(NR%3==1){name=$NF};if(NR%3==2){x=$NF};if(NR%3==0){y=$NF;print name,y/x*100}}' $Temp_file1 > $Temp_file2
CNT=`awk '$1 ~ /^G/ {if($2>95){print $0"%"}}' $Temp_file2|wc -l`
if [ $CNT -gt 0 ] ; then
echo "***********CRITICAL GPCDB***********" >> $CRITICAL
date >> $CRITICAL
awk '$1 ~ /^G/ {if($2>95){print $0"%"}}' $Temp_file2 >> $CRITICAL
fi
TABLE=$LogDir/TABLESPACE_GALDB_$YEAR$Month$Day.txt
su - galp /dev/null
db2 list tablespaces show detail >> $TABLE
db2 connect reset > /dev/null
exit
!!
grep -E -w "Name|Useable pages|Used pages" $TABLE > $Temp_file1
awk '{if(NR%3==1){name=$NF};if(NR%3==2){x=$NF};if(NR%3==0){y=$NF;print name,y/x*100}}' $Temp_file1 > $Temp_file2
CNT=`awk '$1 ~ /^G/ {if($2>95){print $0"%"}}' $Temp_file2|wc -l`
if [ $CNT -gt 0 ] ; then
echo "***********CRITICAL GALDB***********" >> $CRITICAL
date >> $CRITICAL
awk '$1 ~ /^G/ {if($2>95){print $0"%"}}' $Temp_file2 >> $CRITICAL
fi
TABLE=$LogDir/TABLESPACE_GSIDB_$YEAR$Month$Day.txt
su - gsip /dev/null
db2 list tablespaces show detail >> $TABLE
db2 connect reset > /dev/null
exit
!!
grep -E -w "Name|Useable pages|Used pages" $TABLE > $Temp_file1
awk '{if(NR%3==1){name=$NF};if(NR%3==2){x=$NF};if(NR%3==0){y=$NF;print name,y/x*100}}' $Temp_file1 > $Temp_file2
CNT=`awk '$1 ~ /^G/ {if($2>95){print $0"%"}}' $Temp_file2|wc -l`
if [ $CNT -gt 0 ] ; then
CRITICAL=$LogDir/CRITICAL_TABLESPACE_$YEAR$Month$Day.txt
echo "***********CRITICAL GSIDB***********" >> $CRITICAL
date >> $CRITICAL
awk '$1 ~ /^G/ {if($2>95){print $0"%"}}' $Temp_file2 >> $CRITICAL
fi
######Remove Temp file#####
rm $Temp_file1
rm $Temp_file2
######Remove Old file#####
find $LogDir -name "*.txt" -mtime +90 -print -exec rm {} ;
PRODUCT DB2 SPACE MONITOR SHELL
#! /bin/sh
Month=`date "+%m"`
Day=`date "+%d"`
Year=`date "+%y"`
YEAR=`date "+%Y"`
LogDir=/tmp/sysmonitor
DISK=$LogDir/FILESYSTEM_$YEAR$Month$Day.txt
Temp_file1=$LogDir/temp1.log
Temp_file2=$LogDir/temp2.log
#####Monitor FileSpace#####
date>> $DISK
df -m >> $DISK
CNT1=`grep dev $DISK|grep -E -w "hd4|var|maestro"|awk '{if($3/$2> $CRITICAL
date >> $CRITICAL
grep -w Free $DISK >> $CRITICAL
grep dev $DISK|grep -E -w "hd4|var|maestro"|awk '{if($3/$2> $CRITICAL
grep dev $DISK|grep -E -w -v "hd4|var|hd3|usr|maestro|hd1|opt|fix|proc"|awk '{if($3/$2> $CRITICAL
grep dev $DISK|grep -E -w "hd3"|awk '{if($3> $CRITICAL
fi
CNT1=`grep dev $DISK|grep -E -w "hd4|var|maestro"|awk '{if($3/$2> $WARNING
date >> $WARNING
grep -w Free $DISK >> $WARNING
grep dev $DISK|grep -E -w "hd4|var|maestro"|awk '{if($3/$2> $WARNING
grep dev $DISK|grep -E -w -v "hd4|var|hd3|usr|maestro|hd1|opt|fix|proc"|awk '{if($3/$2> $WARNING
grep dev $DISK|grep -E -w "hd3"|awk '{if($3> $WARNING
fi
####Monitor TableSpace####
CRITICAL=$LogDir/CRITICAL_TABLESPACE_$YEAR$Month$Day.txt
TABLE=$LogDir/TABLESPACE_GPCDB_$YEAR$Month$Day.txt
su - gpcp /dev/null
db2 list tablespaces show detail >> $TABLE
db2 connect reset > /dev/null
exit
!!
grep -E -w "Name|Useable pages|Used pages" $TABLE > $Temp_file1
awk '{if(NR%3==1){name=$NF};if(NR%3==2){x=$NF};if(NR%3==0){y=$NF;print name,y/x*100}}' $Temp_file1 > $Temp_file2
CNT=`awk '$1 ~ /^G/ {if($2>95){print $0"%"}}' $Temp_file2|wc -l`
if [ $CNT -gt 0 ] ; then
echo "***********CRITICAL GPCDB***********" >> $CRITICAL
date >> $CRITICAL
awk '$1 ~ /^G/ {if($2>95){print $0"%"}}' $Temp_file2 >> $CRITICAL
fi
TABLE=$LogDir/TABLESPACE_GALDB_$YEAR$Month$Day.txt
su - galp /dev/null
db2 list tablespaces show detail >> $TABLE
db2 connect reset > /dev/null
exit
!!
grep -E -w "Name|Useable pages|Used pages" $TABLE > $Temp_file1
awk '{if(NR%3==1){name=$NF};if(NR%3==2){x=$NF};if(NR%3==0){y=$NF;print name,y/x*100}}' $Temp_file1 > $Temp_file2
CNT=`awk '$1 ~ /^G/ {if($2>95){print $0"%"}}' $Temp_file2|wc -l`
if [ $CNT -gt 0 ] ; then
echo "***********CRITICAL GALDB***********" >> $CRITICAL
date >> $CRITICAL
awk '$1 ~ /^G/ {if($2>95){print $0"%"}}' $Temp_file2 >> $CRITICAL
fi
TABLE=$LogDir/TABLESPACE_GSIDB_$YEAR$Month$Day.txt
su - gsip /dev/null
db2 list tablespaces show detail >> $TABLE
db2 connect reset > /dev/null
exit
!!
grep -E -w "Name|Useable pages|Used pages" $TABLE > $Temp_file1
awk '{if(NR%3==1){name=$NF};if(NR%3==2){x=$NF};if(NR%3==0){y=$NF;print name,y/x*100}}' $Temp_file1 > $Temp_file2
CNT=`awk '$1 ~ /^G/ {if($2>95){print $0"%"}}' $Temp_file2|wc -l`
if [ $CNT -gt 0 ] ; then
CRITICAL=$LogDir/CRITICAL_TABLESPACE_$YEAR$Month$Day.txt
echo "***********CRITICAL GSIDB***********" >> $CRITICAL
date >> $CRITICAL
awk '$1 ~ /^G/ {if($2>95){print $0"%"}}' $Temp_file2 >> $CRITICAL
fi
######Remove Temp file#####
rm $Temp_file1
rm $Temp_file2
######Remove Old file#####
find $LogDir -name "*.txt" -mtime +90 -print -exec rm {} ;
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/6371/showart_35460.html |
|