1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-26 02:48:28 +00:00

The original relied on thin listening on TCP ports, but that has no actual bearing. I killed all the port nonsense and labeled them by pid.

This commit is contained in:
ElFurbe 2011-08-17 05:34:13 +02:00 committed by Steve Schnepp
parent e41d7bd1af
commit afe66001fa

View file

@ -6,11 +6,15 @@
# DOES NOT WORK on OSX, Solaris or BSD. # DOES NOT WORK on OSX, Solaris or BSD.
# only linux, because this script relies on proc filesystem # only linux, because this script relies on proc filesystem
# #
# Author: # Original author:
# Frederico de Souza Araujo - fred.the.master@gmail.com # Frederico de Souza Araujo - fred.the.master@gmail.com
# http://www.frederico-araujo.com # http://www.frederico-araujo.com
# #
# Based on: # Usurper:
# Adam Michel - elfurbe@furbism.com
# http://www.furbism.com
#
# Originally based on:
# thin_process_memory - # thin_process_memory -
# A munin plugin to monitor memory size of # A munin plugin to monitor memory size of
# each individual thin process # each individual thin process
@ -38,10 +42,9 @@ module Munin
def run def run
pids = get_pids() pids = get_pids()
port_list = Hash.new pids.sort.each do |pid|
pids.sort.each do |pid, port|
res = (get_threads(pid).to_i) res = (get_threads(pid).to_i)
puts "thin_#{port}.value #{res}" puts "thin_#{pid}.value #{res}"
end end
end end
@ -64,14 +67,7 @@ module Munin
# look for listening tcp applications # look for listening tcp applications
# that match the name thin # that match the name thin
def get_pids def get_pids
pids_ports = []
pids = `pgrep thin`.split 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
@ -91,11 +87,11 @@ 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,port| mpm.get_pids.sort.each do |pid|
puts "thin_#{port}.label thin_#{port}" puts "thin_#{pid}.label thin_#{pid}"
puts "thin_#{port}.info Threads per Thin process" puts "thin_#{pid}.info Threads per Thin process"
puts "thin_#{port}.type GAUGE" puts "thin_#{pid}.type GAUGE"
puts "thin_#{port}.min 0" puts "thin_#{pid}.min 0"
end end
when "autoconf" when "autoconf"
if mpm.autoconf if mpm.autoconf