My friend Nicolai Langfeldt (author of the
DNS HOWTO) works at a
large ISP, where he recently needed to ping somewhere between 10,000 and
100,000 hosts every ten seconds and feed the up/down data to Nagios. He
had started hacking on fping to do this, but I thought it could be done
better by a smaller program written specifically for this purpose.
I wrote most of
on a flight home. It takes a list of IP addresses on the command line,
writes ICMP echo requests for each address to a raw socket every ten
seconds, and creates another process to print the response time (or
"unreachable") for each response. It does nothing else, and does not
need to allocate any memory after startup.
Nicolai's preliminary tests show that it can send out the 10k pings in
under 100ms, which far exceeds the performance I was hoping for (though
his networking colleagues may yet frown upon sending that many pings so
fast). With that kind of performance, monitoring 100k hosts isn't out of
the question, even if the sender has to be slowed down a bit.
The code is on github in case anyone else finds it useful. Feedback is
While looking for something that could be adapted for this use, I found
the source code of the original ping.c
on the ISOC web site. I decided against modifying it because of several
misleading comments, type abuse (e.g. allocating a struct sockaddr and
casting its address to struct sockaddr_in *), and other K&R/BSD
oddities. But it's good code overall, and it was instructive to look