mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
361a5316c7
The tools grep, sed and wc may have a different path. Therefore they are now evaluated via "which". If a command is not found the script exits with an error message and the exit code 1.
53 lines
1.3 KiB
Bash
Executable File
53 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# -*- sh -*-
|
|
#
|
|
# Plugin to monitor the number of PHP processes on the machine.
|
|
#
|
|
# Copyright Khalid Baheyeldin 2009 http://2bits.com
|
|
#
|
|
# Parameters:
|
|
#
|
|
# config (required)
|
|
# autoconf (optional - used by munin-config)
|
|
#
|
|
# Magick markers (optional - used by munin-config and som installation
|
|
# scripts):
|
|
#%# family=manual
|
|
#%# capabilities=autoconf
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
echo yes
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$1" = "config" ]; then
|
|
echo 'graph_title Number of php-cgi processes'
|
|
echo 'graph_args --base 1000 -l 0 '
|
|
echo 'graph_vlabel number of php-cgi processes'
|
|
echo 'graph_category apache'
|
|
echo 'graph_info This graph shows the number of php-cgi processes in the system.'
|
|
echo 'php_processes.label php-cgi'
|
|
echo 'php_processes.draw LINE2'
|
|
echo 'php_processes.info The current number of php-cgi processes.'
|
|
exit 0
|
|
fi
|
|
|
|
CMD_GREP=`which grep`
|
|
if [ ! -e ${CMD_GREP} ]; then
|
|
echo "Command grep (${CMD_GREP}) not found!"
|
|
exit 1
|
|
fi
|
|
CMD_SED=`which sed`
|
|
if [ ! -e ${CMD_SED} ]; then
|
|
echo "Command sed (${CMD_SED}) not found!"
|
|
exit 1
|
|
fi
|
|
CMD_WC=`which wc`
|
|
if [ ! -e ${CMD_WC} ]; then
|
|
echo "Command wc (${CMD_WC}) not found!"
|
|
exit 1
|
|
fi
|
|
|
|
echo -n "php_processes.value "
|
|
/bin/ps ax | ${CMD_GREP} -i php-cgi | ${CMD_GREP} -v grep | ${CMD_WC} -l | ${CMD_SED} 's/\t +//' | ${CMD_SED} 's/ *//'
|