Révision e41d7bd1
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.
| plugins/other/thin_memory | ||
|---|---|---|
| 1 | 1 |
#!/usr/bin/env ruby |
| 2 |
# thin_memory - A munin plugin for Linux to monitor memory size of |
|
| 3 |
# each individual thin process |
|
| 4 |
# I havent tested on OSX or Solaris. Works great on Linux (gentoo) |
|
| 5 |
# Author: |
|
| 2 |
# thin_memory - A munin plugin for Linux to monitor memory size of each individual thin process |
|
| 3 |
# |
|
| 4 |
# For Linux ONLY ! |
|
| 5 |
# DOES NOT WORK on OSX, Solaris or BSD. |
|
| 6 |
# only linux, because this script relies on proc filesystem |
|
| 7 |
# |
|
| 8 |
# Original author: |
|
| 6 | 9 |
# Frederico de Souza Araujo - fred.the.master@gmail.com |
| 7 | 10 |
# http://www.frederico-araujo.com |
| 8 | 11 |
# |
| 9 |
# Based on: |
|
| 12 |
# Usurper: |
|
| 13 |
# Adam Michel - elfurbe@furbism.com |
|
| 14 |
# http://www.furbism.com |
|
| 15 |
# |
|
| 16 |
# Originally based on: |
|
| 10 | 17 |
# thin_process_memory - |
| 11 | 18 |
# A munin plugin to monitor memory size of |
| 12 | 19 |
# each individual thin process |
| ... | ... | |
| 35 | 42 |
# run main method |
| 36 | 43 |
def run |
| 37 | 44 |
pids = get_pids() |
| 38 |
port_list = Hash.new |
|
| 39 |
pids.sort.each do |pid, port| |
|
| 45 |
pids.sort.each do |pid| |
|
| 40 | 46 |
rss = (pid_rss(pid).to_i)/1024 |
| 41 |
puts "thin_#{port}.value #{rss}"
|
|
| 47 |
puts "thin_#{pid}.value #{rss}"
|
|
| 42 | 48 |
end |
| 43 | 49 |
end |
| 44 | 50 |
|
| ... | ... | |
| 54 | 60 |
|
| 55 | 61 |
# fetch all pids that match thin |
| 56 | 62 |
def get_pids |
| 57 |
pids_ports = [] |
|
| 58 | 63 |
pids = `pgrep thin`.split |
| 59 |
pids.each do |t| |
|
| 60 |
# only works for linux i'm affraid |
|
| 61 |
# using lsof (list open files) |
|
| 62 |
port = `lsof -p #{t} | grep LISTEN`.split[8]
|
|
| 63 |
port = port.split(":")[1]
|
|
| 64 |
pids_ports << [t,port] |
|
| 65 |
end |
|
| 66 |
pids_ports |
|
| 67 | 64 |
end |
| 68 | 65 |
|
| 69 | 66 |
def autoconf |
| ... | ... | |
| 83 | 80 |
puts "graph_args --base 1024 -l 0" |
| 84 | 81 |
puts "graph_scale yes" |
| 85 | 82 |
puts "graph_info Tracks the size of individual thin processes" |
| 86 |
mpm.get_pids.sort.each do |pid,port|
|
|
| 87 |
puts "thin_#{port}.label thin_#{port}"
|
|
| 88 |
puts "thin_#{port}.info Process memory"
|
|
| 89 |
puts "thin_#{port}.type GAUGE"
|
|
| 90 |
puts "thin_#{port}.min 0"
|
|
| 83 |
mpm.get_pids.sort.each do |pid| |
|
| 84 |
puts "thin_#{pid}.label thin_#{pid}"
|
|
| 85 |
puts "thin_#{pid}.info Process memory"
|
|
| 86 |
puts "thin_#{pid}.type GAUGE"
|
|
| 87 |
puts "thin_#{pid}.min 0"
|
|
| 91 | 88 |
end |
| 92 | 89 |
when "autoconf" |
| 93 | 90 |
if mpm.autoconf |
Formats disponibles : Unified diff