Compare commits

..

4 Commits

Author SHA1 Message Date
oleg 0f6d7874de progress 2024-06-13 19:40:49 -04:00
oleg 769d8116d5 fix 2024-06-13 18:17:13 -04:00
oleg a7ad7f45f5 fix 2024-06-13 18:13:27 -04:00
oleg 0e6190f999 progress 2024-06-13 18:11:54 -04:00
2 changed files with 17 additions and 8 deletions
+1 -1
View File
@@ -1 +1 @@
0.8.1.1 0.8.3
+16 -7
View File
@@ -35,6 +35,15 @@ Hosts="${Hosts} cvtt-prod-02.cvtt.vpn"
Hosts="${Hosts} cvtt-prod-03.cvtt.vpn" Hosts="${Hosts} cvtt-prod-03.cvtt.vpn"
Metrics=() Metrics=()
TempFiles=
function cleanup {
echo Cleaing up temporary files: ${TempFiles}
if [ "" != "${TempFiles}" ]; then
rm -f ${TempFiles}
fi
}
trap cleanup EXIT
function space_alert() { function space_alert() {
ALERT_USAGE=75% ALERT_USAGE=75%
@@ -45,8 +54,6 @@ function space_alert() {
fs=${args[1]} fs=${args[1]}
space_used=${args[2]} space_used=${args[2]}
echo "if [ ${space_used%?} -ge ${ALERT_USAGE%?} ]; then" >&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
@@ -92,7 +99,11 @@ function storage_check() {
} }
tmpfile=$(mktemp) tmpfile=$(mktemp)
TempFiles="${TempFiles} ${tmpfile}"
tmpfile2=$(mktemp) tmpfile2=$(mktemp)
TempFiles="${TempFiles} ${tmpfile2}"
storage_check > ${tmpfile2} storage_check > ${tmpfile2}
echo "## :card_file_box: STORAGE HEALTH CHECK" >> ${tmpfile} echo "## :card_file_box: STORAGE HEALTH CHECK" >> ${tmpfile}
@@ -101,17 +112,15 @@ 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=()
tmpfile=$(mktemp) tmpfile=$(mktemp)
TempFiles="${TempFiles} ${tmpfile}"
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}