Class: Munin::RakeProcesses::Plugin
- Inherits:
-
Object
- Object
- Munin::RakeProcesses::Plugin
show all
- Defined in:
- lib/munin/rake_processes/plugin.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(args, environment = {}) ⇒ Plugin
Returns a new instance of Plugin.
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/munin/rake_processes/plugin.rb', line 7
def initialize(args, environment={})
self.graph_category = environment['graph_category'] || 'RakeProcesses'
case args[0]
when "config"
config
when "autoconf"
autoconf
else
run
end
end
|
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
4
5
6
|
# File 'lib/munin/rake_processes/plugin.rb', line 4
def debug
@debug
end
|
#graph_category ⇒ Object
Returns the value of attribute graph_category.
5
6
7
|
# File 'lib/munin/rake_processes/plugin.rb', line 5
def graph_category
@graph_category
end
|
Class Method Details
.rake_ps_string ⇒ Object
20
21
22
|
# File 'lib/munin/rake_processes/plugin.rb', line 20
def self.rake_ps_string
`ps -eo user,pid,%cpu,%mem,cputime,command | grep -v -e grep -e munin | grep rake`
end
|
Instance Method Details
#autoconf ⇒ Object
40
41
42
|
# File 'lib/munin/rake_processes/plugin.rb', line 40
def autoconf
puts "yes"
end
|
#rake_processes ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/munin/rake_processes/plugin.rb', line 24
def rake_processes
@rake_processes ||= begin
_rake_processes = {}
rake_ps_lines = self.class.rake_ps_string.split("\n")
rake_ps_lines.each do |ps_line|
user, pid, cpu, memory, cpu_time, cmd = ps_line.split ' ', 6
cmd =~ /rake([^-]+)/
rake_cmd = $1.split('-').first.strip.gsub(/[^\w]/, '_')
label = "#{user}_#{pid}_#{rake_cmd}"
time_in_seconds = ps_time_to_seconds(cpu_time)
_rake_processes[label] = {:cpu => cpu, :memory => memory, :time => time_in_seconds}
end
_rake_processes
end
end
|
#run ⇒ Object
44
45
46
|
# File 'lib/munin/rake_processes/plugin.rb', line 44
def run
end
|