Révision 91cffec4
Added php_fpm_status plugin
This is a replacement for the php5-fpm_status plugin.
Changes:
- Supports multiple pools using environment variables to specify urls
- Supports wget and curl
- Added GPLv3 License
| plugins/php/php5-fpm_status | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
# |
|
| 3 |
# Plugin to monitor php5-fpm process manager, php5-fpm 5.3.3 is required |
|
| 4 |
# 20100726 21:15:39 radar AT aol DOT pl |
|
| 5 |
# modified by Daniel Caillibaud on 20110926 |
|
| 6 |
# |
|
| 7 |
# /etc/php5/fpm/php5-fpm.conf: |
|
| 8 |
# |
|
| 9 |
# pm.status_path = /fpm-status |
|
| 10 |
# |
|
| 11 |
# |
|
| 12 |
# Magic markers (optional - only used by munin-config and some installation scripts): |
|
| 13 |
#%# family=contrib |
|
| 14 |
|
|
| 15 |
vhost=${0#/etc/munin/plugins/php5-fpm_status_}
|
|
| 16 |
url="http://$vhost/fpm-status" |
|
| 17 |
statusfile="/tmp/fpm-status_$vhost.txt" |
|
| 18 |
|
|
| 19 |
wget $url -O $statusfile 2>/dev/null |
|
| 20 |
|
|
| 21 |
if [ "$1" = "config" ]; then |
|
| 22 |
pool=$(awk '/pool/{print $2}' $statusfile)
|
|
| 23 |
echo "graph_title php5-fpm status $pool" |
|
| 24 |
echo "graph_args --base 1000 -l 0" |
|
| 25 |
echo "graph_vlabel Processes" |
|
| 26 |
echo "graph_scale yes" |
|
| 27 |
echo "graph_category processes" |
|
| 28 |
echo "graph_info This graph shows the php5-fpm process manager status from pool: $pool" |
|
| 29 |
echo "active.label Active processes" |
|
| 30 |
echo "active.type GAUGE" |
|
| 31 |
echo "active.draw AREA" |
|
| 32 |
echo "active.info The number of active processes" |
|
| 33 |
echo "idle.label Idle processes" |
|
| 34 |
echo "idle.type GAUGE" |
|
| 35 |
echo "idle.draw STACK" |
|
| 36 |
echo "idle.info The number of idle processes" |
|
| 37 |
echo "total.label Total processes" |
|
| 38 |
echo "total.type GAUGE" |
|
| 39 |
echo "total.draw LINE2" |
|
| 40 |
echo "total.info The number of idle + active processes" |
|
| 41 |
exit 0 |
|
| 42 |
else |
|
| 43 |
awk ' |
|
| 44 |
/^idle/ {print "idle.value " $3}
|
|
| 45 |
/^active/{print "active.value " $3}
|
|
| 46 |
/^total/ {print "total.value " $3}
|
|
| 47 |
' < $statusfile |
|
| 48 |
fi |
|
| 49 |
|
|
| 50 |
rm -f $statusfile |
|
| 51 |
|
|
| plugins/php/php_fpm_status | ||
|---|---|---|
| 1 |
#!/bin/sh |
|
| 2 |
|
|
| 3 |
: <<=cut |
|
| 4 |
|
|
| 5 |
=head CONFIGURATION |
|
| 6 |
|
|
| 7 |
Plugin to monitor php-fpm process manager, php-fpm >=5.3.3 is required |
|
| 8 |
|
|
| 9 |
INSTALLATION |
|
| 10 |
1. Install curl or wget |
|
| 11 |
2. Configure PHP to respond to status request by setting pm.status_path in your php fpm config file. |
|
| 12 |
3. Configure your websever to respond to this path, it's advisable to restrict |
|
| 13 |
this to localhost |
|
| 14 |
4. Configure munin-node with a url environment variable for the url you wish to test |
|
| 15 |
|
|
| 16 |
You can use symlinks and config files to monitor multiple pools |
|
| 17 |
ln -s /usr/share/munin/php_fpm_status /usr/share/munin/php_fpm_status_www |
|
| 18 |
ln -s /usr/share/munin/php_fpm_status /usr/share/munin/php_fpm_status_www2 |
|
| 19 |
|
|
| 20 |
[php_fpm_status_www] |
|
| 21 |
env.url http://127.0.0.1/fpm-status-www |
|
| 22 |
[php_fpm_status_www2] |
|
| 23 |
env.url http://127.0.0.1/fpm-status-www2 |
|
| 24 |
|
|
| 25 |
=head COPYRIGHT |
|
| 26 |
|
|
| 27 |
Copyright (C) 2020 Rowan Wookey <https://www.rwky.net> |
|
| 28 |
Copyright (C) 2011 Daniel Caillibaud |
|
| 29 |
Copyright (C) 2010 radar AT aol DOT pl |
|
| 30 |
|
|
| 31 |
=head LICENSE |
|
| 32 |
|
|
| 33 |
This program is free software: you can redistribute it and/or modify |
|
| 34 |
it under the terms of the GNU General Public License as published by |
|
| 35 |
the Free Software Foundation, either version 3 of the License, or |
|
| 36 |
(at your option) any later version. |
|
| 37 |
|
|
| 38 |
This program is distributed in the hope that it will be useful, |
|
| 39 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 40 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 41 |
GNU General Public License for more details. |
|
| 42 |
|
|
| 43 |
You should have received a copy of the GNU General Public License |
|
| 44 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
| 45 |
|
|
| 46 |
=head MAGIC MARKERS |
|
| 47 |
|
|
| 48 |
#%# family=auto |
|
| 49 |
#%# capabilities=autoconf |
|
| 50 |
|
|
| 51 |
=cut |
|
| 52 |
|
|
| 53 |
url=${url:-'http://127.0.0.1/fpm-status'}
|
|
| 54 |
|
|
| 55 |
if command -v wget > /dev/null 2>&1 |
|
| 56 |
then |
|
| 57 |
data=$(wget -O - -q "$url") |
|
| 58 |
elif command -v curl > /dev/null 2>&1 |
|
| 59 |
then |
|
| 60 |
data=$(curl -s "$url") |
|
| 61 |
else |
|
| 62 |
echo "wget or curl must be installed" >&2 |
|
| 63 |
exit 1 |
|
| 64 |
fi |
|
| 65 |
|
|
| 66 |
pool=$(echo "$data" | awk '/pool/{print $2}')
|
|
| 67 |
|
|
| 68 |
if [ "$1" = "autoconf" ] |
|
| 69 |
then |
|
| 70 |
if [ -n "$pool" ] |
|
| 71 |
then |
|
| 72 |
echo 'yes' |
|
| 73 |
fi |
|
| 74 |
exit 0 |
|
| 75 |
fi |
|
| 76 |
|
|
| 77 |
if [ "$1" = "config" ]; then |
|
| 78 |
echo "graph_title php-fpm status $pool" |
|
| 79 |
echo "graph_args --base 1000 -l 0" |
|
| 80 |
echo "graph_vlabel Processes" |
|
| 81 |
echo "graph_scale yes" |
|
| 82 |
echo "graph_category webserver" |
|
| 83 |
echo "graph_info This graph shows the php-fpm process manager status from pool: $pool" |
|
| 84 |
echo "active.label Active processes" |
|
| 85 |
echo "active.type GAUGE" |
|
| 86 |
echo "active.draw AREA" |
|
| 87 |
echo "active.info The number of active processes" |
|
| 88 |
echo "idle.label Idle processes" |
|
| 89 |
echo "idle.type GAUGE" |
|
| 90 |
echo "idle.draw STACK" |
|
| 91 |
echo "idle.info The number of idle processes" |
|
| 92 |
echo "total.label Total processes" |
|
| 93 |
echo "total.type GAUGE" |
|
| 94 |
echo "total.draw LINE2" |
|
| 95 |
echo "total.info The number of idle + active processes" |
|
| 96 |
exit 0 |
|
| 97 |
else |
|
| 98 |
echo "$data" | awk ' |
|
| 99 |
/^idle/ {print "idle.value " $3}
|
|
| 100 |
/^active/{print "active.value " $3}
|
|
| 101 |
/^total/ {print "total.value " $3}
|
|
| 102 |
' |
|
| 103 |
fi |
|
Formats disponibles : Unified diff