root / plugins / php / php-cgi @ e15ed8cb
Historique | Voir | Annoter | Télécharger (1,52 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
# -*- sh -*- |
| 3 |
# |
| 4 |
# Plugin to monitor the number of PHP processes on the machine. |
| 5 |
# |
| 6 |
# Copyright Khalid Baheyeldin 2009 http://2bits.com |
| 7 |
# |
| 8 |
# Parameters: |
| 9 |
# |
| 10 |
# config (required) |
| 11 |
# autoconf (optional - used by munin-config) |
| 12 |
# |
| 13 |
# Magick markers (optional - used by munin-config and som installation |
| 14 |
# scripts): |
| 15 |
#%# family=manual |
| 16 |
#%# capabilities=autoconf |
| 17 |
|
| 18 |
if [ "$1" = "autoconf" ]; then |
| 19 |
echo yes |
| 20 |
exit 0 |
| 21 |
fi |
| 22 |
|
| 23 |
if [ "$1" = "config" ]; then |
| 24 |
echo "graph_title PHP CGI Memory"; |
| 25 |
echo "graph_vlabel PHP CGI Memory usage in GB"; |
| 26 |
echo "graph_category apache"; |
| 27 |
echo "graph_args -l 0"; |
| 28 |
echo "php_cgi_ram.label PHP CGI Used RAM"; |
| 29 |
echo "php_cgi_ram.draw LINE2"; |
| 30 |
echo "php_cgi_processes.info Number of PHP CGI processes"; |
| 31 |
echo "php_cgi_processes.label processes"; |
| 32 |
exit 0 |
| 33 |
fi |
| 34 |
|
| 35 |
CMD_GREP=`which grep` |
| 36 |
if [ ! -e ${CMD_GREP} ]; then
|
| 37 |
echo "Command grep not found!" |
| 38 |
exit 1 |
| 39 |
fi |
| 40 |
CMD_SED=`which sed` |
| 41 |
if [ ! -e ${CMD_SED} ]; then
|
| 42 |
echo "Command sed not found!" |
| 43 |
exit 1 |
| 44 |
fi |
| 45 |
CMD_WC=`which wc` |
| 46 |
if [ ! -e ${CMD_WC} ]; then
|
| 47 |
echo "Command wc not found!" |
| 48 |
exit 1 |
| 49 |
fi |
| 50 |
CMD_AWK=`which awk` |
| 51 |
if [ ! -e ${CMD_AWK} ]; then
|
| 52 |
echo "Command awk not found!" |
| 53 |
exit 1 |
| 54 |
fi |
| 55 |
CMD_BC=`which bc` |
| 56 |
if [ ! -e ${CMD_BC} ]; then
|
| 57 |
echo "Command bc not found!" |
| 58 |
exit 1 |
| 59 |
fi |
| 60 |
|
| 61 |
echo -n "php_cgi_processes.value " |
| 62 |
ps ax | grep -i php-cgi | grep -v grep | wc -l | sed 's/\t +//' | sed 's/ *//' |
| 63 |
|
| 64 |
MEMORY=0 |
| 65 |
for mem in `ps avx | grep -i php-cgi | grep -v grep | grep "Ss" | awk '{ print $7 }'`; do
|
| 66 |
MEMORY=$(($MEMORY + $mem)) |
| 67 |
done |
| 68 |
echo -n "php_cgi_ram.value " |
| 69 |
echo "scale=4;${MEMORY}/1024/1024" | bc
|
