Pinging the Server and saving the status on a CSV file.

Jonathan Stowe jns at
Fri Jun 8 09:08:54 PDT 2007

On Fri, 2007-06-08 at 15:27 +0000, Ravi Patel wrote:
> Guy's,
> I'm a beginner PERL developer and I need some guidance on the
> following problem by starting me off with some coding?  I have studied
> the Net::Ping module in CPAN, it's linking this code to create a CSV
> file is causing me difficultly.  Not sure what to do?
> The Problem:
> I am going to set up a Server status area on our companys website
> (sits on server A), the PERL coding will PING two other servers
> (server B & C) to see their currently status every 5 mins. 

Right, well that's all fairly simple:


use strict;
use warnings;
use Net::Ping;

use CGI qw(:standard);

my @servers = qw(localhost crm-p-pbs01 rabelais);

my $ping = Net::Ping->new();

print header(-Refresh => 300);

print <<EOHTML;

foreach my $host ( @servers )
   my $status = $ping->ping($host) ? 'ALIVE' : 'DEAD';
   print <<EOHOST;

print "</table></body></html>";

I'll leave nicely templating it and making it use an external
configuration file as an exercise.  I'm not quite sure where the CSV
part comes in though.

> Finally which protocol will I be using?

Well there are two things that you need to balance - on most systems
only the superuser can use ICMP to do a true 'ping' however it is
equally possible that the TCP (or UDP) echo service might be disabled on
a host you want to check for "security reasons". I've just used the
default TCP on the above.

> Thank you
> Ravi 
> ______________________________________________________________________
> Play your part in making history - Email Britain! 
> _______________________________________________
> MiltonKeynes-pm mailing list
> MiltonKeynes-pm at

More information about the MiltonKeynes-pm mailing list