Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 769d8116d5 | |||
| a7ad7f45f5 | |||
| 0e6190f999 | |||
| 180e3f89cf | |||
| 80bbf47755 |
+1
-1
@@ -1 +1 @@
|
|||||||
0.7.9
|
0.8.2.2
|
||||||
|
|||||||
@@ -34,14 +34,33 @@ Hosts="${Hosts} cvtt-prod-01.cvtt.vpn"
|
|||||||
Hosts="${Hosts} cvtt-prod-02.cvtt.vpn"
|
Hosts="${Hosts} cvtt-prod-02.cvtt.vpn"
|
||||||
Hosts="${Hosts} cvtt-prod-03.cvtt.vpn"
|
Hosts="${Hosts} cvtt-prod-03.cvtt.vpn"
|
||||||
|
|
||||||
|
Metrics=()
|
||||||
|
TempFiles=
|
||||||
|
|
||||||
|
function cleanup {
|
||||||
|
if [ "" != "${TempFiles}" ]; then
|
||||||
|
echo rm -f ${TempFiles}
|
||||||
|
rm -f ${TempFiles}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
|
||||||
|
function new_tempfile {
|
||||||
|
tmpfile=$(mktemp)
|
||||||
|
TempFiles="${TempFiles} ${tmpfile}"
|
||||||
|
echo ${tmpfile}
|
||||||
|
}
|
||||||
|
|
||||||
function space_alert() {
|
function space_alert() {
|
||||||
ALERT_USAGE=75%
|
ALERT_USAGE=75%
|
||||||
for ln in "${Measurements[@]}"
|
for metric in "${Metrics[@]}"
|
||||||
do
|
do
|
||||||
IFS=$' '; args=($ln); unset IFS
|
IFS=$' '; args=($metric); unset IFS
|
||||||
host=${args[0]}
|
host=${args[0]}
|
||||||
fs=${args[1]}
|
fs=${args[1]}
|
||||||
space_used=${args[2]}
|
space_used=${args[2]}
|
||||||
|
|
||||||
if [ ${space_used%?} -ge ${ALERT_USAGE%?} ]; then
|
if [ ${space_used%?} -ge ${ALERT_USAGE%?} ]; then
|
||||||
echo ":red_circle: Filesystem **${host}:${fs}** is using **${space_used}** :red_circle:"
|
echo ":red_circle: Filesystem **${host}:${fs}** is using **${space_used}** :red_circle:"
|
||||||
fi
|
fi
|
||||||
@@ -52,6 +71,7 @@ function storage_check() {
|
|||||||
|
|
||||||
result_lines=()
|
result_lines=()
|
||||||
|
|
||||||
|
declare -a SingleMeas
|
||||||
for host in ${Hosts}
|
for host in ${Hosts}
|
||||||
do
|
do
|
||||||
if [[ "${host}" == *"cryptovaltrading.com" ]]; then
|
if [[ "${host}" == *"cryptovaltrading.com" ]]; then
|
||||||
@@ -70,7 +90,12 @@ function storage_check() {
|
|||||||
do
|
do
|
||||||
IFS=$' '; args=($ln); unset IFS
|
IFS=$' '; args=($ln); unset IFS
|
||||||
res="${args[5]}| **${host}** | ***${args[6]}*** | *${args[5]}* |"
|
res="${args[5]}| **${host}** | ***${args[6]}*** | *${args[5]}* |"
|
||||||
|
|
||||||
result_lines+=("$res")
|
result_lines+=("$res")
|
||||||
|
|
||||||
|
fs=${args[6]}
|
||||||
|
used=${args[5]}
|
||||||
|
Metrics+=("$host $fs $used")
|
||||||
done
|
done
|
||||||
unset IFS
|
unset IFS
|
||||||
done
|
done
|
||||||
@@ -80,8 +105,8 @@ function storage_check() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(new_tempfile)
|
||||||
tmpfile2=$(mktemp)
|
tmpfile2=$(new_tempfile)
|
||||||
storage_check > ${tmpfile2}
|
storage_check > ${tmpfile2}
|
||||||
|
|
||||||
echo "## :card_file_box: STORAGE HEALTH CHECK" >> ${tmpfile}
|
echo "## :card_file_box: STORAGE HEALTH CHECK" >> ${tmpfile}
|
||||||
@@ -90,17 +115,14 @@ echo "| host | filesystem | usage |" >> ${tmpfile}
|
|||||||
echo "| --- | --- | --- |" >> ${tmpfile}
|
echo "| --- | --- | --- |" >> ${tmpfile}
|
||||||
cat ${tmpfile2} | sort -h -r | awk -F'%' '{printf "%s%%%s\n",$2,$3}' >> ${tmpfile}
|
cat ${tmpfile2} | sort -h -r | awk -F'%' '{printf "%s%%%s\n",$2,$3}' >> ${tmpfile}
|
||||||
cat ${tmpfile} | ${Sender} ${StatusChannel}
|
cat ${tmpfile} | ${Sender} ${StatusChannel}
|
||||||
rm ${tmpfile} ${tmpfile2}
|
|
||||||
|
|
||||||
Measurements=()
|
Measurements=()
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(new_tempfile)
|
||||||
space_alert > ${tmpfile}
|
space_alert > ${tmpfile}
|
||||||
cat ${tmpfile}
|
|
||||||
if [ -s ${tmpfile} ]
|
if [ -s ${tmpfile} ]
|
||||||
then
|
then
|
||||||
(echo "### :card_file_box: STORAGE ALERTS" && cat ${tmpfile}) | ${Sender} ${AlertChannel}
|
(echo "### :card_file_box: STORAGE ALERTS" && cat ${tmpfile}) | ${Sender} ${AlertChannel}
|
||||||
else
|
else
|
||||||
echo File ${tmpfile} is empty
|
echo "No Storage Alerts"
|
||||||
fi
|
fi
|
||||||
rm ${tmpfile}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user