turbot/oci_thrifty
Loading controls...

Control: MySQL DB systems with low CPU utilization should be reviewed

Description

These DB systems have very little usage in last 30 days and should be shutdown when not in use.

Usage

Run the control in your terminal:

powerpipe control run oci_thrifty.control.mysql_db_system_low_usage

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run oci_thrifty.control.mysql_db_system_low_usage --share

Steampipe Tables

Params

ArgsNameDefaultDescriptionVariable
$1mysql_db_system_avg_cpu_utilization_low
25
The average CPU utilization required for DB systems to be considered infrequently used. This value should be lower than mysql_db_system_avg_cpu_utilization_high.
$2mysql_db_system_avg_cpu_utilization_high
50
The average CPU utilization required for DB systems to be considered frequently used. This value should be higher than mysql_db_system_avg_cpu_utilization_low.

SQL

with mysql_db_usage as (
select
id,
round(cast(sum(maximum) / count(maximum) as numeric), 1) as avg_max,
count(maximum) days
from
oci_mysql_db_system_metric_memory_utilization_daily
where
date_part('day', now() - timestamp) <= 30
group by
id
)
select
display_name as resource,
case
when avg_max is null then 'error'
when avg_max <= $1 then 'alarm'
when avg_max <= $2 then 'info'
else 'ok'
end as status,
case
when avg_max is null then 'Monitoring metrics not available for ' || i.title || '.'
else i.title || ' is averaging ' || avg_max || '% max utilization over the last ' || days || ' days.'
end as reason,
coalesce(c.name, 'root') as compartment,
i.region
from
oci_mysql_db_system i
left join mysql_db_usage as u on u.id = i.id
left join oci_identity_compartment as c on c.id = i.compartment_id
where
i.lifecycle_state <> 'DELETED';

Tags