系统集成db2 9.7

分享一个DB实时监控的脚本

#!/bin/ksh#monitor db2 -----------------------------------------------------v_dbname=spshismo_run(){# run db2pdstart_or_not=`db2 -x "select count(*) from sysibmadm.SNAPAPPL   where uow_stop_time is null and  current timestamp- uow...显示全部
#!/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>>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收起
参与5

查看其它 2 个回答lihj2015的回答

lihj2015lihj2015网站架构师lihj2015
语句耗时超过5秒,cpu负载超过30,有锁等待的时候! 会监控出来!
生产上开发人员要获取执行时间超过5秒!
系统集成 · 2014-04-10
浏览1047

回答者

lihj2015
网站架构师lihj2015

lihj2015 最近回答过的问题

回答状态

  • 发布时间:2014-04-10
  • 关注会员:2 人
  • 回答浏览:1047
  • X社区推广