Home‎ > ‎unix/linux‎ > ‎



fping is a utility that allows you to ping multiple sites with one command. The following doc reviews some of it's capabilities, and gives examples.


To ping an entire network

fping -g
fping -g

To ping an entire network and only see the links that are alive.

fping -g 2>/dev/null | grep -v unreachable
This version includes the average ping response time 
fping -e -g 2>/dev/null | grep -v unreachable

The following perl script will check a list of hosts and send mail if any are unreachable. It uses the open2 function which allows a program to be opened for reading and writing. fping does not start pinging the list of systems until it reads EOF, which it gets after INPUT is closed. Sure the open2 usage is not needed in this example, but it's a good open2 example none the less.

require 'open2.pl';

$MAILTO = "root";

$pid = &open2("OUTPUT","INPUT","/usr/local/bin/fping -u");


foreach(@check) { print INPUT "$_\n"; }

if ($#output != -1) {
open(MAIL,"|mail -s 'unreachable systems' $MAILTO");
print MAIL "\nThe following systems are unreachable as of: $date\n\n";
print MAIL @output;
close MAIL;

Another good example is when you want to perform an action only on hosts that are currently reachable.


$hosts_to_backup = 'cat /etc/hosts.backup | fping -a';

foreach $host (split(/\n/,$hosts_to_backup)) {
# do it