1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Added output of memory usage to graph.

The memory consumption of all processes (not threads) is calculated
in GB and added to the graph.
This commit is contained in:
Jens Jahnke 2012-08-24 10:29:55 +02:00
parent 361a5316c7
commit 123d91cf70

View file

@ -21,14 +21,14 @@ 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.'
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
@ -47,6 +47,23 @@ 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_processes.value "
/bin/ps ax | ${CMD_GREP} -i php-cgi | ${CMD_GREP} -v grep | ${CMD_WC} -l | ${CMD_SED} 's/\t +//' | ${CMD_SED} 's/ *//'
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