免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1731 | 回复: 0
打印 上一主题 下一主题

[新手入门] PRODUCT DB2 SPACE MONITOR SHELL [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-07-13 10:54 |只看该作者 |倒序浏览

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
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP