Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Ping a Server

by AcidHawk (Vicar)
on Apr 28, 2004 at 08:25 UTC ( #348751=note: print w/replies, xml ) Need Help??

in reply to Ping a Server

What have you tried?

What does your list of servers look like?

Post some code so we can look and make suggestions.

Update: Assuming you file has a server name on each line try the following..

  • open the Server List file
  • read in line by line
  • for each line/servername ping the server (either OS ping with $result = `ping $_`;then do some regex on the $result or look at Net::Ping)
  • close Server List file
  • The code below works for me using Net::Ping PS I havent done the open file and read in a list etc.

    #! /usr/bin/perl use strict; use warnings; use Net::Ping; my ($host,$rtt,$ip); my @host_array = ("OSSTNGMCN01", "OSSTNGMCN04", "PROJECTX99"); my $p = Net::Ping->new("syn"); $p->{port_num} = getservbyname("http", "tcp"); foreach $host (@host_array) { $p->ping($host); } while (($host,$rtt,$ip) = $p->ack) { print "HOST: $host [$ip] ACKed in $rtt seconds.\n"; }
    Of all the things I've lost in my life, its my mind I miss the most.

    Log In?

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: note [id://348751]
    [MidLifeXis]: hahaha: Just received a buzz-word-bingo- compliant email (internal) that starts with "%Firstname% %Lastname%...". It only gets better from there.
    choroba finds working in a small company boring comparing to a large corporation
    [MidLifeXis]: At least test before mass distribution.
    [MidLifeXis]: More opportunities for anonymous snafus :-)
    [MidLifeXis]: In a small group / company, at least you know who needs to buy the next round of beer for their mess-up.
    [MidLifeXis]: :-)
    [Discipulus]: are sure you are not really named "%Firstname% %Lastname%..." ? have you check your identity card?
    [Discipulus]: Bobby Tables?

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (10)
    As of 2017-01-19 12:16 GMT
    Find Nodes?
      Voting Booth?
      Do you watch meteor showers?

      Results (170 votes). Check out past polls.