mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Plugin-Gallery: Get better 2nd level headings
Review of category processes, system, snmp
This commit is contained in:
parent
4b400a7320
commit
e777037d06
27 changed files with 15 additions and 15 deletions
70
plugins/memory/memory_by_process
Executable file
70
plugins/memory/memory_by_process
Executable file
|
@ -0,0 +1,70 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2006 Holger Levsen
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; version 2 dated June,
|
||||
# 1991.
|
||||
#
|
||||
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title VM by Process"
|
||||
echo 'graph_args --base 1024k'
|
||||
echo 'graph_vlabel VM size'
|
||||
echo 'graph_category processes'
|
||||
echo "graph_info Shows contribution of each process to VM size"
|
||||
|
||||
ps auxww | perl -e '
|
||||
$junk = <>;
|
||||
while (<>)
|
||||
{
|
||||
@a = split;
|
||||
$proc = $a[10];
|
||||
$label = $proc;
|
||||
$proc =~ s/ .*//;
|
||||
if($proc =~ /^\[/) { $proc =~ s|/.*||; } else { $proc =~ s|.*/||; }
|
||||
$proc =~ s/:.*//;
|
||||
$proc =~ tr/[]//d;
|
||||
$proc =~ tr/A-Za-z0-9/_/c;
|
||||
$vsz = $a[4];
|
||||
$total{$proc} += $vsz;
|
||||
$labels{$proc} = $label;
|
||||
}
|
||||
my $stack = 0;
|
||||
sub draw() { return $stack++ ? "STACK" : "AREA" }
|
||||
print map
|
||||
{
|
||||
"$_.label " . $labels{$_} . "\n" .
|
||||
"$_.min 0\n" .
|
||||
"$_.draw " . draw() . "\n" .
|
||||
"$_.cdef $_,1024,*\n"
|
||||
}
|
||||
sort keys %total;
|
||||
'
|
||||
exit 0
|
||||
else
|
||||
ps auxww | perl -e '
|
||||
$junk = <>;
|
||||
while (<>)
|
||||
{
|
||||
@a = split;
|
||||
$proc = $a[10];
|
||||
if($proc =~ /^\[/) { $proc =~ s|/.*||; } else { $proc =~ s|.*/||; }
|
||||
$proc =~ s/:.*//;
|
||||
$proc =~ tr/[]//d;
|
||||
$proc =~ tr/A-Za-z0-9/_/c;
|
||||
$vsz = $a[4];
|
||||
$total{$proc} += $vsz;
|
||||
}
|
||||
print map {"$_.value $total{$_}\n"} sort keys %total'
|
||||
fi
|
102
plugins/memory/multimemory
Executable file
102
plugins/memory/multimemory
Executable file
|
@ -0,0 +1,102 @@
|
|||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
|
||||
: <<=cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
multimemory - Munin plugin to monitor memory usage of processes. Which processes
|
||||
are configured in client-conf.d
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Any system with a compatible ps command.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
There is no default configuration. This is an example:
|
||||
|
||||
[multimemory]
|
||||
env.os freebsd
|
||||
env.names apache2 mysqld php-cgi
|
||||
|
||||
Set env.os to freebsd if you are running this script on a machine which doesnt have
|
||||
GNU sed installed (FreeBSD / OpenBSD / Solaris ...), else set it to linux.
|
||||
|
||||
The names are used to grep with directly, after cleaning. So, this plugin
|
||||
only supports very basic pattern matching. To fix: see multips
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
This plugin adds up the RSS of all processes matching the
|
||||
regex given as the process name, as reported by ps.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=manual
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=head1 VERSION
|
||||
0.3 light improvement in FreeBSD part of ps parsing
|
||||
0.2 second release, it should now work on machines without GNU sed
|
||||
0.1 first release, based on:
|
||||
multimemory.in 1590 2008-04-17 18:21:31Z matthias
|
||||
As distributed in Debian.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
None known
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Originally: matthias?
|
||||
Modified by: github.com/dominics github.com/yhager
|
||||
Thanks to: wix
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=cut
|
||||
|
||||
if [ -z "$MUNIN_LIBDIR" ]; then
|
||||
MUNIN_LIBDIR="`dirname $(dirname "$0")`"
|
||||
fi
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$names" -o -z "$os" ]; then
|
||||
echo "Configuration required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo graph_title Total memory usage
|
||||
echo 'graph_category processes'
|
||||
echo 'graph_args --base 1024 --vertical-label memory -l 0'
|
||||
for name in $names; do
|
||||
fieldname=$(clean_fieldname $name)
|
||||
REGEX='\<'"$name"'\>'
|
||||
|
||||
echo "$fieldname.label $name"
|
||||
echo "$fieldname.draw LINE2"
|
||||
echo "$fieldname.info Processes matching this regular expression: /$REGEX/"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for name in $names; do
|
||||
fieldname=$(clean_fieldname $name)
|
||||
printf "$fieldname.value "
|
||||
|
||||
if [ "$os" = "freebsd" ]; then
|
||||
ps awxo rss,command | grep -w $name | grep -v grep | /usr/bin/awk '{ total += $1 } END { print total * 1024 }'
|
||||
else
|
||||
ps auxww | grep -w $name | grep -v grep | sed -re 's/[ ]{1,}/ /g' | /usr/bin/cut -d ' ' -f 6 | /usr/bin/awk '{ total = total + $1 } END { print total * 1024 }'
|
||||
fi
|
||||
done
|
40
plugins/memory/proc_mem
Executable file
40
plugins/memory/proc_mem
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# (c) 2010, Rodrigo Sieiro <rsieiro@gmail.com>
|
||||
# Based on the 'du_multidirs' plugin, written by Christian Kujau <lists@nerdbynature.de>
|
||||
#
|
||||
# Configure it by using the processes env var, i.e.:
|
||||
#
|
||||
# [proc_mem]
|
||||
# env.processes munin-node apache2
|
||||
#
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
processes=${processes:="munin-node"}
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Memory usage by process'
|
||||
echo 'graph_args --base 1024 -l 0'
|
||||
echo 'graph_vlabel Bytes'
|
||||
echo 'graph_category processes'
|
||||
echo 'graph_info This graph shows the memory usage of several processes'
|
||||
|
||||
for proc in $processes; do
|
||||
echo "$proc.label $proc"
|
||||
done
|
||||
|
||||
# echo "$u".warning 0
|
||||
# echo "$u".critical 0
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for proc in $processes; do
|
||||
echo "$proc.value " `ps u -C $proc | awk 'BEGIN { sum = 0 } NR > 1 { sum += $6 }; END { print sum * 1024 }'`
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue