diff --git a/handler/display/step/sql.py b/handler/display/step/sql.py index 2b166598..11bb0103 100644 --- a/handler/display/step/sql.py +++ b/handler/display/step/sql.py @@ -63,6 +63,10 @@ def execute(self): table = PrettyTable(columns) for row in data: table.add_row(row) + title = self.step.get("tittle") + if title is not None: + formatted_title = f"\n[obdiag display]: {title} " + self.stdio.print(formatted_title) self.stdio.print(table) except Exception as e: self.stdio.error("StepSQLHandler execute Exception: {0}".format(e).strip()) diff --git a/handler/display/tasks/observer/cluster_info.yaml b/handler/display/tasks/observer/cluster_info.yaml index 386b9495..e23c06fa 100644 --- a/handler/display/tasks/observer/cluster_info.yaml +++ b/handler/display/tasks/observer/cluster_info.yaml @@ -53,3 +53,51 @@ 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, *]" + 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 + union all + (select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"cluster_id\" stat_name, cluster_id value from oceanbase.v$ob_cluster limit 1) + union all + (select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"version\" stat_name, build_version value from oceanbase.__all_server limit 1) + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"observers\" stat_name, count(*) value from oceanbase.__all_server + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"zones\" stat_name, count(distinct zone) value from oceanbase.__all_server + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"tenants\" stat_name, count(*) value from oceanbase.__all_tenant + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"rs_list\" stat_name, value from oceanbase.__all_sys_parameter where name ='rootservice_list' + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"config_url\" stat_name, value from oceanbase.__all_sys_parameter where name ='obconfig_url' + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"memory_limit\" stat_name, concat(sum(round((memory_limit+value)/1024/1024/1024,2)),'G') value from (select concat(round(a.mem_capacity/1024/1024/1024,2),'G') + mem_capacity,a.mem_capacity memory_limit, + case when right(b.value,1)='G' then substring(b.value,1,position('G' in b.value)-1)*1024*1024*1024 + when right(b.value,1)='M' then substring(b.value,1,position('G' in b.value)-1)*1024*1024 + end as value,a.svr_ip + from oceanbase.__all_virtual_server_stat a + inner join oceanbase.__all_virtual_sys_parameter_stat b on a.svr_ip=b.svr_ip and b.name='system_memory') + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"data_disk_allocated\" stat_name, concat(sum(TRUNCATE(disk_assigned/1024/1024/1024,0)),'G') value from oceanbase.__all_virtual_server_stat + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"cpu_total\" stat_name, sum(cpu_capacity) value from oceanbase.__all_virtual_server_stat + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"cpu_assigned\" stat_name, sum(cpu_assigned) value from oceanbase.__all_virtual_server_stat + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"cpu_assinged_per\" stat_name, concat(round(sum(cpu_assigned)/sum(cpu_capacity), 2)*100, '%') value from oceanbase.__all_virtual_server_stat + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"memory_total\" stat_name, concat(sum(TRUNCATE(mem_total/1024/1024/1024,0)),'G') value from oceanbase.__all_virtual_server_stat + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"memory_assigned\" stat_name, concat(sum(TRUNCATE(mem_assigned/1024/1024/1024,0)),'G') value from oceanbase.__all_virtual_server_stat + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"memory_assigned_per\" stat_name, concat(round(sum(mem_assigned/1024/1024/1024)/sum(mem_capacity/1024/1024/1024), 2)*100, '%') value from oceanbase.__all_virtual_server_stat + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"data_disk_total\" stat_name, concat(sum(TRUNCATE(disk_total/1024/1024/1024,0)),'G') value from oceanbase.__all_virtual_server_stat + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"data_disk_in_use\" stat_name, concat(sum(TRUNCATE(disk_in_use/1024/1024/1024,0)),'G') value from oceanbase.__all_virtual_server_stat + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"data_disk_in_use_per\" stat_name, concat(round(sum(disk_in_use/1024/1024/1024)/sum(disk_total/1024/1024/1024), 2)*100, '%') value from oceanbase.__all_virtual_server_stat;" + global: true + \ No newline at end of file diff --git a/handler/display/tasks/observer/database_datasize.yml b/handler/display/tasks/observer/database_datasize.yml new file mode 100644 index 00000000..b13971c6 --- /dev/null +++ b/handler/display/tasks/observer/database_datasize.yml @@ -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, *]" + 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 + __all_virtual_meta_table a inner join + (select a.* from + gv$table a + inner join + 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 + diff --git a/handler/display/tasks/observer/event.yaml b/handler/display/tasks/observer/event.yaml index 45c8bf91..219bda3d 100644 --- a/handler/display/tasks/observer/event.yaml +++ b/handler/display/tasks/observer/event.yaml @@ -1,11 +1,12 @@ 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 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, *]" steps: - type: sql - sql: "SELECT + sql: "select b.tenant_name,a.* from (SELECT /* MONITOR_AGENT */ con_id tenant_id, CASE @@ -27,9 +28,9 @@ task: SUM(total_waits) AS total_waits, SUM(time_waited_micro / 1000000) AS time_waited FROM - oceanbase.v$system_event + oceanbase.gv$system_event WHERE - oceanbase.v$system_event.wait_class <> 'IDLE' + oceanbase.gv$system_event.wait_class <> 'IDLE' AND ( con_id > 1000 OR con_id = 1 @@ -39,5 +40,46 @@ task: event_group ORDER BY tenant_id, - event_group;" + 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, *]" + steps: + - type: sql + sql: "select b.tenant_name,a.* from (SELECT + /* MONITOR_AGENT */ + con_id tenant_id, + CASE + WHEN event_id = 10000 THEN 'INTERNAL' + WHEN event_id = 13000 THEN 'SYNC_RPC' + WHEN event_id = 14003 THEN 'ROW_LOCK_WAIT' + WHEN ( + event_id >= 10001 + AND event_id <= 11006 + ) + OR ( + event_id >= 11008 + AND event_id <= 11011 + ) THEN 'IO' + WHEN event LIKE 'latch:%' THEN 'LATCH' + ELSE 'OTHER' + END + event_group, + SUM(total_waits) AS total_waits, + SUM(time_waited_micro / 1000000) AS time_waited + FROM + oceanbase.gv$system_event + WHERE + oceanbase.gv$system_event.wait_class <> 'IDLE' + AND ( + con_id > 1000 + OR con_id = 1 + ) + GROUP BY + tenant_id, + event_group + ORDER BY + tenant_id, + event_group) a, oceanbase.__all_tenant b + where a.tenant_id=b.tenant_id and b.tenant_name='{tenant_name}';" + global: true \ No newline at end of file diff --git a/handler/display/tasks/observer/plan.yaml b/handler/display/tasks/observer/plan.yaml index c68d44a7..18dd7bb6 100644 --- a/handler/display/tasks/observer/plan.yaml +++ b/handler/display/tasks/observer/plan.yaml @@ -1,9 +1,17 @@ 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 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}';" - global: true \ No newline at end of file + #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}';" + global: true + - version: "[3.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}';" + global: true \ No newline at end of file diff --git a/handler/display/tasks/observer/processlist.yaml b/handler/display/tasks/observer/processlist.yaml index 3a93179c..e4bb7d8f 100644 --- a/handler/display/tasks/observer/processlist.yaml +++ b/handler/display/tasks/observer/processlist.yaml @@ -1,9 +1,16 @@ 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 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;" + sql: "select * from oceanbase.gv$ob_processlist where tenant='{tenant_name}';" global: true + - version: "[3.0.0.0, *]" + steps: + - type: sql + sql: "select * from oceanbase.__all_virtual_processlist where tenant='{tenant_name}';" + global: true + diff --git a/handler/display/tasks/observer/rs.yaml b/handler/display/tasks/observer/rs.yaml index 662b1bec..ce396f52 100644 --- a/handler/display/tasks/observer/rs.yaml +++ b/handler/display/tasks/observer/rs.yaml @@ -3,6 +3,14 @@ info_cn: "[查看rootservice信息]" command: obdiag display scene run --scene=observer.rs task: - version: "[4.0.0.0, *]" + steps: + - type: sql + sql: "show parameters like '%rootservice_list%';" + global: true + - type: sql + sql: "select * from oceanbase.__all_rootservice_event_history order by 1 desc limit 10;" + global: true + - version: "[3.0.0.0, *]" steps: - type: sql sql: "show parameters like '%rootservice_list%';" diff --git a/handler/display/tasks/observer/server_info.yaml b/handler/display/tasks/observer/server_info.yaml index bc2b6463..83c432ad 100644 --- a/handler/display/tasks/observer/server_info.yaml +++ b/handler/display/tasks/observer/server_info.yaml @@ -5,5 +5,10 @@ task: - version: "[4.0.0.0, *]" steps: - type: sql - sql: "select * from oceanbase.__all_server;" + 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, *]" + 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;" global: true diff --git a/handler/display/tasks/observer/slowsql.yaml b/handler/display/tasks/observer/slowsql.yaml index 005e84d5..213bed73 100644 --- a/handler/display/tasks/observer/slowsql.yaml +++ b/handler/display/tasks/observer/slowsql.yaml @@ -1,6 +1,8 @@ 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 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: - version: "[4.0.0.0, *]" steps: @@ -28,10 +30,45 @@ task: FROM oceanbase.gv$ob_sql_audit WHERE - 1 = 1 + tenant_name='{tenant_name}' + AND 1 = 1 AND request_time > (time_to_usec(now()) - {mtime} * 60 * 1000000) AND is_inner_sql = 0 ORDER BY elapsed_time DESC LIMIT 10;" global: true + - version: "[3.0.0.0, *]" + steps: + - type: sql + sql: "SELECT + /*+READ_CONSISTENCY(WEAK), QUERY_TIMEOUT(100000000)*/ + tenant_id, + tenant_name, + user_name, + db_name, + svr_ip, + plan_id, + plan_type, + affected_rows, + return_rows, + elapsed_time, + execute_time, + sql_id, + usec_to_time(request_time), + substr( + replace(query_sql, '\n', ' '), + 1, + 100 + ) + FROM + oceanbase.gv$sql_audit + WHERE + tenant_name='{tenant_name}' + AND 1 = 1 + AND request_time > (time_to_usec(now()) - {mtime} * 60 * 1000000) + AND is_inner_sql = 0 + ORDER BY + elapsed_time DESC + LIMIT 10;" + global: true \ No newline at end of file diff --git a/handler/display/tasks/observer/table_datasize.yml b/handler/display/tasks/observer/table_datasize.yml new file mode 100644 index 00000000..6dbc84fd --- /dev/null +++ b/handler/display/tasks/observer/table_datasize.yml @@ -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, *]" + 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 + __all_virtual_meta_table a + JOIN + (select a.* from + gv$table a + inner join + 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 + + diff --git a/handler/display/tasks/observer/tenant_info.yaml b/handler/display/tasks/observer/tenant_info.yaml index d073b009..e0a3f081 100644 --- a/handler/display/tasks/observer/tenant_info.yaml +++ b/handler/display/tasks/observer/tenant_info.yaml @@ -9,4 +9,80 @@ task: global: true - 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, *]" + 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}' + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"tenant_id\" stat_name, tenant_id value from oceanbase.__all_tenant where tenant_name='{tenant_name}' + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"primary_zone\" stat_name, primary_zone value from oceanbase.__all_tenant where tenant_name='{tenant_name}' + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"locality\" stat_name, locality value from oceanbase.__all_tenant where tenant_name='{tenant_name}' + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"status\" stat_name, status value from oceanbase.__all_tenant where tenant_name='{tenant_name}' + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"unit_count\" stat_name, a.unit_count as value + from oceanbase.__all_resource_pool a ,oceanbase.__all_tenant b where a.tenant_id=b.tenant_id and b.tenant_name='{tenant_name}' + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"ip_list\" stat_name, + GROUP_CONCAT(DISTINCT b.svr_ip) value + FROM + oceanbase.__all_resource_pool a + JOIN + oceanbase.__all_unit b ON a.resource_pool_id = b.resource_pool_id + JOIN + oceanbase.__all_tenant c ON a.tenant_id = c.tenant_id + WHERE c.tenant_name='{tenant_name}' + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"min_cpu\" stat_name,min_cpu value + from oceanbase.gv$unit where tenant_name='{tenant_name}' group by unit_config_id + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"max_cpu\" stat_name,max_cpu value + from oceanbase.gv$unit where tenant_name='{tenant_name}' group by unit_config_id + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"min_memory\" stat_name,concat(TRUNCATE(min_memory/1024/1024/1024,0),'G') as value + from oceanbase.gv$unit where tenant_name='{tenant_name}' group by unit_config_id + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"max_memory\" stat_name,concat(TRUNCATE(max_memory/1024/1024/1024,0),'G') as value + from oceanbase.gv$unit where tenant_name='{tenant_name}' group by unit_config_id + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"cpu_use_total\" stat_name,round(SUM(a.value)/100, 2) as value + from oceanbase.gv$sysstat a, oceanbase.__all_tenant b + where name = 'cpu usage' and a.con_id = b.tenant_id and b.tenant_name ='{tenant_name}' + GROUP by b.tenant_id, b.tenant_name + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"cpu_use_avage\" stat_name,round(SUM(s.value)/100/3/s.unit_count, 2) as value + from (select a.*,b.unit_count from oceanbase.gv$sysstat a,oceanbase.__all_resource_pool b where a.CON_ID=b.tenant_id and a.STAT_ID ='140006' and a.CON_ID>1000) s, oceanbase.__all_tenant b + where s.con_id = b.tenant_id and b.tenant_name ='{tenant_name}' + GROUP by b.tenant_id, b.tenant_name + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"cpu_use_per\" stat_name,concat(round(100*(sum(case when STAT_ID='140006' then s.VALUE else 0 end)/sum(case when STAT_ID='140005' then s.VALUE else 0 end)),2),'%') as value + from oceanbase.gv$sysstat s left join oceanbase.__all_tenant t on s.CON_ID=t.tenant_id + where s.STAT_ID in(140005,140006) and s.CON_ID>1000 and tenant_name='{tenant_name}' + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"memory_use_total\" stat_name,concat(round(SUM(a.value)/1024/1024/1024, 2),'G') as value + from oceanbase.gv$sysstat a, oceanbase.__all_tenant b + where name = 'memory usage' and a.con_id = b.tenant_id and b.tenant_name ='{tenant_name}' + GROUP by b.tenant_id, b.tenant_name + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"memory_use_avg\" stat_name,concat(round(SUM(s.value)/1024/1024/1024/3/s.unit_count, 2),'G') as value + from (select a.*,b.unit_count from oceanbase.gv$sysstat a,oceanbase.__all_resource_pool b where a.CON_ID=b.tenant_id and a.STAT_ID ='140003' and a.CON_ID>1000) s, oceanbase.__all_tenant b + where s.con_id = b.tenant_id and b.tenant_name ='{tenant_name}' + GROUP by b.tenant_id, b.tenant_name + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"memory_use_per\" stat_name,concat(round(100*(sum(case when STAT_ID='140003' then s.VALUE else 0 end)/sum(case when STAT_ID='140002' then s.VALUE else 0 end)),2),'%') as value + from oceanbase.gv$sysstat s left join oceanbase.__all_tenant t on s.CON_ID=t.tenant_id + where s.STAT_ID in(140003,140002) and s.CON_ID>1000 and tenant_name='{tenant_name}' + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"disk_use_total\" stat_name,concat(ROUND(SUM(a.required_size)/1024/1024/1024, 2),'G') as value + from oceanbase.gv$partition a, oceanbase.__all_tenant b + where a.tenant_id = b.tenant_id and b.tenant_name ='{tenant_name}' + group by a.tenant_id , b.tenant_name + union all + select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ \"disk_use_avg\" stat_name,concat(ROUND(SUM(a.required_size)/1024/1024/1024/count(distinct a.svr_ip), 2),'G') as value + from oceanbase.gv$partition a, oceanbase.__all_tenant b + where a.tenant_id = b.tenant_id and b.tenant_name ='{tenant_name}' + group by a.tenant_id , b.tenant_name" global: true \ No newline at end of file diff --git a/handler/display/tasks/observer/unit_info.yaml b/handler/display/tasks/observer/unit_info.yaml index 82c6cdac..1db17166 100644 --- a/handler/display/tasks/observer/unit_info.yaml +++ b/handler/display/tasks/observer/unit_info.yaml @@ -46,5 +46,47 @@ task: svr_port, unit_id;" global: true + - version: "[3.0.0.0, *]" + steps: + - type: sql + sql: "SELECT + unit_config_id, + name, + max_cpu, + min_cpu, + round(max_memory / 1024 / 1024 / 1024) max_memory_gb, + round(min_memory / 1024 / 1024 / 1024) min_memory_gb, + round(max_disk_size / 1024 / 1024 / 1024) max_disk_size_gb, + max_iops, + min_iops, + max_session_num + FROM + oceanbase.__all_unit_config + ORDER BY unit_config_id;" + global: true + - type: sql + sql: "SELECT + tenant_name, + tenant_id, + svr_ip, + svr_port, + zone, + unit_config_id, + max_cpu, + min_cpu, + round(max_memory / 1024 / 1024 / 1024) max_memory_gb, + round(min_memory / 1024 / 1024 / 1024) min_memory_gb, + round(max_disk_size / 1024 / 1024 / 1024) max_disk_size_gb, + max_iops, + min_iops, + max_session_num + FROM + oceanbase.gv$unit + ORDER BY + tenant_id, + svr_ip, + svr_port;" + global: true + diff --git a/handler/display/tasks/observer/zone_info.yaml b/handler/display/tasks/observer/zone_info.yaml index e8e203a2..aadc809c 100644 --- a/handler/display/tasks/observer/zone_info.yaml +++ b/handler/display/tasks/observer/zone_info.yaml @@ -6,4 +6,9 @@ task: steps: - type: sql sql: "select * from oceanbase.dba_ob_zones;" + global: true + - version: "[3.0.0.0, *]" + steps: + - type: sql + sql: "select * from oceanbase.__all_zone;" global: true \ No newline at end of file