2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Don't use hard coded paths to the used command line tools.

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.
This commit is contained in:
Jens Jahnke 2012-08-24 09:44:52 +02:00
parent 12045d8019
commit 361a5316c7

View File

@ -32,5 +32,21 @@ 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 | /usr/bin/grep -i php-cgi | /usr/bin/grep -v grep | /usr/bin/wc -l | /usr/bin/sed 's/\t +//' | /usr/bin/sed 's/ *//'
/bin/ps ax | ${CMD_GREP} -i php-cgi | ${CMD_GREP} -v grep | ${CMD_WC} -l | ${CMD_SED} 's/\t +//' | ${CMD_SED} 's/ *//'