root / plugins / php / php-cgi @ f25c788c
Historique | Voir | Annoter | Télécharger (1,64 ko)
| 1 | f6fb7233 | Khalid Baheyeldin | #!/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 | f25c788c | Jens Jahnke | echo "graph_title PHP CGI Memory"; |
| 25 | echo "graph_vlabel PHP CGI Memory usage in GB"; |
||
| 26 | 123d91cf | Jens Jahnke | 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 | f6fb7233 | Khalid Baheyeldin | exit 0 |
| 33 | fi |
||
| 34 | |||
| 35 | 361a5316 | Jens Jahnke | CMD_GREP=`which grep` |
| 36 | if [ ! -e ${CMD_GREP} ]; then
|
||
| 37 | echo "Command grep (${CMD_GREP}) not found!"
|
||
| 38 | exit 1 |
||
| 39 | fi |
||
| 40 | CMD_SED=`which sed` |
||
| 41 | if [ ! -e ${CMD_SED} ]; then
|
||
| 42 | echo "Command sed (${CMD_SED}) not found!"
|
||
| 43 | exit 1 |
||
| 44 | fi |
||
| 45 | CMD_WC=`which wc` |
||
| 46 | if [ ! -e ${CMD_WC} ]; then
|
||
| 47 | echo "Command wc (${CMD_WC}) not found!"
|
||
| 48 | exit 1 |
||
| 49 | fi |
||
| 50 | 123d91cf | Jens Jahnke | CMD_AWK=`which awk` |
| 51 | if [ ! -e ${CMD_AWK} ]; then
|
||
| 52 | echo "Command awk (${CMD_AWK}) not found!"
|
||
| 53 | exit 1 |
||
| 54 | fi |
||
| 55 | CMD_BC=`which bc` |
||
| 56 | if [ ! -e ${CMD_BC} ]; then
|
||
| 57 | echo "Command bc (${CMD_BC}) not found!"
|
||
| 58 | exit 1 |
||
| 59 | fi |
||
| 60 | |||
| 61 | echo -n "php_cgi_processes.value " |
||
| 62 | ps ax | ${CMD_GREP} -i php-cgi | ${CMD_GREP} -v grep | ${CMD_WC} -l | ${CMD_SED} 's/\t +//' | ${CMD_SED} 's/ *//'
|
||
| 63 | 361a5316 | Jens Jahnke | |
| 64 | 123d91cf | Jens Jahnke | MEMORY=0 |
| 65 | for mem in `ps avx | ${CMD_GREP} -i php-cgi | ${CMD_GREP} -v grep | ${CMD_GREP} "Ss" | ${CMD_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 |
