-
Notifications
You must be signed in to change notification settings - Fork 45
/
phpfpm_average
62 lines (43 loc) · 1.37 KB
/
phpfpm_average
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/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