0% found this document useful (0 votes)
53 views

Scripts For References

The document contains SQL statements to create tables and common table expressions (CTEs) to query data from database tables and calculate metrics. The CTEs join data from system monitoring tables to retrieve database, host, and service metrics grouped by time period. The results are further joined to a portfolio table to return business context fields in the final output.

Uploaded by

M. Natarajan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Scripts For References

The document contains SQL statements to create tables and common table expressions (CTEs) to query data from database tables and calculate metrics. The CTEs join data from system monitoring tables to retrieve database, host, and service metrics grouped by time period. The results are further joined to a portfolio table to return business context fields in the final output.

Uploaded by

M. Natarajan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

WITH base_one AS

(SELECT entity_type,
SUBSTR(entity_name,
1,
4) AS database_machine,
entity_name AS host_name,
metric_column_label,
metric_column_name,
metric_group_label,
collection_time,
TO_CHAR(collection_time,
’yyyy’) || ‘ - Q’ || TO_CHAR(collection_time,
’q’) AS year_quarter,
extract( YEAR
FROM collection_time ) || ’ - ’ || ltrim( TO_CHAR( extract( MONTH
FROM collection_time ), ’09’ ) ) AS year_month, TO_CHAR(collection_time,
’yyyy - ww’) AS year_week, collection_time AS year_month_day,
ROUND(avg_value, 2) AS avg_value, max_value, stddev_value
FROM sysman.gc$metric_values_daily
WHERE entity_type = ‘host’
AND metric_column_name = ‘cpuUtil’
AND metric_group_label = ‘Load’ ), , base_two AS
(SELECT database_machine,
metric_column_label ,
year_month ,
ROUND( MAX(max_value)
OVER ( partition BY database_machine, year_month ), 2 ) AS
per_m_dbm_max_cpuutil_pct , ROUND( AVG(avg_value)
OVER ( partition BY database_machine, year_month ), 2 ) AS
per_m_dbm_avg_cpuutil_pct , ROUND( percentile_cont(0.05) within GROUP (
ORDER BY max_value DESC ),
OVER ( partition BY database_machine, year_month ), 2 ) AS
per_m_dbm_95th_cpuutil_pct
FROM base_one )
SELECT DISTINCT database_machine,
metric_column_label,
year_month,
per_m_dbm_max_cpuutil_pct,
per_m_dbm_avg_cpuutil_pct,
per_m_dbm_95th_cpuutil_pct
FROM base_two
ORDER BY year_month;

CREATE TABLE portfolio { line_of_business NOT NULL VARCHAR2(4000),


department NOT NULL VARCHAR2(256) ,application NOT NULL
VARCHAR2(256) ,database_name NOT NULL VARCHAR2(256), service_name
NOT NULL VARCHAR2(256)};

WITH base_one AS
(SELECT SUBSTR (i.host_name,
1,
4) AS database_machine,
j.host_name,
UPPER (i.target_name) AS join_database_name,
COALESCE(SUBSTR (i.target_name,
1,
INSTR (i.target_name,
‘_’,
1) -1),
i.target_name) AS database_name,
entity_name AS instance_name,
UPPER ( SUBSTR ( entity_name,
INSTR (entity_name,
‘_’,
1) + 1,
LENGTH (entity_name) ) ) AS instance_name_short,
UPPER (key_part_1) AS service_name,
collection_time,
TO_CHAR (collection_time,
‘yyyy’)|| ‘ - Q’ || TO_CHAR (collection_time,
‘q’) AS year_quarter,
EXTRACT ( YEAR
FROM collection_time )|| ‘ - ’ || LTRIM ( TO_CHAR ( EXTRACT ( MONTH
FROM collection_time ), ‘09’ ) ) AS year_month, TO_CHAR (collection_time,
‘yyyy - ww’) AS year_week, collection_time AS year_month_day, ROUND
( (avg_value) * count_of_col - lections, 2 ) db_cpu_time_per_service,
a.count_of_collectionsFROM sysman.gc$metric_values_daily a,
sysman.mgmt$db_dbninstanceinfo i, sysman.mgmt$os_hw_summary jWHERE
SUBSTR (i.host_name, 1, 4) LIKE ‘dm % ’AND j.host_name = i.host_nameAND
a.entity_type IN ( ‘rac_database’, ‘ora - cle_database’ )
AND a.entity_guid = i.target_guidAND metric_column_name =
‘DBcpu_delta’AND metric_group_name = ‘DBService’ )
SELECT b.line_of_business,
b.department,
b.application,
a.database_machine,
a.host_name,
a.database_name,
a.instance_name,
a.instance_name_short,
a.service_name,
a.collection_time,
a.year_quarter,
a.year_month,
a.year_week,
a.year_month_day,
a.db_cpu_time_per_serviceFROM base_one a,
portfolio bWHERE a.join_database_name LIKE ‘ % ’ || b.data - base_name
|| ’ % ’AND a.service_name = b.service_name;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy