Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (43 sloc) 1.37 KB
#!/bin/sh
# -*- sh -*-
: <<=cut
=head1 NAME
phpfpm_average - Munin plugin to monitor the average process size of PHP-FPM on the machine.
=head1 CONFIGURATION
You might need to specify connection parameters in the plugin
configuration to override the defaults. These are the defaults:
[phpfpm_*]
env.phpbin php-fpm
env.phppool www
=head1 PARAMETERS:
config (required)
autoconf (optional - used by munin-config)
=over
=head1 LICENSE
Copyright TJ Stein 2010 http://constantshift.com
=head1 MAGICK MARKERS
#%# family=manual
#%# capabilities=autoconf
=cut
PHP_BIN=${phpbin-"php-fpm"}
PHP_POOL=${phppool-"www"}
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title PHP-FPM Average Process Size'
echo 'graph_args --base 1024 -l 0 '
echo 'graph_vlabel PHP-FPM Average Process Size'
echo 'graph_category PHP'
echo 'graph_info This graph shows the average process size for PHP-FPM'
echo 'php_average.label PHP-FPM Average Proccess Size'
echo 'php_average.draw LINE2'
echo 'php_average.info The average process size for PHP-FPM'
exit 0
fi
echo -n "php_average.value "
tmpfile=/dev/shm/$$
ps awwwux | grep "${PHP_BIN}: pool $PHP_POOL" | grep -v grep | grep -v master > $tmpfile
test -s $tmpfile && awk '{total_mem = $6 * 1024 + total_mem; total_proc++} END{printf("%d\n", total_mem / total_proc)}' $tmpfile || echo N
rm -f $tmpfile