Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display功能补充 #667

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions plugins/display/tasks/observer/aplan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
info_en: "[aplan]"
info_cn: "[实际执行计划信息]"
command: obdiag display scene run --scene=observer.aplan --env svr_ip=test --env tenant_id=test --env plan_id=test
task:
- version: "[*,*]"
steps:
- type: sql
sql: "select plan_id, operator, name, rows, cost
from oceanbase.__all_virtual_plan_cache_plan_explain
where svr_ip = '#{svr_ip}'
and svr_port = 2882
and tenant_id = '#{tenant_id}'
and plan_id = '#{plan_id}'"
global: true
18 changes: 18 additions & 0 deletions plugins/display/tasks/observer/cpu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
info_en: "[cpu]"
info_cn: "[tenant的cpu信息]"
command: obdiag display scene run --scene=observer.cpu
task:
- version: "[*,*]"
steps:
- type: sql
sql: " select NOW() 'chenck_time', t.tenant_name,t.tenant_id,ca.svr_ip,
round(sum(case when STAT_ID='140006' then ca.VALUE else 0 end)/100,2) 'cpu_usage',
round(sum(case when STAT_ID='140005' then ca.VALUE else 0 end)/100,2) 'cpu_max' ,
round(100*(sum(case when STAT_ID='140006' then ca.VALUE else 0 end)/sum(case when STAT_ID='140005' then ca.VALUE else 0 end)),2) 'cpu_percent'
from
(select s.CON_ID, s.svr_ip,s.STAT_ID, sum(s.VALUE) VALUE
from oceanbase.gv$sysstat s where s.STAT_ID in(140005,140006)
group by s.CON_ID, s.svr_ip,s.STAT_ID, s.NAME) ca,oceanbase.__all_tenant t
where t.tenant_id=ca.CON_ID
group by t.tenant_name,ca.svr_ip;"
global: true
15 changes: 15 additions & 0 deletions plugins/display/tasks/observer/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
info_en: "[index]"
info_cn: "[查询表上的index信息]"
command: obdiag display scene run --scene=observer.index --env user_name=test --env table_name=test
task:
- version: "[*,*]"
steps:
- type: sql
sql: "select t1.tenant_name,a.table_id index_id,d.database_name tab_owner,a2.table_name ,d.database_name idx_owner,substr(substring_index(e.table_name,'_',4),7) table_id, substring(e.table_name,length(substring_index(e.table_name,'_',4))+2) index_name, group_concat(distinct a.column_name order by a.rowkey_position separator',') as index_column
from oceanbase.__all_virtual_column a
inner join oceanbase.__all_virtual_table e on a.table_id=e.table_id and e.table_type=5 and a.tenant_id=e.tenant_id
inner join oceanbase.__all_virtual_table a2 on e.data_table_id=a2.table_id and a2.table_name=upper('#{table_name}') And a2.tenant_id=e.tenant_id
inner join oceanbase.__all_tenant t1 on t1.tenant_id=a2.tenant_id and t1.tenant_id>1000
inner join oceanbase.__all_virtual_database d on d.database_id=a2.database_id and d.database_name=upper('#{user_name}') and e.database_id=d.database_id
group by t1.tenant_name,a.table_id,d.database_name,a2.table_name,d.database_name,e.table_name; "
global: true
16 changes: 16 additions & 0 deletions plugins/display/tasks/observer/leader.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
info_en: "[leader]"
info_cn: "[ob集群的leader信息]"
command: obdiag display scene run --scene=observer.leader --env level=('all' or tenant_id or table_name)
task:
- version: "[*,4.0.0]"
steps:
- type: sql
sql: "select a.tenant_id, b.tenant_name, a.svr_ip, a.role, count(1) part_count from oceanbase.__all_virtual_meta_table a, oceanbase.__all_tenant b
where a.tenant_id = b.tenant_id and (('all'='#{level}') or (a.tenant_id = '#{level}') or (a.table_id in (select table_id from oceanbase.__all_virtual_table where table_name ='#{level}'))) group by a.tenant_id, b.tenant_name, a.svr_ip, a.role order by 4,1;"
global: true
- version: "[4.0.0,*]"
steps:
- type: sql
sql: "select a.tenant_id, b.tenant_name, a.svr_ip, a.role, count(1) part_count from oceanbase.CDB_OB_TABLE_LOCATIONS a, oceanbase.__all_tenant b
where a.tenant_id = b.tenant_id and (('all'='#{level}') or (a.tenant_id = '#{level}') or (a.table_name ='#{level}')) group by a.tenant_id, b.tenant_name, a.svr_ip, a.role order by 4,1;"
global: true
19 changes: 19 additions & 0 deletions plugins/display/tasks/observer/lock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
info_en: "[lock]"
info_cn: "[库里所有表持有锁的信息]"
command: obdiag display scene run --scene=observer.lock
task:
- version: "[*,4.0.0]"
steps:
- type: sql
sql: "select a.tenant_id,a.svr_ip,a.table_id,c.table_name,a.session_id,substring_index(substring_index(a.trans_id,',',1),':',-1) hash,a.ctx_create_time,a.expired_time,count(*)
from oceanbase.__all_virtual_trans_lock_stat a
inner join oceanbase.__all_virtual_table c on a.table_id=c.table_id and c.table_name not like '__idx_%' and a.tenant_id>1000 group by a.tenant_id,a.trans_id,a.svr_ip,a.table_id,c.table_name,a.session_id,substring_index(substring_index(a.trans_id,',',1),':',-1),a.ctx_create_time,a.expired_time;"
global: true
- version: "[4.0.0,*]"
steps:
- type: sql
sql: "select a.tenant_id,a.svr_ip,a.ls_id,a.table_id,c.table_id table_actual_id,c.table_name,a.tablet_id,a.session_id,a.ctx_create_time
from oceanbase.__all_virtual_trans_lock_stat a
inner join oceanbase.__all_virtual_tablet_to_ls b on b.tablet_id=a.tablet_id and a.tenant_id=b.tenant_id and a.ls_id=b.ls_id
inner join oceanbase.__all_virtual_table c on b.table_id=c.table_id and c.table_name not like '__idx_%' where a.tenant_id>1000;"
global: true
20 changes: 20 additions & 0 deletions plugins/display/tasks/observer/locked.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
info_en: "[locked]"
info_cn: "[库里被阻塞会话的信息]"
command: obdiag display scene run --scene=observer.locked
Teingi marked this conversation as resolved.
Show resolved Hide resolved
task:
- version: "[*,4.0.0]"
steps:
- type: sql
sql: "select distinct a.svr_ip,c.table_id table_actual_id,c.table_name,a.session_id,a.block_session_id,a.lock_mode,a.type
from oceanbase.__all_virtual_lock_wait_stat a
left join oceanbase.__all_virtual_table c on a.table_id=c.table_id order by c.table_name;"
global: true
- version: "[4.0.0,*]"
steps:
- type: sql
sql: "select distinct a.tenant_id,a.svr_ip,c.table_id table_actual_id,c.table_name,a.tablet_id,a.session_id,a.block_session_id,a.trans_id,
a.holder_trans_id,a.lock_mode,a.type
from oceanbase.__all_virtual_lock_wait_stat a
left join oceanbase.__all_virtual_tablet_to_ls b on b.tablet_id=a.tablet_id and a.tenant_id=b.tenant_id and a.ls_id=b.ls_id
left join oceanbase.__all_virtual_table c on b.table_id=c.table_id order by c.table_name,a.tenant_id;"
global: true
19 changes: 19 additions & 0 deletions plugins/display/tasks/observer/locktab.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
info_en: "[locktab]"
info_cn: "[某张表上持有锁的信息]"
command: obdiag display scene run --scene=observer.locktab --env tablename=test
task:
- version: "[*,4.0.0]"
steps:
- type: sql
sql: "select * from (select a.tenant_id,a.svr_ip,a.table_id,c.table_name,a.session_id,substring_index(substring_index(a.trans_id,',',1),':',-1) hash,a.ctx_create_time,a.expired_time,timestampdiff(second,date_format(a.ctx_create_time,'%Y-%m-%d %T'),now()) wait_time_s
from oceanbase.__all_virtual_trans_lock_stat a
left join oceanbase.__all_virtual_table c on a.table_id=c.table_id ) t where t.table_name like '%#{tablename}%';"
global: true
- version: "[4.0.0,*]"
steps:
- type: sql
sql: "select * from (select a.tenant_id,a.svr_ip,a.ls_id,a.table_id,c.table_id table_actual_id,c.table_name,a.tablet_id,a.session_id,a.ctx_create_time,timestampdiff(second,date_format(a.ctx_create_time,'%Y-%m-%d %T'),now()) wait_time_s
from oceanbase.__all_virtual_trans_lock_stat a
left join oceanbase.__all_virtual_tablet_to_ls b on b.tablet_id=a.tablet_id
left join oceanbase.__all_virtual_table c on b.table_id=c.table_id) t where t.table_name like '%#{tablename}%';"
global: true
25 changes: 25 additions & 0 deletions plugins/display/tasks/observer/lvss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
info_en: "[lvss]"
info_cn: "[processlist实时会话信息汇总]"
command: obdiag display scene run --scene=observer.lvss
task:
- version: "[*,3.0.0.0]"
steps:
- type: sql
sql: " select a.db,a.tenant,a.user,b.svr_ip,ifnull(b.sql_id,''),avg(b.time),max(b.time),count(*),a.id,a.master_sessid from oceanbase.__all_virtual_processlist a
inner join oceanbase.__all_virtual_session_info b on a.id=b.id and a.svr_ip=b.svr_ip
inner join oceanbase.__all_tenant c on a.tenant=c.tenant_name and c.tenant_id>1000
where b.sql_id<>'' and a.state<>'SLEEP' group by a.db,a.tenant,a.user,a.svr_ip,b.sql_id order by count(*) desc limit 10; "
global: true
- type: sql
sql: " select user,svr_ip,replace(substr(info,1,40),char(10),'') as q_sql,avg(time),max(time),count(*),id from oceanbase.__all_virtual_processlist
where tenant in (select b.tenant_name from __all_tenant b where b.tenant_id>1000)
and state<>'SLEEP' group by user,svr_ip,substr(info,1,40) order by count(*) desc limit 10; "
global: true
- version: "[3.0.0.0,*]"
steps:
- type: sql
sql: "select tenant,user,svr_ip,ifnull(sql_id,''),avg(retry_cnt),avg(time),max(time),count(*),id from oceanbase.__all_virtual_processlist where tenant<>'sys' and sql_id<>'' group by user,svr_ip,sql_id order by count(*) desc limit 10; "
global: true
- type: sql
sql: "select tenant,user,svr_ip,substr(info,1,40) as q_sql,avg(retry_cnt),avg(time),max(time),count(*),id from oceanbase.__all_virtual_processlist where tenant<>'sys' and sql_id<>'' group by user,svr_ip,substr(info,1,40) order by count(*) desc limit 10; "
global: true
49 changes: 49 additions & 0 deletions plugins/display/tasks/observer/mem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
info_en: "[mem]"
info_cn: "[所有tenant的mermory信息]"
command: obdiag display scene run --scene=observer.mem
task:
- version: "[4.0.0.0,*]"
steps:
- type: sql
sql: " select NOW() 'chenck_time',b.tenant_id,b.tenant_name, a.SVR_IP ,
round(sum(case when a.STAT_ID='140003' then a.VALUE else 0 end)/1024/1024/1024,2) 'mem_usage/G',
round(sum(case when a.STAT_ID='140002' then a.VALUE else 0 end)/1024/1024/1024,2) 'mem_max/G' ,round(100*(sum(case when STAT_ID='140003' then a.VALUE else 0 end)/sum(case when STAT_ID='140002' then a.VALUE else 0 end)),2) 'mem_percent'
from oceanbase.gv$sysstat a inner join oceanbase.__all_tenant b on a.con_id = b.tenant_id where a.stat_id IN (140003,140002) and (a.con_id > 1000 or a.con_id = 1) and a.class < 1000
group by b.tenant_id,b.tenant_name, a.SVR_IP order by b.tenant_name,a.SVR_IP ; "
global: true
- type: sql
sql: " SELECT tenant_id, svr_ip
, round(ACTIVE_SPAN / 1024 / 1024/1024,2) AS active_gb
, round(freeze_trigger / 1024 / 1024/1024,2) AS freeze_trg_gb
, round(ACTIVE_SPAN / freeze_trigger*100,2) AS freeze_percent
, FREEZE_CNT
, round(MEMSTORE_USED /1024 / 1024/1024, 2) AS memstore_usage
, round(MEMSTORE_LIMIT / 1024 / 1024/1024, 2) AS memstore_total
,round(MEMSTORE_USED / MEMSTORE_LIMIT*100,2) as memstore_percent
FROM oceanbase.gv$ob_memstore
where tenant_id>1000 or tenant_id= 1
ORDER BY tenant_id, svr_ip desc; "
global: true

- version: "[*,4.0.0.0]"
steps:
- type: sql
sql: " select NOW() 'chenck_time',b.tenant_id,b.tenant_name, a.SVR_IP ,
round(sum(case when a.STAT_ID='140003' then a.VALUE else 0 end)/1024/1024/1024,2) 'mem_usage/G',
round(sum(case when a.STAT_ID='140002' then a.VALUE else 0 end)/1024/1024/1024,2) 'mem_max/G' ,round(100*(sum(case when STAT_ID='140003' then a.VALUE else 0 end)/sum(case when STAT_ID='140002' then a.VALUE else 0 end)),2) 'mem_percent'
from oceanbase.gv$sysstat a inner join oceanbase.__all_tenant b on a.con_id = b.tenant_id where a.stat_id IN (140003,140002) and (a.con_id > 1000 or a.con_id = 1) and a.class < 1000
group by b.tenant_id,b.tenant_name, a.SVR_IP order by b.tenant_name,a.SVR_IP ; "
global: true
- type: sql
sql: " SELECT tenant_id, ip
, round(active / 1024 / 1024) AS active_mb
, round(total / 1024 / 1024) AS total_mb
, round(freeze_trigger / 1024 / 1024) AS freeze_trg_mb
, round(mem_limit / 1024 / 1024) AS mem_limit_mb
, freeze_cnt, round(active / freeze_trigger, 2) AS freeze_pct
, round(total / mem_limit, 2) AS mem_usage
FROM oceanbase.gv$memstore
where tenant_id>1000 or tenant_id= 1
ORDER BY tenant_id, mem_usage desc; "
global: true

9 changes: 9 additions & 0 deletions plugins/display/tasks/observer/obtab.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
info_en: "[obtab]"
info_cn: "[ob内部表信息]"
command: obdiag display scene run --scene=observer.obtab --env tablename=test
task:
- version: "[*,*]"
steps:
- type: sql
sql: "SELECT distinct table_name FROM oceanbase.__all_virtual_table t1 JOIN oceanbase.__all_virtual_database t2 ON t2.database_id = t1.database_id JOIN oceanbase.__all_tenant t3 ON t3.tenant_id = t1.tenant_id WHERE tenant_name = 'sys' AND database_name = 'oceanbase' AND (table_name LIKE '__all%' OR table_name LIKE '__tenant%' OR table_name LIKE 'gv%' OR table_name LIKE 'v%' OR table_name LIKE 'dba%' OR table_name LIKE 'cdb%') and table_name like '%#{tablename}%' ORDER BY ORA_DECODE(SUBSTR(table_name, 1, 1), 'v', 3, 'g', 4, ORA_DECODE(SUBSTR(table_name, 3, 1), 'a', 2, 1)), table_name;"
global: true
25 changes: 25 additions & 0 deletions plugins/display/tasks/observer/splan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
info_en: "[splan]"
info_cn: "[执行记录信息]"
command: obdiag display scene run --scene=observer.splan --env sqlid=test
task:
- version: "[*,4.0.0.0]"
steps:
- type: sql
sql: "select database_name,svr_ip,plan_id,a.TENANT_ID,type,sql_id,substr(first_load_time,1,19) first_load_time,
substr(last_active_time,1,19) last_active_time,avg_exe_usec/1000 'avg_exe_usec(ms)',executions,elapsed_time/1000/1000 'elapsed_time(s)',
round(slowest_exe_usec/1000/1000,2) 'slowest_time(s)',substr(slowest_exe_time,1,19) slowest_exe_time,slow_count,ps_stmt_id,
rows_processed/executions rows,outline_id
from oceanbase.gv$plan_cache_plan_stat a,oceanbase.__all_virtual_database d
where sql_id='#{sqlid}' and d.database_id=db_id and d.tenant_id=a.tenant_id;"
global: true

- version: "[4.0.0.0,*]"
steps:
- type: sql
sql: "select database_name,svr_ip,plan_id,a.TENANT_ID,type,sql_id,substr(first_load_time,1,19) first_load_time,
substr(last_active_time,1,19) last_active_time,avg_exe_usec/1000 'avg_exe_usec(ms)',executions,elapsed_time/1000/1000 'elapsed_time(s)',
round(slowest_exe_usec/1000/1000,2) 'slowest_time(s)',substr(slowest_exe_time,1,19) slowest_exe_time,slow_count,ps_stmt_id,
rows_processed/executions rows,outline_id
from oceanbase.gv$ob_plan_cache_plan_stat a,oceanbase.__all_virtual_database d
where sql_id='#{sqlid}' and d.database_id=db_id and d.tenant_id=a.tenant_id;"
global: true
14 changes: 14 additions & 0 deletions plugins/display/tasks/observer/status.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
info_en: "[status]"
info_cn: "[server status信息]"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一条和obdiag display scene run --scene=observer.server_info 重复了,需要整合成一条

command: obdiag display scene run --scene=observer.status
task:
- version: "[*,*]"
steps:
- type: sql
sql: "select b.info cluster_name,a.svr_ip,a.with_rootserver rs,a.zone,
ora_decode(a.start_service_time,0,null,date_format(usec_to_time(a.start_service_time),'%Y-%m-%d %h:%i:%s')) start_service_time,
ora_decode(a.last_offline_time,0,null,date_format(usec_to_time(a.last_offline_time),'%Y-%m-%d %h:%i:%s')) last_offline_time,
ora_decode(a.stop_time,0,null,date_format(usec_to_time(a.stop_time),'%Y-%m-%d %h:%i:%s')) stop_time,
a.status,SUBSTR(a.build_version, 1, INSTR(build_version, '-') - 1) build_version
from oceanbase.__All_server a ,oceanbase.__all_zone b where b.name='cluster' order by a.zone,a.svr_ip; "
global: true
48 changes: 48 additions & 0 deletions plugins/display/tasks/observer/tabndv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
info_en: "[tabndv]"
info_cn: "[查询表ndv信息]"
command: obdiag display scene run --scene=observer.tabndv --env user_name=test --env table_name=test
task:
- version: "[*,4.0.0.0]"
steps:
- type: sql
sql: "select t.database_name,
t.table_name,
c.column_name,
(case c.data_type
when 22 then 'VARCHAR2' when 17 then 'DATE' when 15 then 'NUMBER' when 38 then 'TIMESTAMP' when 30 then 'CLOB/BLOB' when 23 then 'CHAR' when 42 then 'FLOAT' when 39 then 'RAW' when 44 then 'NCHAR' when 43 then 'NVARCHAR2' else c.data_type end) AS COLUMN_TYPE,
SUM(s.num_distinct) as NDV,
sum(s.num_null) as num_null
from oceanbase.gv$table t
inner join oceanbase.__all_virtual_column c on t.table_id = c.table_id
inner join oceanbase.__all_virtual_column_statistic s on t.table_id = s.table_id and c.column_id = s.column_id
where t.table_name = upper('#{table_name}')
and t.database_name = upper('#{user_name}')
group by t.database_name, t.table_name, c.column_name,c.data_type;"
global: true
- type: sql
sql: "select a.svr_ip,
c.database_name,
tb.table_name,b.part_id,
b.part_name,b.part_high_bound part_high_value,b.part_func_type,b.subpart_id,b.subpart_name,b.subpart_high_bound subpart_high_value,b.subpart_func_type,
a.row_count
from oceanbase.__all_virtual_table tb join
oceanbase.__all_virtual_partition_table a on a.table_id = tb.table_id join
oceanbase.__all_virtual_database c on c.database_id = tb.database_id left join
oceanbase.__all_virtual_partition_item b on a.partition_id = b.partition_id and a.table_id = b.table_id
where tb.table_name = upper('#{table_name}')
and c.database_name = upper('#{user_name}') and a.role=1 order by 4,8;"
global: true

- version: "[4.0.0.0,*]"
steps:
- type: sql
sql: "select
s.OWNER,s.TABLE_NAME,s.COLUMN_NAME,s.NUM_DISTINCT as ndv,s.NUM_NULLS,s.LAST_ANALYZED,(case c.data_type
when 22 then 'VARCHAR2' when 17 then 'DATE' when 15 then 'NUMBER' when 38 then 'TIMESTAMP' when 30 then 'CLOB/BLOB' when 23 then 'CHAR' when 42 then 'FLOAT' when 39 then 'RAW' when 44 then 'NCHAR' when 43 then 'NVARCHAR2' else c.data_type end) AS COLUMN_TYPE
from oceanbase.CDB_TAB_COL_STATISTICS s
inner join oceanbase.__all_database d on s.OWNER=d.database_name
inner join oceanbase.__all_virtual_table t on s.TABLE_NAME=t.TABLE_NAME and s.CON_ID=t.tenant_id and d.database_id=t.database_id
inner join oceanbase.__all_virtual_column c on t.table_id = c.table_id and c.COLUMN_NAME=s.COLUMN_NAME
where s.table_name = upper('{#table_name}')
and s.OWNER=upper('#{user_name}');"
global: true
9 changes: 9 additions & 0 deletions plugins/display/tasks/observer/tenant.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
info_en: "[tenant]"
info_cn: "[tenant信息]"
Teingi marked this conversation as resolved.
Show resolved Hide resolved
command: obdiag display scene run --scene=observer.tenant
task:
- version: "[*,*]"
steps:
- type: sql
sql: "select tenant_id,tenant_name,zone_list,primary_zone,status from oceanbase.__all_tenant;"
global: true
Loading
Loading