forked from itsderek23/highgroove-scout-plugins
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:highgroove/scout-plugins
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |