steampipe schedule
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__init (){
|
||||
pwd
|
||||
cd ${git_path}
|
||||
pwd
|
||||
# pwd
|
||||
# cd ${git_path}
|
||||
# pwd
|
||||
|
||||
git pull
|
||||
|
||||
@@ -33,6 +33,8 @@ __query_exec (){
|
||||
__log_sed (){
|
||||
sed -i 's/+/|/g' ${exec_log}
|
||||
sed -i "s/node-role.kubernetes.io\///g" ${exec_log}
|
||||
sed -i "s/31/32/g" ${exec_log}
|
||||
sed -i "s/62/64/g" ${exec_log}
|
||||
sed -i '1d;$d' ${exec_log}
|
||||
}
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
@@ -112,11 +114,67 @@ where type='NodePort' and name not like '%rel-%'
|
||||
order by
|
||||
Node_Port
|
||||
"""
|
||||
|
||||
aws_ri_query="""
|
||||
SELECT
|
||||
COALESCE(a.availability_zone, b.availability_zone, '-') AS availability_zone,
|
||||
COALESCE(a.instance_type, b.instance_type, c.instance_type, '-') AS instance_type,
|
||||
COALESCE(c.cpu, 0) AS cpu,
|
||||
COALESCE(c.memory, 0) AS memory,
|
||||
COALESCE(a.ri_count, 0) AS ri_count,
|
||||
COALESCE(b.ec2_count, 0) AS ec2_count,
|
||||
COALESCE(b.ec2_count, 0) - COALESCE(a.ri_count, 0) AS result
|
||||
FROM
|
||||
(SELECT
|
||||
availability_zone,
|
||||
instance_type,
|
||||
SUM(instance_count) AS ri_count
|
||||
FROM
|
||||
aws_ec2_reserved_instance
|
||||
WHERE
|
||||
instance_state='active'
|
||||
GROUP BY
|
||||
availability_zone,
|
||||
instance_type
|
||||
) a
|
||||
FULL OUTER JOIN
|
||||
(SELECT
|
||||
placement_availability_zone AS availability_zone,
|
||||
instance_type,
|
||||
COUNT(*) AS ec2_count
|
||||
FROM
|
||||
aws_ec2_instance
|
||||
WHERE
|
||||
instance_state='running' AND
|
||||
instance_lifecycle!='spot'
|
||||
GROUP BY
|
||||
availability_zone,
|
||||
instance_type
|
||||
) b
|
||||
ON
|
||||
a.availability_zone = b.availability_zone AND
|
||||
a.instance_type = b.instance_type
|
||||
INNER JOIN
|
||||
(SELECT
|
||||
instance_type,
|
||||
(CAST(memory_info ->> 'SizeInMiB' AS FLOAT) / 1024) AS memory,
|
||||
(CAST(v_cpu_info ->> 'DefaultCores' AS FLOAT) * 2) AS cpu
|
||||
FROM
|
||||
aws_ec2_instance_type
|
||||
WHERE
|
||||
instance_type in (SELECT instance_type FROM aws_ec2_instance WHERE instance_state='running' AND instance_lifecycle!='spot')
|
||||
GROUP BY
|
||||
instance_type, memory, cpu
|
||||
) c
|
||||
ON
|
||||
COALESCE(a.instance_type, b.instance_type, '-') = c.instance_type
|
||||
ORDER BY availability_zone
|
||||
"""
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
git_path="/home/jhjung/git/dsk-iac"
|
||||
#git_path="/home/jhjung/git/dsk-iac"
|
||||
origin="$(pwd)/org_README.md"
|
||||
exec_log="${git_path}/query.log"
|
||||
file="README.md"
|
||||
exec_log="query.log"
|
||||
file="../../README.md"
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__init
|
||||
|
||||
@@ -132,6 +190,10 @@ title="## 서비스 목록 (NodePort)"
|
||||
__query_exec "${service_query}"
|
||||
__append
|
||||
|
||||
title="## 예약 인스턴스 사용 내역"
|
||||
__query_exec "${aws_ri_query}"
|
||||
__append
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
rm ${exec_log}
|
||||
|
||||
__git_push
|
||||
|
||||
Reference in New Issue
Block a user