memcached_graphite 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/memcached_graphite +31 -16
- data/lib/memcached_graphite/version.rb +1 -1
- data/memcached_graphite.gemspec +1 -1
- metadata +6 -6
data/bin/memcached_graphite
CHANGED
@@ -4,7 +4,7 @@ require 'pp'
|
|
4
4
|
require 'logger'
|
5
5
|
require 'optparse'
|
6
6
|
require 'rubygems'
|
7
|
-
require '
|
7
|
+
require 'memcache_do'
|
8
8
|
require 'graphite'
|
9
9
|
require 'memcached_graphite'
|
10
10
|
|
@@ -22,19 +22,24 @@ def format_hostname ( hostname, options )
|
|
22
22
|
options[:reverse_hostname] ? hn.reverse : hn.to_s
|
23
23
|
end
|
24
24
|
|
25
|
+
def get_stats_slabs (host, port)
|
26
|
+
Hash[MemcacheDo.exec('stats slabs',host,port).gsub(/^STAT (\d+):/,'STAT slab_\1.').scan(/^STAT (.*?) (.*)\r$/)]
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_stats (host, port)
|
30
|
+
Hash[MemcacheDo.exec('stats',host,port).scan(/^STAT (.*?) (.*)\r$/)]
|
31
|
+
end
|
32
|
+
|
25
33
|
#format the stats in a way that graphite expects
|
26
|
-
def format_stats (
|
27
|
-
carbon_prefix = options[:carbon_prefix]
|
34
|
+
def format_stats ( server_stats, host = 'localhost', port = 11211, options = {} )
|
28
35
|
stats = {}
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
server_split[1] || 11211 )
|
36
|
+
carbon_prefix = options[:carbon_prefix]
|
37
|
+
server_piece = sprintf("%s.port_%s",
|
38
|
+
format_hostname(host, options),
|
39
|
+
port)
|
34
40
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
41
|
+
prefix = [carbon_prefix, server_piece].join('.')
|
42
|
+
stats.merge! server_stats.prefix_keys("#{prefix}.")
|
38
43
|
|
39
44
|
# only return numeric values
|
40
45
|
# & convert to floats
|
@@ -82,9 +87,19 @@ opts.on("-h", "--help", "help" ) do |v|
|
|
82
87
|
end
|
83
88
|
opts.parse!
|
84
89
|
|
85
|
-
|
86
|
-
|
87
|
-
|
90
|
+
g = Graphite::Logger.new(options[:carbon_server], logger)
|
91
|
+
|
92
|
+
options[:memcached_servers].each do |server|
|
93
|
+
stats = {}
|
94
|
+
host,port = server.split(':')
|
95
|
+
host ||= 'localhost'
|
96
|
+
port ||= 11211
|
97
|
+
|
98
|
+
stats = get_stats(host,port)
|
99
|
+
stats.merge! get_stats_slabs(host,port)
|
100
|
+
stats = format_stats(stats, host, port, options)
|
101
|
+
|
102
|
+
g.log(Time.now.to_i, stats)
|
103
|
+
end
|
104
|
+
|
88
105
|
|
89
|
-
stats = format_stats(dc.stats, options)
|
90
|
-
g.log(Time.now.to_i, stats)
|
data/memcached_graphite.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
# specify any dependencies here; for example:
|
22
22
|
# s.add_development_dependency "rspec"
|
23
|
-
s.add_runtime_dependency "dalli"
|
24
23
|
s.add_runtime_dependency "graphite"
|
24
|
+
s.add_runtime_dependency "memcache_do"
|
25
25
|
s.rubygems_version = '1.3.5'
|
26
26
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memcached_graphite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Aaron Brown
|
@@ -15,10 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-11-01 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: graphite
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
35
|
+
name: memcache_do
|
36
36
|
prerelease: false
|
37
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
38
|
none: false
|