#!/bin/sh # # Author deelkar@gmx.de # # /usr/local/bin/online # # Version 7.3.3 # # Requires: ping of SuSE 7.3 # # Public: yes # Copyright (C) 2002 "Dirk-Lueder Kreie" # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the # # Free Software Foundation, Inc. # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 # USA. count=$1 wait=$2 pingip1=$3 pingip2=$4 pingver=`ping -V 2>&1` #test "$pingver" = "ping utility, iputils-ss010824" || echo -e "WARNING ping versions don't match \n \"$pingver\" != \"ping utility, iputils-ss010824\"" if [ "$1" == "" ]; then count="4" fi if [ "$2" == "" ]; then wait="10" fi if [ "$3" == "" ]; then pingip1="193.99.144.85" fi if [ "$4" == "" ]; then pingip2="134.102.20.20" fi pingresult1=`ping -qnc $count -w $wait $pingip1 2>&1` # Turn on for debug: #echo "1: $pingresult1" #echo "2: $pingresult2" case "$pingresult1" in *'100% loss'*) date echo "ping to $pingip1 failed" ;; *'100% packet loss'*) date echo "ping to $pingip1 failed" ;; *'unreachable'*) date echo "ping to $pingip1 failed" ;; *'No buffer space available'*) date echo "ping to $pingip1 failed" sleep 5 ;; *'broadcast'*) echo "trying to ping broadcast IP?" exit 1 ;; *) exit 0 ;; esac pingresult2=`ping -qnc $count -w $wait $pingip2 2>&1` case "$pingresult2" in *'100% loss'*) echo "ping to $pingip2 failed" exit 1 ;; *'100% packet loss'*) echo "ping to $pingip2 failed" exit 1 ;; *'unreachable'*) echo "ping to $pingip2 failed" exit 1 ;; *'No buffer space available'*) echo "ping to $pingip1 failed" exit 1 ;; *'broadcast'*) echo "trying to ping broadcast IP?" exit 1 ;; *) exit 0 ;; esac