#!/bin/sh # -*- sh -*- : <<=cut =head1 NAME ps_memory - Munin plugin to monitor memory usage of processes. Which processes are configured in plugin-conf.d =head1 APPLICABLE SYSTEMS Any system with a compatible ps command. =head1 CONFIGURATION There is no default configuration. This is an example: [ps_memory] user root env.names apache2 nagios3 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 gets the real memory usage (Private + Shared) from ps_mem.py =head1 MAGIC MARKERS #%# family=manual #%# capabilities=autoconf =head1 VERSION 0.2 use ps_mem.py 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 Modified by: benjamin@coding4coffee.ch =head1 LICENSE GPLv2 =cut . $MUNIN_LIBDIR/plugins/plugin.sh if [ -z "$names" ]; then echo "Configuration required" exit 1 fi if [ "$1" = "autoconf" ]; then echo yes exit 0 fi if [ "$1" = "config" ]; then echo graph_title Process 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) echo "$fieldname.label $name" echo "$fieldname.draw LINE1" echo "$fieldname.info Processes matching: $name" done exit 0 fi for name in $names; do fieldname=$(clean_fieldname $name) printf "$fieldname.value " pids=$(pgrep -f $name | paste -d, -s) if [ -n "$pids" ]; then python /etc/munin/helper/ps_mem.py -p $pids -t else echo 0 fi done