1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

- have some dirs

This commit is contained in:
Steve Schnepp 2012-02-13 18:24:46 +01:00
parent 0b089ea777
commit 08346aac58
687 changed files with 0 additions and 0 deletions

98
plugins/thin/thin_memory Executable file
View file

@ -0,0 +1,98 @@
#!/usr/bin/env ruby
# thin_memory - A munin plugin for Linux to monitor memory size of each individual thin process
#
# For Linux ONLY !
# DOES NOT WORK on OSX, Solaris or BSD.
# only linux, because this script relies on proc filesystem
#
# Original author:
# Frederico de Souza Araujo - fred.the.master@gmail.com
# http://www.frederico-araujo.com
#
# Usurper:
# Adam Michel - elfurbe@furbism.com
# http://www.furbism.com
#
# Originally based on:
# thin_process_memory -
# A munin plugin to monitor memory size of
# each individual thin process
# by Ben VandenBos and Avvo, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
#%# family=auto
#%# capabilities=autoconf
module Munin
class ThinProcessMemory
# run main method
def run
pids = get_pids()
pids.sort.each do |pid|
rss = (pid_rss(pid).to_i)/1024
puts "thin_#{pid}.value #{rss}"
end
end
# only get the memory for each pid
def pid_rss(pid)
res = `grep "VmRSS" /proc/#{pid}/status`.split[1]
if res.match("cannot access")
return nil
else
return res
end
end
# fetch all pids that match thin
def get_pids
pids = `pgrep thin`.split
end
def autoconf
get_pids().length > 0
end
end
end
mpm = Munin::ThinProcessMemory.new
case ARGV[0]
when "config"
puts "graph_title Thin Memory"
puts "graph_vlabel RSS"
puts "graph_category Thin"
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 |pid|
puts "thin_#{pid}.label thin_#{pid}"
puts "thin_#{pid}.info Process memory"
puts "thin_#{pid}.type GAUGE"
puts "thin_#{pid}.min 0"
end
when "autoconf"
if mpm.autoconf
puts "yes"
exit 0
end
puts "no"
exit 1
else
mpm.run
end

105
plugins/thin/thin_threads Executable file
View file

@ -0,0 +1,105 @@
#!/usr/bin/env ruby
# thin_threads -
# A munin plugin for Linux to monitor how many threads per thin process
#
# For Linux ONLY !
# DOES NOT WORK on OSX, Solaris or BSD.
# only linux, because this script relies on proc filesystem
#
# Original author:
# Frederico de Souza Araujo - fred.the.master@gmail.com
# http://www.frederico-araujo.com
#
# Usurper:
# Adam Michel - elfurbe@furbism.com
# http://www.furbism.com
#
# Originally based on:
# thin_process_memory -
# A munin plugin to monitor memory size of
# each individual thin process
# by Ben VandenBos and Avvo, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
#%# family=auto
#%# capabilities=autoconf
module Munin
class ThinThreads
def run
pids = get_pids()
pids.sort.each do |pid|
res = (get_threads(pid).to_i)
puts "thin_#{pid}.value #{res}"
end
end
# only get threads count for each pid
# Using Proc filesystem
# ONLY LINUX! because relies on proc filesystem
# 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]
if res.match("cannot access")
return nil
else
return res
end
end
# Get pis using lsof (list open files)
# look for listening tcp applications
# that match the name thin
def get_pids
pids = `pgrep thin`.split
end
def autoconf
get_pids().length > 0
end
end
end
mpm = Munin::ThinThreads.new
case ARGV[0]
when "config"
puts "graph_title Thin Threads"
puts "graph_vlabel Threads"
puts "graph_category Thin"
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 |pid|
puts "thin_#{pid}.label thin_#{pid}"
puts "thin_#{pid}.info Threads per Thin process"
puts "thin_#{pid}.type GAUGE"
puts "thin_#{pid}.min 0"
end
when "autoconf"
if mpm.autoconf
puts "yes"
exit 0
end
puts "no"
exit 1
else
mpm.run
end

110
plugins/thin/thins_peak_memory Executable file
View file

@ -0,0 +1,110 @@
#!/usr/bin/env ruby
# thin_peak_memory -
# A munin plugin for Linux to monitor the maximum memory size
# that an each individual thin process has reached
#
# For Linux ONLY !
# DOES NOT WORK on OSX, Solaris or BSD.
# only linux, because this script relies on proc filesystem
#
# Author:
# Frederico de Souza Araujo - fred.the.master@gmail.com
# http://www.frederico-araujo.com
#
# Based on:
# thin_process_memory -
# A munin plugin to monitor memory size of
# each individual thin process
# by Ben VandenBos and Avvo, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
#%# family=auto
#%# capabilities=autoconf
module Munin
class ThinPeakMemory
def run
pids = get_pids()
port_list = Hash.new
pids.sort.each do |pid, port|
hwm = (pid_hwm(pid).to_i)/1024
puts "thin_#{port}.value #{hwm}"
end
end
# only get VmHWM count for each pid
# (Virtual Memory High Water Mark)
# Using Proc filesystem
# ONLY LINUX! because relies on proc filesystem
# TODO: make this work on OSX and Solaris,
# so the whole unix gang is happy ;)
def pid_hwm(pid)
res = `grep "VmHWM" /proc/#{pid}/status`.split[1]
if res.match("cannot access")
return nil
else
return res
end
end
# Get pis using lsof (list open files)
# look for listening tcp applications
# that match the name thin
def get_pids
pids_ports = []
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
def autoconf
get_pids().length > 0
end
end
end
mpm = Munin::ThinPeakMemory.new
case ARGV[0]
when "config"
puts "graph_title Thin Peak Memory (High Water Mark)"
puts "graph_vlabel HWM"
puts "graph_category Thin"
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 |pid,port|
puts "thin_#{port}.label thin_#{port}"
puts "thin_#{port}.info Peak Memory"
puts "thin_#{port}.type GAUGE"
puts "thin_#{port}.min 0"
end
when "autoconf"
if mpm.autoconf
puts "yes"
exit 0
end
puts "no"
exit 1
else
mpm.run
end