Skip to content

Instantly share code, notes, and snippets.

@iDiogenes
Created July 10, 2009 17:45
Show Gist options
  • Save iDiogenes/144654 to your computer and use it in GitHub Desktop.
Save iDiogenes/144654 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#Requirements
require 'rubygems'
require 'net/ssh'
require 'patron'
servers = ["viola-dev.loni.ucla.edu"]
#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"]
sites = ["wwwdev.loni.ucla.edu"]
servers.each do |server|
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
puts "\nChecking LONI websites...\n\n"
sites.each do |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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment