Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ehs_flow_statistics plugin

  • Loading branch information...
commit ffba00687e12b83d5f87e76e06c09b64414ba744 1 parent e4b1d0b
@dml dml authored
Showing with 18 additions and 18 deletions.
  1. +2 −15 ehs_flow_statistics/plugin.rb
  2. +16 −3 redis_stat/redis.rb
View
17 ehs_flow_statistics/plugin.rb
@@ -1,24 +1,11 @@
class EhsFlowStatistics < Scout::Plugin
needs 'yaml'
+ needs 'rp-stat'
+
KILOBYTE = 1024
MEGABYTE = 1048576
def build_report
- cmd = "#{option('redis-cli')||'redis-cli'} info"
- result = `#{cmd}`
- redis_info = YAML.load(result.gsub(/:/, ": "))
- error(:subject => 'redis-cli error', :body => "[#{cmd}]:#{result}") unless redis_info
- data = {}
-
- data['used_memory_in_kb'] = redis_info['used_memory'].to_f / KILOBYTE
- data['used_memory_in_mb'] = redis_info['used_memory'].to_f / MEGABYTE
- data['last_save_time'] = Time.at(redis_info['last_save_time']).strftime("%Y-%m-%d %H:%M:%S")
-
- # General Stats
-
- option('general_fields') && option('general_fields').split(',').map{|f| f.strip}.each do |key|
- data[key] = redis_info[key]
- end
report(data)
end
end
View
19 redis_stat/redis.rb
@@ -1,11 +1,24 @@
class Redis < Scout::Plugin
needs 'yaml'
- needs 'rp-stat'
-
KILOBYTE = 1024
MEGABYTE = 1048576
-
+
def build_report
+ cmd = "#{option('redis-cli')||'redis-cli'} info"
+ result = `#{cmd}`
+ redis_info = YAML.load(result.gsub(/:/, ": "))
+ error(:subject => 'redis-cli error', :body => "[#{cmd}]:#{result}") unless redis_info
+ data = {}
+
+ data['used_memory_in_kb'] = redis_info['used_memory'].to_f / KILOBYTE
+ data['used_memory_in_mb'] = redis_info['used_memory'].to_f / MEGABYTE
+ data['last_save_time'] = Time.at(redis_info['last_save_time']).strftime("%Y-%m-%d %H:%M:%S")
+
+ # General Stats
+
+ option('general_fields') && option('general_fields').split(',').map{|f| f.strip}.each do |key|
+ data[key] = redis_info[key]
+ end
report(data)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.