201 lines
6.9 KiB
Bash
201 lines
6.9 KiB
Bash
#!/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
|
|
else
|
|
StorageInGB=$StorageInTB
|
|
echo $StorageInGB GB
|
|
fi
|
|
else
|
|
StorageInGB=$1
|
|
echo $StorageInGB MB
|
|
>>>>>>> 7b3a121 (Script aufgeräumt.)
|
|
fi
|
|
}
|
|
|
|
function ConvertOnlyToTB () {
|
|
|
|
SpaceInTB=$(echo $1 | awk '{printf "%.1f\n", $1 / 1024}')
|
|
>>>>>>> 7b3a121 (Script aufgeräumt.)
|
|
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: ).*(?=)')
|
|
|
|
|
|
# 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}"
|
|
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 Capacity 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> Usable Capacity </td>
|
|
<td> Available Capacity </td>
|
|
<td> Allocated Capacity </td>
|
|
</tr>
|
|
<tr>"
|
|
|
|
echo "<td> ${license_number} </td>"
|
|
echo "<td> ${raw_capacity} TB </td>"
|
|
echo "<td> ${usable_capacity} TB </td>"
|
|
echo "<td> ${available_capacity_TB} TB </td>"
|
|
echo "<td> ${allocated_capacity_TB} TB </td>
|
|
|
|
|
|
>>>>>>> 7b3a121 (Script aufgeräumt.)
|
|
</tr>
|
|
<tr>
|
|
<!-- <td colspan="3"> Further information about possible extensions. </td> -->
|
|
</tr>
|
|
</table>
|
|
</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> Available Capacity </td>
|
|
<td> Number of disks </td>
|
|
<td> Logical drives </td>
|
|
</tr>
|
|
<tr>"
|
|
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 "<td> ${HOST} </td>"
|
|
echo "<td> ${raw_per_node} TB </td>"
|
|
echo "<td> ${available_capacity_node_TB} TB </td>"
|
|
echo "<td> ${disks} </td>"
|
|
echo "<td> ${logicalDrive} of 64</td>
|
|
</tr>"
|
|
done
|
|
echo "<tr>
|
|
<!-- <td colspan="3"> Further information about possible extensions. </td> -->
|
|
</tr>
|
|
</table>
|
|
<h2><p style='text-align: center;color:rgb(45, 235, 45)'>Overview of repository capacities</p></h2>
|
|
<table id="Tabelle1">
|
|
<tr>
|
|
<td> Repository </td>
|
|
<td> Size </td>
|
|
<td> Avail </td>
|
|
<td> Used </td>
|
|
<td> Use% </td>
|
|
</tr>
|
|
<tr>"
|
|
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 "<td> ${Repository} </td>"
|
|
repo_size=$(GetRepoCapacity size $Repo)
|
|
echo "<td> ${repo_size} </td>"
|
|
repo_avail=$(GetRepoCapacity avail $Repo)
|
|
echo "<td> ${repo_avail} </td>"
|
|
repo_used=$(GetRepoCapacity used $Repo)
|
|
echo "<td> ${repo_used} </td>"
|
|
repo_pcent=$(df -BG --output=pcent,target | grep -w -m 1 $Repo | cut -d % -f1)
|
|
echo "<td> ${repo_pcent} %</td>
|
|
</tr>"
|
|
done
|
|
echo "<tr>
|
|
<!-- <td colspan="3"> Further information about possible extensions. </td> -->
|
|
</tr>
|
|
</table>
|
|
</body>
|
|
</html>
|
|
"
|
|
) | sudo sendmail -t -f $sender
|
|
|
|
|
|
|
|
>>>>>>> 7b3a121 (Script aufgeräumt.)
|