Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of modified multimemory plugin
- Loading branch information
Dominic Scheirlinck
committed
Jun 21, 2009
0 parents
commit 5bdeb95
Showing
1 changed file
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
!/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.names apache2 mysqld php-cgi | ||
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.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: dominic@dubdot.com | ||
=head1 LICENSE | ||
GPLv2 | ||
=cut | ||
|
||
. $MUNIN_LIBDIR/plugins/plugin.sh | ||
|
||
if [ "$1" = "autoconf" ]; then | ||
echo yes | ||
exit 0 | ||
fi | ||
|
||
if [ -z "$names" ]; 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) | ||
eval REGEX='"${regex_'$name'-\<'$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 " | ||
|
||
ps auxww | grep $name | grep -v grep | sed -re 's/[ ]{1,}/ /g' | /usr/bin/cut -d ' ' -f 6 | /usr/bin/awk '{ total = total + $1 } END { print total }' | ||
done |