/usr/share/munin/plugins/ps_ is in munin-node 1.4.6-3ubuntu3.4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | #!/bin/sh
# -*- sh -*-
: << =cut
=head1 NAME
ps_ - Wildcard plugin to monitor number of processes
=head1 CONFIGURATION
This is a wildcard plugin. The wildcard prefix link name should be the process
name to monitor.
This plugin uses the following configuration variables:
[ps_*]
env.regex - Regular expression used to filter output from pgrep / ps.
Whatever matches this regular expression is included in the count.
=head2 DEFAULT CONFIGURATION
The default configuration is to set "env.regex" to the link name prefix.
=head2 EXAMPLE WILDCARD USAGE
C<ln -s /usr/share/munin/node/plugins-auto/ps_ /etc/munin/node.d/ps_exim>
...will monitor number of exim-processes.
=head1 AUTHOR
Unknown author
=head1 LICENSE
Unknown license
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf suggest
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
myname=`basename $0 | sed 's/^ps_//g'`
name="${name-\<$myname\>}"
REGEX="${regex-\<$name\>}"
if [ "$1" = "autoconf" ]; then
# Makes little sense to autoconf if you can't suggest
echo no
exit 0
fi
if [ "$1" = "suggest" ]; then
exit 0
fi
if [ "$1" = "config" ]; then
echo graph_title Number of $myname processes
echo 'graph_args --base 1000 --vertical-label processes -l 0'
echo 'graph_category processes'
echo "count.label $myname"
print_warning count
print_critical count
exit 0
fi
printf "count.value "
PGREP=/usr/bin/pgrep
if [ -x "$PGREP" ]; then
$PGREP -f -l "$name" | grep "$REGEX" | grep -v grep | 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
|