From d5ee1a6157065363843e6367e932f7b11b17706c Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 24 Feb 2009 20:17:15 +0100 Subject: added watchdog script --- .gitignore | 1 + watchdog.sh | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 .gitignore create mode 100755 watchdog.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..35fcdf9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +watchdog_ips diff --git a/watchdog.sh b/watchdog.sh new file mode 100755 index 0000000..a0fb1ec --- /dev/null +++ b/watchdog.sh @@ -0,0 +1,186 @@ +#!/bin/bash +#---------------------------------------------------- +# File: watchdog.sh +# Version: 0.1.7.0 +# Author: Florian "Bluewind" Pritz +# +# Copyright (C) 2008-2009 Florian Pritz +# +# Licensed under GNU General Public License v3 +# (see COPYING for full license text) +# +#---------------------------------------------------- +# Script to check if services are working and take +# actions if not +#---------------------------------------------------- +# NOTE: +# Format for service file +# + +#-------------------------- CONFIGURATION -----------------------------# +# Time to wait between 2 checks; Shouldn't be lower than 10 as that +# could cause overlap with the timeouts +WAIT=60 + +# Take action after x faild checks +MAX_FAIL=2 + +# set to /dev/null if you don't want logs +LOGFILE="$HOME/watchdog.log" + +# Paths (Shouldn't need to be changed) +CURL="/usr/bin/curl" +WGET="/usr/bin/wget" +PING="/bin/ping" +#----------------------------------------------------------------------# + +SCRIPTNAME=$(basename $0) + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +EXIT_ERROR=2 +EXIT_BUG=10 + +# Colors for output +red='\e[0;31m' +RED='\e[1;31m' +green='\e[0;32m' +GREEN='\e[1;32m' +blue='\e[0;34m' +BLUE='\e[1;34m' +cyan='\e[0;36m' +CYAN='\e[1;36m' +NC='\e[0m' + +function usage { + echo -e "${blue}Usage:${NC} ${SCRIPTNAME} [OPTIONS] [ ]" >&2 + echo -e "Possible service types: http, ping (default)" + echo -e "Options:" >&2 + echo -e "-h this help" >&2 + echo -e "-f loads IP list from a file" >&2 + echo -e "-t