mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-25 18:38:30 +00:00
Merge pull request #259 from tomav/add_port_number
Add port number and fix process matching
This commit is contained in:
commit
fc63981ec4
3 changed files with 32 additions and 39 deletions
|
@ -41,10 +41,11 @@ module Munin
|
||||||
|
|
||||||
# run main method
|
# run main method
|
||||||
def run
|
def run
|
||||||
pids = get_pids()
|
instances = get_pids()
|
||||||
pids.sort.each do |pid|
|
instances.each do |instance|
|
||||||
|
pid, port = instance.split("|")
|
||||||
rss = (pid_rss(pid).to_i)/1024
|
rss = (pid_rss(pid).to_i)/1024
|
||||||
puts "thin_#{pid}.value #{rss}"
|
puts "thin_#{port}.value #{rss}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ module Munin
|
||||||
|
|
||||||
# fetch all pids that match thin
|
# fetch all pids that match thin
|
||||||
def get_pids
|
def get_pids
|
||||||
pids = `pgrep thin`.split
|
pids = `pgrep -f 'thin' -l | awk -F " " '{ if (substr( $4, 10, 4)>=1) print $1"|"substr( $4, 10, 4)}'`.split(/\r?\n/)
|
||||||
end
|
end
|
||||||
|
|
||||||
def autoconf
|
def autoconf
|
||||||
|
@ -80,11 +81,12 @@ when "config"
|
||||||
puts "graph_args --base 1024 -l 0"
|
puts "graph_args --base 1024 -l 0"
|
||||||
puts "graph_scale yes"
|
puts "graph_scale yes"
|
||||||
puts "graph_info Tracks the size of individual thin processes"
|
puts "graph_info Tracks the size of individual thin processes"
|
||||||
mpm.get_pids.sort.each do |pid|
|
mpm.get_pids.sort.each do |instance|
|
||||||
puts "thin_#{pid}.label thin_#{pid}"
|
pid, port = instance.split("|")
|
||||||
puts "thin_#{pid}.info Process memory"
|
puts "thin_#{port}.label thin_#{port}"
|
||||||
puts "thin_#{pid}.type GAUGE"
|
puts "thin_#{port}.info Process memory"
|
||||||
puts "thin_#{pid}.min 0"
|
puts "thin_#{port}.type GAUGE"
|
||||||
|
puts "thin_#{port}.min 0"
|
||||||
end
|
end
|
||||||
when "autoconf"
|
when "autoconf"
|
||||||
if mpm.autoconf
|
if mpm.autoconf
|
||||||
|
|
|
@ -41,10 +41,11 @@ module Munin
|
||||||
class ThinThreads
|
class ThinThreads
|
||||||
|
|
||||||
def run
|
def run
|
||||||
pids = get_pids()
|
instances = get_pids()
|
||||||
pids.sort.each do |pid|
|
instances.each do |instance|
|
||||||
res = (get_threads(pid).to_i)
|
pid, port = instance.split("|")
|
||||||
puts "thin_#{pid}.value #{res}"
|
rss = (get_threads(pid).to_i)/1024
|
||||||
|
puts "thin_#{port}.value #{rss}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -61,13 +62,10 @@ module Munin
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# fetch all pids that match thin
|
||||||
# Get pis using lsof (list open files)
|
|
||||||
# look for listening tcp applications
|
|
||||||
# that match the name thin
|
|
||||||
def get_pids
|
def get_pids
|
||||||
pids = `pgrep thin`.split
|
pids = `pgrep -f 'thin' -l | awk -F " " '{ if (substr( $4, 10, 4)>=1) print $1"|"substr( $4, 10, 4)}'`.split(/\r?\n/)
|
||||||
end
|
end
|
||||||
|
|
||||||
def autoconf
|
def autoconf
|
||||||
|
@ -87,11 +85,12 @@ when "config"
|
||||||
puts "graph_args -l 0"
|
puts "graph_args -l 0"
|
||||||
puts "graph_scale yes"
|
puts "graph_scale yes"
|
||||||
puts "graph_info Tracks how many threads per thin processes"
|
puts "graph_info Tracks how many threads per thin processes"
|
||||||
mpm.get_pids.sort.each do |pid|
|
mpm.get_pids.sort.each do |instance|
|
||||||
puts "thin_#{pid}.label thin_#{pid}"
|
pid, port = instance.split("|")
|
||||||
puts "thin_#{pid}.info Threads per Thin process"
|
puts "thin_#{port}.label thin_#{port}"
|
||||||
puts "thin_#{pid}.type GAUGE"
|
puts "thin_#{port}.info Threads per Thin process"
|
||||||
puts "thin_#{pid}.min 0"
|
puts "thin_#{port}.type GAUGE"
|
||||||
|
puts "thin_#{port}.min 0"
|
||||||
end
|
end
|
||||||
when "autoconf"
|
when "autoconf"
|
||||||
if mpm.autoconf
|
if mpm.autoconf
|
||||||
|
|
|
@ -38,9 +38,9 @@ module Munin
|
||||||
class ThinPeakMemory
|
class ThinPeakMemory
|
||||||
|
|
||||||
def run
|
def run
|
||||||
pids = get_pids()
|
instances = get_pids()
|
||||||
port_list = Hash.new
|
instances.each do |instance|
|
||||||
pids.sort.each do |pid, port|
|
pid, port = instance.split("|")
|
||||||
hwm = (pid_hwm(pid).to_i)/1024
|
hwm = (pid_hwm(pid).to_i)/1024
|
||||||
puts "thin_#{port}.value #{hwm}"
|
puts "thin_#{port}.value #{hwm}"
|
||||||
end
|
end
|
||||||
|
@ -61,18 +61,9 @@ module Munin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get pis using lsof (list open files)
|
# fetch all pids that match thin
|
||||||
# look for listening tcp applications
|
|
||||||
# that match the name thin
|
|
||||||
def get_pids
|
def get_pids
|
||||||
pids_ports = []
|
pids = `pgrep -f 'thin' -l | awk -F " " '{ if (substr( $4, 10, 4)>=1) print $1"|"substr( $4, 10, 4)}'`.split(/\r?\n/)
|
||||||
pids = `pgrep thin`.split
|
|
||||||
pids.each do |t|
|
|
||||||
port = `lsof -p #{t} | grep LISTEN`.split[8]
|
|
||||||
port = port.split(":")[1]
|
|
||||||
pids_ports << [t,port]
|
|
||||||
end
|
|
||||||
pids_ports
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def autoconf
|
def autoconf
|
||||||
|
@ -92,7 +83,8 @@ when "config"
|
||||||
puts "graph_args -l 0"
|
puts "graph_args -l 0"
|
||||||
puts "graph_scale yes"
|
puts "graph_scale yes"
|
||||||
puts "graph_info Tracks the peak memory of thin processes, aka High Water Mark."
|
puts "graph_info Tracks the peak memory of thin processes, aka High Water Mark."
|
||||||
mpm.get_pids.sort.each do |pid,port|
|
mpm.get_pids.sort.each do |instance|
|
||||||
|
pid, port = instance.split("|")
|
||||||
puts "thin_#{port}.label thin_#{port}"
|
puts "thin_#{port}.label thin_#{port}"
|
||||||
puts "thin_#{port}.info Peak Memory"
|
puts "thin_#{port}.info Peak Memory"
|
||||||
puts "thin_#{port}.type GAUGE"
|
puts "thin_#{port}.type GAUGE"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue