153 lines
5.7 KiB
Bash
153 lines
5.7 KiB
Bash
#!/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 "
|
|
<html><head><title>iTernity iCAS FS Capacities Report</title></head>
|
|
|
|
|
|
<link rel="stylesheet" type="text/css" href="styles.css">
|
|
|
|
<head>
|
|
<style>
|
|
table#Tabelle1 {
|
|
border: 1px solid black;
|
|
width: 100%;
|
|
}
|
|
|
|
table#Tabelle1 tr:nth-child(even) {
|
|
background-color: #eee
|
|
}
|
|
|
|
table#Tabelle1 tr:nth-child(odd) {
|
|
background-color: #fff;
|
|
}
|
|
|
|
table#Tabelle1 th {
|
|
color: rgb(45, 235, 45);
|
|
background-color: black;
|
|
padding: 4px 4px 2px 4px;
|
|
}
|
|
|
|
table#Tabelle1 td {
|
|
border: 1px solid black;
|
|
padding: 2px;
|
|
color: rgb(118, 211, 160);
|
|
}
|
|
|
|
table#Tabelle1 tr:last-of-type td {
|
|
background-color: fffb99;
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body style='background-color:rgb(46, 48, 45);'>
|
|
<h1><p style='text-align: center;color:rgb(45, 235, 45)'>iTernity iCAS FS Capacities Report </p></h1>
|
|
<h2><p style='text-align: center;color:rgb(45, 235, 45)'>Overview of cluster capacities</p></h2>
|
|
<table id="Tabelle1">
|
|
<tr>
|
|
<td> License Number </td>
|
|
<td> Raw Capacity </td>
|
|
<td> Total Usable </td>
|
|
<td> Available Capacity </td>
|
|
<td> Used </td>
|
|
</tr>
|
|
<tr>"
|
|
|
|
echo "<td> ${license_number} </td>"
|
|
# 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 "<td> ${raw_capacity} TB </td>"
|
|
# 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 "<td> ${usable_total_TB} TB </td>"
|
|
# 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 "<td> ${available_capacity_TB} TB </td>"
|
|
# 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 "<td> ${used_capacity_TB} TB </td>
|
|
</tr>
|
|
<tr>
|
|
<!-- <td colspan="3"> An expansion for Repo1 has been initialised. </td> -->
|
|
</tr>
|
|
</table>
|
|
<h2><p style='text-align: center;color:rgb(45, 235, 45)'>Overview of node capacities</p></h2>
|
|
<table id="Tabelle1">
|
|
<tr>
|
|
<td> Node </td>
|
|
<td> Raw Capacity </td>
|
|
<td> Number of disks </td>
|
|
<td> Assigned to S3 </td>
|
|
<td> Unassigned </td>
|
|
</tr>
|
|
<tr>"
|
|
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 "<td> ${HOST} </td>"
|
|
echo "<td> ${raw_per_node} TB </td>"
|
|
echo "<td> ${disks} </td>"
|
|
echo "<td> ${minio_disk} </td>"
|
|
echo "<td> ${gluster_disks} </td>
|
|
</tr>"
|
|
done
|
|
fi
|
|
echo "<tr>
|
|
<!-- <td colspan="3"> An expansion for Repo1 has been initialised. </td> -->
|
|
</tr>
|
|
</table>
|
|
</body>
|
|
</html>
|
|
"
|
|
) | sudo sendmail -t -f $sender
|
|
|