memcachestats 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +19 -0
- data/LICENSE.txt +20 -0
- data/README.md +19 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/bin/memclusterstats +181 -0
- data/config/example.yml +21 -0
- data/features/memcachestats.feature +9 -0
- data/features/step_definitions/memcachestats_steps.rb +0 -0
- data/features/support/env.rb +13 -0
- data/lib/memcachestats.rb +194 -0
- data/spec/memcachestats_spec.rb +7 -0
- data/spec/spec_helper.rb +32 -0
- metadata +167 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "rest-client"
|
7
|
+
gem "gmetric"
|
8
|
+
|
9
|
+
# Add dependencies to develop your gem here.
|
10
|
+
# Include everything needed to run rake, tests, features, etc.
|
11
|
+
group :development do
|
12
|
+
gem "rspec", "~> 2.8.0"
|
13
|
+
gem "yard", "~> 0.7"
|
14
|
+
gem "rdoc", "~> 3.12"
|
15
|
+
gem "cucumber", ">= 0"
|
16
|
+
gem "bundler", "> 1.0.0"
|
17
|
+
gem "jeweler", "~> 1.8.3"
|
18
|
+
gem (RUBY_VERSION =~ /^1\.9/ ? "simplecov" : "rcov"), ">= 0"
|
19
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Artem Veremey
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
### Memcachestats
|
2
|
+
|
3
|
+
Memcachestats is a library that captures important Memcached cluster statistics and pushes metrics to Ganglia.
|
4
|
+
|
5
|
+
### Contributing to memcachestats
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
### Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2013 Artem Veremey. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "memcachestats"
|
18
|
+
gem.homepage = "http://github.com/aia/memcachestats"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Memcachestats is a library that captures important Memcached cluster statistics and pushes metrics to Ganglia}
|
21
|
+
gem.description = %Q{Memcachestats is a library that captures important Memcached cluster statistics and pushes metrics to Ganglia }
|
22
|
+
gem.email = "artem@veremey.net"
|
23
|
+
gem.authors = ["Artem Veremey"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
if RUBY_VERSION =~ /^1\.9/
|
35
|
+
desc "Code coverage detail"
|
36
|
+
task :simplecov do
|
37
|
+
ENV['COVERAGE'] = "true"
|
38
|
+
Rake::Task['spec'].execute
|
39
|
+
end
|
40
|
+
else
|
41
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
42
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
43
|
+
spec.rcov = true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
require 'cucumber/rake/task'
|
48
|
+
Cucumber::Rake::Task.new(:features)
|
49
|
+
|
50
|
+
task :default => :spec
|
51
|
+
|
52
|
+
require 'yard'
|
53
|
+
YARD::Rake::YardocTask.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/memclusterstats
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
4
|
+
|
5
|
+
require 'memcachestats'
|
6
|
+
require 'json'
|
7
|
+
require 'rest-client'
|
8
|
+
require 'gmetric'
|
9
|
+
require 'yaml'
|
10
|
+
|
11
|
+
@counter_list = {}
|
12
|
+
|
13
|
+
def counter_to_gauge(prefix, counter, value)
|
14
|
+
field_name = [prefix, counter].join("_")
|
15
|
+
if @counter_list[field_name].nil?
|
16
|
+
@counter_list[field_name] = value.to_f
|
17
|
+
return 0.0
|
18
|
+
else
|
19
|
+
ret = value.to_f - @counter_list[field_name]
|
20
|
+
@counter_list[field_name] = value.to_f
|
21
|
+
return ret
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_memcached_clusters(discovery, port)
|
26
|
+
res = {}
|
27
|
+
begin
|
28
|
+
if (state = JSON.parse(RestClient.get("http://#{discovery}:#{port}/state"))) #, :symbolize_keys => true))
|
29
|
+
state.each do |service|
|
30
|
+
if service['serviceName'] == "memcached"
|
31
|
+
res[service['serviceType']] ||= []
|
32
|
+
res[service['serviceType']] << {
|
33
|
+
:host => service['properties']['serviceAddress'],
|
34
|
+
:port => service['properties']['servicePort']
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
rescue
|
40
|
+
return nil
|
41
|
+
end
|
42
|
+
|
43
|
+
remove_dups = 0
|
44
|
+
|
45
|
+
if remove_dups
|
46
|
+
res_keys = res.keys
|
47
|
+
res_dups = {}
|
48
|
+
|
49
|
+
res_keys.each_with_index do |clustera, indexa|
|
50
|
+
next if res_dups[clustera]
|
51
|
+
for indexb in (indexa + 1 .. res_keys.length - 1)
|
52
|
+
clusterb = res_keys[indexb]
|
53
|
+
if res[clusterb].include?(res[clustera][0])
|
54
|
+
res_dups[clusterb] = clustera
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
res_fixes = {}
|
60
|
+
|
61
|
+
res_dups.each_key do |cluster|
|
62
|
+
res_fixes[res_dups[cluster]] = res_dups[cluster] if res_fixes[res_dups[cluster]].nil?
|
63
|
+
res_fixes[res_dups[cluster]] = [res_fixes[res_dups[cluster]], cluster].join("-")
|
64
|
+
res.delete(cluster)
|
65
|
+
end
|
66
|
+
|
67
|
+
res_fixes.each_key do |cluster|
|
68
|
+
res[res_fixes[cluster]] = res[cluster]
|
69
|
+
res.delete(cluster)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
return res
|
74
|
+
end
|
75
|
+
|
76
|
+
def publish_metric(config, publish_host, name, value, slope, units, type)
|
77
|
+
#pp ["publishing", config, publish_host, name, value, slope, units, type]
|
78
|
+
return
|
79
|
+
|
80
|
+
c_value = (type == 'double') ? value.to_f : value.to_i
|
81
|
+
|
82
|
+
Ganglia::GMetric.send(
|
83
|
+
config['gmond']['host'],
|
84
|
+
config['gmond']['port'], {
|
85
|
+
:name => name,
|
86
|
+
:units => units,
|
87
|
+
:type => type,
|
88
|
+
:value => c_value,
|
89
|
+
:tmax => 60,
|
90
|
+
:dmax => 300,
|
91
|
+
:group => config['gmond']['group'],
|
92
|
+
:slope => slope,
|
93
|
+
:spoof => 1,
|
94
|
+
:hostname => "#{publish_host}:#{publish_host}"
|
95
|
+
})
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
STDOUT.sync = true
|
100
|
+
|
101
|
+
usage = <<-USAGE
|
102
|
+
memclusterstats <configuration file>
|
103
|
+
USAGE
|
104
|
+
|
105
|
+
if !ARGV[0].nil? && File.exists?(ARGV[0])
|
106
|
+
config = YAML.load_file(ARGV[0])
|
107
|
+
else
|
108
|
+
puts usage
|
109
|
+
exit
|
110
|
+
end
|
111
|
+
|
112
|
+
memcache_ds = MemcacheStats.new({})
|
113
|
+
|
114
|
+
while (true)
|
115
|
+
config['environments'].each do |environment|
|
116
|
+
env_time_start = Time.now()
|
117
|
+
#clusters = get_memcached_clusters(environment['discovery']['host'], environment['discovery']['port'])
|
118
|
+
|
119
|
+
while (true)
|
120
|
+
updated_clusters = get_memcached_clusters(environment['discovery']['host'], environment['discovery']['port'])
|
121
|
+
if (updated_clusters)
|
122
|
+
clusters = updated_clusters
|
123
|
+
break
|
124
|
+
elsif (clusters)
|
125
|
+
break
|
126
|
+
else
|
127
|
+
sleep 60
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
clusters.each_key do |cluster_name|
|
132
|
+
memcache_ds.stats = {}
|
133
|
+
acc_stats = {}
|
134
|
+
|
135
|
+
time_start = Time.now()
|
136
|
+
|
137
|
+
clusters[cluster_name].each do |node|
|
138
|
+
memcache_ds.get_memcached_stats(node[:host], node[:port])
|
139
|
+
|
140
|
+
memcache_ds.metrics.keys.each do |metric|
|
141
|
+
acc_stats[metric] ||= 0
|
142
|
+
memcache_ds.stats[metric] ||= 0
|
143
|
+
acc_stats[metric] += memcache_ds.stats[metric].to_i
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
time_mid = Time.now
|
148
|
+
memcache_ds.log.info("Processed #{environment['name']}/#{cluster_name} cluster in #{time_mid - time_start}")
|
149
|
+
|
150
|
+
memcache_ds.counters.keys.each do |counter|
|
151
|
+
acc_stats[counter] = counter_to_gauge(
|
152
|
+
"#{environment['name']}_#{cluster_name}",
|
153
|
+
counter,
|
154
|
+
acc_stats[counter]
|
155
|
+
)
|
156
|
+
end
|
157
|
+
|
158
|
+
memcache_ds.add_derived_metrics(acc_stats)
|
159
|
+
|
160
|
+
acc_stats.keys.each do |metric|
|
161
|
+
next if memcache_ds.metrics[metric]['publish'] == 'no'
|
162
|
+
|
163
|
+
publish_metric(
|
164
|
+
environment,
|
165
|
+
cluster_name,
|
166
|
+
metric,
|
167
|
+
acc_stats[metric],
|
168
|
+
'both',
|
169
|
+
memcache_ds.metrics[metric]['units'],
|
170
|
+
memcache_ds.metrics[metric]['type']
|
171
|
+
)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
env_time_end = Time.now()
|
176
|
+
memcache_ds.log.info("Processed #{environment['name']} environment in #{env_time_end - env_time_start}")
|
177
|
+
end
|
178
|
+
|
179
|
+
sleep(30)
|
180
|
+
|
181
|
+
end
|
data/config/example.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
environments:
|
3
|
+
- name: production
|
4
|
+
prefix: prd
|
5
|
+
discovery:
|
6
|
+
host: your discovery host
|
7
|
+
port: port on your discover host
|
8
|
+
gmond:
|
9
|
+
host: gmond host
|
10
|
+
port: port on your gmond host
|
11
|
+
group: memcached
|
12
|
+
|
13
|
+
- name: staging
|
14
|
+
prefix: stg
|
15
|
+
discovery:
|
16
|
+
host: your discovery host
|
17
|
+
port: port on your discover host
|
18
|
+
gmond:
|
19
|
+
host: gmond host
|
20
|
+
port: port on your gmond host
|
21
|
+
group: memcached
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
begin
|
3
|
+
Bundler.setup(:default, :development)
|
4
|
+
rescue Bundler::BundlerError => e
|
5
|
+
$stderr.puts e.message
|
6
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
7
|
+
exit e.status_code
|
8
|
+
end
|
9
|
+
|
10
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
11
|
+
require 'memcachestats'
|
12
|
+
|
13
|
+
require 'rspec/expectations'
|
@@ -0,0 +1,194 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
class MemcacheStats
|
4
|
+
|
5
|
+
attr_accessor :config, :connection, :host, :log
|
6
|
+
|
7
|
+
attr_accessor :gauges, :counters, :metrics, :stats
|
8
|
+
|
9
|
+
def initialize(config, logger = nil)
|
10
|
+
@config = config
|
11
|
+
|
12
|
+
initialize_log unless logger
|
13
|
+
@log = logger if logger
|
14
|
+
@log.error("Logging started")
|
15
|
+
|
16
|
+
initialize_metrics
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize_log
|
20
|
+
@config['log'] = {
|
21
|
+
'file' => STDOUT,
|
22
|
+
'level' => 'INFO'
|
23
|
+
}.merge(@config['log'] || {})
|
24
|
+
|
25
|
+
log_initialize = [@config['log']['file']]
|
26
|
+
log_initialize << @config['log']['shift_age'] if @config['log']['shift_age']
|
27
|
+
log_initialize << @config['log']['shift_size'] if @config['log']['shift_size']
|
28
|
+
|
29
|
+
begin
|
30
|
+
@log = Logger.new(*log_initialize)
|
31
|
+
@log.level = Logger.const_get(@config['log']['level'])
|
32
|
+
rescue Exception => e
|
33
|
+
@config['log'] = {
|
34
|
+
'file' => STDOUT,
|
35
|
+
'level' => 'INFO'
|
36
|
+
}
|
37
|
+
@log = Logger.new(@config['log']['file'])
|
38
|
+
@log.level = Logger.const_get(@config['log']['level'])
|
39
|
+
@log.error("Caught a problem with log settings")
|
40
|
+
@log.error("#{e.message}")
|
41
|
+
@log.error("Setting log settings to defaults")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize_metrics
|
46
|
+
@gauges = {
|
47
|
+
'curr_connections' => {
|
48
|
+
'units' => 'conn',
|
49
|
+
'type' => 'uint32'
|
50
|
+
},
|
51
|
+
'curr_items' => {
|
52
|
+
'units' => 'keys',
|
53
|
+
'type' => 'double'
|
54
|
+
},
|
55
|
+
'threads' => {
|
56
|
+
'units' => 'threads',
|
57
|
+
'type' => 'uint32'
|
58
|
+
},
|
59
|
+
'bytes' => {
|
60
|
+
'units' => 'bytes',
|
61
|
+
'publish' => 'no'
|
62
|
+
},
|
63
|
+
'limit_maxbytes' => {
|
64
|
+
'units' => 'bytes',
|
65
|
+
'publish' => 'no'
|
66
|
+
},
|
67
|
+
'total_connections_total' => {
|
68
|
+
'units' => 'conn',
|
69
|
+
'publish' => 'no'
|
70
|
+
},
|
71
|
+
'total_items_total' => {
|
72
|
+
'units' => 'key',
|
73
|
+
'publish' => 'no'
|
74
|
+
},
|
75
|
+
'get_hits_total' => {
|
76
|
+
'units' => 'r',
|
77
|
+
'publish' => 'no'
|
78
|
+
},
|
79
|
+
'get_misses_total' => {
|
80
|
+
'units' => 'r',
|
81
|
+
'publish' => 'no'
|
82
|
+
},
|
83
|
+
'delete_misses_total' => {
|
84
|
+
'units' => 'r',
|
85
|
+
'publish' => 'no'
|
86
|
+
},
|
87
|
+
'delete_hits_total' => {
|
88
|
+
'units' => 'r',
|
89
|
+
'publish' => 'no'
|
90
|
+
},
|
91
|
+
'bytes_read_total' => {
|
92
|
+
'units' => 'bytes',
|
93
|
+
'publish' => 'no'
|
94
|
+
},
|
95
|
+
'bytes_written_total' => {
|
96
|
+
'units' => 'bytes',
|
97
|
+
'publish' => 'no'
|
98
|
+
},
|
99
|
+
"get_hit_percentage" => {
|
100
|
+
'units' => '%',
|
101
|
+
'type' => 'double'
|
102
|
+
},
|
103
|
+
"get_miss_percentage" => {
|
104
|
+
'units' => '%',
|
105
|
+
'type' => 'double'
|
106
|
+
},
|
107
|
+
"delete_hit_percentage" => {
|
108
|
+
'units' => '%',
|
109
|
+
'type' => 'double'
|
110
|
+
},
|
111
|
+
"delete_miss_percentage" => {
|
112
|
+
'units' => '%',
|
113
|
+
'type' => 'double'
|
114
|
+
},
|
115
|
+
"used_percentage" => {
|
116
|
+
'units' => '%',
|
117
|
+
'type' => 'double'
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
@counters = {
|
122
|
+
'total_connections' => {
|
123
|
+
'units' => 'conn/s',
|
124
|
+
'type' => 'uint32'
|
125
|
+
},
|
126
|
+
'total_items' => {
|
127
|
+
'units' => 'keys/s',
|
128
|
+
'type' => 'uint32'
|
129
|
+
},
|
130
|
+
'get_hits' => {
|
131
|
+
'units' => 'r/s',
|
132
|
+
'type' => 'uint32'
|
133
|
+
},
|
134
|
+
'get_misses' => {
|
135
|
+
'units' => 'r/s',
|
136
|
+
'type' => 'uint32'
|
137
|
+
},
|
138
|
+
'delete_misses' => {
|
139
|
+
'units' => 'r/s',
|
140
|
+
'type' => 'uint32'
|
141
|
+
},
|
142
|
+
'delete_hits' => {
|
143
|
+
'units' => 'r/s',
|
144
|
+
'type' => 'uint32'
|
145
|
+
},
|
146
|
+
'bytes_read' => {
|
147
|
+
'units' => 'bytes/s',
|
148
|
+
'type' => 'double'
|
149
|
+
},
|
150
|
+
'bytes_written' => {
|
151
|
+
'units' => 'bytes/s',
|
152
|
+
'type' => 'double'
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
@metrics = @counters.merge(@gauges)
|
157
|
+
end
|
158
|
+
|
159
|
+
def connect(host, port = '11211')
|
160
|
+
return if @connection and ((@host == host) && (@port == port))
|
161
|
+
|
162
|
+
@connection = TCPSocket.new(host, port)
|
163
|
+
@host = host
|
164
|
+
@port = port
|
165
|
+
end
|
166
|
+
|
167
|
+
def get_memcached_stats(host, port = '11211')
|
168
|
+
@stats = {}
|
169
|
+
matched = {}
|
170
|
+
|
171
|
+
begin
|
172
|
+
connect(host, port)
|
173
|
+
|
174
|
+
@connection.puts("stats")
|
175
|
+
|
176
|
+
while ((line = @connection.gets.chomp) != "END")
|
177
|
+
if (matched = /STAT (?<key>\w+) (?<value>\d+)/.match(line))
|
178
|
+
@stats[matched['key']] = matched['value']
|
179
|
+
@stats["#{matched['key']}_total"] = matched['value'] if @gauges["#{matched['key']}_total"]
|
180
|
+
end
|
181
|
+
end
|
182
|
+
rescue Exception => e
|
183
|
+
pp ["ex", e]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def add_derived_metrics(stats)
|
188
|
+
stats['get_hit_percentage'] = stats['get_hits_total'].to_f / (stats['get_hits_total'] + stats['get_misses_total'] + 1)
|
189
|
+
stats['get_miss_percentage'] = stats['get_misses_total'].to_f / (stats['get_hits_total'] + stats['get_misses_total'] + 1)
|
190
|
+
stats['delete_hit_percentage'] = stats['delete_hits_total'].to_f / (stats['delete_hits_total'] + stats['delete_misses_total'] + 1)
|
191
|
+
stats['delete_miss_percentage'] = stats['delete_misses_total'].to_f / (stats['delete_hits_total'] + stats['delete_misses_total'] + 1)
|
192
|
+
stats['used_percentage'] = stats['bytes'].to_i / (stats['limit_maxbytes'].to_f + 1)
|
193
|
+
end
|
194
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
if RUBY_VERSION =~ /^1\.9/
|
5
|
+
require 'simplecov'
|
6
|
+
|
7
|
+
module SimpleCov::Configuration
|
8
|
+
def clean_filters
|
9
|
+
@filters = []
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
SimpleCov.configure do
|
14
|
+
clean_filters
|
15
|
+
load_adapter 'test_frameworks'
|
16
|
+
end
|
17
|
+
|
18
|
+
ENV["COVERAGE"] && SimpleCov.start do
|
19
|
+
add_filter "/.rvm/"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rspec'
|
24
|
+
require 'memcachestats'
|
25
|
+
|
26
|
+
# Requires supporting files with custom matchers and macros, etc,
|
27
|
+
# in ./support/ and its subdirectories.
|
28
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
29
|
+
|
30
|
+
RSpec.configure do |config|
|
31
|
+
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: memcachestats
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Artem Veremey
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: &70228108732660 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70228108732660
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: gmetric
|
27
|
+
requirement: &70228108731920 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70228108731920
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70228108730520 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.8.0
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70228108730520
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: yard
|
49
|
+
requirement: &70228108728280 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.7'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70228108728280
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rdoc
|
60
|
+
requirement: &70228108741960 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '3.12'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70228108741960
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cucumber
|
71
|
+
requirement: &70228108739680 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70228108739680
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: bundler
|
82
|
+
requirement: &70228108737000 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>'
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 1.0.0
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70228108737000
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: jeweler
|
93
|
+
requirement: &70228108750740 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ~>
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 1.8.3
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70228108750740
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: simplecov
|
104
|
+
requirement: &70228108748720 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70228108748720
|
113
|
+
description: ! 'Memcachestats is a library that captures important Memcached cluster
|
114
|
+
statistics and pushes metrics to Ganglia '
|
115
|
+
email: artem@veremey.net
|
116
|
+
executables:
|
117
|
+
- memclusterstats
|
118
|
+
extensions: []
|
119
|
+
extra_rdoc_files:
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
files:
|
123
|
+
- .document
|
124
|
+
- .rspec
|
125
|
+
- Gemfile
|
126
|
+
- LICENSE.txt
|
127
|
+
- README.md
|
128
|
+
- Rakefile
|
129
|
+
- VERSION
|
130
|
+
- bin/memclusterstats
|
131
|
+
- config/example.yml
|
132
|
+
- features/memcachestats.feature
|
133
|
+
- features/step_definitions/memcachestats_steps.rb
|
134
|
+
- features/support/env.rb
|
135
|
+
- lib/memcachestats.rb
|
136
|
+
- spec/memcachestats_spec.rb
|
137
|
+
- spec/spec_helper.rb
|
138
|
+
homepage: http://github.com/aia/memcachestats
|
139
|
+
licenses:
|
140
|
+
- MIT
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ! '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
hash: 3897026917400312312
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
156
|
+
requirements:
|
157
|
+
- - ! '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
requirements: []
|
161
|
+
rubyforge_project:
|
162
|
+
rubygems_version: 1.8.17
|
163
|
+
signing_key:
|
164
|
+
specification_version: 3
|
165
|
+
summary: Memcachestats is a library that captures important Memcached cluster statistics
|
166
|
+
and pushes metrics to Ganglia
|
167
|
+
test_files: []
|