Work on server status scripts
This commit is contained in:
		
							parent
							
								
									bb8c20cf9e
								
							
						
					
					
						commit
						9e2af8057a
					
				
					 2 changed files with 20 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -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" "<b>Server:</b> $2\n<b>Responce:</b> $responce"
 | 
			
		||||
	fi
 | 
			
		||||
	echo $responce
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -39,6 +42,7 @@ if [ ! -z "$1" ]; then
 | 
			
		|||
			echo "#00FF00"
 | 
			
		||||
		else
 | 
			
		||||
			echo "#FF8000"
 | 
			
		||||
 | 
			
		||||
		fi
 | 
			
		||||
	elif [ "$2" = "all" ]; then
 | 
			
		||||
		checkAllSites $1
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue