[Soks] soks site down

Bil.Kleb at NASA.gov Bil.Kleb at nasa.gov
Tue May 17 16:00:49 EDT 2005


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... :)

#!/home/xpair/ab/kleb/local/bin/ruby
#
# Originally from
#
#  http://www.pragmaticautomation.com/cgi-bin/pragauto.cgi/Monitor/CheckupCompetition.rdoc
#
# Modified by Bil.Kleb and Bill.Wood at 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 at vtext.com"
FROM = "monitor at 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) }





More information about the Soks-discuss mailing list