commit ade57c0a83b68bf4b9ecb65d8ee76c8b011f2e50 Author: aleksandar.sujic Date: Mon Sep 30 11:01:09 2024 +0000 Dateien nach "/" hochladen diff --git a/capacity-report-s3-ssd.sh b/capacity-report-s3-ssd.sh new file mode 100644 index 0000000..91a2b81 --- /dev/null +++ b/capacity-report-s3-ssd.sh @@ -0,0 +1,151 @@ +#!/bin/bash + +function ConvertToTB () { + 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=$(ConvertToTB $getRepoValue) + echo $getRepoValue $3; \ +} + +# License number +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: ).*(?=)') + +( + 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 Capacities Report + + + + + + + + +

iTernity iCAS FS Capacities Report

+

Overview of cluster capacities

+ + + + + + + + + " + +echo "" +# 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 "" +# 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 "" +# 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 "" +# 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 " + + + + +
License Number Raw Capacity Total Usable Available Capacity Used
${license_number} ${raw_capacity} TB ${usable_total_TB} TB ${available_capacity_TB} TB ${used_capacity_TB} TB
+

Overview of node capacities

+ + + + + + + + + " +if [[ $(sudo gluster vo info | grep brick | grep arbiter | grep -o -P '(?<=: ).*(?=:)' | sort -u) ]]; then + echo -e "\nArbiter: Yes" +else +sudo gluster vo info | grep brick | grep -o -P '(?<=: ).*(?=:)' | sort -u | \ +while read HOST; \ +do \ + raw_per_node="$(ssh $HOST "sudo ssacli ctrl all show config | grep -o -P '(?<=SSD, ).*(?= TB)' | awk '{sum+=\$1} END {print sum}'" < /dev/null)";\ + gluster_disks="$(ssh $HOST "df -h | grep /gluster/brick | wc -l" < /dev/null)";\ + disks="$(ssh $HOST "sudo ssacli ctrl all show config | grep physicaldrive | wc -l" < /dev/null)";\ + minio_disk="$(ssh $HOST "df -h | grep /minio/disk | wc -l" < /dev/null)";\ + echo "" + echo "" + echo "" + echo "" + echo " + " +done +fi +echo " + + +
Node Raw Capacity Number of disks Assigned to S3 Unassigned
${HOST} ${raw_per_node} TB ${disks} ${minio_disk} ${gluster_disks}
+ + +" +) | sudo sendmail -t -f $sender diff --git a/capacity-report-s3.sh b/capacity-report-s3.sh new file mode 100644 index 0000000..ffafa19 --- /dev/null +++ b/capacity-report-s3.sh @@ -0,0 +1,152 @@ +#!/bin/bash + +function ConvertToTB () { + 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'/\G.*//'); \ + getRepoValue=$(ConvertToTB $getRepoValue) + echo $getRepoValue $3; \ +} + +# License number +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: ).*(?=)') + +( + 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 Capacities Report + + + + + + + + +

iTernity iCAS FS Capacities Report

+

Overview of cluster capacities

+ + + + + + + + + " + +echo "" +# 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 "" +# 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 "" +# 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 "" +# 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 " + + + + +
License Number Raw Capacity Total Usable Available Capacity Used
${license_number} ${raw_capacity} TB ${usable_total_TB} TB ${available_capacity_TB} TB ${used_capacity_TB} TB
+

Overview of node capacities

+ + + + + + + + + " +if [[ $(sudo gluster vo info | grep brick | grep arbiter | grep -o -P '(?<=: ).*(?=:)' | sort -u) ]]; then + echo -e "\nArbiter: Yes" +else +sudo gluster vo info | grep brick | grep -o -P '(?<=: ).*(?=:)' | sort -u | \ +while read HOST; \ +do \ + raw_per_node="$(ssh $HOST "sudo ssacli ctrl all show config | grep -o -P '(?<=HDD, ).*(?= TB)' | awk '{sum+=\$1} END {print sum}'" < /dev/null)";\ + gluster_disks="$(ssh $HOST "df -h | grep /gluster/brick | wc -l" < /dev/null)";\ + disks="$(ssh $HOST "sudo ssacli ctrl all show config | grep physicaldrive | grep -vw SSD | wc -l" < /dev/null)";\ + minio_disk="$(ssh $HOST "df -h | grep /minio/disk | wc -l" < /dev/null)";\ + echo "" + echo "" + echo "" + echo "" + echo " + " +done +fi +echo " + + +
Node Raw Capacity Number of disks Assigned to S3 Unassigned
${HOST} ${raw_per_node} TB ${disks} ${minio_disk} ${gluster_disks}
+ + +" +) | sudo sendmail -t -f $sender + diff --git a/capacity-report.sh b/capacity-report.sh new file mode 100644 index 0000000..f0a7a29 --- /dev/null +++ b/capacity-report.sh @@ -0,0 +1,180 @@ +#!/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 Capacities Report + + + + + + + + +

iTernity iCAS FS Capacity Report

+

Overview of cluster capacities

+ + + + + + + + + " +# License number +echo "" +# 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 "" +# 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 "" +# 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 "" +# Usable Capacity +usable_capacity=$(echo $allocated_capacity_TB + $available_capacity_TB | bc) # is technically TiB +echo " + + + + +
License Number Raw Capacity Allocated Capacity Available Capacity Usable Capacity
${license_number} ${raw_capacity} TB ${allocated_capacity_TB} TB ${available_capacity_TB} TB ${usable_capacity} TB
+ +

Overview of node capacities

+ + + + + + + + + " +sudo gluster vo info | grep brick | grep -iv arbiter | grep -o -P '(?<=: ).*(?=:)' | sort -u | \ +while read HOST; \ +do \ + raw_per_node="$(ssh $HOST "sudo ssacli ctrl all show config | grep -o -P '(?<=HDD, ).*(?= TB)' | awk '{sum+=\$1} END {print sum}'" < /dev/null)";\ + available_capacity_node_GB="$(ssh $HOST "sudo ssacli ctrl all show config | grep 'Unused Space:' | grep -o '[[:digit:]]*' | awk '{sum+=\$1} END {sum=sum/1024} END {print sum}'" < /dev/null)";\ + disks="$(ssh $HOST "sudo ssacli ctrl all show config | grep physicaldrive | grep -vw SSD | wc -l" < /dev/null)";\ + logicalDrive="$(ssh $HOST "sudo ssacli ctrl all show config | grep -w 'RAID 6' | wc -l" < /dev/null)";\ + available_capacity_node_TB=$(ConvertOnlyToTB $available_capacity_node_GB);\ + echo "" + echo "" + echo "" + echo "" + echo " + " +done +echo " + + +
Node Raw Capacity Available Capacity Number of disks Logical drives
${HOST} ${raw_per_node} TB ${available_capacity_node_TB} TB ${disks} ${logicalDrive} of 64
+

Overview of repository capacities

+ + + + + + + + + " +df | grep repositories | sed s'/.*\/gluster\/repositories\///' | sort -k1 | \ +while read Repo; \ +do \ + Repository=$(df | grep -w -m 1 $Repo | cut -d / -f2 | cut -d " " -f1); \ +echo "" + repo_size=$(GetRepoCapacity size $Repo) +echo "" + repo_avail=$(GetRepoCapacity avail $Repo) +echo "" + repo_used=$(GetRepoCapacity used $Repo) +echo "" + repo_pcent=$(df -BG --output=pcent,target | grep -w -m 1 $Repo | cut -d % -f1) +echo " + " +done +echo " + + +
Repository Size Avail Used Use%
${Repository} ${repo_size} ${repo_avail} ${repo_used} ${repo_pcent} %
+ + +" +) | sudo sendmail -t -f $sender +