#!/bin/bash function ConvertToTiB () { if awk "BEGIN{exit ($1 > 1000 ? 0 : 1)}" then StorageInTB=$(echo $1 | awk '{printf "%.1f\n", $1 / 1024}') if awk "BEGIN{exit ($StorageInTB > 1000 ? 0 : 1)}" then StorageInTB=$(echo $StorageInTB | awk '{printf "%.1f\n", $1 / 1024}') echo $StorageInTB TB # is technically TiB else StorageInGB=$StorageInTB echo $StorageInGB GB # is technically GiB fi else StorageInGB=$1 echo $StorageInGB MB # is technically MiB fi } function ConvertOnlyToTB () { SpaceInTB=$(echo $1 | awk '{printf "%.1f\n", $1 / 1024}') # is technically TiB echo $SpaceInTB } function GetRepoCapacity () { getRepoValue=$(df -BM --output=$1,target | grep -w -m 1 $2 | sed 's/[[:blank:]]*//' | sed s'/\M.*//'); \ getRepoValue=$(ConvertToTiB $getRepoValue) echo $getRepoValue $3; \ } # Get license number, sender and recipien license_number=$(grep -w 'license_number' /etc/filescale/cluster.ansible.yml | grep -o -P '(?<=license_number: ).*(?=)') sender=$(grep -w sender /etc/filescale/cluster.yml | grep -o -P '(?<=sender: ).*(?=)') recipient=$(grep -w recipient /etc/filescale/cluster.yml | grep -o -P '(?<=recipient: ).*(?=)') # CSS/html/bash ( echo "To: ${recipient}" echo "From: ${sender}" echo "Subject: [INFO] ${license_number} - iTernity - iCAS FS - Capacity-Report" echo "Mime-Version: 1.0" echo "Content-Type: text/html; charset='utf-8'" echo "
iTernity iCAS FS Capacity Report
Overview of cluster capacities
| License Number | Raw Capacity | Allocated Capacity | Available Capacity | Usable Capacity |
| ${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 '(?<=HDD, ).*(?= TB)' | awk '{sum+=\$1} END {print sum}'" | awk '{sum+=$1} END {print sum}') echo "${raw_capacity} TB | " # Allocated Capacity allocated_capacity_GB=$(df -BG | grep '/gluster/repositories/' | grep -v fs-ss | grep -v '/tmp/' | awk '{ sum+=$2} END {print sum}') allocated_capacity_TB=$(ConvertOnlyToTB $allocated_capacity_GB) # is technically TiB echo "${allocated_capacity_TB} TB | " # 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) # is technically TiB echo "${available_capacity_TB} TB | " # Usable Capacity usable_capacity=$(echo $allocated_capacity_TB + $available_capacity_TB | bc) # is technically TiB echo "${usable_capacity} TB |
Overview of node capacities
| Node | Raw Capacity | Available Capacity | Number of disks | Logical drives |
| ${HOST} | " echo "${raw_per_node} TB | " echo "${available_capacity_node_TB} TB | " echo "${disks} | " echo "${logicalDrive} of 64 |
Overview of repository capacities
| Repository | Size | Avail | Used | Use% |
| ${Repository} | " repo_size=$(GetRepoCapacity size $Repo) echo "${repo_size} | " repo_avail=$(GetRepoCapacity avail $Repo) echo "${repo_avail} | " repo_used=$(GetRepoCapacity used $Repo) echo "${repo_used} | " repo_pcent=$(df -BG --output=pcent,target | grep -w -m 1 $Repo | cut -d % -f1) echo "${repo_pcent} % |