From 835f964ee537ffce44b7a52ea74f46c4d9da37d5 Mon Sep 17 00:00:00 2001 From: "jimmyo, G. Stewart" Date: Thu, 17 Jul 2008 12:52:30 +0200 Subject: [PATCH] Initial version --- plugins/other/multips | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 plugins/other/multips diff --git a/plugins/other/multips b/plugins/other/multips new file mode 100755 index 00000000..712135f0 --- /dev/null +++ b/plugins/other/multips @@ -0,0 +1,61 @@ +#!/bin/bash +# +# Script to monitor number of processes. Programs are configured +# in /etc/munin/plugin-conf.d/munin-node +# +# Parameters: +# +# config (required) +# autoconf (optional - used by lrrd-config) +# +# Configuration example +# +# [multips] +# env.multipsnames pop3d imapd sslwrap +# env.regex_imapd ^[0-9]* imapd: +# env.regex_pop3d ^[0-9]* pop3d: +# +# $Log$ +# Revision 1.1 2004/01/29 19:42:45 jimmyo +# Added a new plugin generic/multips to count several procs in one graph. (SF#885579) +# +# +# Magic markers (optional): +#%# family=manual +#%# capabilities=autoconf + +if [ "$1" = "autoconf" ]; then + if [ -z "$multipsnames" ]; then + echo "Configuration required $multipsnames" + else + echo yes + fi + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo graph_title Number of selected processes + echo 'graph_category processes' + echo 'graph_args --base 1000 --vertical-label processes -l 0' + for name in $multipsnames; do + echo "$name.label $name" + echo "$name.draw LINE2" + done + exit 0 +fi + +for name in $multipsnames; do + printf "$name.value " + + eval REGEX='"${regex_'$name'-\<'$name'\>}"' + PGREP=`which pgrep` + if [ -n "$PGREP" ]; then + $PGREP -f -l "$name" | grep "$REGEX" | wc -l + elif [ -x /usr/ucb/ps ]; then + # Solaris without pgrep. How old is that? + /usr/ucb/ps auxwww | grep "$REGEX" | grep -v grep | wc -l + else + ps auxwww | grep "$REGEX" | grep -v grep | wc -l + fi +done