using fping to monitor internet connection status

Alex Zbyslaw xfb52 at dial.pipex.com
Thu Jul 6 15:20:16 UTC 2006


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




More information about the freebsd-questions mailing list