Skip to content

Commit

Permalink
displsy and gather env use '#{env_name}' (oceanbase#623)
Browse files Browse the repository at this point in the history
* displsy and gather env use '#{env_name}'

* displsy and gather env use '#{env_name}'
  • Loading branch information
wayyoungboy authored Dec 12, 2024
1 parent 7699585 commit 4bf8ba5
Show file tree
Hide file tree
Showing 21 changed files with 105 additions and 123 deletions.
6 changes: 3 additions & 3 deletions plugins/display/tasks/observer/database_datasize.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;"
Expand Down
4 changes: 2 additions & 2 deletions plugins/display/tasks/observer/event.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions plugins/display/tasks/observer/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions plugins/display/tasks/observer/processlist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

8 changes: 4 additions & 4 deletions plugins/display/tasks/observer/slowsql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions plugins/display/tasks/observer/table_datasize.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions plugins/display/tasks/observer/table_info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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
42 changes: 21 additions & 21 deletions plugins/display/tasks/observer/tenant_info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Loading

0 comments on commit 4bf8ba5

Please sign in to comment.