2010-06-02 20:59:43 +02:00
|
|
|
#!/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
|
2012-08-24 17:24:40 +02:00
|
|
|
echo "graph_title PHP CGI Memory";
|
|
|
|
echo "graph_vlabel PHP CGI Memory usage in GB";
|
2017-02-21 18:24:41 +01:00
|
|
|
echo "graph_category processes";
|
2012-08-24 10:29:55 +02:00
|
|
|
echo "graph_args -l 0";
|
|
|
|
echo "php_cgi_ram.label PHP CGI Used RAM";
|
|
|
|
echo "php_cgi_ram.draw LINE2";
|
|
|
|
echo "php_cgi_processes.info Number of PHP CGI processes";
|
|
|
|
echo "php_cgi_processes.label processes";
|
2010-06-02 20:59:43 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2012-08-24 09:44:52 +02:00
|
|
|
CMD_GREP=`which grep`
|
|
|
|
if [ ! -e ${CMD_GREP} ]; then
|
2012-08-24 17:33:41 +02:00
|
|
|
echo "Command grep not found!"
|
2012-08-24 09:44:52 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
CMD_SED=`which sed`
|
|
|
|
if [ ! -e ${CMD_SED} ]; then
|
2012-08-24 17:33:41 +02:00
|
|
|
echo "Command sed not found!"
|
2012-08-24 09:44:52 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
CMD_WC=`which wc`
|
|
|
|
if [ ! -e ${CMD_WC} ]; then
|
2012-08-24 17:33:41 +02:00
|
|
|
echo "Command wc not found!"
|
2012-08-24 09:44:52 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2012-08-24 10:29:55 +02:00
|
|
|
CMD_AWK=`which awk`
|
|
|
|
if [ ! -e ${CMD_AWK} ]; then
|
2012-08-24 17:33:41 +02:00
|
|
|
echo "Command awk not found!"
|
2012-08-24 10:29:55 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
CMD_BC=`which bc`
|
|
|
|
if [ ! -e ${CMD_BC} ]; then
|
2012-08-24 17:33:41 +02:00
|
|
|
echo "Command bc not found!"
|
2012-08-24 10:29:55 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -n "php_cgi_processes.value "
|
2012-08-24 17:33:41 +02:00
|
|
|
ps ax | grep -i php-cgi | grep -v grep | wc -l | sed 's/\t +//' | sed 's/ *//'
|
2012-08-24 09:44:52 +02:00
|
|
|
|
2012-08-24 10:29:55 +02:00
|
|
|
MEMORY=0
|
2012-08-24 17:33:41 +02:00
|
|
|
for mem in `ps avx | grep -i php-cgi | grep -v grep | grep "Ss" | awk '{ print $7 }'`; do
|
2012-08-24 10:29:55 +02:00
|
|
|
MEMORY=$(($MEMORY + $mem))
|
|
|
|
done
|
|
|
|
echo -n "php_cgi_ram.value "
|
|
|
|
echo "scale=4;${MEMORY}/1024/1024" | bc
|