Skip to content

Commit

Permalink
update1113
Browse files Browse the repository at this point in the history
  • Loading branch information
jingyd66 committed Nov 13, 2024
1 parent a5bd8d9 commit e3592a2
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 36 deletions.
1 change: 1 addition & 0 deletions handler/display/step/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def execute(self):
table.add_row(row)
title = self.step.get("tittle")
if title is not None:
title = StringUtils.replace_parameters(formatted_title, self.env)
formatted_title = f"\n[obdiag display]: {title} "
self.stdio.print(formatted_title)
self.stdio.print(table)
Expand Down
2 changes: 1 addition & 1 deletion handler/display/tasks/observer/cluster_info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ task:
union all
select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"data_disk_in_use_per\" stat_name, concat(round(sum(data_disk_in_use/1024/1024/1024)/sum(data_disk_capacity/1024/1024/1024), 2)*100, '%') value from oceanbase.gv$ob_servers;"
global: true
- version: "[3.0.0.0, *]"
- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"cluster_name\" stat_name, cluster_name value from oceanbase.v$ob_cluster limit 1
Expand Down
33 changes: 33 additions & 0 deletions handler/display/tasks/observer/database_datasize.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
info_en: "[database data_size]"
info_cn: "[查看库占用磁盘大小]"
command: obdiag display scene run --scene=observer.database_datasize --env tenant_id=1006 --env database_name=test
task:
- version: "[4.0.0.0, *]"
steps:
- type: sql
sql: "select tenant_id,tenant_name,DATABASE_NAME,sum(data_size_in_GB) as data_size_in_GB from
(SELECT /*+ query_timeout(30000000) */ a.TENANT_ID, c.tenant_name, a.DATABASE_NAME, a.TABLE_NAME, a.TABLE_ID,
SUM(CASE WHEN b.nested_offset = 0 THEN IFNULL(b.data_block_count + b.index_block_count + b.linked_block_count, 0) * 2 * 1024 * 1024 ELSE IFNULL(b.size, 0) END ) /1024.0 /1024/1024 AS data_size_in_GB
FROM oceanbase.CDB_OB_TABLE_LOCATIONS a INNER JOIN oceanbase.__all_virtual_table_mgr b ON a.svr_ip = b.svr_ip
AND a.svr_port = b.svr_port AND a.tenant_id = b.tenant_id AND a.LS_ID = b.LS_ID AND a.TABLET_ID = b.TABLET_ID
inner join oceanbase.__all_tenant c on a.tenant_id=c.tenant_id WHERE a.role = 'LEADER'
AND c.tenant_id = {tenant_id} AND b.table_type >= 10 AND b.size > 0 AND a.TABLE_NAME NOT REGEXP '^__'
and a.database_name='{database_name}' GROUP BY a.TABLE_ID) group by database_name;"
global: true
- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
sql: "select a.tenant_id, b.database_name,SUM(a.data_size) / 1024 / 1024 / 1024 AS data_size_G,
SUM(a.required_size) / 1024 / 1024 / 1024 AS required_size_G from
oceanbase.__all_virtual_meta_table a inner join
(select a.* from
oceanbase.gv$table a
inner join
oceanbase.gv$database b
on a.database_id=b.database_id
where b.tenant_id={tenant_id} and b.database_name='{database_name}')b
on a.table_id=b.table_id
where a.role = 1
group by a.tenant_id, b.database_name;"
global: true

3 changes: 1 addition & 2 deletions handler/display/tasks/observer/event.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
info_en: "[event]"
info_cn: "[event信息]"
# command: obdiag display scene run --scene=observer.event --env db_connect='-h127.0.0.1 -P2881 -utest@test -p****** -Dtest'
command: obdiag display scene run --scene=observer.event --env tenant_name=test
task:
- version: "[4.0.0.0, *]"
Expand Down Expand Up @@ -43,7 +42,7 @@ task:
event_group) a, oceanbase.__all_tenant b
where a.tenant_id=b.tenant_id and b.tenant_name='{tenant_name}';"
global: true
- version: "[3.0.0.0, *]"
- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
sql: "select b.tenant_name,a.* from (SELECT
Expand Down
6 changes: 2 additions & 4 deletions handler/display/tasks/observer/plan.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
info_en: "[plan]"
info_cn: "[查看sql的执行计划]"
# command: obdiag display scene run --scene=observer.plan --env db_connect='-h127.0.0.1 -P2881 -utest@test -p****** -Dtest' --env sqlid=test
command: obdiag display scene run --scene=observer.plan --env tenant_name=test --env sqlid=test

task:
- version: "[4.0.0.0, *]"
steps:
- type: sql
#sql: "SELECT * FROM oceanbase.V$OB_PLAN_CACHE_PLAN_STAT where sql_id = '{sqlid}';"
sql: "SELECT a.* FROM oceanbase.V$OB_PLAN_CACHE_PLAN_STAT a left join oceanbase.__all_tenant b on a.tenant_id=b.tenant_id where b.tenant_name='{tenant_name}' and a.sql_id = '{sqlid}';"
sql: "SELECT a.* FROM oceanbase.GV$OB_PLAN_CACHE_PLAN_STAT a left join oceanbase.__all_tenant b on a.tenant_id=b.tenant_id where b.tenant_name='{tenant_name}' and a.sql_id = '{sqlid}';"
global: true
- version: "[3.0.0.0, *]"
- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
sql: "SELECT a.* FROM oceanbase.GV$plan_cache_plan_stat a left join oceanbase.__all_tenant b on a.tenant_id=b.tenant_id where b.tenant_name='{tenant_name}' and a.sql_id = '{sqlid}';"
Expand Down
3 changes: 1 addition & 2 deletions handler/display/tasks/observer/processlist.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
info_en: "[processlist]"
info_cn: "[查看processlist]"
# command: obdiag display scene run --scene=observer.processlist --env db_connect='-h127.0.0.1 -P2881 -utest@test -p****** -Dtest'
command: obdiag display scene run --scene=observer.processlist --env tenant_name=test
task:
- version: "[4.0.0.0, *]"
steps:
- type: sql
sql: "select * from oceanbase.gv$ob_processlist where tenant='{tenant_name}';"
global: true
- version: "[3.0.0.0, *]"
- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
sql: "select * from oceanbase.__all_virtual_processlist where tenant='{tenant_name}';"
Expand Down
2 changes: 1 addition & 1 deletion handler/display/tasks/observer/rs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ task:
- type: sql
sql: "select * from oceanbase.__all_rootservice_event_history order by 1 desc limit 10;"
global: true
- version: "[3.0.0.0, *]"
- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
sql: "show parameters like '%rootservice_list%';"
Expand Down
2 changes: 1 addition & 1 deletion handler/display/tasks/observer/server_info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ task:
- type: sql
sql: "SELECT /*+READ_CONSISTENCY(WEAK), QUERY_TIMEOUT(100000000)*/ zone, svr_ip, with_rootserver rs, case when start_service_time = 0 then NULL else CAST(usec_to_time(start_service_time) AS DATETIME) end start_service_time, case when stop_time = 0 then NULL else CAST(usec_to_time(stop_time) AS DATETIME) end stop_time, case when last_offline_time = 0 then NULL else CAST(usec_to_time(last_offline_time) AS DATETIME) end last_offline_time, status, SUBSTR(build_version, 1, INSTR(build_version, '-') - 1) build_version FROM oceanbase.__all_server order by zone, svr_ip;"
global: true
- version: "[3.0.0.0, *]"
- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
sql: "SELECT /*+READ_CONSISTENCY(WEAK), QUERY_TIMEOUT(100000000)*/ zone, svr_ip, with_rootserver rs, case when start_service_time = 0 then NULL else CAST(usec_to_time(start_service_time) AS DATETIME) end start_service_time, case when stop_time = 0 then NULL else CAST(usec_to_time(stop_time) AS DATETIME) end stop_time, case when last_offline_time = 0 then NULL else CAST(usec_to_time(last_offline_time) AS DATETIME) end last_offline_time, status, SUBSTR(build_version, 1, INSTR(build_version, '-') - 1) build_version FROM oceanbase.__all_server order by zone, svr_ip;"
Expand Down
3 changes: 1 addition & 2 deletions handler/display/tasks/observer/slowsql.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
info_en: "[slowsql]"
info_cn: "[查看慢sql]"
# command: obdiag display scene run --scene=observer.slowsql --env db_connect='-h127.0.0.1 -P2881 -utest@test -p****** -Dtest' --env mtime=10
command: obdiag display scene run --scene=observer.slowsql --env tenant_name=test --env mtime=10

task:
Expand Down Expand Up @@ -38,7 +37,7 @@ task:
elapsed_time DESC
LIMIT 10;"
global: true
- version: "[3.0.0.0, *]"
- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
sql: "SELECT
Expand Down
43 changes: 43 additions & 0 deletions handler/display/tasks/observer/table_datasize.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
info_en: "[table data_size]"
info_cn: "[查看表占用磁盘大小]"
command: obdiag display scene run --scene=observer.table_datasize --env tenant_id=1006 --env database_name=test --env table_name=ttt2
task:
- version: "[4.0.0.0, *]"
steps:
- type: sql
sql: "SELECT /*+ query_timeout(30000000) */ a.TENANT_ID, c.tenant_name, a.DATABASE_NAME, a.TABLE_NAME, a.TABLE_ID,
SUM(CASE WHEN b.nested_offset = 0 THEN IFNULL(b.data_block_count + b.index_block_count + b.linked_block_count, 0) * 2 * 1024 * 1024 ELSE IFNULL(b.size, 0) END ) / 1024.0 / 1024 / 1024 AS data_size_in_GB
FROM oceanbase.CDB_OB_TABLE_LOCATIONS a INNER JOIN oceanbase.__all_virtual_table_mgr b ON a.svr_ip = b.svr_ip AND a.svr_port = b.svr_port AND a.tenant_id = b.tenant_id AND a.LS_ID = b.LS_ID AND a.TABLET_ID = b.TABLET_ID
inner join oceanbase.__all_tenant c on a.tenant_id=c.tenant_id
WHERE a.role = 'LEADER' AND c.tenant_id = {tenant_id}
AND b.table_type >= 10 AND b.size > 0
AND a.TABLE_NAME NOT REGEXP '^__'
and a.database_name='{database_name}'
and a.TABLE_NAME='{table_name}' GROUP BY a.TABLE_ID;"
global: true

- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
sql: "SELECT
a.tenant_id,
b.table_name,
SUM(a.data_size) / 1024 / 1024 / 1024 AS data_size_G,
SUM(a.required_size) / 1024 / 1024 / 1024 AS required_size_G
FROM
oceanbase.__all_virtual_meta_table a
JOIN
(select a.* from
oceanbase.gv$table a
inner join
oceanbase.gv$database b
on a.database_id=b.database_id
where b.tenant_id={tenant_id} and b.database_name='{database_name}' and a.table_name='{table_name}') b
ON
a.table_id = b.table_id
WHERE
a.role = 1
group by a.tenant_id, b.table_name;"
global: true


2 changes: 1 addition & 1 deletion handler/display/tasks/observer/tenant_info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ task:
- type: sql
sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ dot.tenant_name, dou.zone, dou.svr_ip observer, cotl.replica_type, dou.max_cpu cpu, concat(round(dou.memory_size/1024/1024/1024,0), 'G') memory_size, concat(round(dou.log_disk_size/1024/1024/1024,0), 'G') log_disk_size, concat(round(sum(cotr.data_size)/1024/1024/1024, 2), 'G') data_size, concat(round(sum(cotr.required_size)/1024/1024/1024, 2), 'G') required_size, dot.unit_num from oceanbase.dba_ob_tenants dot, oceanbase.dba_ob_units dou, oceanbase.cdb_ob_table_locations cotl, oceanbase.cdb_ob_tablet_replicas cotr where tenant_name = '{tenant_name}' and dot.tenant_id = dou.tenant_id and dot.tenant_id = cotl.tenant_id and dou.svr_ip = cotl.svr_ip and cotl.tenant_id = cotr.tenant_id and cotl.svr_ip = cotr.svr_ip and cotl.ls_id = cotr.ls_id and cotl.tablet_id = cotr.tablet_id group by dot.tenant_id, cotl.svr_ip order by dot.tenant_id, zone, cotl.svr_ip;"
global: true
- version: "[3.0.0.0, *]"
- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"tenant_name\" stat_name, tenant_name value from oceanbase.__all_tenant where tenant_name='{tenant_name}'
Expand Down
25 changes: 5 additions & 20 deletions handler/display/tasks/observer/topsql.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
info_en: "[topsql info]"
info_cn: "[查看topsql]"
# command: obdiag display scene run --scene=observer.topsql --env db_connect='-h127.0.0.1 -P2881 -utest@test -p****** -Dtest' --env mtime=10
command: obdiag display scene run --scene=observer.tenant_info --env tenant_name=test --env mtime=10
command: obdiag display scene run --scene=observer.topsql --env tenant_name=test --env mtime=10

task:
# - version: "[4.0.0.0, *]"
# steps:
# - type: sql
# sql: "select tenant_name, SQL_ID, count(*) as QPS, avg(t1.ELAPSED_TIME) as ELAPSED_TIME_AVG, substr(query_sql,1,50)
# from oceanbase.gv$ob_sql_audit t1
# where
# IS_EXECUTOR_RPC = 0
# and request_time > (time_to_usec(now()) - {mtime} * 60 * 1000000)
# and request_time < time_to_usec(now())
# and length(query_sql) > 0
# and IS_INNER_SQL = 0
# and length(sql_id) > 0
# group by t1.sql_id order by QPS desc limit 10;"
# global: true
- version: "[4.0.0.0, *]"
steps:
- type: sql
tittle: Top SQL time consumption in the last {mtime} minutes
sql: "select /*+read_consistency(weak),query_timeout(100000000)*/ tenant_name,SQL_ID,QUERY_SQL,count(1),avg(ELAPSED_TIME),avg(EXECUTE_TIME),avg(QUEUE_TIME),avg(AFFECTED_ROWS),avg(GET_PLAN_TIME)
from gv$ob_sql_audit
from oceanbase.gv$ob_sql_audit
where time_to_usec(now(6))-request_time <{mtime}*60*1000000
and tenant_name='{tenant_name}'
group by SQL_ID order by avg(ELAPSED_TIME)*count(1) desc limit 20;"
Expand All @@ -50,7 +35,7 @@ task:
global: true
- type: sql
tittle: Check whether there have been a large number of unreasonable remote execution requests for SQL executions in the past {mtime} minutes
sql: "select/ *+read_consistency(weak),query_timeout(100000000)*/ count(*), plan_type
sql: "select / *+read_consistency(weak),query_timeout(100000000)*/ count(*), plan_type
from oceanbase.gv$ob_sql_audit
where tenant_name ='{tenant_name}'
and IS_EXECUTOR_RPC = 0
Expand All @@ -67,12 +52,12 @@ task:
and request_time < time_to_usec(now())
group by sql_id limit 20;"
global: true
- version: "[3.0.0.0, *]"
- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
tittle: Top SQL time consumption in the last {mtime} minutes
sql: "select /*+read_consistency(weak),query_timeout(100000000)*/ tenant_name,SQL_ID,QUERY_SQL,count(1),avg(ELAPSED_TIME),avg(EXECUTE_TIME),avg(QUEUE_TIME),avg(AFFECTED_ROWS),avg(GET_PLAN_TIME)
from gv$sql_audit
from oceanbase.gv$sql_audit
where time_to_usec(now(6))-request_time <{mtime}*60*1000000
and tenant_name='{tenant_name}'
group by SQL_ID order by avg(ELAPSED_TIME)*count(1) desc limit 20 ;"
Expand Down
2 changes: 1 addition & 1 deletion handler/display/tasks/observer/unit_info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ task:
svr_port,
unit_id;"
global: true
- version: "[3.0.0.0, *]"
- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
sql: "SELECT
Expand Down
2 changes: 1 addition & 1 deletion handler/display/tasks/observer/zone_info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ task:
- type: sql
sql: "select * from oceanbase.dba_ob_zones;"
global: true
- version: "[3.0.0.0, *]"
- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
sql: "select * from oceanbase.__all_zone;"
Expand Down

0 comments on commit e3592a2

Please sign in to comment.