diff --git a/capacity-report.sh b/capacity-report.sh index f0a7a29..c37e74e 100644 --- a/capacity-report.sh +++ b/capacity-report.sh @@ -7,19 +7,23 @@ function ConvertToTiB () { if awk "BEGIN{exit ($StorageInTB > 1000 ? 0 : 1)}" then StorageInTB=$(echo $StorageInTB | awk '{printf "%.1f\n", $1 / 1024}') - echo $StorageInTB TB # is technically TiB + + echo $StorageInTB TB else StorageInGB=$StorageInTB - echo $StorageInGB GB # is technically GiB + echo $StorageInGB GB fi else StorageInGB=$1 - echo $StorageInGB MB # is technically MiB + echo $StorageInGB MB +>>>>>>> 7b3a121 (Script aufgeräumt.) fi } function ConvertOnlyToTB () { - SpaceInTB=$(echo $1 | awk '{printf "%.1f\n", $1 / 1024}') # is technically TiB + + SpaceInTB=$(echo $1 | awk '{printf "%.1f\n", $1 / 1024}') +>>>>>>> 7b3a121 (Script aufgeräumt.) echo $SpaceInTB } @@ -35,6 +39,26 @@ 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 '(?<=HDD, ).*(?= TB)' | awk '{sum+=\$1} END {print sum}'" | awk '{sum+=$1} END {print sum}') + +# Usable Capacity +getArray=$(ansible -b -i /etc/filescale/cluster.ansible.yml storage_nodes -m shell -a "ssacli ctrl all show config | grep -o -P '(?=Array ).*(?= \()' | grep -v Slot | sort -u | wc -l" | awk '{sum+=$1} END {print sum}') +diskCount=$(ansible -b -i /etc/filescale/cluster.ansible.yml storage_nodes -m shell -a "ssacli ctrl all show config | grep -v SSD | grep physicaldrive | wc -l" | awk '{sum+=$1} END {print sum}') +lostDisks=$(($getArray * 2)) +disks=$(($diskCount - $lostDisks)) +diskSize=$(sudo ssacli ctrl all show config | grep -o -P '(?<=HDD, ).*(?= TB)' | sort -u | tail -1) +usable_capacity=$(($disks * $diskSize)) + +# Available Capacity +available_capacity_GB=$(ansible -b -i /etc/filescale/cluster.ansible.yml storage_nodes -m shell -a "ssacli ctrl all show config | grep 'Unused Space:' | grep -o '[[:digit:]]*'" | awk '{sum+=$1} END {sum=sum/1024} END {print sum}') +available_capacity_TB=$(ConvertOnlyToTB $available_capacity_GB) + +# Allocated Capacity +allocated_capacity_TB=$(awk "BEGIN {print $usable_capacity - $available_capacity_TB}") + +>>>>>>> 7b3a121 (Script aufgeräumt.) # CSS/html/bash ( echo "To: ${recipient}" @@ -88,27 +112,20 @@ recipient=$(grep -w recipient /etc/filescale/cluster.yml | grep -o -P '(?<=recip