A library for interacting with Scout, a hosted server monitoring service. Query for metric data, manage servers, and more.
Install the gem if you haven't already:
gem install scout_api
Require the gem and authenticate to get your Scout on:
require 'scout_api' scout = ::.('youraccountname', '[email protected]', 'sekret')
You can query for the following high-level objects:
Each of the classes have Rails-like finder methods. For example:
# all servers ::. # first server ::. # first metric with ID=1 ::.(1) # all groups with name =~ 'Web' ::.(:name => 'Web') # all servers in a group (or groups) with group name =~ 'Web' ::.(:group_name => "Web")
Access your metric data stored in Scout. You can retrieve data for a specific metric, a group of metrics, and aggregated metrics. For example:
# average value of the metric with ID=1 over the past hour ::.(1) # maximum rate of insert queries over the previous 24 hours ::.(:name => "DB Server")..maximum(:name => 'inserts', :start => Time.now.utc-(24*3600)*2,:end => Time.now.utc-(24*3600) ) # average memory used across all servers in the 'web servers' group ::.(:name => 'web servers')..average(:name => 'Memory Used') ::.(:name => 'web servers')..average(:name => 'Memory Used').to_sparkline ::.(:name => 'web servers')..average(:name => 'Memory Used').to_a # total throughput across web servers ::.(:name => 'web servers')..average(:name => 'request_rate', :aggregate => true)
Create and delete servers:
# create a server using the server with id=6 as the template. Scout::Server.create('heavy metal',:id => 6) => <#Scout::Server> # delete the server with id=10 Scout::Server.delete(10)
scout_api has been tested against Ruby 1.8.7, and Ruby 1.9.2.
Note on Patches/Pull Requests
Fork the project.
Make your feature addition or bug fix.
Add tests for it. This is important so I don't break it in a future version unintentionally.
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
Send me a pull request. Bonus points for topic branches.
Copyright © 2011 Jesse Newland, Derek Haynes. See LICENSE for details.