From 7ae383c2e9e0780d78261471afbd264d381805a2 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Tue, 6 Nov 2018 17:37:26 +0000 Subject: [PATCH] Work on server status scripts --- i3/blocks/serverStatus | 10 +++++++--- i3/i3blocks-secondary.conf | 21 +++++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/i3/blocks/serverStatus b/i3/blocks/serverStatus index 34bce4c2..7cb382d4 100755 --- a/i3/blocks/serverStatus +++ b/i3/blocks/serverStatus @@ -8,7 +8,7 @@ source $SCRIPTPATH/servers.private checkAllSites(){ eval server=( \${$1[@]} ) for site in ${server[@]}; do - printf "%-35s | %s \n" "$site" "$(checkURL $site)" + printf "%-35s | %s \n" "$site" "$(checkURL $site $1)" done } @@ -19,11 +19,14 @@ checkRandomSite(){ random=$(( ( RANDOM % (${#server[@]} - 1) ) + 1 )) urlToCheck=${server[$random]} echo $urlToCheck - echo $(checkURL $urlToCheck) + echo $(checkURL $urlToCheck $1) } checkURL(){ - responce=$(curl -s --head -w %{http_code} $1 -L -o /dev/null --connect-timeout 60) + responce=$(curl -s --head -w %{http_code} $1 -L -o /dev/null --connect-timeout 10) + if [ "$responce" != 200 ]; then + pgrep -x dunst && notify-send -u critical "$1 is down" "Server: $2\nResponce: $responce" + fi echo $responce } @@ -39,6 +42,7 @@ if [ ! -z "$1" ]; then echo "#00FF00" else echo "#FF8000" + fi elif [ "$2" = "all" ]; then checkAllSites $1 diff --git a/i3/i3blocks-secondary.conf b/i3/i3blocks-secondary.conf index 187503de..c3943404 100644 --- a/i3/i3blocks-secondary.conf +++ b/i3/i3blocks-secondary.conf @@ -66,42 +66,47 @@ label=Home Server Updates [vps01status] command=~/.dotfiles/i3/blocks/serverStatus VPS01 -interval=30 +interval=10 separator=false [vps02status] command=~/.dotfiles/i3/blocks/serverStatus VPS02 -interval=30 +interval=10 separator=false [vps03status] command=~/.dotfiles/i3/blocks/serverStatus VPS03 -interval=30 +interval=10 separator=false [freightlinerstatus] command=~/.dotfiles/i3/blocks/serverStatus Freightliner -interval=30 +interval=10 +separator=false + +[wilks] +command=~/.dotfiles/i3/blocks/serverStatus Wilks +interval=10 separator=false [nhsstatus] command=~/.dotfiles/i3/blocks/serverStatus NHS -interval=30 +interval=10 separator=false [vapourtecstatus] command=~/.dotfiles/i3/blocks/serverStatus Vapourtec -interval=30 +interval=10 separator=false [checkitstatus] command=~/.dotfiles/i3/blocks/serverStatus Checkit -interval=30 +interval=10 [wanip] label=🌍 command=echo "$label $(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')" -interval=30 +interval=600 color=#00FF00