From e2c2377e41cc284aebe5bb3ae703f211927b9942 Mon Sep 17 00:00:00 2001 From: Oleg Sheynin Date: Wed, 3 Jan 2024 14:09:31 -0500 Subject: [PATCH] progress --- doc/CVTT Hosts Map.drawio | 31 ++++++++++++++++++ release_version.txt | 2 +- scripts/healthcheck/storage_health_check.sh | 35 +++++++++++++-------- 3 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 doc/CVTT Hosts Map.drawio diff --git a/doc/CVTT Hosts Map.drawio b/doc/CVTT Hosts Map.drawio new file mode 100644 index 0000000..b0037ab --- /dev/null +++ b/doc/CVTT Hosts Map.drawio @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/release_version.txt b/release_version.txt index 267577d..2b7c5ae 100644 --- a/release_version.txt +++ b/release_version.txt @@ -1 +1 @@ -0.4.1 +0.4.2 diff --git a/scripts/healthcheck/storage_health_check.sh b/scripts/healthcheck/storage_health_check.sh index 390966a..c6fffbb 100755 --- a/scripts/healthcheck/storage_health_check.sh +++ b/scripts/healthcheck/storage_health_check.sh @@ -1,7 +1,6 @@ #!/bin/sh echo $0 $* | /usr/bin/ts '[%Y-%m-%d %H:%M:%S]' -# RootDir=/home/oleg/develop/cvtt2 RootDir="${HOME}/prod" export PYTHONPATH=${RootDir} @@ -11,6 +10,9 @@ StatusChannel=Status-CVTT AlertChannel=Alerts-CVTT Sender=${RootDir}/ops/utils/send_mmost.sh +# Sender=cat +# StatusChannel= + Hosts= Hosts="${Hosts} cloud11.cvtt.vpn" Hosts="${Hosts} cloud14.cvtt.vpn" @@ -30,8 +32,6 @@ Hosts="${Hosts} nsbackup.cvtt.vpn" Hosts="${Hosts} dtvmhost.cvtt.vpn" Hosts="${Hosts} ops-server.cvtt.vpn" - - function space_alert() { ALERT_USAGE=75% for ln in "${Measurements[@]}" @@ -48,10 +48,8 @@ function space_alert() { function storage_check() { - echo "## :card_file_box: STORAGE HEALTH CHECK" - echo - echo "| host | filesystem | usage |" - echo "| --- | --- | --- |" + result_lines=() + for host in ${Hosts} do Cmd="ssh $host" @@ -64,19 +62,30 @@ function storage_check() { for ln in $lines do IFS=$' '; args=($ln); unset IFS - echo "| **${host}** | ***${args[6]}*** | *${args[5]}* |" - Measurements+=("${host} ${args[6]} ${args[5]}") + res="${args[5]}| **${host}** | ***${args[6]}*** | *${args[5]}* |" + result_lines+=("$res") done unset IFS - echo "| | | |" + done + for ln in "${result_lines[@]}" + do + echo "${ln}" done } -Measurements=() tmpfile=$(mktemp) -storage_check > ${tmpfile} -cat ${tmpfile} | ${Sender} ${StatusChannel} +tmpfile2=$(mktemp) +storage_check > ${tmpfile2} +echo "## :card_file_box: STORAGE HEALTH CHECK" >> ${tmpfile} +echo >> ${tmpfile} +echo "| host | filesystem | usage |" >> ${tmpfile} +echo "| --- | --- | --- |" >> ${tmpfile} +cat ${tmpfile2} | sort -h -r | awk -F'%' '{printf "%s%%%s\n",$2,$3}' >> ${tmpfile} +cat ${tmpfile} | ${Sender} ${StatusChannel} +rm ${tmpfile} ${tmpfile2} + +Measurements=() tmpfile=$(mktemp) space_alert > ${tmpfile} cat ${tmpfile}