Software to monitor domains

Ray Parrish crp at cmc.net
Mon Nov 17 09:31:53 UTC 2008


Ray Parrish wrote:
> Ray Parrish wrote:
>   
>> Derek Broughton wrote:
>>   
>>     
>>> You won't find a Linux packaged solution to just do that because it's as 
>>> simple as running a script that uses "wget" to get anything from the 
>>> site (outputting it to /dev/null) and echos a message if wget fails, 
>>> being careful to create no output at all when the wget succeeds.  Stick 
>>> the script in cron, and you'll get an email every time it fails.
>>>   
>>>     
>>>       
>>   
>>     
> Hello,
>
> Well, it took me a little while, but I've come up with a solution that 
> seems to work. Following is my code for two scripts I created. One 
> starts the polling of the web site, and the other stops the polling script.
>
> [start of PollWebSite.sh]
> #!/bin/sh
> cd ~/SiteCheck
> touch go.txt
> while [ -e go.txt ]
> do
>     wget --connect-timeout=20 "$1" 2>/dev/null || xmessage "$1 is down";
>     rm index.html
>     sleep 10;
> done
> xmessage "Exiting Poll Web Site"
> [end of PollWebSite.sh]
>
> [start of StopPoll.sh]
> #!/bin/sh
> cd ~/SiteCheck
> rm go.txt
> [end of StopPoll.sh]
>
> I'm going to change the polling interval in actual use, I set it to loop 
> fast so I could test the loop exit to be sure it worked. I of course 
> created a folder named ~/SiteCheck first, but a person could add that to 
> the script as well.
>
> Later, Ray Parrish
>
>   
Hello again,

I've modified the script to play a sound file if the web site goes down, 
as well as popping up a message. I tried with the cat command first, but 
it only works with .au files, and try as I might I couldn't create an 
.au file with any software I already had, or that I installed tonight. I 
had to install the bplay command line sound file player so my script 
could play a .wav file instead. Here is the modified code -

[start of PollWebSite.sh]
#!/bin/sh
cd ~/SiteCheck;
touch go.txt;
while [ -e go.txt ]
do
    wget --connect-timeout=20 "$1" 2>/dev/null || xmessage -nearmouse 
"$1 is down";
    if [ -e index.html ]
       then rm index.html;
       else bplay 1>/dev/null 2>/dev/null sitedown.wav;
    fi
    sleep 60;
done
xmessage "Exiting Web Site Monitor";
[end of PollWebSite.sh]

This version tests to see if index.html was successfully downloaded, if 
it was, it deletes it and goes to sleep, if the file doesn't exist it 
plays the site down sound file, and of course the wget line pops up the 
message box as well.

The script expects one command line argument in the form of a complete 
web site url including the http:// portion.

You're welcome to use these scripts if you wish, or modify them to your 
uses, it doesn't matter to me, I'm just glad to be using Ubuntu.

Later, Ray Parrish

-- 
http://www.rayslinks.com/ Web index of human reviewed links.
<http://www.rayslinks.com/Troubleshooting%20and%20fixing%20Windows.html>
Trouble shooting and Fixing Windows
http://www.writingsoftheschizophrenic.com My poetry in web pages





More information about the ubuntu-users mailing list