Révision b0b39b01
Ruby plugins: apply style changes as suggested by "rubocop --fix-layout"
| plugins/http/mongrel_process_memory | ||
|---|---|---|
| 1 | 1 |
#!/usr/bin/env ruby |
| 2 |
# |
|
| 3 |
# mongrel_process_memory - A munin plugin to monitor memory size of |
|
| 4 |
# each individual mongrel process |
|
| 5 |
# Copyright (C) 2007 Ben VandenBos and Avvo, Inc. |
|
| 6 |
# |
|
| 7 |
# This program is free software; you can redistribute it and/or modify |
|
| 8 |
# it under the terms of the GNU General Public License version 2 |
|
| 9 |
# as published by the Free Software Foundation. |
|
| 10 |
# |
|
| 11 |
# This program is distributed in the hope that it will be useful, |
|
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 14 |
# GNU General Public License for more details. |
|
| 15 |
# |
|
| 16 |
# You should have received a copy of the GNU General Public License along |
|
| 17 |
# with this program; if not, write to the Free Software Foundation, Inc., |
|
| 18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 19 |
# |
|
| 20 |
# Author: Ben VandenBos |
|
| 21 |
# Contributors: Adam Jacob (<adam@hjksolutions.com>) |
|
| 22 |
# Ryan Woodrum |
|
| 23 |
# |
|
| 2 |
|
|
| 3 |
=begin |
|
| 4 |
|
|
| 5 |
mongrel_process_memory - A munin plugin to monitor memory size of |
|
| 6 |
each individual mongrel process |
|
| 7 |
Copyright (C) 2007 Ben VandenBos and Avvo, Inc. |
|
| 8 |
|
|
| 9 |
This program is free software; you can redistribute it and/or modify |
|
| 10 |
it under the terms of the GNU General Public License version 2 |
|
| 11 |
as published by the Free Software Foundation. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License along |
|
| 19 |
with this program; if not, write to the Free Software Foundation, Inc., |
|
| 20 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 21 |
|
|
| 22 |
Author: Ben VandenBos |
|
| 23 |
Contributors: Adam Jacob (<adam@hjksolutions.com>) |
|
| 24 |
Ryan Woodrum |
|
| 25 |
|
|
| 24 | 26 |
#%# family=auto |
| 25 | 27 |
#%# capabilities=autoconf |
| 26 | 28 |
|
| 29 |
=end |
|
| 30 |
|
|
| 31 |
|
|
| 27 | 32 |
module Munin |
| 28 | 33 |
class MongrelProcessMemory |
| 29 |
|
|
| 30 | 34 |
def run |
| 31 | 35 |
h = get_pids() |
| 32 | 36 |
ps_output = "" |
| 33 |
#I have no doubt that this is a terrible way of doing this. |
|
| 37 |
# I have no doubt that this is a terrible way of doing this.
|
|
| 34 | 38 |
h.each do |k, v| |
| 35 | 39 |
ps_output = ps_output + `ps --no-heading l #{k}`
|
| 36 | 40 |
end |
| ... | ... | |
| 59 | 63 |
pids = `pgrep mongrel_rails` |
| 60 | 64 |
pids.each { |p|
|
| 61 | 65 |
l = `ps #{p}`
|
| 62 |
l =~ /-p (\d+)/
|
|
| 63 |
h[p] = $1
|
|
| 66 |
l =~ /-p (\d+)/
|
|
| 67 |
h[p] = $1
|
|
| 64 | 68 |
} |
| 65 | 69 |
h |
| 66 | 70 |
end |
| ... | ... | |
| 68 | 72 |
def autoconf |
| 69 | 73 |
pids.length > 0 |
| 70 | 74 |
end |
| 71 |
|
|
| 72 | 75 |
end |
| 73 | 76 |
end |
| 74 | 77 |
|
Formats disponibles : Unified diff