Skip to content

Commit

Permalink
Merge branch 'master' of github.com:highgroove/scout-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
itsderek23 committed Mar 16, 2012
2 parents c72f43b + e4f4963 commit fa86a2d
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
48 changes: 48 additions & 0 deletions kestrel/kestrel_monitor.rb
@@ -0,0 +1,48 @@
#
# Created by Eric Lindvall <eric@sevenscale.com>
#

class KestrelMonitor < Scout::Plugin
OPTIONS=<<-EOS
host:
label: Host
notes: Kestrel host
default: localhost
port:
label: Port
notes: Kestrel admin HTTP port
default: 2223
EOS

needs 'open-uri'
needs 'json'

def build_report
counter 'data_read_per_second', counter_stat(:bytes_read).to_i / 1024.0, :per => :second
counter 'data_written_per_second', counter_stat(:bytes_written).to_i / 1024.0, :per => :second
counter 'gets_per_second', counter_stat(:cmd_get), :per => :second
counter 'peeks_per_second', counter_stat(:cmd_peek), :per => :second
counter 'sets_per_second', counter_stat(:cmd_set), :per => :second
counter 'hits_per_second', counter_stat(:get_hits), :per => :second
counter 'misses_per_second', counter_stat(:get_misses), :per => :second
counter 'connections_per_second', counter_stat(:total_connections), :per => :second
counter 'items_per_second', counter_stat(:total_items), :per => :second

report 'connections' => gauge_stat(:connections)
report 'items' => gauge_stat(:items)
report 'jvm_heap_used' => gauge_stat(:jvm_heap_used).to_i / 1024.0 / 1024.0
report 'jvm_heap_max' => gauge_stat(:jvm_heap_max).to_i / 1024.0 / 1024.0
end

def counter_stat(stat)
stats['counters'][stat.to_s]
end

def gauge_stat(stat)
stats['gauges'][stat.to_s]
end

def stats
@stats ||= JSON.parse(open("http://#{option(:host)}:#{option(:port)}/admin/stats").read)
end
end
42 changes: 42 additions & 0 deletions kestrel_queue/kestrel_queue.rb
@@ -0,0 +1,42 @@
#
# Created by Eric Lindvall <eric@sevenscale.com>
#

class KestrelQueueMonitor < Scout::Plugin
OPTIONS=<<-EOS
host:
label: Host
notes: Kestrel host
default: localhost
port:
label: Port
notes: Kestrel admin HTTP port
default: 2223
queue:
label: Queue
notes: Name of Kestrel queue
EOS

needs 'open-uri'
needs 'json'

def build_report
report :items => gauge_stat(:items), :open_transacitons => gauge_stat(:open_transactions),
:mem_items => gauge_stat(:mem_items), :age => gauge_stat(:age_msec).to_f / 1000,
:waiters => gauge_stat(:waiters)

counter(:item_rate, counter_stat(:total_items), :per => :second)
end

def counter_stat(stat)
stats['counters']["q/#{option(:queue)}/#{stat.to_s}"]
end

def gauge_stat(stat)
stats['gauges']["q/#{option(:queue)}/#{stat.to_s}"]
end

def stats
@stats ||= JSON.parse(open("http://#{option(:host)}:#{option(:port)}/admin/stats").read)
end
end

0 comments on commit fa86a2d

Please sign in to comment.