From efb2bc4a850fab0fb49b088a8a21da3606102d5c Mon Sep 17 00:00:00 2001 From: Aleksandar Sujic Date: Tue, 4 Feb 2025 09:59:30 +0000 Subject: [PATCH] =?UTF-8?q?Script=20f=C3=BCr=20S3=20Setups=20die=20nur=20S?= =?UTF-8?q?SDs=20verwenden=20aufger=C3=A4umt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- capacity-report-s3-ssd.sh | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/capacity-report-s3-ssd.sh b/capacity-report-s3-ssd.sh index 91a2b81..37395ad 100644 --- a/capacity-report-s3-ssd.sh +++ b/capacity-report-s3-ssd.sh @@ -24,7 +24,7 @@ function ConvertOnlyToTB () { } function GetRepoCapacity () { - getRepoValue=$(df -BM --output=$1,target | grep -w -m 1 $2 | sed 's/[[:blank:]]*//' | sed s'/\M.*//'); \ + getRepoValue=$(df -BM --output=$1,target | grep -w -m 1 $2 | sed 's/[[:blank:]]*//' | sed s'/\G.*//'); \ getRepoValue=$(ConvertToTB $getRepoValue) echo $getRepoValue $3; \ } @@ -34,6 +34,21 @@ license_number=$(grep -w 'license_number' /etc/filescale/cluster.ansible.yml | g sender=$(grep -w sender /etc/filescale/cluster.yml | grep -o -P '(?<=sender: ).*(?=)') recipient=$(grep -w recipient /etc/filescale/cluster.yml | grep -o -P '(?<=recipient: ).*(?=)') +# RAW capacity +raw_capacity=$(ansible -b -i /etc/filescale/cluster.ansible.yml storage_nodes -m shell -a "ssacli ctrl all show config | grep -o -P '(?<=SSD, ).*(?= TB)' | awk '{sum+=\$1} END {print sum}'" | awk '{sum+=$1} END {print sum}') + +# usable total +usable_total_bytes=$(influx -precision rfc3339 -database telegraf -execute 'SELECT last(minio_cluster_capacity_usable_total_bytes) as usable_total_bytes FROM telegraf.autogen.ec_s3_space_metrics' | grep -o -P '(?<=Z ).*(?=)') +usable_total_TB=$(echo $usable_total_bytes | awk '{printf "%.1f\n", $usable_total_bytes / 1000 / 1000 / 1000 / 1000}') # is technically TiB + +# Available Capacity +available_capacity_bytes=$(influx -precision rfc3339 -database telegraf -execute 'SELECT last(minio_cluster_capacity_usable_free_bytes) as usable_free_bytes FROM telegraf.autogen.ec_s3_space_metrics' | grep -o -P '(?<=Z ).*(?=)') +available_capacity_TB=$(echo $available_capacity_bytes | awk '{printf "%.1f\n", $available_capacity_bytes / 1000 / 1000 / 1000 / 1000}') # is technically TiB + +# Used Capacity +used_capacity=$(echo $usable_total_bytes - $available_capacity_bytes | bc) +used_capacity_TB=$(echo $used_capacity | awk '{printf "%.1f\n", $used_capacity / 1000 / 1000 / 1000 / 1000}') # is technically TiB + ( echo "To: ${recipient}" echo "From: ${sender}" @@ -93,20 +108,9 @@ recipient=$(grep -w recipient /etc/filescale/cluster.yml | grep -o -P '(?<=recip " echo " ${license_number} " -# RAW capacity -raw_capacity=$(ansible -b -i /etc/filescale/cluster.ansible.yml storage_nodes -m shell -a "ssacli ctrl all show config | grep -o -P '(?<=SSD, ).*(?= TB)' | awk '{sum+=\$1} END {print sum}'" | awk '{sum+=$1} END {print sum}') echo " ${raw_capacity} TB " -# usable total -usable_total_bytes=$(influx -precision rfc3339 -database telegraf -execute 'SELECT last(minio_cluster_capacity_usable_total_bytes) as usable_total_bytes FROM telegraf.autogen.ec_s3_space_metrics' | grep -o -P '(?<=Z ).*(?=)') -usable_total_TB=$(echo $usable_total_bytes | awk '{printf "%.1f\n", $usable_total_bytes / 1000 / 1000 / 1000 / 1000}') # is technically TiB echo " ${usable_total_TB} TB " -# Available Capacity -available_capacity_bytes=$(influx -precision rfc3339 -database telegraf -execute 'SELECT last(minio_cluster_capacity_usable_free_bytes) as usable_free_bytes FROM telegraf.autogen.ec_s3_space_metrics' | grep -o -P '(?<=Z ).*(?=)') -available_capacity_TB=$(echo $available_capacity_bytes | awk '{printf "%.1f\n", $available_capacity_bytes / 1000 / 1000 / 1000 / 1000}') # is technically TiB echo " ${available_capacity_TB} TB " -# Used Capacity -used_capacity=$(echo $usable_total_bytes - $available_capacity_bytes | bc) -used_capacity_TB=$(echo $used_capacity | awk '{printf "%.1f\n", $used_capacity / 1000 / 1000 / 1000 / 1000}') # is technically TiB echo " ${used_capacity_TB} TB @@ -149,3 +153,4 @@ echo " " ) | sudo sendmail -t -f $sender +