Work on server status scripts

master
Jonathan Hodgson 6 years ago
parent 932615aa20
commit 7ae383c2e9
  1. 10
      i3/blocks/serverStatus
  2. 21
      i3/i3blocks-secondary.conf

@ -8,7 +8,7 @@ source $SCRIPTPATH/servers.private
checkAllSites(){ checkAllSites(){
eval server=( \${$1[@]} ) eval server=( \${$1[@]} )
for site in ${server[@]}; do for site in ${server[@]}; do
printf "%-35s | %s \n" "$site" "$(checkURL $site)" printf "%-35s | %s \n" "$site" "$(checkURL $site $1)"
done done
} }
@ -19,11 +19,14 @@ checkRandomSite(){
random=$(( ( RANDOM % (${#server[@]} - 1) ) + 1 )) random=$(( ( RANDOM % (${#server[@]} - 1) ) + 1 ))
urlToCheck=${server[$random]} urlToCheck=${server[$random]}
echo $urlToCheck echo $urlToCheck
echo $(checkURL $urlToCheck) echo $(checkURL $urlToCheck $1)
} }
checkURL(){ 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" "<b>Server:</b> $2\n<b>Responce:</b> $responce"
fi
echo $responce echo $responce
} }
@ -39,6 +42,7 @@ if [ ! -z "$1" ]; then
echo "#00FF00" echo "#00FF00"
else else
echo "#FF8000" echo "#FF8000"
fi fi
elif [ "$2" = "all" ]; then elif [ "$2" = "all" ]; then
checkAllSites $1 checkAllSites $1

@ -66,42 +66,47 @@ label=Home Server Updates
[vps01status] [vps01status]
command=~/.dotfiles/i3/blocks/serverStatus VPS01 command=~/.dotfiles/i3/blocks/serverStatus VPS01
interval=30 interval=10
separator=false separator=false
[vps02status] [vps02status]
command=~/.dotfiles/i3/blocks/serverStatus VPS02 command=~/.dotfiles/i3/blocks/serverStatus VPS02
interval=30 interval=10
separator=false separator=false
[vps03status] [vps03status]
command=~/.dotfiles/i3/blocks/serverStatus VPS03 command=~/.dotfiles/i3/blocks/serverStatus VPS03
interval=30 interval=10
separator=false separator=false
[freightlinerstatus] [freightlinerstatus]
command=~/.dotfiles/i3/blocks/serverStatus Freightliner command=~/.dotfiles/i3/blocks/serverStatus Freightliner
interval=30 interval=10
separator=false
[wilks]
command=~/.dotfiles/i3/blocks/serverStatus Wilks
interval=10
separator=false separator=false
[nhsstatus] [nhsstatus]
command=~/.dotfiles/i3/blocks/serverStatus NHS command=~/.dotfiles/i3/blocks/serverStatus NHS
interval=30 interval=10
separator=false separator=false
[vapourtecstatus] [vapourtecstatus]
command=~/.dotfiles/i3/blocks/serverStatus Vapourtec command=~/.dotfiles/i3/blocks/serverStatus Vapourtec
interval=30 interval=10
separator=false separator=false
[checkitstatus] [checkitstatus]
command=~/.dotfiles/i3/blocks/serverStatus Checkit command=~/.dotfiles/i3/blocks/serverStatus Checkit
interval=30 interval=10
[wanip] [wanip]
label=🌍 label=🌍
command=echo "$label $(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')" command=echo "$label $(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')"
interval=30 interval=600
color=#00FF00 color=#00FF00

Loading…
Cancel
Save