System CPU Metrics (SYSMETRIC_CPU.sql)
What This Script Does
Section titled “What This Script Does”This script analyzes historical CPU utilization from AWR system metrics, providing a snapshot-based view of host CPU utilization across all instances. Essential for historical performance analysis and capacity planning.
The Script
Section titled “The Script”rem sysmetric_cpu.sqlremset lines 600remalter session set nls_date_format='YYYY-MM-DD HH24:Mi'/col SNAP_ID format 999999 heading 'SNAP ID'col instance_number format 99 head 'INST'col end_interval_time format a15 heading 'SNAP TIME'col EVENT_NAME format a35 heading 'EVENT'col total_waits format b999,999,990 heading 'TOTAL WAITS'col waits_per_sec format b99,990 heading 'WAITS|PER|SEC'col timeout_pct format b990.0 heading 'TIMEOUT|PCT'col time_waited_micro format b999,999,990 heading 'TIME WAITED(ms)'col avg_wait format 990.0 heading 'AVG|WAIT|TIME(ms)'remremttitle 'System Wait Events CPU'remclear breakclear computeremselect snap_id, INSTANCE_NUMBER,min(begin_time) awr_start, max(end_time) awr_end, sum(case metric_name when 'Host CPU Utilization (%)' then average end) Host_CPU_utilfrom dba_hist_sysmetric_summarygroup by snap_id , instance_numberorder by snap_id desc, INSTANCE_NUMBER;remundefine start_dtundefine end_dtundefine namundefine instno
Parameters
Section titled “Parameters”The script prompts for:
- None - this script requires no parameters
-- Basic usage@SYSMETRIC_CPU.sql
Sample Output
Section titled “Sample Output” System Wait Events CPU
SNAP ID INST AWR_START AWR_END HOST_CPU_UTIL------- ---- ------------------- ------------------- ------------- 12345 1 2025-01-05 14:00:00 2025-01-05 15:00:00 45.2 12345 2 2025-01-05 14:00:00 2025-01-05 15:00:00 52.8 12344 1 2025-01-05 13:00:00 2025-01-05 14:00:00 38.9 12344 2 2025-01-05 13:00:00 2025-01-05 14:00:00 41.7 12343 1 2025-01-05 12:00:00 2025-01-05 13:00:00 35.1 12343 2 2025-01-05 12:00:00 2025-01-05 13:00:00 37.4