Révision 17f78427
Whitespace cleanup
- remove trailing whitespace
- remove empty lines at the end of files
| plugins/thin/thin_memory | ||
|---|---|---|
| 4 | 4 |
# For Linux ONLY ! |
| 5 | 5 |
# DOES NOT WORK on OSX, Solaris or BSD. |
| 6 | 6 |
# only linux, because this script relies on proc filesystem |
| 7 |
#
|
|
| 8 |
# Original author:
|
|
| 7 |
# |
|
| 8 |
# Original author: |
|
| 9 | 9 |
# Frederico de Souza Araujo - fred.the.master@gmail.com |
| 10 | 10 |
# http://www.frederico-araujo.com |
| 11 | 11 |
# |
| ... | ... | |
| 14 | 14 |
# http://www.furbism.com |
| 15 | 15 |
# |
| 16 | 16 |
# Originally based on: |
| 17 |
# thin_process_memory -
|
|
| 18 |
# A munin plugin to monitor memory size of
|
|
| 17 |
# thin_process_memory - |
|
| 18 |
# A munin plugin to monitor memory size of |
|
| 19 | 19 |
# each individual thin process |
| 20 | 20 |
# by Ben VandenBos and Avvo, Inc. |
| 21 | 21 |
# |
| 22 | 22 |
# This program is free software; you can redistribute it and/or modify |
| 23 |
# it under the terms of the GNU General Public License version 2
|
|
| 23 |
# it under the terms of the GNU General Public License version 2 |
|
| 24 | 24 |
# as published by the Free Software Foundation. |
| 25 |
#
|
|
| 25 |
# |
|
| 26 | 26 |
# This program is distributed in the hope that it will be useful, |
| 27 | 27 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 28 | 28 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 29 | 29 |
# GNU General Public License for more details. |
| 30 |
#
|
|
| 30 |
# |
|
| 31 | 31 |
# You should have received a copy of the GNU General Public License along |
| 32 | 32 |
# with this program; if not, write to the Free Software Foundation, Inc., |
| 33 | 33 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| ... | ... | |
| 38 | 38 |
|
| 39 | 39 |
module Munin |
| 40 | 40 |
class ThinProcessMemory |
| 41 |
|
|
| 41 |
|
|
| 42 | 42 |
# run main method |
| 43 | 43 |
def run |
| 44 | 44 |
instances = get_pids() |
| ... | ... | |
| 48 | 48 |
puts "thin_#{port}.value #{rss}"
|
| 49 | 49 |
end |
| 50 | 50 |
end |
| 51 |
|
|
| 51 |
|
|
| 52 | 52 |
# only get the memory for each pid |
| 53 | 53 |
def pid_rss(pid) |
| 54 | 54 |
res = `grep "VmRSS" /proc/#{pid}/status`.split[1]
|
| ... | ... | |
| 58 | 58 |
return res |
| 59 | 59 |
end |
| 60 | 60 |
end |
| 61 |
|
|
| 61 |
|
|
| 62 | 62 |
# fetch all pids that match thin |
| 63 | 63 |
def get_pids |
| 64 | 64 |
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/)
|
| ... | ... | |
| 67 | 67 |
def autoconf |
| 68 | 68 |
get_pids().length > 0 |
| 69 | 69 |
end |
| 70 |
|
|
| 70 |
|
|
| 71 | 71 |
end |
| 72 | 72 |
end |
| 73 | 73 |
|
Formats disponibles : Unified diff