Sign in to follow this  
Followers 0
Legacy99

Checking status of a website

7 posts in this topic

Hi all

For about a year I've had a script that would open our internal webpage, check if it loaded then email the result to a monitoring station. This is done with a scheduled task on an XP box and worked as long as the account running the script had access to the website (even if the workstation was locked or nobody logged in, it worked). The purpose for the script was the webpage is dependant on an Oracle Database running. We shut the database down in the evening for backups and bring it back up. We had times when the DB did not restart and the script was born as an early warning system. Two days ago for some unexplained reason it broke and if the console is locked the script fires off the "failed" email that the page did not load and I can't trace it to anything in particular.

My first question is can anyone replicate the scenario (both the working example and failure) and would anyone have a better idea than this to test if the webpage loads?

Here is the original code that worked, I have tried working it different ways but I'm having no luck.

$o_IE = _IECreate ()
WinSetState("", "", @SW_MAXIMIZE)
_IENavigate ($o_IE, "https://intranet.company.com")
Sleep(1000);
If Not WinActivate("Business Activity Network","")Then
   EmailFailure()
   WinClose("[class:IEFrame]")

ElseIf WinActivate("Business Activity Network","") Then
   EmailSuccess()
   WinClose("[class:IEFrame]")

Else
   EmailOtherError()
EndIf

Share this post


Link to post
Share on other sites



Hi all

For about a year I've had a script that would open our internal webpage, check if it loaded then email the result to a monitoring station. This is done with a scheduled task on an XP box and worked as long as the account running the script had access to the website (even if the workstation was locked or nobody logged in, it worked). The purpose for the script was the webpage is dependant on an Oracle Database running. We shut the database down in the evening for backups and bring it back up. We had times when the DB did not restart and the script was born as an early warning system. Two days ago for some unexplained reason it broke and if the console is locked the script fires off the "failed" email that the page did not load and I can't trace it to anything in particular.

My first question is can anyone replicate the scenario (both the working example and failure) and would anyone have a better idea than this to test if the webpage loads?

Here is the original code that worked, I have tried working it different ways but I'm having no luck.

Personally I think I'd take this approach..

$oIE = _IECreate ("https://intranet.company.com")

$sHTML = _IEDocReadHTML ($oIE)

If StringInStr ($sHTML, "Business Activity Network") Then
   EmailSuccess()
ElseIf Not StringInStr ($sHTML, "Business Activity Network") Then
   EmailFailure()
Else
   EmailOtherError()
EndIf

_IEQuit ($oIE)

As far as it failing, I imagine you'd want to try this on that computer while it was unlocked first to see if it works, then try having it run a few seconds after you lock the computer and see if it still works, then try scheduling it and logging off the computer... You need to figure out what scenario it's not working in before you can effectively troubleshoot it.

Share this post


Link to post
Share on other sites

Personally I think I'd take this approach..

$oIE = _IECreate ("https://intranet.company.com")

$sHTML = _IEDocReadHTML ($oIE)

If StringInStr ($sHTML, "Business Activity Network") Then
   EmailSuccess()
ElseIf Not StringInStr ($sHTML, "Business Activity Network") Then
   EmailFailure()
Else
   EmailOtherError()
EndIf

_IEQuit ($oIE)

As far as it failing, I imagine you'd want to try this on that computer while it was unlocked first to see if it works, then try having it run a few seconds after you lock the computer and see if it still works, then try scheduling it and logging off the computer... You need to figure out what scenario it's not working in before you can effectively troubleshoot it.

I will try that code, I've tried my script on 4 different pc's and Im getting the same result. It emails success if the console is logged into and unlocked, but when I lock the console the script fires off the failed email (these are all done with scheduled tasks). For some reason when it's locked, it does not read info from IE anymore.

Share this post


Link to post
Share on other sites

I will try that code, I've tried my script on 4 different pc's and Im getting the same result. It emails success if the console is logged into and unlocked, but when I lock the console the script fires off the failed email (these are all done with scheduled tasks). For some reason when it's locked, it does not read info from IE anymore.

I know that I control IE at work with the same type of code, where everything is done with _IE functions and it works non-stop whether the computer's unlocked and use or locked and just sitting there idle... The only time that I've not really seen it work is when I'm not logged into the computer, presumably because it's outside of windows at that point (unless you were to make your script be a service or something to that effect, which has been discussed on the forums before)

Share this post


Link to post
Share on other sites

It's weird why it's not working. For troubleshooting I rem'd ( ; ) out the winclose parts on all sections to see if IE was actually loading. When I logged in it was there and on the page that I load up. I also had it write each line to a log file and the WinActivate part comes back that it failed. I can't remember but I'm pretty sure it ran if I was logged out. It had run for almost 200 consecutive days since I logged into the pc to check why it failed on Monday, I could be mistaken on the logged out part (obviously 200days ago I forgot to log off), none the less, now it's not working when the console locks. The pc had taken updates in the last few days, I removed an updates installed for the last few months (about 15 in total) but it did not help. I will test the new script later on today and let you know.

Share this post


Link to post
Share on other sites

Ok. I tested the code and it runs if the console is locked or if nobody is logged into the PC

:D I'm a happy camper again. Thanks Exodius

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Ok. I tested the code and it runs if the console is locked or if nobody is logged into the PC

:D I'm a happy camper again. Thanks Exodius

No problem, and remember, only you can prevent forest fires. :D

Edited by exodius

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0