db2 生产应用监控

#!/bin/ksh
#monitor db2 -----------------------------------------------------
v_dbname=spshis




mo_run(){
# run db2pd
start_or_not=`db2 -x "select count(*) from sysibmadm.SNAPAPPL   where uow_stop_time is null and  current timestamp- uow_start_time >5 with ur"`
start_or_not1=`uptime|awk -F"," '{print $6}'`
start_or_not2=`db2pd -d sample -lock wait|wc -l`




date >> monitor_log


if [ $start_or_not -gt 0 ];then
    v_f=`date +%y%m%H%M%S`
     
    start_or_not4=`db2 -x "select count(*) from sysibmadm.SNAPAPPL   where uow_stop_time is null and  current timestamp- uow_start_time >200 with ur"`


    if [ $start_or_not4 -gt 0 ];then
db2pd -d $v_dbname -tran -dyn -lock  wait -app >monitor_log"$v_f"
    fi


    db2 -x "select a.agent_id ,c.tpmon_client_wkstn ,b.stmt_text, current timestamp- a.uow_start_time used_time
           from sysibmadm.SNAPAPPL  a ,sysibmadm.SNAPSTMT b,sysibmadm.SNAPAPPL_INFO c
          where a.agent_id=b.agent_id
            and a.agent_id=c.agent_id
            and a.uow_stop_time is null 
            and current timestamp- a.uow_start_time >5 with ur" >> monitor_log"$v_f"
    
    #rmove wuxiao---
    sh hj_file


    sleep 20
    return
fi


if [[ $start_or_not1 > 30 ]];then
     v_f=`date +%d%m%H%M%S`

     db2pd -d $v_dbname -tran -dyn -lock   wait  -app -latch>>monitor_log"$v_f"

     sleep 20
     return
fi


if [ $start_or_not2 -gt 5 ];then
    v_f=`date +%d%m%H%M%S`
    db2pd -d $v_dbname -tran -dyn -lock  wait -app >>monitor_log"$v_f"
    sleep 20
    return
fi


}
 




db2 connect to $v_dbname > /dev/null


# run ever 20 second
second=0
while true
do
  echo 'start-------------------'
  mo_run
  sleep 5
  let second=${second}+5
  if [ ${second} -gt 7200 ];then
    break
  fi
done


db2 terminate


----如果发现新的功能 会更新该文件

 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值