Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Mark Leighton Fisher (4252)

Mark Leighton Fisher
  (email not shown publicly)
http://mark-fisher.home.mindspring.com/

I am a Systems Engineer at Regenstrief Institute [regenstrief.org]. I also own Fisher's Creek Consulting [comcast.net].
Thursday March 03, 2005
03:58 PM

perlping - portable ping(1) in Pure Perl

[ #23481 ]

perlping is a Unix-like ping(1) implementation, using Net::Ping for the low-level ping functionality. perlping was written because I wanted to install the Nagios network monitoring software on a client's hosted FreeBSD 4.8 system, but FreeBSD 4.8's built-in ping would not accept a ping count argument -- and Nagios needs a count-accepting ping to perform basic "host alive" checking.

perlping takes the following command-line arguments:

bind=s
Bind to the specified interface (using Net::Ping::bind()).
count=i
Number of pings to send - default is one.
help
Prints help message.
port=s
Port name or number "s" to bind to - defaults to the HTTP port, 80. (This default is different from the built-in ping(1).)
proto=s
Protocol to use - defaults to "tcp". (This default is different from the built-in ping(1).)
verbose
Verbose results - prints type of ping used and results for each ping. Default is to print only the cumulative results.

perlping defaults to connecting the HTTP (webserver) port 80 using TCP, which may be helpful in getting through firewalls that (justifiably) block ICMP packets. The ability to specify the protocol and port number is also useful for basic connectivity testing of other network services, like SSH.

perlping reports minimum, average, and maximum ping times, along with any packets lost. This functionality is sufficient for Nagios. If the standard deviation of ping response times was needed, you could easily add it using Statistics::Descriptive.

To install perlping, download the perlping source file, then type at the command line:

perl perlping-PL.TXT PERLPINGBINARYNAME

where PERLPINGBINARYNAME is the filename for your executable copy of perlping. (All the source program does is install perlping with the configured copy of Perl.)

perlping has been tested on FreeBSD 4.8, Windows XP, and Redhat Linux. It should work everywhere that Perl can use Net::Ping and command-line arguments. Enjoy!

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I've recently noticed a bug shared by at least two different ping implementations.

    The average time is computed as: (total of all received ping times) / (number of pings). This counts dropped packets as having responded in time 0 rather than either ignoring them or counting them as time infinity. I've seen a report saying min/max/average were 80/120/13.5 - an average of 13.5 calculated from a group of numbers in which the minimum was 80! The average should instead by computed as (total of all received pi

  • Personally I'd remove "perl" from the name. Two reasons.

    1) Its an implementation detail that the user shouldn't care about. Its not important to the user that its written in Perl its important that its Portable. Thus pping. Portable Ping. And you can still referr to it as Perl Ping if you want. :) Same reason I'm so against the .pl suffix.

    2) Having Perl in the name can immediately turn some folks off and they won't touch it at all. If you instead get them using an innocously named program... "Hey,