mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Ruby plugins: apply code changes as suggested by "rubocop --auto-correct"
This commit is contained in:
parent
b0b39b018e
commit
809639ab65
33 changed files with 904 additions and 910 deletions
|
@ -34,33 +34,32 @@ Contributors: Adam Jacob (<adam@hjksolutions.com>)
|
|||
|
||||
=end
|
||||
|
||||
|
||||
module Munin
|
||||
class MongrelProcessMemory
|
||||
def run
|
||||
pid_port_map = get_pids()
|
||||
port_list = Hash.new
|
||||
pid_port_map = get_pids
|
||||
port_list = {}
|
||||
pid_port_map.sort.each do |pid, port|
|
||||
rss = `pmap -x #{pid} | grep total`.split(" ")[3]
|
||||
rss = `pmap -x #{pid} | grep total`.split(' ')[3]
|
||||
puts "mongrel_#{port}.value #{rss}"
|
||||
end
|
||||
end
|
||||
|
||||
def get_pids
|
||||
h = Hash.new
|
||||
h = {}
|
||||
pids = []
|
||||
pids += `pgrep mongrel_rails`.split("\n")
|
||||
pids += `pgrep ruby`.split("\n")
|
||||
pids.each { |pid|
|
||||
pids.each do |pid|
|
||||
l = `pargs -l #{pid}`
|
||||
l =~ /-p (\d+)/
|
||||
h[pid] = $1 if $1
|
||||
}
|
||||
h[pid] = Regexp.last_match(1) if Regexp.last_match(1)
|
||||
end
|
||||
h
|
||||
end
|
||||
|
||||
def autoconf
|
||||
get_pids().length > 0
|
||||
get_pids.length > 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -68,25 +67,25 @@ end
|
|||
mpm = Munin::MongrelProcessMemory.new
|
||||
|
||||
case ARGV[0]
|
||||
when "config"
|
||||
puts "graph_title Mongrel Memory"
|
||||
puts "graph_vlabel RSS"
|
||||
puts "graph_category memory"
|
||||
puts "graph_args --base 1024 -l 0"
|
||||
puts "graph_scale yes"
|
||||
puts "graph_info Tracks the size of individual mongrel processes"
|
||||
when 'config'
|
||||
puts 'graph_title Mongrel Memory'
|
||||
puts 'graph_vlabel RSS'
|
||||
puts 'graph_category memory'
|
||||
puts 'graph_args --base 1024 -l 0'
|
||||
puts 'graph_scale yes'
|
||||
puts 'graph_info Tracks the size of individual mongrel processes'
|
||||
mpm.get_pids.values.sort.each do |port|
|
||||
puts "mongrel_#{port}.label mongrel_#{port}"
|
||||
puts "mongrel_#{port}.info Process memory"
|
||||
puts "mongrel_#{port}.type GAUGE"
|
||||
puts "mongrel_#{port}.min 0"
|
||||
end
|
||||
when "autoconf"
|
||||
when 'autoconf'
|
||||
if mpm.autoconf
|
||||
puts "yes"
|
||||
puts 'yes'
|
||||
exit 0
|
||||
end
|
||||
puts "no"
|
||||
puts 'no'
|
||||
exit 0
|
||||
else
|
||||
mpm.run
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue