Date: Thu, 06 Jul 2006 16:19:56 +0100 From: Alex Zbyslaw <xfb52@dial.pipex.com> To: Paul Hamilton <paulh@bdug.org.au> Cc: freebsd-questions@freebsd.org Subject: Re: using fping to monitor internet connection status Message-ID: <44AD2A1C.3010405@dial.pipex.com> In-Reply-To: <032f01c6a10e$494e4c40$6600a8c0@w2k2> References: <032f01c6a10e$494e4c40$6600a8c0@w2k2>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44AD2A1C.3010405>
