1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Changed label from pid to instance port

This commit is contained in:
Thomas VIAL 2013-02-15 10:00:06 +01:00
parent 3e548c97a8
commit c39b74e17e
2 changed files with 13 additions and 24 deletions

View file

@ -38,9 +38,9 @@ module Munin
class ThinPeakMemory
def run
pids = get_pids()
port_list = Hash.new
pids.sort.each do |pid, port|
instances = get_pids()
instances.each do |instance|
pid, port = instance.split("|")
hwm = (pid_hwm(pid).to_i)/1024
puts "thin_#{port}.value #{hwm}"
end
@ -61,18 +61,9 @@ module Munin
end
end
# Get pis using lsof (list open files)
# look for listening tcp applications
# that match the name thin
# fetch all pids that match thin
def get_pids
pids_ports = []
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
pids = `pgrep -f 'thin' -l | awk -F " " '{ if (substr( $4, 10, 4)>=1) print $1"|"substr( $4, 10, 4)}'`.split(/\r?\n/)
end
def autoconf