Iv searched google and the archive, maybe I missed something but either way I'm putting this request here. If you know of something let me know what to search for or where to look. I don't mind doing some more digging.
What I'm looking for is a script that checks if a configured website is up eg returning the html status code 200 this can just be from a trigger, and then update the topic to say the website is up or down or just poke fun of the person if the site not down on a check.
I'm not afraid of a little work but I'm no coder the best I can do is edit existing scripts.
bind TIME - * checkHostReachable
set temp(chan) "#channel"
set temp(url) "www.chanrank.com"
package require http
proc checkHostReachable {min hour day month year} {
global temp
if {[catch {
set tok [http::geturl "http://$temp(url)"]
http::cleanup $tok
return 1
} err]} {
if {[string match -nocase "*host is unreachable*" $err]} {
putserv "TOPIC $temp(chan) :Website is down"
} else {
putserv "TOPIC $temp(chan) :Website is UP"
}
}
}
bind time - * change:topic
set temp(chan) "#channel"
set temp(website) "www.website"
proc change:topic {min hour day month year} {
global temp
set website [http::config -useragent "Mozilla"]
set website [http::geturl "http://$temp(website)" -timeout 50000]
set updown [http::status $website]
set err [http::error $website]
http::cleanup $website
switch -exact -- $updown {
"ok" {
putserv "TOPIC $temp(chan) :the website is UP"
}
"eof" {
putserv "TOPIC $temp(chan) :the website is down"
}
error {
putserv "TOPIC $temp(chan) :Website is $err"
}
}
}
yet at the second version i couldnt test the EOF part it only worked if the website was UP and running but i heard the second version is more likely to be as it shouldl