I'm trying to create a simple network monitoring tool with perl.

I've tried Net:Ping and it works but for some reason isn't successfully pinging my all my devices. ( I've tried rebinding, changing timeouts... etc) so I've resorted to using system ping (solaris)

I'm trying to get the pings out and complete as fast as possible so I'm calling a system command with "&" and for some reason the program isn't getting the correct exit statuses.

If I remove "&" everything work correctly, but takes minutes to run instead of seconds

use Time::HiRes qw( time ); $MDIR="/tmp/"; #save list into an array open(LIST, "$MDIR/list"); @list=<LIST>; close LIST; @updevices=grep(!/known down|unmanaged/i,@list); my $start = Time::HiRes::gettimeofday(); foreach $element (@updevices) { #hostname:status:ip @ip = split(':',$element); system("ping $ip[2] 1 &"); $result = $?; print "ping $ip[0] $ip[2] $result\n"; if ( $result != 0) { print "$ip[0] is dead\n"; } } my $end = Time::HiRes::gettimeofday(); printf("%.2f\n", $end - $start);

In reply to Problem with exit status of bash script by dizzyd719

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.