Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
aah ahh not so cool but handy maybe!!
linux peoples can rearrange easely.
run as follow: Aping.pl -i 10.0.0.1
or without args to get help

Lor*
#!perl use strict; use warnings; $|++; use Getopt::Long; use Win32::Sound; my $sleep = 60; my $conteggio = 4; my $echook = ( $conteggio - 1 ); my $alarmnum = 3; my $sound; my $volume = 100; my $host; &aiuto() if ( ! GetOptions ( 'ip=s' => \$host, 'sleep=i' => \$sleep, 'conteggio=i' => \$conteggio, 'ok=i' => \$echook, 'alarm=i' => \$alarmnum, 'play=s' => \$sound, 'volume=i' => \$volume, ) or ! $host ); $alarmnum = 3 if $alarmnum < 1; if ( $echook > $conteggio ){ $echook = $conteggio-1 } if (defined $sound && !(-e $sound)) {$sound = 'crow.wav'} while (1){ sleep $sleep; my $ok = &controlla($host); if ($ok < $echook){ for (1..$alarmnum) { &suona() } print "ERROR !\n"; } else {print "OK $host\n";} } sub suona { if (defined $sound && -e $sound) { Win32::Sound::Volume($volume,$volume); Win32::Sound::Play($sound); } else {sleep 1; print"\a\a"} } sub controlla{ my $ok =0; open CMD,"ping -n $conteggio -l 1 $host 2>&1|"; while (<CMD>) {++$ok if $_ =~/$host/;print"."} close CMD; return $ok; } sub aiuto { print <<EOA; USAGE OF $0: $0 -i 10.0.0.1 [-sleep n] [-conteggio n] [-ok n] [-alarm n] [-play + file.wav] [-volume %] -i 10.0.0.1 ping specified IP every 60 seconds 4 times expecting 3 positives repl +y or play 3 system bell during 3 seconds --ip=10.10.0.1 --sleep = 30 --conteggio = 10 --ok = 5 --alarm = 20 -i 10.10.0.1 -s 30 -c 10 -o 5 -a 20 same of above EOA exit 1; }

In reply to when no ping say 'moo!' by Discipulus

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, 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, 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.
  • 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 perusing the Monastery: (3)
    As of 2024-07-24 08:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?
      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.