Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

    In reply to Re: Ping a Server by AcidHawk
    in thread Ping a Server by damianpadden

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post; it's "PerlMonks-approved HTML":



    • Are you posting in the right place? Check out Where do I post X? to know for sure.
    • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
      <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
    • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
    • Want more info? How to link or How to display code and escape characters are good places to start.
    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others studying the Monastery: (3)
    As of 2024-03-29 02:14 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found