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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Commits
e1aa0a9c
Commit
e1aa0a9c
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update php-fpm check using full status now
parent
16bbe108
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_php-fpm-status
+56
-19
56 additions, 19 deletions
check_php-fpm-status
with
56 additions
and
19 deletions
check_php-fpm-status
+
56
−
19
View file @
e1aa0a9c
...
...
@@ -7,18 +7,32 @@
# script checks output of fpm "/status" and counts scoreboard chars
# ----------------------------------------------------------------------
# 2021-09-22 v0.1 <axel.hahn@iml.unibe.ch> initial version
# 2021-10-01 v0.2 <axel.hahn@iml.unibe.ch> fetch full status as json
# ======================================================================
.
`
dirname
$0
`
/inc_pluginfunctions
tmpfile
=
/tmp/check_fpm_processes_1
defaulturl
=
localhost/status
# ----------------------------------------------------------------------
# functions
# ----------------------------------------------------------------------
# get service data from json output
function
_getServicedata
(){
cat
$tmpfile
| jq |
grep
'^\ \ "'
|
grep
-v
"
\[
"
|
cut
-f
1
-d
","
}
function
_getWorkerStates
(){
cat
$tmpfile
| jq |
grep
'"state": '
|
cut
-f
2
-d
":"
|
cut
-f
1
-d
","
|
sort
-u
}
function
_getWorkerOfState
(){
cat
$tmpfile
| jq
-c
".processes[] | select(.state ==
\"
$1
\"
)"
}
# get a value from fpm status
#
# example output:
...
...
@@ -39,9 +53,11 @@ defaulturl=localhost/status
#
# param string variable (part before ":")
function
_getvalue
(){
grep
"^
$1
:"
$tmpfile
|
cut
-d
":"
-f
2 |
awk
'{ print $1 }'
# grep "^$1:" $tmpfile | cut -d ":" -f 2 | awk '{ print $1 }'
_getServicedata |
grep
"^
\ \ \"
$1
\"
:"
|
cut
-d
":"
-f
2 |
awk
'{ print $1 }'
}
function
showHelp
(){
cat
<<
EOF
______________________________________________________________________
...
...
@@ -100,7 +116,7 @@ esac
# ----------------------------------------------------------------------
# pre checks
# ----------------------------------------------------------------------
ph.require wget
ph.require
jq
wget
# ----------------------------------------------------------------------
...
...
@@ -113,18 +129,13 @@ 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
wget
--no-check-certificate
-O
$tmpfile
"
$url
?full&json"
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
...
...
@@ -140,6 +151,11 @@ typeset -i iSlow=$( ph.perfdeltaspeed "fpm-slow" $iSlowTotal )
typeset
-i
iMaxChilds
=
$(
_getvalue
"max children reached"
)
typeset
-i
iWorkerRunning
=
$(
_getWorkerOfState
"Running"
|
wc
-l
)
typeset
-i
iWorkerReading
=
$(
_getWorkerOfState
"Reading headers"
|
wc
-l
)
typeset
-i
iWorkerIdle
=
$(
_getWorkerOfState
"Idle"
|
wc
-l
)
# ----------------------------------------------------------------------
# set status
# ----------------------------------------------------------------------
...
...
@@ -153,20 +169,30 @@ if [ $iMaxChilds -gt 0 ]; then
# ph.setStatus critical
ph.setStatus warning
fi
if
[
$iIdle
-eq
0
]
;
then
ph.setStatus critical
if
[
$iWorkerIdle
-eq
0
]
;
then
ph.setStatus warning
fi
if
[
$iWorkerReading
-eq
0
]
;
then
ph.setStatus warning
fi
# ----------------------------------------------------------------------
# output
# ----------------------------------------------------------------------
ph.status
"PHP-FPM: active:
$iActive
(max:
$iMaxActive
) .. idle workers:
$iIdle
.. queue:
$iQueue
(max:
$iMaxQueue
) .. speed:
$iSpeed
req per sec ... slow:
$iSlow
req per sec (total:
$iSlowTotal
)"
echo
Worker states: running:
$iWorkerRunning
.. Reading headers:
$iWorkerReading
.. Idle:
$iWorkerIdle
echo
hint
=
"!! IMPORTANT !! Any non-OK status is still experimmental."
if
[
$iIdle
-eq
0
]
;
then
if
[
$iWorkerIdle
-eq
0
]
;
then
echo
$hint
echo
"WARNING: No 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."
echo
fi
if
[
$iWorkerReading
-eq
0
]
;
then
echo
$hint
echo
"WARNING:
$iIdle
idle
workers available."
echo
"WARNING:
No reading
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."
echo
...
...
@@ -187,20 +213,31 @@ if [ $iSlow -gt 0 ]; then
echo
fi
cat
$tmpfile
echo
"--- Status of service"
_getServicedata
echo
echo
"--- workers in state Running"
_getWorkerOfState
"Running"
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-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
# use process infos to count by worker state:
ph.perfadd
"php-fpm-idle"
"
${
iWorkerIdle
}
"
""
""
0 0
ph.perfadd
"php-fpm-running"
"
${
iWorkerRunning
}
"
""
""
0 0
ph.perfadd
"php-fpm-reading"
"
${
iWorkerReading
}
"
""
""
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