#!/bin/bash #---------------------------------------------------- # 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