diff --git a/plugins/thin/thin_memory b/plugins/thin/thin_memory index cf7814df..a496ede4 100755 --- a/plugins/thin/thin_memory +++ b/plugins/thin/thin_memory @@ -61,7 +61,7 @@ module Munin # fetch all pids that match thin def get_pids - pids = `pgrep -f 'thin' -l | awk -F " " '{ if (substr( $4, 10, 4)>=1) print $1"|"substr( $4, 10, 4)}'`.split(/\r?\n/) + pids = `pgrep -f 'thin' -l | awk -F " " '{ if (substr( $4, 10, 4)>=1) print $1"|"substr( $4, 10, 4)}' | sort -t'|' -nk 2`.split(/\r?\n/) end def autoconf @@ -81,7 +81,7 @@ when "config" puts "graph_args --base 1024 -l 0" puts "graph_scale yes" puts "graph_info Tracks the size of individual thin processes" - mpm.get_pids.sort.each do |instance| + mpm.get_pids.each do |instance| pid, port = instance.split("|") puts "thin_#{port}.label thin_#{port}" puts "thin_#{port}.info Process memory" diff --git a/plugins/thin/thin_threads b/plugins/thin/thin_threads index 16cbd567..bfb09bc7 100755 --- a/plugins/thin/thin_threads +++ b/plugins/thin/thin_threads @@ -44,7 +44,7 @@ module Munin instances = get_pids() instances.each do |instance| pid, port = instance.split("|") - rss = (get_threads(pid).to_i)/1024 + rss = (get_threads(pid).to_i) puts "thin_#{port}.value #{rss}" end end @@ -55,7 +55,7 @@ module Munin # TODO: make this work on OSX and Solaris, # so the whole unix gang is happy ;) def get_threads(pid) - res = `grep "Threads" /proc/#{pid}/status`.split[1] + res = `grep "Threads" /proc/#{pid}/status | cut -d ":" -f2`.gsub(/\s+/, "") if res.match("cannot access") return nil else @@ -65,7 +65,7 @@ module Munin # fetch all pids that match thin def get_pids - pids = `pgrep -f 'thin' -l | awk -F " " '{ if (substr( $4, 10, 4)>=1) print $1"|"substr( $4, 10, 4)}'`.split(/\r?\n/) + pids = `pgrep -f 'thin' -l | awk -F " " '{ if (substr( $4, 10, 4)>=1) print $1"|"substr( $4, 10, 4)}' | sort -t'|' -nk 2`.split(/\r?\n/) end def autoconf @@ -85,7 +85,7 @@ when "config" puts "graph_args -l 0" puts "graph_scale yes" puts "graph_info Tracks how many threads per thin processes" - mpm.get_pids.sort.each do |instance| + mpm.get_pids.each do |instance| pid, port = instance.split("|") puts "thin_#{port}.label thin_#{port}" puts "thin_#{port}.info Threads per Thin process" diff --git a/plugins/thin/thins_peak_memory b/plugins/thin/thins_peak_memory index 049fda29..4dc47e5b 100755 --- a/plugins/thin/thins_peak_memory +++ b/plugins/thin/thins_peak_memory @@ -63,7 +63,7 @@ module Munin # fetch all pids that match thin def get_pids - pids = `pgrep -f 'thin' -l | awk -F " " '{ if (substr( $4, 10, 4)>=1) print $1"|"substr( $4, 10, 4)}'`.split(/\r?\n/) + pids = `pgrep -f 'thin' -l | awk -F " " '{ if (substr( $4, 10, 4)>=1) print $1"|"substr( $4, 10, 4)}' | sort -t'|' -nk 2`.split(/\r?\n/) end def autoconf @@ -83,7 +83,7 @@ when "config" puts "graph_args -l 0" puts "graph_scale yes" puts "graph_info Tracks the peak memory of thin processes, aka High Water Mark." - mpm.get_pids.sort.each do |instance| + mpm.get_pids.each do |instance| pid, port = instance.split("|") puts "thin_#{port}.label thin_#{port}" puts "thin_#{port}.info Peak Memory"