DB2_狀態監視

redhouser發表於2011-07-15

目的:
測試DB2狀態監視,本指令碼摘錄自DB2安裝目錄admin_scripts/monitor.db2。
版本:Windows DB2 Express-C V9.7

操作步驟:
使用"db2cmd db2 -t"進入互動模式,執行後續操作。

-- Connect to SAMPLE
CONNECT TO sample;

-- List the top CPU consuming applications for the currently connected
-- database on the currently connected partition
SELECT s2.APPL_NAME,
       s2.APPL_ID,
       s1.AGENT_ID,
       s2.PRIMARY_AUTH_ID,
       ((s1.AGENT_USR_CPU_TIME_S + s1.AGENT_SYS_CPU_TIME_S)*1000000 +
       s1.AGENT_USR_CPU_TIME_MS + s1.AGENT_SYS_CPU_TIME_MS) AS TOTAL_CPU_TIME,
       (s1.AGENT_USR_CPU_TIME_S*1000000 + s1.AGENT_USR_CPU_TIME_MS) AS AGENT_USR_CPU_TIME,
       (s1.AGENT_SYS_CPU_TIME_S*1000000 + s1.AGENT_SYS_CPU_TIME_MS) AS AGENT_SYS_CPU_TIME
   FROM TABLE( SNAP_GET_APPL( '', -1 )) as s1,
        TABLE( SNAP_GET_APPL_INFO( '', -1 )) as s2
   WHERE s1.AGENT_ID = s2.AGENT_ID
   ORDER BY TOTAL_CPU_TIME DESC, s2.APPL_NAME;
--select * from table(snap_get_appl('',-1)) as s1;可以獲取該應用(會話)的統計資訊,包括當前持有鎖,io,cpu,sort等
--select * from table(snap_get_appl_info('',-1)) as s2;可以獲取應用連線資訊


-- Retrieving the snapshot statistics about the progress
-- of all active utilities per partition.
SELECT u1.UTILITY_DBNAME,
       u1.DBPARTITIONNUM,
       u1.UTILITY_ID,
       u1.UTILITY_PRIORITY,
       u1.UTILITY_DESCRIPTION,
       u2.UTILITY_STATE,
       u2.PROGRESS_WORK_METRIC,
       u2.PROGRESS_COMPLETED_UNITS,
       u2.PROGRESS_TOTAL_UNITS,
       DEC( ( FLOAT( u2.PROGRESS_COMPLETED_UNITS ) / FLOAT( u2.PROGRESS_TOTAL_UNITS ) ) * 100, 4, 2 )
         AS PERCENT_SEQ_COMPLETE
  FROM SYSIBMADM.SNAPUTIL as u1, SYSIBMADM.SNAPUTIL_PROGRESS as u2
  WHERE u1.UTILITY_ID = u2.UTILITY_ID and u1.DBPARTITIONNUM = u2.DBPARTITIONNUM
  ORDER BY u1.UTILITY_DBNAME, u1.DBPARTITIONNUM, u2.PROGRESS_SEQ_NUM;
--select * from SYSIBMADM.SNAPUTIL;工具基本資訊
--select * from SYSIBMADM.SNAPUTIL_PROGRESS;工具進度資訊,總量,當前

-- Retrieving the snapshot statistics about total amount of space
-- used by all tablespaces per partition in the currently connected database.
SELECT SUM( TBSP_TOTAL_SIZE_KB ) AS DBPART_TBSP_TOTAL_SIZE,
       DBPARTITIONNUM  FROM SYSIBMADM.TBSP_UTILIZATION
   GROUP BY DBPARTITIONNUM  ORDER BY DBPART_TBSP_TOTAL_SIZE DESC;
--select * FROM SYSIBMADM.TBSP_UTILIZATION;表空間基本資訊和使用資訊,分配,已用,空閒

-- Connect reset
CONNECT RESET;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18922393/viewspace-702288/,如需轉載,請註明出處,否則將追究法律責任。

相關文章