Wednesday 25 January 2012

Graphical Internet Server Monitor

Carl Sassenrath wrote this script:
http://www.rebol.com/view/demos/gismo.r

I used that code to produce the simpler version:
Rebol []
time-out: 5 ; Seconds to wait for the connection (adjust it!)
poll-time: 0:00:10
system/schemes/default/timeout: time-out
system/schemes/http/timeout: time-out
sites: [
    ; List of URLs (http or tcp are allowed)
    http://www.rebol.com
    http://www.rebol.net
    http://www.rebol.org
    http://mail.rebol.net
    http://www.altme.com
    http://rebol2.blogspot.com/
]
;main layout
out: [
    backeffect [ gradient 0x1 black coal ]
    vh1 "Graphical Internet Server Monitor"
]
foreach site sites [
  append out (reduce ['text   (to-string site) ] )
]
append out [
    pad 50x0
    btn water 100 "Refresh" rate poll-time feel [
        engage: func [ f a e ] [
            if find [   time down   ]   a [check-sites ]
        ]
    ]
]
append out reduce ['vh4 yellow reform [ "Automatic refresh in" poll-time ] ]
check-sites: does [
    foreach face out/pane [
        if face/style = 'text [
            face/color: gray
            show face
            either attempt [ close open to-url face/text true ] [
                face/color: green
                show face
            ] [
                face/color: red
                show face
            ]
        ]
    ]
]
out: layout out
view out


Wait 10 seconds and this will be the result:

No comments:

Post a Comment