Software to monitor domains

Loïc Grenié loic.grenie at
Mon Nov 17 11:41:04 UTC 2008

2008/11/17 Ray Parrish <crp at>:
> 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]
>> #!/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]
>> [start of]
>> #!/bin/sh
>> cd ~/SiteCheck
>> rm go.txt
>> [end of]
>> 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]
> #!/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]
> 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.

    You'll get the sound only if you dismiss the xmessage box I think. You could
  modify things that way:

while [ -e go.txt ]
   if wget -o /dev/null --connect-timeout=20 "$1"
       rm index.html
       bplay sitedown.wav >/dev/null 2>&1
       xmessage -nearmouse "$1 is down"
   sleep 60

        Loïc Grenié

More information about the ubuntu-users mailing list