Skip to content

Instantly share code, notes, and snippets.

@kevinkarwaski
Created July 9, 2012 16:32
Show Gist options
  • Save kevinkarwaski/3077473 to your computer and use it in GitHub Desktop.
Save kevinkarwaski/3077473 to your computer and use it in GitHub Desktop.
Scout Management Script
#!/usr/bin/env ruby
require 'scout_api'
#*************************************
# Playing around with the Scout API...
#*************************************
#Create the connection object.
scout = Scout::Account.new(ENV['SCOUT_ACCOUNT'], ENV['SCOUT_USER'], ENV['SCOUT_PASSWORD'])
# Get an array of all servers as hashes.
servers = Scout::Server.all
count = 0
# Find all the servers where checkup_status is "Failure".
0.upto(servers.length - 1) do |i|
if servers[i][:checkup_status] == "Failure"
puts "#{servers[i][:name]}\n"
puts "#{servers[i][:hostname]}\n"
puts "#{servers[i][:checkup_status]}\n"
puts "#{servers[i][:last_checkin]}\n"
count += 1
puts "#{count}\n"
end
end
puts "Servers with Checkup failure: #{count}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment