diff --git a/plugins/display/tasks/observer/database_datasize.yaml b/plugins/display/tasks/observer/database_datasize.yaml index b3049588..97fda7b9 100644 --- a/plugins/display/tasks/observer/database_datasize.yaml +++ b/plugins/display/tasks/observer/database_datasize.yaml @@ -12,8 +12,8 @@ task: 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;" + 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: @@ -27,7 +27,7 @@ task: 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 + 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;" diff --git a/plugins/display/tasks/observer/event.yaml b/plugins/display/tasks/observer/event.yaml index ddf91417..20cec922 100644 --- a/plugins/display/tasks/observer/event.yaml +++ b/plugins/display/tasks/observer/event.yaml @@ -40,7 +40,7 @@ task: ORDER BY tenant_id, event_group) a, oceanbase.__all_tenant b - where a.tenant_id=b.tenant_id and b.tenant_name='{tenant_name}';" + where a.tenant_id=b.tenant_id and b.tenant_name='#{tenant_name}';" global: true - version: "[3.0.0.0, 4.0.0.0]" steps: @@ -80,5 +80,5 @@ task: ORDER BY tenant_id, event_group) a, oceanbase.__all_tenant b - where a.tenant_id=b.tenant_id and b.tenant_name='{tenant_name}';" + where a.tenant_id=b.tenant_id and b.tenant_name='#{tenant_name}';" global: true \ No newline at end of file diff --git a/plugins/display/tasks/observer/plan.yaml b/plugins/display/tasks/observer/plan.yaml index 83df3ec9..65ae4929 100644 --- a/plugins/display/tasks/observer/plan.yaml +++ b/plugins/display/tasks/observer/plan.yaml @@ -6,10 +6,10 @@ task: - version: "[4.0.0.0, *]" steps: - type: sql - 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}';" + 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, 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}';" + 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/plugins/display/tasks/observer/processlist.yaml b/plugins/display/tasks/observer/processlist.yaml index acea5951..575bbe02 100644 --- a/plugins/display/tasks/observer/processlist.yaml +++ b/plugins/display/tasks/observer/processlist.yaml @@ -5,11 +5,11 @@ task: - version: "[4.0.0.0, *]" steps: - type: sql - sql: "select * from oceanbase.gv$ob_processlist where tenant='{tenant_name}';" + sql: "select * from oceanbase.gv$ob_processlist where tenant='#{tenant_name}';" global: true - version: "[3.0.0.0, 4.0.0.0]" steps: - type: sql - sql: "select * from oceanbase.__all_virtual_processlist where tenant='{tenant_name}';" + sql: "select * from oceanbase.__all_virtual_processlist where tenant='#{tenant_name}';" global: true diff --git a/plugins/display/tasks/observer/slowsql.yaml b/plugins/display/tasks/observer/slowsql.yaml index 0f77c012..ba0fc2ad 100644 --- a/plugins/display/tasks/observer/slowsql.yaml +++ b/plugins/display/tasks/observer/slowsql.yaml @@ -29,9 +29,9 @@ task: FROM oceanbase.gv$ob_sql_audit WHERE - tenant_name='{tenant_name}' + tenant_name='#{tenant_name}' AND 1 = 1 - AND request_time > (time_to_usec(now()) - {mtime} * 60 * 1000000) + AND request_time > (time_to_usec(now()) - #{mtime} * 60 * 1000000) AND is_inner_sql = 0 ORDER BY elapsed_time DESC @@ -63,9 +63,9 @@ task: FROM oceanbase.gv$sql_audit WHERE - tenant_name='{tenant_name}' + tenant_name='#{tenant_name}' AND 1 = 1 - AND request_time > (time_to_usec(now()) - {mtime} * 60 * 1000000) + AND request_time > (time_to_usec(now()) - #{mtime} * 60 * 1000000) AND is_inner_sql = 0 ORDER BY elapsed_time DESC diff --git a/plugins/display/tasks/observer/table_datasize.yaml b/plugins/display/tasks/observer/table_datasize.yaml index 70d3801b..2399d43f 100644 --- a/plugins/display/tasks/observer/table_datasize.yaml +++ b/plugins/display/tasks/observer/table_datasize.yaml @@ -10,11 +10,11 @@ task: 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 ) AS data_size_in_B 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} + 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;" + 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]" @@ -33,7 +33,7 @@ task: 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 + 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 diff --git a/plugins/display/tasks/observer/table_info.yaml b/plugins/display/tasks/observer/table_info.yaml index c66db392..2a85c8ca 100644 --- a/plugins/display/tasks/observer/table_info.yaml +++ b/plugins/display/tasks/observer/table_info.yaml @@ -5,10 +5,10 @@ task: - version: "[4.0.0.0, *]" steps: - type: sql - sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ table_schema, table_name, table_type, engine, row_format, table_rows, avg_row_length, table_collation from information_schema.tables where table_name = '{table_name}' and table_schema = '{database_name}';" + sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ table_schema, table_name, table_type, engine, row_format, table_rows, avg_row_length, table_collation from information_schema.tables where table_name = '#{table_name}' and table_schema = '#{database_name}';" global: true - type: sql - sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ dotl.database_name, dotl.table_name, dotl.ls_id, dotl.zone, dotl.svr_ip, dotl.svr_port, dotl.role, dotl.replica_type from oceanbase.dba_ob_table_locations dotl where dotl.table_name = '{table_name}' and dotl.database_name = '{database_name}';" + sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ dotl.database_name, dotl.table_name, dotl.ls_id, dotl.zone, dotl.svr_ip, dotl.svr_port, dotl.role, dotl.replica_type from oceanbase.dba_ob_table_locations dotl where dotl.table_name = '#{table_name}' and dotl.database_name = '#{database_name}';" global: true - type: sql sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ dotl.database_name, @@ -25,8 +25,8 @@ task: and dotl.svr_port = dotr.svr_port and dotl.ls_id = dotr.ls_id and dotl.role = 'leader' - and dotl.table_name = '{table_name}' - and dotl.database_name = '{database_name}' + and dotl.table_name = '#{table_name}' + and dotl.database_name = '#{database_name}' group by dotl.table_name union all select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ dotl.database_name, @@ -48,8 +48,8 @@ task: and dotl.tablet_id = dotr.tablet_id and dotl.role = 'leader' and dotl.table_type = 'INDEX' - and dotl2.table_name = '{table_name}' - and dotl.database_name = '{database_name}' + and dotl2.table_name = '#{table_name}' + and dotl.database_name = '#{database_name}' group by dotl.index_name union all select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ dotl.database_name, @@ -71,7 +71,7 @@ task: and dotl.tablet_id = dotr.tablet_id and dotl.role = 'leader' and dotl.table_type = 'LOB AUX TABLE' - and dotl2.table_name = '{table_name}' - and dotl.database_name = '{database_name}' + and dotl2.table_name = '#{table_name}' + and dotl.database_name = '#{database_name}' group by dotl.table_name;" global: true diff --git a/plugins/display/tasks/observer/tenant_info.yaml b/plugins/display/tasks/observer/tenant_info.yaml index a9c9c5c9..fa686012 100644 --- a/plugins/display/tasks/observer/tenant_info.yaml +++ b/plugins/display/tasks/observer/tenant_info.yaml @@ -5,26 +5,26 @@ task: - version: "[4.0.0.0, *]" steps: - type: sql - sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ tenant_name, tenant_type, primary_zone, locality, tenant_role from oceanbase.dba_ob_tenants where tenant_name = '{tenant_name}' and tenant_type in ('SYS','USER');" + sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ tenant_name, tenant_type, primary_zone, locality, tenant_role from oceanbase.dba_ob_tenants where tenant_name = '#{tenant_name}' and tenant_type in ('SYS','USER');" 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;" + 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, 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}' + 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}' + 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}' + 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}' + 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}' + 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}' + 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 @@ -34,55 +34,55 @@ task: 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}' + 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 + 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 + 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 + 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 + 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}' + 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}' + 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}' + 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}' + 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}' + 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}' + 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}' + 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}' + 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/plugins/display/tasks/observer/topsql.yaml b/plugins/display/tasks/observer/topsql.yaml index 34a3e859..5aabe429 100644 --- a/plugins/display/tasks/observer/topsql.yaml +++ b/plugins/display/tasks/observer/topsql.yaml @@ -6,45 +6,45 @@ task: - version: "[4.0.0.0, *]" steps: - type: sql - tittle: Top SQL time consumption in the last {mtime} minutes + tittle: Top SQL time consumption in the last #{mtime} minutes sql: "select /*+read_consistency(weak),query_timeout(100000000)*/ tenant_name,SQL_ID,substr(query_sql, 1, 20) as query_sql,count(1),avg(ELAPSED_TIME),avg(EXECUTE_TIME),avg(QUEUE_TIME),avg(AFFECTED_ROWS),avg(GET_PLAN_TIME) from oceanbase.gv$ob_sql_audit - where time_to_usec(now(6))-request_time <{mtime}*60*1000000 - and tenant_name='{tenant_name}' + 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;" global: true - type: sql - tittle: Top-N SQL queries ranked by request count in the last {mtime} minutes + tittle: Top-N SQL queries ranked by request count in the last #{mtime} minutes sql: "select /*+read_consistency(weak),query_timeout(100000000)*/ tenant_name,SQL_ID, substr(query_sql, 1, 20) as query_sql,count(*) as QPS, avg(t1.elapsed_time) RT from oceanbase.gv$ob_sql_audit t1 - where tenant_name='{tenant_name}' and IS_EXECUTOR_RPC = 0 - and request_time > (time_to_usec(now()) - {mtime}*60*1000000) + where tenant_name='#{tenant_name}' and IS_EXECUTOR_RPC = 0 + and request_time > (time_to_usec(now()) - #{mtime}*60*1000000) and request_time < time_to_usec(now()) group by t1.sql_id order by QPS desc limit 20;" global: true - type: sql - tittle: The SQL that consumes the most CPU among all SQLs in the last {mtime} minutes + tittle: The SQL that consumes the most CPU among all SQLs in the last #{mtime} minutes sql: "select /*+read_consistency(weak),query_timeout(100000000)*/ tenant_name,sql_id, substr(query_sql, 1, 20) as query_sql, sum(elapsed_time - queue_time) as cpu_time, count(*) cnt, avg(get_plan_time), avg(execute_time) from oceanbase.gv$ob_sql_audit - where tenant_name ='{tenant_name}' - and request_time > (time_to_usec(now()) - {mtime}*60*1000000) + where tenant_name ='#{tenant_name}' + and request_time > (time_to_usec(now()) - #{mtime}*60*1000000) and request_time < time_to_usec(now()) group by sql_id order by cpu_time desc limit 20;" 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 + 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 from oceanbase.gv$ob_sql_audit - where tenant_name ='{tenant_name}' + where tenant_name ='#{tenant_name}' and IS_EXECUTOR_RPC = 0 and is_inner_sql = 0 - and request_time > (time_to_usec(now()) - {mtime}*60*1000000) + and request_time > (time_to_usec(now()) - #{mtime}*60*1000000) and request_time < time_to_usec(now()) group by plan_type limit 20;" global: true @@ -53,8 +53,8 @@ task: sql: "select /*+read_consistency(weak),query_timeout(100000000)*/ tenant_name, SQL_ID, substr(query_sql, 1, 20) as query_sql, elapsed_time from oceanbase.gv$ob_sql_audit - where table_scan = 1 and tenant_name = '{tenant_name}' - and request_time > (time_to_usec(now()) - {mtime}*60*1000000) + where table_scan = 1 and tenant_name = '#{tenant_name}' + and request_time > (time_to_usec(now()) - #{mtime}*60*1000000) and request_time < time_to_usec(now()) and is_inner_sql = 0 order by elapsed_time desc limit 20;" @@ -62,48 +62,48 @@ task: - version: "[3.0.0.0, 4.0.0.0]" steps: - type: sql - tittle: Top SQL time consumption in the last {mtime} minutes + tittle: Top SQL time consumption in the last #{mtime} minutes sql: "select /*+read_consistency(weak),query_timeout(100000000)*/ tenant_name,SQL_ID,substr(query_sql, 1, 20) as query_sql,count(1),avg(ELAPSED_TIME),avg(EXECUTE_TIME),avg(QUEUE_TIME),avg(AFFECTED_ROWS),avg(GET_PLAN_TIME) from oceanbase.gv$sql_audit - where time_to_usec(now(6))-request_time <{mtime}*60*1000000 - and tenant_name='{tenant_name}' + where time_to_usec(now(6))-request_time <#{mtime}*60*1000000 + and tenant_name='#{tenant_name}' and is_inner_sql = 0 group by SQL_ID order by avg(ELAPSED_TIME)*count(1) desc limit 20 ;" global: true - type: sql - tittle: Top-N SQL queries ranked by request count in the last {mtime} minutes + tittle: Top-N SQL queries ranked by request count in the last #{mtime} minutes sql: "select /*+read_consistency(weak),query_timeout(100000000)*/ tenant_name, SQL_ID,substr(query_sql, 1, 20) as query_sql, count(*) as QPS, avg(t1.elapsed_time) RT from oceanbase.gv$sql_audit t1 - where tenant_name='{tenant_name}' + where tenant_name='#{tenant_name}' and IS_EXECUTOR_RPC = 0 and is_inner_sql = 0 - and request_time > (time_to_usec(now()) - {mtime}*60*1000000) + and request_time > (time_to_usec(now()) - #{mtime}*60*1000000) and request_time < time_to_usec(now()) group by t1.sql_id order by QPS desc limit 20;" global: true - type: sql - tittle: The SQL that consumes the most CPU among all SQLs in the last {mtime} minutes + tittle: The SQL that consumes the most CPU among all SQLs in the last #{mtime} minutes sql: "select /*+read_consistency(weak),query_timeout(100000000)*/ tenant_name,sql_id, substr(query_sql, 1, 20) as query_sql, sum(elapsed_time - queue_time) as cpu_time, count(*) cnt, avg(get_plan_time), avg(execute_time) from oceanbase.gv$sql_audit - where tenant_name='{tenant_name}' - and request_time > (time_to_usec(now()) - {mtime}*60*1000000) + where tenant_name='#{tenant_name}' + and request_time > (time_to_usec(now()) - #{mtime}*60*1000000) and request_time < time_to_usec(now()) and is_inner_sql = 0 group by sql_id order by cpu_time desc limit 20;" 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 + 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 from oceanbase.gv$sql_audit - where tenant_name='{tenant_name}' + where tenant_name='#{tenant_name}' and IS_EXECUTOR_RPC = 0 - and request_time > (time_to_usec(now()) - {mtime}*60*1000000) + and request_time > (time_to_usec(now()) - #{mtime}*60*1000000) and request_time < time_to_usec(now()) group by plan_type limit 20;" global: true @@ -112,8 +112,8 @@ task: sql: "select /*+read_consistency(weak),query_timeout(100000000)*/ tenant_name, SQL_ID, substr(query_sql, 1, 20) as query_sql from oceanbase.gv$sql_audit - where table_scan = 1 and tenant_name = '{tenant_name}' - and request_time > (time_to_usec(now()) - {mtime}*60*10000) + where table_scan = 1 and tenant_name = '#{tenant_name}' + and request_time > (time_to_usec(now()) - #{mtime}*60*10000) and request_time < time_to_usec(now()) and is_inner_sql = 0 order by elapsed_time desc limit 20;" diff --git a/plugins/gather/tasks/obproxy/restart.yaml b/plugins/gather/tasks/obproxy/restart.yaml index 65725159..d2d265b3 100644 --- a/plugins/gather/tasks/obproxy/restart.yaml +++ b/plugins/gather/tasks/obproxy/restart.yaml @@ -11,7 +11,7 @@ task: ssh: "cat /proc/sys/kernel/core_pattern" global: false - type: ssh - ssh: "ls -lhrt ${obproxy_data_dir}" + ssh: "ls -lhrt #{obproxy_data_dir}" global: false - type: obproxy_log grep: "" diff --git a/plugins/gather/tasks/observer/backup.yaml b/plugins/gather/tasks/observer/backup.yaml index 63112953..f08ee58d 100644 --- a/plugins/gather/tasks/observer/backup.yaml +++ b/plugins/gather/tasks/observer/backup.yaml @@ -50,7 +50,7 @@ task: sql: "select svr_ip, log_archive_status, count(*) from oceanbase.__all_virtual_pg_backup_log_archive_status group by svr_ip, log_archive_status;" global: true - type: sql - sql: "select * from oceanbase.__all_rootservice_event_history where gmt_create > ${from_time} and gmt_create < ${to_time} order by gmt_create desc;" + sql: "select * from oceanbase.__all_rootservice_event_history where gmt_create > #{from_time} and gmt_create < #{to_time} order by gmt_create desc;" global: true - type: sql sql: "select b.* from oceanbase.__all_virtual_pg_backup_log_archive_status a,oceanbase.__all_virtual_pg_log_archive_stat b where a.table_id=b.table_id and a.partition_id=b.partition_id order by log_archive_cur_ts limit 100;" @@ -103,22 +103,22 @@ task: sql: "show parameters like '%ha_low_thread_score%';" global: true - type: sql - sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_PARAMETER where tenant_id = ${tenant_id}" + sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_PARAMETER where tenant_id = #{tenant_id}" global: true - type: sql - sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_JOBS where tenant_id = ${tenant_id};" + sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_JOBS where tenant_id = #{tenant_id};" global: true - type: sql sql: "SELECT * FROM oceanbase.DBA_OB_ROOTSERVICE_EVENT_HISTORY WHERE module='backup_data' AND event ='start_backup_data';" global: true - type: sql - sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_TASKS where tenant_id = ${tenant_id};" + sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_TASKS where tenant_id = #{tenant_id};" global: true - type: sql - sql: "SELECT * FROM oceanbase.__all_virtual_backup_schedule_task where tenant_id = ${tenant_id}" + sql: "SELECT * FROM oceanbase.__all_virtual_backup_schedule_task where tenant_id = #{tenant_id}" global: true - type: sql - sql: "SELECT * from oceanbase.CDB_OB_BACKUP_JOB_HISTORY where STATUS = 'FAILED' and tenant_id = ${tenant_id};" + sql: "SELECT * from oceanbase.CDB_OB_BACKUP_JOB_HISTORY where STATUS = 'FAILED' and tenant_id = #{tenant_id};" global: true - type: log global: false diff --git a/plugins/gather/tasks/observer/backup_clean.yaml b/plugins/gather/tasks/observer/backup_clean.yaml index bd89ecc4..fb33dbfb 100644 --- a/plugins/gather/tasks/observer/backup_clean.yaml +++ b/plugins/gather/tasks/observer/backup_clean.yaml @@ -53,13 +53,13 @@ task: sql: "select * from oceanbase.CDB_OB_BACKUP_SET_DETAILS order by START_TIME desc" global: true - type: sql - sql: "select * from oceanbase.__all_backup_task_clean_history where gmt_create > ${from_time} and gmt_create < ${to_time} order by gmt_create desc;" + sql: "select * from oceanbase.__all_backup_task_clean_history where gmt_create > #{from_time} and gmt_create < #{to_time} order by gmt_create desc;" global: true - type: sql - sql: "select * from oceanbase.__all_backup_clean_info_history where gmt_create > ${from_time} and gmt_create < ${to_time} order by gmt_create desc;" + sql: "select * from oceanbase.__all_backup_clean_info_history where gmt_create > #{from_time} and gmt_create < #{to_time} order by gmt_create desc;" global: true - type: sql - sql: "select * from oceanbase.__all_rootservice_event_history where module='backup_clean' and gmt_create > ${from_time} and gmt_create < ${to_time} order by gmt_create desc;" + sql: "select * from oceanbase.__all_rootservice_event_history where module='backup_clean' and gmt_create > #{from_time} and gmt_create < #{to_time} order by gmt_create desc;" global: true - type: log grep: "" @@ -106,34 +106,34 @@ task: sql: "show parameters like '%backup%';" global: true - type: sql - sql: "select * from oceanbase.CDB_OB_BACKUP_JOB_HISTORY where tenant_id=${tenant_id}" + sql: "select * from oceanbase.CDB_OB_BACKUP_JOB_HISTORY where tenant_id=#{tenant_id}" global: true - type: sql sql: "SELECT * FROM oceanbase.DBA_OB_ROOTSERVICE_EVENT_HISTORY WHERE module='backup_data' AND event ='start_backup_data';" global: true - type: sql - sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_TASKS where tenant_id=${tenant_id};" + sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_TASKS where tenant_id=#{tenant_id};" global: true - type: sql - sql: "SELECT * FROM oceanbase.__all_virtual_backup_schedule_task where tenant_id=${tenant_id}" + sql: "SELECT * FROM oceanbase.__all_virtual_backup_schedule_task where tenant_id=#{tenant_id}" global: true - type: sql - sql: "SELECT * from oceanbase.CDB_OB_BACKUP_JOB_HISTORY where STATUS = 'FAILED' and tenant_id=${tenant_id};" + sql: "SELECT * from oceanbase.CDB_OB_BACKUP_JOB_HISTORY where STATUS = 'FAILED' and tenant_id=#{tenant_id};" global: true - type: sql - sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_POLICY where tenant_id=${tenant_id};" + sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_POLICY where tenant_id=#{tenant_id};" global: true - type: sql - sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_JOBS where tenant_id=${tenant_id}" + sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_JOBS where tenant_id=#{tenant_id}" global: true - type: sql - sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_TASKS where tenant_id=${tenant_id}" + sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_TASKS where tenant_id=#{tenant_id}" global: true - type: sql - sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_TASK_HISTORY where tenant_id=${tenant_id}" + sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_TASK_HISTORY where tenant_id=#{tenant_id}" global: true - type: sql - sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_JOB_HISTORY where tenant_id=${tenant_id}" + sql: "SELECT * FROM oceanbase.CDB_OB_BACKUP_DELETE_JOB_HISTORY where tenant_id=#{tenant_id}" global: true - type: log global: false diff --git a/plugins/gather/tasks/observer/cluster_down.yaml b/plugins/gather/tasks/observer/cluster_down.yaml index 1f01c2ba..ef37879c 100644 --- a/plugins/gather/tasks/observer/cluster_down.yaml +++ b/plugins/gather/tasks/observer/cluster_down.yaml @@ -11,7 +11,7 @@ task: ssh: "cat /proc/sys/kernel/core_pattern" global: false - type: ssh - ssh: "ls -lhrt ${observer_data_dir}" + ssh: "ls -lhrt #{observer_data_dir}" global: false - type: ssh ssh: "df -h" diff --git a/plugins/gather/tasks/observer/log_archive.yaml b/plugins/gather/tasks/observer/log_archive.yaml index c6d7c9ae..ded5de22 100644 --- a/plugins/gather/tasks/observer/log_archive.yaml +++ b/plugins/gather/tasks/observer/log_archive.yaml @@ -50,7 +50,7 @@ task: sql: "select count(*) ,DATE_FORMAT(gmt_create, '%Y-%c-%d') as date from oceanbase.__all_virtual_ddl_operation where ddl_stmt_str !='' group by date order by date limit 10;" global: true - type: sql - sql: "select * from oceanbase.__all_rootservice_event_history where gmt_create > ${from_time} and gmt_create < ${to_time} order by gmt_create desc;" + sql: "select * from oceanbase.__all_rootservice_event_history where gmt_create > #{from_time} and gmt_create < #{to_time} order by gmt_create desc;" global: true - type: sql sql: "(select table_id, partition_idx from oceanbase.__all_virtual_election_info group by table_id, partition_idx) except (select table_id, partition_idx from oceanbase.__all_virtual_election_info where role = 1);" diff --git a/plugins/gather/tasks/observer/memory.yaml b/plugins/gather/tasks/observer/memory.yaml index cd96d560..c871f6e5 100644 --- a/plugins/gather/tasks/observer/memory.yaml +++ b/plugins/gather/tasks/observer/memory.yaml @@ -100,7 +100,7 @@ task: sql: "SELECT CASE WHEN tenant_name IS NULL THEN TENANT_ID ELSE tenant_name END tenant_name, host,ctx_name, mod_name, hold, used, count FROM ( SELECT tenant_name,tenant_id,HOST,ctx_name,mod_name,hold,used,COUNT, ROW_NUMBER () OVER ( PARTITION BY tenant_name, HOST ORDER BY hold desc) rnum FROM (SELECT b.tenant_name, a.tenant_id, concat(a.svr_ip, ':', a.svr_port) HOST, a.ctx_name, a.mod_name, round(a.hold / 1024 / 1024 / 1024) hold, round(a.used / 1024 / 1024 / 1024) used, a.COUNT FROM oceanbase.__all_virtual_memory_info a LEFT JOIN oceanbase.__all_tenant b ON a.TENANT_ID = b.TENANT_ID WHERE a.hold > 1024 * 1024 * 1024 ));" global: true - type: ssh # 可看到租户的规格、线程、队列及请求统计等信息,且这条日志每个租户每 30s 打印一次 - ssh: "grep 'dump tenant info.tenant=' ${observer_data_dir}/log/observer.log | sed 's/,/,/g'" + ssh: "grep 'dump tenant info.tenant=' #{observer_data_dir}/log/observer.log | sed 's/,/,/g'" global: false - type: log grep: "" diff --git a/plugins/gather/tasks/observer/recovery.yaml b/plugins/gather/tasks/observer/recovery.yaml index 10ef5441..f51bd357 100644 --- a/plugins/gather/tasks/observer/recovery.yaml +++ b/plugins/gather/tasks/observer/recovery.yaml @@ -35,7 +35,7 @@ task: sql: "select * from oceanbase.__all_restore_info;" global: true - type: sql - sql: "select * from oceanbase.__all_rootservice_event_history where gmt_create > ${from_time} and gmt_create < ${to_time} order by gmt_create desc;" + sql: "select * from oceanbase.__all_rootservice_event_history where gmt_create > #{from_time} and gmt_create < #{to_time} order by gmt_create desc;" global: true - type: sql sql: "select svr_ip,role, is_restore, count(*) from oceanbase.__all_root_table as a, (select value from oceanbase.__all_restore_info where name='tenant_id') as b where a.tenant_id=b.value group by role, is_restore, svr_ip order by svr_ip, is_restore;" diff --git a/plugins/gather/tasks/observer/restart.yaml b/plugins/gather/tasks/observer/restart.yaml index 9ada284f..14e02027 100644 --- a/plugins/gather/tasks/observer/restart.yaml +++ b/plugins/gather/tasks/observer/restart.yaml @@ -38,7 +38,7 @@ task: ssh: "cat /proc/sys/kernel/core_pattern" global: false - type: ssh - ssh: "ls -lhrt ${observer_data_dir}" + ssh: "ls -lhrt #{observer_data_dir}" global: false - type: log grep: "" @@ -85,7 +85,7 @@ task: ssh: "cat /proc/sys/kernel/core_pattern" global: false - type: ssh - ssh: "ls -lhrt ${observer_data_dir}" + ssh: "ls -lhrt #{observer_data_dir}" global: false - type: log grep: "" diff --git a/plugins/gather/tasks/observer/rootservice_switch.yaml b/plugins/gather/tasks/observer/rootservice_switch.yaml index 8afb6595..f2e63b9b 100644 --- a/plugins/gather/tasks/observer/rootservice_switch.yaml +++ b/plugins/gather/tasks/observer/rootservice_switch.yaml @@ -56,10 +56,10 @@ task: sql: "select count(*) from oceanbase.__all_virtual_replica_task where cmd_type in ('ADD_REPLICA', 'MIGRATE_REPLICA', 'TYPE_TRANSFORM'); " global: true - type: sql - sql: "select * from oceanbase.__all_rootservice_event_history where gmt_create > ${from_time} and gmt_create < ${to_time} order by gmt_create desc;" + sql: "select * from oceanbase.__all_rootservice_event_history where gmt_create > #{from_time} and gmt_create < #{to_time} order by gmt_create desc;" global: true - type: sql - sql: "select * from oceanbase.__all_virtual_election_event_history where gmt_create > ${from_time} and gmt_create < ${to_time} order by gmt_create desc;" + sql: "select * from oceanbase.__all_virtual_election_event_history where gmt_create > #{from_time} and gmt_create < #{to_time} order by gmt_create desc;" global: true - type: sql sql: "(select table_id, partition_idx from oceanbase.__all_virtual_election_info group by table_id, partition_idx) except (select table_id, partition_idx from oceanbase.__all_virtual_election_info where role = 1) ;" diff --git a/plugins/gather/tasks/observer/unit_data_imbalance.yaml b/plugins/gather/tasks/observer/unit_data_imbalance.yaml index a81f5a10..58fb68f4 100644 --- a/plugins/gather/tasks/observer/unit_data_imbalance.yaml +++ b/plugins/gather/tasks/observer/unit_data_imbalance.yaml @@ -83,10 +83,10 @@ task: sql: "select * from oceanbase.__all_virtual_partition_migration_status;" global: true - type: sql - sql: "select * from oceanbase.__all_rootservice_job where gmt_create > ${from_time} and gmt_create < ${to_time} order by gmt_create desc;" + sql: "select * from oceanbase.__all_rootservice_job where gmt_create > #{from_time} and gmt_create < #{to_time} order by gmt_create desc;" global: true - type: sql - sql: "select * from oceanbase.__all_rootservice_event_history where gmt_create > ${from_time} and gmt_create < ${to_time} order by gmt_create desc;" + sql: "select * from oceanbase.__all_rootservice_event_history where gmt_create > #{from_time} and gmt_create < #{to_time} order by gmt_create desc;" global: true - type: sql sql: "select svr_ip,total_size / 1024 / 1024 / 1024 total_G,free_size / 1024 / 1024 / 1024 free_G,(total_size - free_size) / 1024 / 1024 / 1024 used_G,(total_size - free_size) / total_size used_percentage FROM oceanbase.__all_virtual_disk_stat;" diff --git a/src/common/tool.py b/src/common/tool.py index 5f7654bc..beb0f69f 100644 --- a/src/common/tool.py +++ b/src/common/tool.py @@ -1242,14 +1242,14 @@ def parse_env_display(env_list): @staticmethod def extract_parameters(query_template): # 使用正则表达式查找占位符 - pattern = re.compile(r'\{(\w+)\}') + pattern = re.compile(r'#\{(\w+)\}') parameters = pattern.findall(query_template) return parameters @staticmethod def replace_parameters(query_template, params): # 使用正则表达式查找占位符 - pattern = re.compile(r'\{(\w+)\}') + pattern = re.compile(r'#\{(\w+)\}') # 定义替换函数 def replacer(match): diff --git a/src/handler/gather/step/sql.py b/src/handler/gather/step/sql.py index 5fb79ec2..f13e7dc6 100644 --- a/src/handler/gather/step/sql.py +++ b/src/handler/gather/step/sql.py @@ -16,7 +16,6 @@ @desc: """ import os -import re from src.common.stdio import SafeStdio from src.common.ob_connector import OBConnector from tabulate import tabulate @@ -66,23 +65,6 @@ def execute(self): except Exception as e: self.stdio.error("StepSQLHandler execute Exception: {0}".format(e).strip()) - @staticmethod - def extract_parameters(query_template): - pattern = re.compile(r'\$\{(\w+)\}') - parameters = pattern.findall(query_template) - return parameters - - @staticmethod - def replace_parameters(query_template, params): - pattern = re.compile(r'\$\{(\w+)\}') - - def replacer(match): - key = match.group(1) - return str(params.get(key, match.group(0))) - - query = pattern.sub(replacer, query_template) - return query - def update_step_variable_dict(self): return self.task_variable_dict