entombedvirus-munin_manager 1.1.3 → 1.1.4
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/Rakefile +1 -1
- data/lib/munin_manager/plugins/fbproxy_latency.rb +80 -0
- data/munin_manager.gemspec +3 -3
- metadata +3 -1
data/Rakefile
CHANGED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
module MuninManager
|
|
2
|
+
class Plugins::FbProxyLatency < LogReader
|
|
3
|
+
include ActsAsMuninPlugin
|
|
4
|
+
|
|
5
|
+
def data
|
|
6
|
+
@data ||= Hash.new {|h, k| h[k] = Array.new}
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def scan(log_file)
|
|
10
|
+
loop do
|
|
11
|
+
line = log_file.readline
|
|
12
|
+
next unless line.match(/^Benchmark /)
|
|
13
|
+
chunks = line.split(/-/).map{ |x| x.strip }
|
|
14
|
+
data_type = chunks[1] =~ /Queue/ ? 'queue' : 'fb_api'
|
|
15
|
+
puts chunks[2]
|
|
16
|
+
data[data_type] << chunks[2].match('\((.*)\)')[1].to_f
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def process!
|
|
21
|
+
puts data.inspect
|
|
22
|
+
data.each_pair do |component, response_times|
|
|
23
|
+
data[component] = response_times.inject(0.0) {|sum, i| sum + i} / data[component].length rescue 0
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def config
|
|
28
|
+
<<-LABEL
|
|
29
|
+
graph_title Facebook Proxy Latency
|
|
30
|
+
graph_vlabel latency
|
|
31
|
+
graph_category Facebook Proxy
|
|
32
|
+
queue.label queue_latency
|
|
33
|
+
fb_api.label fb_api_latency
|
|
34
|
+
LABEL
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def values
|
|
38
|
+
puts data.inspect
|
|
39
|
+
data.map {|k, v| "#{format_for_munin(k)}.value #{"%.10f" % v}"}.join("\n")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.run
|
|
43
|
+
log_file = ENV['log_file'] || "/var/log/rails.log"
|
|
44
|
+
allowed_commands = ['config']
|
|
45
|
+
|
|
46
|
+
rails = new(log_file)
|
|
47
|
+
|
|
48
|
+
if cmd = ARGV[0] and allowed_commands.include? cmd then
|
|
49
|
+
puts rails.send(cmd.to_sym)
|
|
50
|
+
else
|
|
51
|
+
rails.collect!
|
|
52
|
+
puts rails.values
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.help_text(options = {})
|
|
57
|
+
%Q{
|
|
58
|
+
#{plugin_name.capitalize} Munin Plugin
|
|
59
|
+
===========================
|
|
60
|
+
|
|
61
|
+
Please remember to add something like the lines below to /etc/munin/plugin-conf.d/munin-node
|
|
62
|
+
if the rails log file is not at /var/log/rails.log
|
|
63
|
+
|
|
64
|
+
[#{options[:symlink] || plugin_name}]
|
|
65
|
+
env.log_file /var/log/custom/rails.log
|
|
66
|
+
|
|
67
|
+
Also, make sure that the '/var/lib/munin/plugin-state' is writable by munin.
|
|
68
|
+
|
|
69
|
+
$ sudo chmod 777 /var/lib/munin/plugin-state
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
private
|
|
75
|
+
|
|
76
|
+
def format_for_munin(str)
|
|
77
|
+
str.to_s.gsub(/[^A-Za-z0-9_]/, "_")
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
data/munin_manager.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{munin_manager}
|
|
5
|
-
s.version = "1.1.
|
|
5
|
+
s.version = "1.1.4"
|
|
6
6
|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
|
8
8
|
s.authors = ["Rohith Ravi"]
|
|
@@ -10,8 +10,8 @@ Gem::Specification.new do |s|
|
|
|
10
10
|
s.description = %q{Tool to maintain and install munin plugins written in Ruby}
|
|
11
11
|
s.email = %q{entombedvirus@gmail.com}
|
|
12
12
|
s.executables = ["munin_manager", "runner"]
|
|
13
|
-
s.extra_rdoc_files = ["bin/munin_manager", "bin/runner", "ext/string.rb", "lib/munin_manager/acts_as_munin_plugin.rb", "lib/munin_manager/log_reader.rb", "lib/munin_manager/plugins/haproxy_response_time.rb", "lib/munin_manager/plugins/network_latency.rb", "lib/munin_manager/plugins/packet_loss.rb", "lib/munin_manager/plugins/rails_rendering.rb", "lib/munin_manager/plugins/rails_response_time.rb", "lib/munin_manager/plugins/scribe_net.rb", "lib/munin_manager/plugins/starling_age.rb", "lib/munin_manager/plugins/starling_net.rb", "lib/munin_manager/plugins/starling_ops.rb", "lib/munin_manager/plugins/starling_queue.rb", "lib/munin_manager/plugins.rb", "lib/munin_manager/starling/starling_stats.rb", "lib/munin_manager.rb", "README.markdown"]
|
|
14
|
-
s.files = ["bin/munin_manager", "bin/runner", "ext/string.rb", "lib/munin_manager/acts_as_munin_plugin.rb", "lib/munin_manager/log_reader.rb", "lib/munin_manager/plugins/haproxy_response_time.rb", "lib/munin_manager/plugins/network_latency.rb", "lib/munin_manager/plugins/packet_loss.rb", "lib/munin_manager/plugins/rails_rendering.rb", "lib/munin_manager/plugins/rails_response_time.rb", "lib/munin_manager/plugins/scribe_net.rb", "lib/munin_manager/plugins/starling_age.rb", "lib/munin_manager/plugins/starling_net.rb", "lib/munin_manager/plugins/starling_ops.rb", "lib/munin_manager/plugins/starling_queue.rb", "lib/munin_manager/plugins.rb", "lib/munin_manager/starling/starling_stats.rb", "lib/munin_manager.rb", "Manifest", "munin_manager.gemspec", "Rakefile", "README.markdown", "test/haproxy_response_time_test.rb", "test/log_reader_test.rb", "test/rails_response_time_test.rb", "test/test_helper.rb"]
|
|
13
|
+
s.extra_rdoc_files = ["bin/munin_manager", "bin/runner", "ext/string.rb", "lib/munin_manager/acts_as_munin_plugin.rb", "lib/munin_manager/log_reader.rb", "lib/munin_manager/plugins/fbproxy_latency.rb", "lib/munin_manager/plugins/haproxy_response_time.rb", "lib/munin_manager/plugins/network_latency.rb", "lib/munin_manager/plugins/packet_loss.rb", "lib/munin_manager/plugins/rails_rendering.rb", "lib/munin_manager/plugins/rails_response_time.rb", "lib/munin_manager/plugins/scribe_net.rb", "lib/munin_manager/plugins/starling_age.rb", "lib/munin_manager/plugins/starling_net.rb", "lib/munin_manager/plugins/starling_ops.rb", "lib/munin_manager/plugins/starling_queue.rb", "lib/munin_manager/plugins.rb", "lib/munin_manager/starling/starling_stats.rb", "lib/munin_manager.rb", "README.markdown"]
|
|
14
|
+
s.files = ["bin/munin_manager", "bin/runner", "ext/string.rb", "lib/munin_manager/acts_as_munin_plugin.rb", "lib/munin_manager/log_reader.rb", "lib/munin_manager/plugins/fbproxy_latency.rb", "lib/munin_manager/plugins/haproxy_response_time.rb", "lib/munin_manager/plugins/network_latency.rb", "lib/munin_manager/plugins/packet_loss.rb", "lib/munin_manager/plugins/rails_rendering.rb", "lib/munin_manager/plugins/rails_response_time.rb", "lib/munin_manager/plugins/scribe_net.rb", "lib/munin_manager/plugins/starling_age.rb", "lib/munin_manager/plugins/starling_net.rb", "lib/munin_manager/plugins/starling_ops.rb", "lib/munin_manager/plugins/starling_queue.rb", "lib/munin_manager/plugins.rb", "lib/munin_manager/starling/starling_stats.rb", "lib/munin_manager.rb", "Manifest", "munin_manager.gemspec", "Rakefile", "README.markdown", "test/haproxy_response_time_test.rb", "test/log_reader_test.rb", "test/rails_response_time_test.rb", "test/test_helper.rb"]
|
|
15
15
|
s.has_rdoc = true
|
|
16
16
|
s.homepage = %q{}
|
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Munin_manager", "--main", "README.markdown"]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: entombedvirus-munin_manager
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rohith Ravi
|
|
@@ -26,6 +26,7 @@ extra_rdoc_files:
|
|
|
26
26
|
- ext/string.rb
|
|
27
27
|
- lib/munin_manager/acts_as_munin_plugin.rb
|
|
28
28
|
- lib/munin_manager/log_reader.rb
|
|
29
|
+
- lib/munin_manager/plugins/fbproxy_latency.rb
|
|
29
30
|
- lib/munin_manager/plugins/haproxy_response_time.rb
|
|
30
31
|
- lib/munin_manager/plugins/network_latency.rb
|
|
31
32
|
- lib/munin_manager/plugins/packet_loss.rb
|
|
@@ -46,6 +47,7 @@ files:
|
|
|
46
47
|
- ext/string.rb
|
|
47
48
|
- lib/munin_manager/acts_as_munin_plugin.rb
|
|
48
49
|
- lib/munin_manager/log_reader.rb
|
|
50
|
+
- lib/munin_manager/plugins/fbproxy_latency.rb
|
|
49
51
|
- lib/munin_manager/plugins/haproxy_response_time.rb
|
|
50
52
|
- lib/munin_manager/plugins/network_latency.rb
|
|
51
53
|
- lib/munin_manager/plugins/packet_loss.rb
|