From 46aa4d097868d573edf7b0787de502b3313a7f79 Mon Sep 17 00:00:00 2001 From: Oleg Sheynin Date: Mon, 25 Dec 2023 21:09:09 -0500 Subject: [PATCH] health check storage - initial --- release_version.txt | 2 +- scripts/healthcheck/storage_health_check.sh | 65 +++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100755 scripts/healthcheck/storage_health_check.sh diff --git a/release_version.txt b/release_version.txt index 449d7e7..0f82685 100644 --- a/release_version.txt +++ b/release_version.txt @@ -1 +1 @@ -0.3.6 +0.3.7 diff --git a/scripts/healthcheck/storage_health_check.sh b/scripts/healthcheck/storage_health_check.sh new file mode 100755 index 0000000..2abb512 --- /dev/null +++ b/scripts/healthcheck/storage_health_check.sh @@ -0,0 +1,65 @@ +#!/bin/sh +echo $0 $* | /usr/bin/ts '[%Y-%m-%d %H:%M:%S]' + +RootDir=/home/oleg + + +# Temporary +MmSender=tee +# ~/.pyenv/python3.10-venv/bin/python3 ./cvttpy/apps/utils/mmost_sender.py --channel=Status-CVTT --log_level=ERROR 2>&1 > /dev/null + +Hosts= +Hosts="${Hosts} cloud11.cvtt.vpn" +Hosts="${Hosts} cloud14.cvtt.vpn" +Hosts="${Hosts} cloud15.cvtt.vpn" +Hosts="${Hosts} cloud16.cvtt.vpn" +Hosts="${Hosts} cloud17.cvtt.vpn" +Hosts="${Hosts} cloud19.cvtt.vpn" +Hosts="${Hosts} cloudstore.cvtt.vpn" + +Hosts="${Hosts} cvttdata.cvtt.vpn" +Hosts="${Hosts} cryptoval1.cvtt.vpn" +Hosts="${Hosts} cryptoval2.cvtt.vpn" +Hosts="${Hosts} cryptoval3.cvtt.vpn" + +Hosts="${Hosts} homestore.cvtt.vpn" +Hosts="${Hosts} dtvmhost.cvtt.vpn" + +# With Ports +# Hosts="${Hosts} cloud14.cryptovaltrading.com" +# Hosts="${Hosts} cloud18.cryptovaltrading.com" + + +ALERT_USAGE=75% + +echo "### [$(date +'%Y-%m-%d %H:%M:%S')] Storage Health Check" +function checkSpace() { + fs=$1 + space_used=$2 + + if [ ${space_used%?} -ge ${ALERT_USAGE%?} ]; then + echo ":bangbang: ALERT!!! Filesystem **${fs}** is using **${space_used}** :bangbang:" + fi +} + +function storage_check() { + + for host in ${Hosts} + do + Cmd="ssh $host" + Cmd="${Cmd} eval \"df -hTl -x squashfs | grep -v tmpfs | grep -v Filesystem\"" + IFS=$'\n' ; lines=$(eval ${Cmd}) # | grep -v 'Use%') + for ln in $lines + do + IFS=$' '; args=($ln); unset IFS + echo "**${host}**:***${args[6]}*** *${args[5]}*" + checkSpace "${host}:${args[6]}" ${args[5]} + done + unset IFS + echo '-' + done + +} + +storage_check 2>&1 +