From owner-freebsd-questions@FreeBSD.ORG Thu Jul 6 15:20:16 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 543C316A4E1 for ; Thu, 6 Jul 2006 15:20:16 +0000 (UTC) (envelope-from xfb52@dial.pipex.com) Received: from smtp-out2.blueyonder.co.uk (smtp-out2.blueyonder.co.uk [195.188.213.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6244043D7D for ; Thu, 6 Jul 2006 15:20:05 +0000 (GMT) (envelope-from xfb52@dial.pipex.com) Received: from [172.23.170.141] (helo=anti-virus02-08) by smtp-out2.blueyonder.co.uk with smtp (Exim 4.52) id 1FyVe6-0001lu-3k; Thu, 06 Jul 2006 16:20:02 +0100 Received: from [82.41.34.175] (helo=[192.168.0.2]) by asmtp-out2.blueyonder.co.uk with esmtp (Exim 4.52) id 1FyVe1-00005U-Cx; Thu, 06 Jul 2006 16:19:57 +0100 Message-ID: <44AD2A1C.3010405@dial.pipex.com> Date: Thu, 06 Jul 2006 16:19:56 +0100 From: Alex Zbyslaw User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-GB; rv:1.7.13) Gecko/20060515 X-Accept-Language: en MIME-Version: 1.0 To: Paul Hamilton References: <032f01c6a10e$494e4c40$6600a8c0@w2k2> In-Reply-To: <032f01c6a10e$494e4c40$6600a8c0@w2k2> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: using fping to monitor internet connection status X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jul 2006 15:20:16 -0000 Paul Hamilton wrote: >Hi, > >I need to monitor a number of IP addresses, so that if they ALL go down (say >three IP's), then that is a pretty good indication that my server has lost >internet connectivity. The most probable cause is usually the ADSL router, >and therefore needs a reboot. I was hoping to use the 'fping' program, but >looking through the man file, there doesn't seem to be an exit status on >loosing ALL the pings. > >If one goes down, I don't care, maybe that server is down, so keep pinging >the other two etc. > >I was hoping to write this in Perl (the first fping example looked ok, until >I realised that it would activate when any one IP address became >unreachable, which means that I am still connected to the Internet). > >Any idea's on a ping tool or simple script? > > Pseudo code for perl or sh or pretty much any language that can run commands and determine exit staus: Set a variable to 0 For each server ping server and if it fails increment variable End foreach If variable == number of servers then all pings failed. Variable contains number of unsuccessfully pinged servers. Or Set a variable to 0 For each server ping server and if succeeds, increment variable End foreach If variable == 0 then all pings failed. Variable contains number of successfully pinged servers. From sh "ping -c 1 -q host > /dev/null 2>&1" will ping host and set status with no actual output. Never heard of fping. --Alex