Skip to content
Snippets Groups Projects
Commit 2a3833af authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update php-fpm check

parent 76c2d434
Branches
No related tags found
No related merge requests found
......@@ -42,29 +42,71 @@ function _getvalue(){
grep "^$1:" $tmpfile | cut -d ":" -f 2 | awk '{ print $1 }'
}
function showHelp(){
cat <<EOF
______________________________________________________________________
CHECK_PHP-FPM-Status
Get counters from PHP-FPM status output for active/ idle processes.
(c) Institute for Medical Education - Univerity of Bern
Licence: GNU GPL 3
______________________________________________________________________
The check fetches several counters from php-fm-status page.
It shows a short status in a single line and then the dump of the
status page.
For performance data it eachos:
php-fpm-active count of active workers
php-fpm-maxactive max active processes
php-fpm-idle count of idle workers
php-fpm-queue count of items in the queue
php-fpm-maxqueue max listen queue
php-fpm-slow slow requests
php-fpm-speed requests per second (since last execution)
SYNTAX:
`basename $0` [-u URL]
OPTIONS:
-u url to fpm status page (optional; default: $defaulturl)
-h or --help show this help.
PARAMETERS:
None.
EXAMPLE:
`basename $0` -u http://localhost/my-custom-fpm-statuspage.php
EOF
}
# ----------------------------------------------------------------------
# check help
# ----------------------------------------------------------------------
case "$1" in
"--help"|"-h")
showHelp
exit 0
;;
*)
esac
# ----------------------------------------------------------------------
# pre checks
# ----------------------------------------------------------------------
ph.require wget
# ----------------------------------------------------------------------
# check params
# ----------------------------------------------------------------------
# --- check param -h
if [ "$1" = "-h" ]; then
echo "
Check PHP FPM status
usage: $0 [-u URL]
-u url to fpm status page (optional; default: $defaulturl)
-h this help
"
exit 0
fi
# set default / override from command line params
typeset -i iWarnLimit=` ph.getValueWithParam 75 w "$@"`
typeset -i iCriticalLimit=` ph.getValueWithParam 90 c "$@"`
......@@ -100,25 +142,31 @@ typeset -i iMaxChilds=$( _getvalue "max children reached")
# damn, count of slots is in the config only - not in status output
# iUsage=$iActive*100/$iSlots
# ph.setStatusByLimit $iUsage $iWarnLimit $iCriticalLimit
if [ $iQueue -gt 0 -o $iSlow -gt 0 ]; then
if [ $iQueue -gt 0 -o $iSlow -gt 0 -o $iIdle -eq 0 ]; then
ph.setStatus warning
fi
if [ $iMaxChilds -gt 0 ]; then
ph.setStatus critical
# ph.setStatus critical
ph.setStatus warning
fi
# --- output
ph.status "PHP-FPM: active: $iActive (max: $iMaxActive) .. wait: $iIdle .. queue: $iQueue (max: $iMaxQueue) .. speed: $iSpeed req per sec"
if [ $iIdle -eq 0 ]; then
echo "WARNING: $iIdle idle workers available."
echo " Maybe there is a current peak only."
echo " Or count of allowed workers (pm.max_children) or spare servers (pm.XXX_spare_servers) is too low."
fi
if [ $iQueue -gt 0 ]; then
echo "WARNING: $iQueue queued requests were found"
echo "WARNING: $iQueue queued requests were found."
fi
if [ $iSlow -gt 0 ]; then
echo "WARNING: $iSlow slow requests were found"
echo "WARNING: $iSlow slow requests were found."
fi
if [ $iMaxChilds -gt 0 ]; then
echo "CRITICAL: max. children was reached $iMaxChilds"
echo "WARNING: max. children was reached $iMaxChilds. Max. active were $iMaxActive - maybe count of allowed workers is too low."
fi
echo
cat $tmpfile
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment