Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-checks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Commits
366d5ae2
Commit
366d5ae2
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
add check check_php-fpm-status
parent
fd2ae3af
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_php-fpm-status
+140
-0
140 additions, 0 deletions
check_php-fpm-status
with
140 additions
and
0 deletions
check_php-fpm-status
0 → 100755
+
140
−
0
View file @
366d5ae2
#!/bin/bash
# ======================================================================
#
# NAGIOS CLIENT CHECK :: php-fpm requests
#
# ----------------------------------------------------------------------
# script checks output of fpm "/status" and counts scoreboard chars
# ----------------------------------------------------------------------
# 2021-09-22 v0.1 <axel.hahn@iml.unibe.ch> initial version
# ======================================================================
.
`
dirname
$0
`
/inc_pluginfunctions
tmpfile
=
/tmp/check_fpm_processes_1
defaulturl
=
localhost/status
# ----------------------------------------------------------------------
# functions
# ----------------------------------------------------------------------
# get a value from fpm status
#
# example output:
# pool: www
# process manager: dynamic
# start time: 21/Sep/2021:16:01:12 +0200
# start since: 65914
# accepted conn: 34
# listen queue: 0
# max listen queue: 0
# listen queue len: 0
# idle processes: 6
# active processes: 3
# total processes: 9
# max active processes: 6
# max children reached: 0
# slow requests: 0
#
# param string variable (part before ":")
function
_getvalue
(){
grep
"^
$1
:"
$tmpfile
|
cut
-d
":"
-f
2 |
awk
'{ print $1 }'
}
# ----------------------------------------------------------------------
# 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
"
$@
"
`
url
=
$(
ph.getValueWithParam
$defaulturl
u
"
$@
"
)
# --- get /server-status page
wget
--no-check-certificate
-O
$tmpfile
$url
2>/dev/null
if
[
$?
-ne
0
]
;
then
rm
-f
$tmpfile
ph.abort
"UNKNOWN: request to url
$url
failed.
`
wget
--no-check-certificate
-O
-
-S
$url
`
"
fi
# ----------------------------------------------------------------------
# get values from status output
# ----------------------------------------------------------------------
# --- handled requests per sec
typeset
-i
iConn
=
$(
_getvalue
"accepted conn"
)
typeset
-i
iSpeed
=
$(
ph.perfdeltaspeed
"fpm-accepted"
$iConn
)
# --- count slots
typeset
-i
iActive
=
$(
_getvalue
"active processes"
)
typeset
-i
iMaxActive
=
$(
_getvalue
"max active processes"
)
typeset
-i
iIdle
=
$(
_getvalue
"idle processes"
)
# --- experimental: generate warning / error
typeset
-i
iQueue
=
$(
_getvalue
"listen queue len"
)
typeset
-i
iMaxQueue
=
$(
_getvalue
"max listen queue"
)
typeset
-i
iSlow
=
$(
_getvalue
"slow requests"
)
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
ph.setStatus warning
fi
if
[
$iMaxChilds
-gt
0
]
;
then
ph.setStatus critical
fi
# --- output
ph.status
"PHP-FPM: active:
$iActive
(max:
$iMaxActive
) .. wait:
$iIdle
.. queue:
$iQueue
(max:
$iMaxQueue
) .. speed:
$iSpeed
req per sec"
if
[
$iQueue
-gt
0
]
;
then
echo
"WARNING:
$iQueue
queued requests were found"
fi
if
[
$iSlow
-gt
0
]
;
then
echo
"WARNING:
$iSlow
slow requests were found"
fi
if
[
$iMaxChilds
-gt
0
]
;
then
echo
"CRITICAL: max. children was reached
$iMaxChilds
"
fi
echo
cat
$tmpfile
echo
# --- add performnce data
ph.perfadd
"php-fpm-active"
"
${
iActive
}
"
""
""
0 0
ph.perfadd
"php-fpm-maxactive"
"
${
iMaxActive
}
"
""
""
0 0
ph.perfadd
"php-fpm-idle"
"
${
iIdle
}
"
""
""
0 0
ph.perfadd
"php-fpm-queue"
"
${
iQueue
}
"
""
""
0 0
ph.perfadd
"php-fpm-maxqueue"
"
${
iMaxQueue
}
"
""
""
0 0
ph.perfadd
"php-fpm-slow"
"
${
iSlow
}
"
""
""
0 0
ph.perfadd
"php-fpm-speed"
"
${
iSpeed
}
"
""
""
0 0
rm
-f
$tmpfile
ph.exit
# ----------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment