in reply to (jeffa) Re: Ping Monitor with Email Notification
in thread Ping Monitor with Email Notification

I may very well misread your code, but aren't you sending one mail for every failed host too?

I'd expected something like

[...] my @failed = []; foreach my $host (@host) { print "$host is "; unless ($ping->ping($host, $first)) { sleep ($delay); unless ($ping->ping($host, $second)) { push @failed, $host; print 'NOT '; } } print "reachable.\n"; } notify(@failed) if @failed; [...]
may I humbly ask what I've overlooked?

regards,
tomte


Replies are listed 'Best First'.
(jeffa) 3Re: Ping Monitor with Email Notification
by jeffa (Bishop) on Feb 13, 2003 at 15:04 UTC

    "may I humbly ask what I've overlooked?"

    The fact that i was half-asleep when i wrote that? :D

    May i humbly say, thanks? I will leave my code untouched, but you are absolutely correct. I wrote my code by modifying linebacker's, but i forgot to add that feature. Thanks for catching it, and better yet, offering a solution.

    However, don't initialize an array like this:
    my @array = []; # use empty parens instead ()
    That declared a new array whose first element is an anonymouse array reference. I have been bitten by that error before. ;)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      Or better yet don't use parens at all, since a freshly declared array is empty by definition.

      Makeshifts last the longest.

      However, don't initialize an array like this: my @array = []; # use empty parens instead () That declared a new array whose first element is an anonymouse array reference. I have been bitten by that error before. ;)

      thanks for that ;-), never would have thought this.
      ++jeffa tomorrow, as all my points today are gone.

      regards,
      tomte


Re: Re: (jeffa) Re: Ping Monitor with Email Notification
by tachyon (Chancellor) on Feb 13, 2003 at 14:58 UTC

    I read it the same as you. Good pick up ++Tomte

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print