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
a4342d28
Commit
a4342d28
authored
2 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
check apache status: remove usage of tmp file
parent
4e8d9779
No related branches found
No related tags found
1 merge request
!122
Update docs
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_apache_requests
+12
-19
12 additions, 19 deletions
check_apache_requests
with
12 additions
and
19 deletions
check_apache_requests
+
12
−
19
View file @
a4342d28
...
@@ -10,14 +10,13 @@
...
@@ -10,14 +10,13 @@
# 2021-03-11 v1.1 <axel.hahn@iml.unibe.ch> more error checks for output data
# 2021-03-11 v1.1 <axel.hahn@iml.unibe.ch> more error checks for output data
# 2021-11-18 v1.2 <axel.hahn@iml.unibe.ch> add timeout and max tries; use localhost instead of FQDN
# 2021-11-18 v1.2 <axel.hahn@iml.unibe.ch> add timeout and max tries; use localhost instead of FQDN
# 2022-08-31 v1.3 <axel.hahn@iml.unibe.ch> add help; shellfix corrections
# 2022-08-31 v1.3 <axel.hahn@iml.unibe.ch> add help; shellfix corrections
# 2022-08-31 v1.4 <axel.hahn@iml.unibe.ch> add help; shellfix corrections
# 2023-06-19 v1.5 <axel.hahn@unibe.ch> no more tmpfile
# ======================================================================
# ======================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
.
$(
dirname
$0
)
/inc_pluginfunctions
self_APPNAME
=
$(
basename
$0
|
tr
[
:lower:]
[
:upper:]
)
self_APPNAME
=
$(
basename
$0
|
tr
[
:lower:]
[
:upper:]
)
self_APPVERSION
=
1.4
self_APPVERSION
=
1.5
tmpfile
=
/tmp/check_apache_processes_1
tmpfile2
=
/tmp/check_apache_processes_2
# url=`hostname -f`/server-status
# url=`hostname -f`/server-status
url
=
localhost/server-status
url
=
localhost/server-status
...
@@ -124,9 +123,8 @@ ph.require wget
...
@@ -124,9 +123,8 @@ ph.require wget
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# --- get /server-status page
# --- get /server-status page
wget
$paramsWget
-O
$tmpfile
$url
2>/dev/null
data
=
$(
wget
$paramsWget
-O
-
$url
2>/dev/null
)
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
rm
-f
$tmpfile
ph.abort
"UNKNOWN: request to url
$url
failed.
$(
wget
$paramsWget
-O
-
-S
$url
2>&1
)
"
ph.abort
"UNKNOWN: request to url
$url
failed.
$(
wget
$paramsWget
-O
-
-S
$url
2>&1
)
"
fi
fi
...
@@ -136,32 +134,30 @@ typeset -i iCriticalLimit=$( ph.getValueWithParam 90 c "$@")
...
@@ -136,32 +134,30 @@ typeset -i iCriticalLimit=$( ph.getValueWithParam 90 c "$@")
# --- extract scoreboard
# --- extract scoreboard
iStart
=
$(
grep
-n
'<pre>'
$tmpfile
|
cut
-f
1
-d
':'
)
iStart
=
$(
grep
-n
'<pre>'
<<<
"
$data
"
|
cut
-f
1
-d
':'
)
iEnd
=
$(
grep
-n
'</pre>'
$tmpfile
|
cut
-f
1
-d
':'
)
iEnd
=
$(
grep
-n
'</pre>'
<<<
"
$data
"
|
cut
-f
1
-d
':'
)
if
[
$iStart
-eq
0
-o
$iEnd
-eq
0
]
;
then
if
[
$iStart
-eq
0
-o
$iEnd
-eq
0
]
;
then
rm
-f
$tmpfile
ph.abort
"UNKNOWN: url
$url
has no PRE tag for apache scroreboard. I guess it is not a server-status page."
ph.abort
"UNKNOWN: url
$url
has no PRE tag for apache scroreboard. I guess it is not a server-status page."
fi
fi
sed
-n
"
${
iStart
}
,
${
iEnd
}
p"
$tmpfile
|
sed
's#<.*>##g'
|
tr
-d
"
\n
"
>
$tmpfile2
dataPre
=
$(
sed
-n
"
${
iStart
}
,
${
iEnd
}
p"
<<<
"
$data
"
|
sed
's#<.*>##g'
|
tr
-d
"
\n
"
)
# --- count slots in the scoreboard
# --- count slots in the scoreboard
# total slots available
# total slots available
iSlots
=
$(
cat
$tmpfile2
|
wc
-m
)
iSlots
=
$(
echo
-n
"
$dataPre
"
|
wc
-m
)
if
[
$iSlots
-eq
0
]
;
then
if
[
$iSlots
-eq
0
]
;
then
rm
-f
$tmpfile
$tmpfile2
ph.abort
"UNKNOWN: url
$url
has no count of slots. I guess it is not a server-status page or option for Extended status is off."
ph.abort
"UNKNOWN: url
$url
has no count of slots. I guess it is not a server-status page or option for Extended status is off."
fi
fi
# running apache processes waiting for a request
# running apache processes waiting for a request
iIdle
=
iCount
=
$(
sed
-e
"s/[^_]//g"
$tmpfile2
|
wc
-m
)
iIdle
=
iCount
=
$(
echo
-n
"
$dataPre
"
|
sed
-e
"s/[^_]//g"
|
wc
-m
)
# count of processes apache still can create
# count of processes apache still can create
iUnused
=
iCount
=
$(
sed
-e
"s/[^
\.
]//g"
$tmpfile2
|
wc
-m
)
iUnused
=
iCount
=
$(
echo
-n
"
$dataPre
"
|
sed
-e
"s/[^
\.
]//g"
|
wc
-m
)
# count of actively used slots
# count of actively used slots
iActive
=
$iSlots
-
$iIdle
-
$iUnused
iActive
=
$iSlots
-
$iIdle
-
$iUnused
...
@@ -172,7 +168,7 @@ ph.setStatusByLimit $iUsage $iWarnLimit $iCriticalLimit
...
@@ -172,7 +168,7 @@ ph.setStatusByLimit $iUsage $iWarnLimit $iCriticalLimit
# --- output
# --- output
ph.status
"Apache:
$iSlots
slots ... active:
$iActive
wait:
$iIdle
unused:
$iUnused
(
$iUsage
% usage)"
ph.status
"Apache:
$iSlots
slots ... active:
$iActive
wait:
$iIdle
unused:
$iUnused
(
$iUsage
% usage)"
grep
"^<dt"
$tmpfile
|
sed
's#<dt>##'
|
sed
's#</dt>##'
grep
"^<dt"
<<<
"
$data
"
|
sed
's#<dt>##'
|
sed
's#</dt>##'
echo
echo
# --- add performnce data
# --- add performnce data
...
@@ -181,16 +177,13 @@ ph.perfadd "apache-active" "${iActive}" "" "" 0 $iSlots
...
@@ -181,16 +177,13 @@ ph.perfadd "apache-active" "${iActive}" "" "" 0 $iSlots
echo
"Slots:"
echo
"Slots:"
for
mychar
in
S R W K D C L G I _
.
for
mychar
in
S R W K D C L G I _
.
do
do
iCount
=
$(
sed
-e
"s/[^
${
mychar
}
]//g"
$tmpfile2
|
wc
-m
)
iCount
=
$(
echo
-n
"
$dataPre
"
|
sed
-e
"s/[^
${
mychar
}
]//g"
|
wc
-m
)
label
=
$(
echo
apache-
${
mychar
}
|
tr
[
:upper:]
[
:lower:] |
sed
"s#_#idle#"
|
sed
"s#
\.
#unused#"
)
label
=
$(
echo
apache-
${
mychar
}
|
tr
[
:upper:]
[
:lower:] |
sed
"s#_#idle#"
|
sed
"s#
\.
#unused#"
)
echo
" -
${
mychar
}
:
${
iCount
}
"
echo
" -
${
mychar
}
:
${
iCount
}
"
ph.perfadd
"
${
label
}
"
"
${
iCount
}
"
""
""
0
$iSlots
ph.perfadd
"
${
label
}
"
"
${
iCount
}
"
""
""
0
$iSlots
done
done
rm
-f
$tmpfile
$tmpfile2
ph.exit
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