mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
123d91cf70
The memory consumption of all processes (not threads) is calculated in GB and added to the graph.
70 lines
1.6 KiB
Bash
Executable File
70 lines
1.6 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 PHP CGI [GB]";
|
|
echo "graph_vlabel PHP CGI Memory usage";
|
|
echo "graph_category apache";
|
|
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";
|
|
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
|
|
CMD_AWK=`which awk`
|
|
if [ ! -e ${CMD_AWK} ]; then
|
|
echo "Command awk (${CMD_AWK}) not found!"
|
|
exit 1
|
|
fi
|
|
CMD_BC=`which bc`
|
|
if [ ! -e ${CMD_BC} ]; then
|
|
echo "Command bc (${CMD_BC}) not found!"
|
|
exit 1
|
|
fi
|
|
|
|
echo -n "php_cgi_processes.value "
|
|
ps ax | ${CMD_GREP} -i php-cgi | ${CMD_GREP} -v grep | ${CMD_WC} -l | ${CMD_SED} 's/\t +//' | ${CMD_SED} 's/ *//'
|
|
|
|
MEMORY=0
|
|
for mem in `ps avx | ${CMD_GREP} -i php-cgi | ${CMD_GREP} -v grep | ${CMD_GREP} "Ss" | ${CMD_AWK} '{ print $7 }'`; do
|
|
MEMORY=$(($MEMORY + $mem))
|
|
done
|
|
echo -n "php_cgi_ram.value "
|
|
echo "scale=4;${MEMORY}/1024/1024" | bc
|