From 9ec552e04eac0b4d72eaf6f8f98ce49ecfdab376 Mon Sep 17 00:00:00 2001 From: Thomas VIAL Date: Thu, 4 Apr 2013 10:00:04 +0200 Subject: [PATCH 1/3] Fixed thin_threads which reported 0 all the time --- plugins/thin/thin_threads | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/thin/thin_threads b/plugins/thin/thin_threads index 16cbd567..57a4d542 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 From 08c3a67e8b7031a4801c0dfedc067cfaa81f89a3 Mon Sep 17 00:00:00 2001 From: Thomas Vial Date: Sat, 8 Jun 2013 18:07:26 +0200 Subject: [PATCH 2/3] Fixed instance order using port number and not pid anymore --- plugins/thin/thin_memory | 2 +- plugins/thin/thin_threads | 2 +- plugins/thin/thins_peak_memory | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/thin/thin_memory b/plugins/thin/thin_memory index cf7814df..f800f759 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 diff --git a/plugins/thin/thin_threads b/plugins/thin/thin_threads index 57a4d542..c328b48d 100755 --- a/plugins/thin/thin_threads +++ b/plugins/thin/thin_threads @@ -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 diff --git a/plugins/thin/thins_peak_memory b/plugins/thin/thins_peak_memory index 049fda29..bcf56c9c 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 From 82911254b1b2b9c43deff67d9e84a9fb8b867dc5 Mon Sep 17 00:00:00 2001 From: Thomas Vial Date: Wed, 12 Jun 2013 16:59:48 +0200 Subject: [PATCH 3/3] Fixed element sorting on config call --- plugins/thin/thin_memory | 2 +- plugins/thin/thin_threads | 2 +- plugins/thin/thins_peak_memory | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/thin/thin_memory b/plugins/thin/thin_memory index f800f759..a496ede4 100755 --- a/plugins/thin/thin_memory +++ b/plugins/thin/thin_memory @@ -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 c328b48d..bfb09bc7 100755 --- a/plugins/thin/thin_threads +++ b/plugins/thin/thin_threads @@ -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 bcf56c9c..4dc47e5b 100755 --- a/plugins/thin/thins_peak_memory +++ b/plugins/thin/thins_peak_memory @@ -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"