#! /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
---- If a new feature is found, the file will be updated.