[Soks] soks site down

[Soks] soks site down

Copied from Email on Tue, 17 May 2005 16:00:49 -0400 from Bil.Kleb@NASA.gov (Bil.Kleb@nasa.gov)

Tom Counsell wrote:
> 
> This is happening too much at the moment, but can't find a trace of  why 
> in the logs.

Sounds like you need Mike Clark's script.  In face, maybe I'll add your
site to my crontab... :)

#!/usr/bin/env ruby
#
# Originally from
#
#  http://www.pragmaticautomation.com/cgi-bin/pragauto.cgi/Monitor/CheckupCompetition.rdoc
#
# Modified by Bil.Kleb and Bill.Wood@NASA.gov
#
# Run via a crontab job like,
#
#  13 6-23 * * * $HOME/check_url.rb http://fun3d.larc.nasa.gov

SMTP_HOST = "smtp.somewhere.com" 
TO = "7575551212@vtext.com" 
FROM = "monitor@somemachine.somewhere.com" 
SUBJECT="Uh oh!" 

if ARGV.empty? then
   puts "usage: #$0 <url>" 
   exit 1
end

url = ARGV.first

require 'open-uri'

message = "" 
begin
   page = open(url).read
   exit 0 unless page =~ /(Not\sFound)|Exception/
   message = "Not Found or Exception" 
rescue
   message = "Unavailable - #{$!.message}" 
end

content = <<MAIL
Subject: #{SUBJECT}

Sadly, #{url} isn't feeling well right now.

Diagnosis: #{message}
MAIL

require 'net/smtp'

Net::SMTP.start(SMTP_HOST){ |smtp| smtp.send_mail(content, FROM, TO) }

_______________________________________________
Soks-discuss mailing list
Soks-discuss@rubyforge.org
http://rubyforge.org/mailman/listinfo/soks-discuss

Edit this page or watch for changes using RSS.