Skip to content

Instantly share code, notes, and snippets.

View itsderek23's full-sized avatar

Derek Haynes itsderek23

View GitHub Profile
class Lion
attr_accessor :age
end
@itsderek23
itsderek23 / mysql-health-check.rb
Created September 9, 2011 13:33
MySQL Health Scout plugin
# MySQL Health plugin
#
# Plugin is intended to monitor basic MySQL parametrs
# plugin was inspired by mysqltuner
#
# Currently plugin monitors
# * InnoDB data size / buffer pool
# * Highest usage of available connections
# * Active processes
@itsderek23
itsderek23 / gist:2829455
Created May 29, 2012 16:39
Scout's Realtime metrics implementation via Pusher
# Stream data for 20 minutes
while(streamer_start_time+MAX_DURATION > Time.now)
data=[]
# run each scout plugin (cpu usage, apache stats, etc)
plugins.each do |plugin|
plugin.run
data << {
# plugin.reports example data
# [{"Idle %"=>95, "System %"=>1,"User %"=>4}]
:fields=>plugin.reports.inject{|memo,hash|memo.merge(hash)},
@itsderek23
itsderek23 / gist:2829464
Created May 29, 2012 16:41
Scout's Javascript for handling realtime metrics via Pusher
var pusher = new Pusher(appKey,{encrypted: true});
var channel = pusher.subscribe(streamingKey);
channel.bind('server_data', update);
// The function that's called when we retrieve new data from the realtime_data action
function update(server){
// example data
// var server={"hostname": "nuevo.local","data": [{"name": "CPU Usage","fields": {"idle": 95, "system": 1,"user": 4}},{"fields":{"capacity":59.0,"avail":97.0,"size":233.0,"used":136.0},"name":"Disk Usage"}],"server_time": "02:38:11 PM"};
// append data to a smoothie chart
}
assets_path = File.expand_path("~/projects/rails/scout/public")
log_path = File.expand_path "~/assets.txt"
temp_requested_files_path = File.expand_path "~/processed_assets.txt"
ignore_pattern = /sparkline|datejs/
known_used =[
"javascripts/jquery-1.7.1.min.js",
"javascripts/jquery.extensions.js",
"javascripts/application.js",
"stylesheets/default.css",
require File.expand_path(File.dirname(__FILE__) + "/parent.rb")
class Child < Parent
def build_report
report(:parent_value => parent_method)
end
end
@itsderek23
itsderek23 / py.rb
Created September 18, 2012 17:00
Scout running Python Code
$scout test py.rb
== This plugin doesn't have option metadata.
== You haven't provided any options for running this plugin.
== Output:
{:server_name=>nil,
:errors=>[],
:reports=>
[{:created_at=>"2012-09-18 17:00:05",
:fields=>{:random=>7.0},
}

Scout

scout sidekiq plugin

The Sidekiq Monitor plugin for Scout, a hosted server monitoring service, reports key metrics like enqueued, processed, and failed jobs. Triggers can be configured to alert when the metrics reach specified thresholds. A Scout account is required to use the plugin.

#! /usr/bin/env bash
# This example bash script file is located here: /home/your-username/scripts/scout_cron.sh for our example, but could be anywhere on your server.
# Make sure you remember to make this file an executable script by: chmod +x /home/your-username/scripts/scout_cron.sh.
# Loading the RVM Environment files. To find your unique rvm path use: rvm env --path -- ruby-version[@gemset-name].
# For example: rvm env --path -- 1.9.3-p194@projectX
source /home/deploy/.rvm/environments/ruby-1.9.3-p374
# Changing directories to our rails project. The example below is a Capistrano path.
@itsderek23
itsderek23 / custom_interval.rb
Created March 20, 2013 13:47
Scout Plugin that runs at a custom interval
class CustomInterval < Scout::Plugin
def build_report
interval = 15*60 # 15 minute interval
if @last_run.nil? or Time.now > @last_run + interval
# it's time to report
report(:metric => rand)
end
end
end