Re: Script to ping



Great solution, Jason. But unfortunally it needs in *nix box or installing
perl in win machine. So, maybe you could rewrite it in vbscript??? =)


--

Regards,
Alexander Trofimov

"Jason Gurtz" <jasonNOgurtz@xxxxxxxxxxxxxxx> wrote in message
news:esdqfZ%23uGHA.4512@xxxxxxxxxxxxxxxxxxxxxxx
Glenn wrote:
I'd like to create a script that could ping my switches and servers and
send
me an e-mail as soon as one goes down.

I did this at my last job using perl to monitor and report on the
availability of an interstate frame relay WAN link. Unfortunately for
you, the script ran on a Linux box and some of the perl modules are not
translatable to the Win32 world under activestate perl so I can not
offer any code that would work without a bit of modification.

Nonetheless, here's psuedocode logic for what it did (I leave out many
details that I used generating/formatting the report and error checking).

START main

store date and time #1
ping host once
store ping1 result (fail or response time in ms)
if ping1 is successful
sendEmail()
quit()
else
store ping one fail result
sleep 60 seconds
store date and time #2
ping host once
store ping2 result (fail or response time in ms)
endif
END main

START sendEmail

case ping1 is successful
send success email contents

case ping1 failure and ping2 successful
send warning email about blip in availability

case ping2 failure
send error email about total interruption of service

END sendEmail

I think you could do all this in a plain batch script using the blat.exe
program to send the emails and local environment variables. you can
"ping -n %seconds% 127.0.0.1" as a workable sleep function. ping.exe
will set %ERRORLEVEL% to zero if it is successful, one if unsuccessful,
and a really small number if ping is ^C.

I found that simply pinging the remote host once generated a lot of
false alarms due to momentary drops not affecting LOB, the line being
saturated with data, or etc... Therefore I implemented the delayed
follow up second ping idea. I ran the script via cron every half hour
which is akin to using the task scheduler.

~Jason

--


.



Relevant Pages

  • Re: Script to ping
    ... I did this at my last job using perl to monitor and report on the ... store ping1 result ... store ping one fail result ... case ping1 is successful ...
    (microsoft.public.windows.server.scripting)
  • UTF-8 issues connecting to Oracle
    ... A Google search turned up a known problem with perl on ES 3 and the UTF8 character set. ... <- STORE= 1 at Oracle.pm line 61 ... 'select collection_name from clone_collection' undef) thr#504010 ... <- DESTROY= undef ...
    (perl.dbi.users)
  • Re: make test fails with Devel::Symdump
    ... When I try to compile it ... version on OS perl is 6.17 and *on my customized perl is 6.42. ... *** Error code 255 ... All tests successful, 2 tests skipped. ...
    (perl.beginners)
  • Re: UTF-8 issues connecting to Oracle
    ... I vagely remember that Perl 5.8.0 had some issues regarding UTF-8. ... <- STORE= 1 at Oracle.pm line 61 ... 'select collection_name from clone_collection' undef) thr#504010 ... <- DESTROY= undef ...
    (perl.dbi.users)
  • RE: Capturing the results from Expect with backtick
    ... > better luck using expect than perl here) 2. ... > that responds to ping, perform a series of rsh commands via perl ... > Calling the expect script looks like this, ... case of Unknown Host) using the 2>&1 and pipe ...
    (perl.beginners)