Simple Web Site Monitor

Author: Carl Sassenrath
This example requires REBOL/View
Return to REBOL Cookbook

There are many ways to create a web monitor in REBOL. Here is a simple visual monitor that displays a window with large text that shows the status of a web site.

The web site is checked every 30 seconds (and you can change that in the WAIT line at the end of the example). If the read succeeds, the window will turn green. If the read fails, the window will turn red.

There are many other web monitor examples available from the REBOL library.

    REBOL [Title: "Web Monitor"]

    site: http://www.rebol.com

    out: layout [
        t1: vh1 400x50 "Web Monitor"

    show-status: func [msg color][
        t1/text: reform msg
        out/color: color
        show out

    check-site: does [
        show-status ["Checking" site] navy
        either attempt [read site] [
            show-status ["Up:" site] leaf
            show-status ["Down:" site] maroon

    insert-event-func [if event/type = 'close [quit]]

    view/new out

    forever [
        wait 30

The INSERT-EVENT-FUNC is used to detect the window being closed and terminate the program when that happens. (This is necessary because the program is designed to loop forever.)

Closing the Window

If the site is down and you try to close the window, there may be a slight delay in doing so. This occurs because the READ operation is waiting for the network to respond (or time-out). This can be fixed by using an asynchronous READ operation, but that would complicate the example (which works well enough for most uses).

2006 REBOL Technologies REBOL.com REBOL.net