Created
July 14, 2009 00:38
-
-
Save iDiogenes/146574 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#Requirements | |
require 'rubygems' | |
require 'net/ssh' | |
require 'patron' | |
require 'timeout' | |
servers = ["viola-rs1.loni.ucla.edu","viola-rs2.loni.ucla.edu", "viola-local.loni.ucla.edu", "aragon-rs1.loni.ucla.edu", "aragon-rs2.loni.ucla.edu" , "aragon-rs3.loni.ucla.edu", "aragon-rs4.loni.ucla.edu", "aragon-rs5.loni.ucla.edu" ] | |
sites = ["www.loni.ucla.edu", "ida.loni.ucla.edu", "utilities.loni.ucla.edu"] | |
begin | |
servers.each do |server| | |
Timeout::timeout(20) do | |
Net::SSH.start("#{server}", 'tester', :password => "xxxxxxx") do |ssh| | |
uname = ssh.exec!("uname -a") | |
puts "\nChecking system #{server} \n" | |
puts "#{uname}" | |
mntchk = ssh.exec!("mount | awk '{print $5}' | grep nfs | wc | awk '{print $1}'") | |
fstabchk = ssh.exec!("cat /etc/fstab | awk '{print $3}' | grep nfs | wc | awk '{print $1}'") | |
errors = ssh.exec!("egrep '(reject|warning|error|fatal|panic|not|err)' /var/log/messages") | |
if mntchk == fstabchk | |
puts "All mounts on #{server} are up.\n" | |
else | |
puts "A mount on #{server} is down.\n" | |
end | |
if errors == nil | |
puts "No syslog errors on #{server}" | |
else | |
puts "Syslog errors on #{server}:\n#{errors}" | |
end | |
end | |
end | |
end | |
rescue Timeout::Error | |
puts "\n****Timeout Error: Check network connection and/or NFS mounts***" | |
end | |
begin | |
puts "\nChecking LONI websites...\n\n" | |
sites.each do |site| | |
Timeout::timeout(10) do | |
puts "Connecting to site #{site}..." | |
sess = Patron::Session.new | |
sess.timeout = 10 | |
sess.base_url = "#{site}" | |
resp = sess.get("/index.html") | |
if resp.status > 400 | |
puts "#{site} is down!" | |
puts resp.body | |
else | |
puts "#{site} is up!" | |
end | |
end | |
end | |
rescue Timeout::Error | |
puts "***Connection is hanging!***" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment