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
28f81925
Commit
28f81925
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update help; do not use tmp file anymore
parent
52b64079
No related branches found
No related tags found
1 merge request
!142
6468 docs and harmonize - check_php-fpm-status
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_php-fpm-status
+23
-46
23 additions, 46 deletions
check_php-fpm-status
with
23 additions
and
46 deletions
check_php-fpm-status
+
23
−
46
View file @
28f81925
...
...
@@ -13,12 +13,15 @@
# 2022-04-01 v0.6 <axel.hahn@iml.unibe.ch> use wget default params; shell fixes
# 2022-05-09 v0.7 <axel.hahn@iml.unibe.ch> use wget default params
# 2022-07-08 v0.8 <axel.hahn@iml.unibe.ch> eliminate division by 0
# 2022-10-21 v1.3 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space
# 2022-10-21 v1.0 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space
# 2023-08-24 v1.1 <axel.hahn@unibe.ch> update help; do not use tmp file anymore
# ======================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
.
$(
dirname
$0
)
/inc_pluginfunctions
tmpfile
=
/tmp/check_fpm_processes_1
export
self_APPVERSION
=
1.1
outFpmStatus
=
defaulturl
=
localhost/status
sDeltaunit
=
"min"
...
...
@@ -29,16 +32,16 @@ sDeltaunit="min"
# get service data from json output
function
_getServicedata
(){
cat
$tmpfile
| jq |
grep
'^ "'
|
grep
-v
"
\[
"
|
cut
-f
1
-d
","
echo
"
$outFpmStatus
"
| 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
echo
"
$outFpmStatus
"
| jq |
grep
'"state": '
|
cut
-f
2
-d
":"
|
cut
-f
1
-d
","
|
sort
-u
}
function
_getWorkerOfState
(){
cat
$tmpfile
| jq
-c
".processes[] | select(.state ==
\"
$1
\"
)"
echo
"
$outFpmStatus
"
| jq
-c
".processes[] | select(.state ==
\"
$1
\"
)"
}
# get a value from fpm status
...
...
@@ -61,7 +64,6 @@ function _getWorkerOfState(){
#
# param string variable (part before ":")
function
_getvalue
(){
# grep "^$1:" $tmpfile | cut -d ":" -f 2 | awk '{ print $1 }'
_getServicedata |
grep
"^
\"
$1
\"
:"
|
cut
-d
":"
-f
2 |
awk
'{ print $1 }'
}
...
...
@@ -69,14 +71,7 @@ function _getvalue(){
function
showHelp
(){
local
_self
=
$(
basename
$0
)
cat
<<
EOF
______________________________________________________________________
CHECK_PHP-FPM-Status
Get counters from PHP-FPM status output for active/ idle processes.
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
______________________________________________________________________
$(
ph.showImlHelpHeader
)
The check fetches several counters from php-fm-status page.
...
...
@@ -141,11 +136,14 @@ url=$( ph.getValueWithParam $defaulturl u "$@" )
paramsWget
=
"-T 5 -t 1 --no-check-certificate"
# --- get /server-status page
wget
$paramsWget
-O
$tmpfile
"
$url
?full&json"
2>/dev/null
if
[
$?
-ne
0
]
;
then
rm
-f
$tmpfile
ph.abort
"UNKNOWN: request to url
$url
failed.
$(
wget
$paramsWget
-O
-
-S
$url
)
"
# --- get fpm status page
if
!
outFpmStatus
=
$(
wget
$paramsWget
-O
-
"
$url
?full&json"
2>/dev/null
)
;
then
ph.abort
"UNKNOWN: request to url '
$url
' failed.
DEBUG: repeating the request showing header and STDERR
$(
wget
$paramsWget
-O
-
-S
$url
2>&1
)
"
fi
# ----------------------------------------------------------------------
...
...
@@ -180,32 +178,13 @@ typeset -i iWorkerIdle=$( _getWorkerOfState "Idle" | wc -l )
# ----------------------------------------------------------------------
# set status
# ----------------------------------------------------------------------
# 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
]
;
then
ph.setStatus warning
fi
# remove switch to warning level if just one slow request was detected
# if [ $iSlow -gt 0 ]; then
# ph.setStatus warning
# fi
# something queued and waiting for a free worker?
test
$iQueue
-gt
0
&&
ph.setStatus warning
# 5601 - remove warning for this limit (it is a flag and won't remove)
# if [ $iMaxChilds -gt 0 ]; then
# # ph.setStatus critical
# ph.setStatus warning
# fi
if
[
$iWorkerIdle
-eq
0
]
;
then
ph.setStatus warning
fi
# free worker down to 0?
test
$iWorkerIdle
-eq
0
&&
ph.setStatus warning
# seems not to be useful
# if [ $iWorkerReading -eq 0 ]; then
# ph.setStatus warning
# fi
# ----------------------------------------------------------------------
# output
...
...
@@ -242,7 +221,7 @@ fi
# echo
# fi
if
[
$iQueue
-gt
0
]
;
then
echo
$hint
echo
"
$hint
"
echo
"WARNING:
$iQueue
queued requests were found. Maximum of queued items is
$iMaxQueue
(since last start of fpm service)."
echo
fi
...
...
@@ -275,8 +254,6 @@ 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