本文共总结了db2数据库的7项关键指标数据采集的方法,编写该法的目的旨在将下列KPI指标数据传输给统计监控平台,便于统一监控:
1、活动数据库清单,2、表空间状态,3、数据库的并发数量,
4、排序溢出情况,5、持有锁的情况,6、缓存命中率情况,7、日志使用情况
---------------------------------------------------------------------------------------------------------------------------------------------
1、统计活动的数据库列表(通用)
db2 list active databases|grep -i name|awk -F '=' '{print $2}'
---------------------------------------------------------------------------------------------------------------------------------------------
2、统计表空间名字、类型、状态、使用率情况
一、db2V9.7方法
1)设置mon_obj_metrics参数为base
db2 update db cfg for dbname using mon_obj_metrics base
2)统计表空间使用情况
db2 -x "select substr(tbsp_name,1,30) as "TablespaceName",tbsp_type as "Type",substr(tbsp_state,1,20) as "Status",tbsp_utilization_percent as "UsedPercent" from sysibmadm.mon_tbsp_utilization"
3)设置mon_obj_metrics参数为none
db2 update db cfg for dbname using mon_obj_metrics none
二、db2V9.1方法
1)获取表空间id、使用率以及表空间状态(通用)
db2pd -d dbname -tablespaces|grep -ip FreePgs|awk '$1~/^0x0/ {print $2,$5/$4,$10}'
---------------------------------------------------------------------------------------------------------------------------------------------
3、统计当前数据库并发情况
一、db2V9.7方法
1)设置mon_req_metrics参数为base
db2 update db cfg for dbname using mon_req_metrics base
2)统计当前并发情况
db2 "SELECT count(*) FROM TABLE(MON_GET_CONNECTION(cast(NULL as bigint), -2)) AS t"
二、db2V9.1
1)统计当前并发情况(通用)
db2 list applications for db dbname|grep -i dbname|wc -l
---------------------------------------------------------------------------------------------------------------------------------------------
4、统计当前活动的排序及排序溢出情况
一、db2V9.7方法
1)设置mon_req_metrics为base
db2 update db cfg for sample using mon_req_metrics base
2)统计当前排序溢出情况
db2 "with dbcfg1 as (select int(value) as sheapthres_shr from sysibmadm.dbcfg where name = 'sheapthres_shr') select sort_overflows as "Sort_Overflows",active_sorts as "Active_Sorts" from dbcfg1,sysibmadm.snapdb"
二、db2V9.1方法(通用)
1)设置sort参数为on
db2 "UPDATE MONITOR SWITCHES USING sort on"
2)统计排序信息
db2 get snapshot for dbm |grep -i sort|awk -F "=" '{print $2}'|grep -vi on
3)关闭sort参数
db2 "UPDATE MONITOR SWITCHES USING sort off"
---------------------------------------------------------------------------------------------------------------------------------------------
5、统计当前持有锁的agent、锁所在表、锁类型(通用)
1)设置快照监控开关LOCK参数为on
db2 update db cfg for dbname using LOCK on
2)统计锁情况
db2 -x "SELECT AGENT_ID,substr(TABNAME,1,20), LOCK_OBJECT_TYPE, LOCK_MODE, LOCK_STATUS FROM SYSIBMADM.SNAPLOCK"
3)设置LOCK参数为off
db2 update db cfg for dbname using LOCK off
---------------------------------------------------------------------------------------------------------------------------------------------
6、统计数据、索引的命中率
一、db2V9.7方法
1)设置mon_obj_metrics参数为base
db2 update db cfg for sample using mon_obj_metrics base
2)统计数据、索引命中率情况
db2 "select substr(bp_name,1,30) as bp_name,data_hit_ratio_percent,index_hit_ratio_percent from sysibmadm.mon_bp_utilization where bp_name not like 'IBMSYSTEM%'"
二、db2V9.1方法(通用)
1)统计数据、临时以及索引命中率
db2pd -d dbname -bufferpools|grep -ip HitRatio|awk '{print $4,$7,$10}'
---------------------------------------------------------------------------------------------------------------------------------------------
7、统计数据日志利用率(通用)
1)统计日志使用率
db2 -x "select db_name,LOG_UTILIZATION_PERCENT from SYSIBMADM.LOG_UTILIZATION"
---------------------------------------------------------------------------------------------------------------------------------------------
阅读(5497) | 评论(2) | 转发(0) |