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
c09c2396
Commit
c09c2396
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update dns response time check
parent
f3518944
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_dns_responsetime
+52
-30
52 additions, 30 deletions
check_dns_responsetime
with
52 additions
and
30 deletions
check_dns_responsetime
+
52
−
30
View file @
c09c2396
...
...
@@ -7,14 +7,35 @@
#
# ----------------------------------------------------------------------
# 2020-06-17 v1.0 <axel.hahn@iml.unibe.ch>
# 2021-11-12 v1.1 <axel.hahn@iml.unibe.ch> check fqd instead of fixed value
# test tcp 53 first
# check result depends on 1st nameserver only
# ======================================================================
.
`
dirname
$0
`
/inc_pluginfunctions
tmpfile
=
/tmp/check_netstat_out_
$$
infofile
=
/tmp/check_netstat_out_2_
$$
myHost
=
www.unibe.ch
myHost
=
$(
hostname
-f
)
echo
$myHost
|
cut
-f
3-
-d
"."
|
grep
"
\.
"
>
/dev/null
if
[
$?
-ne
0
]
;
then
ph.setStatus unknown
ph.status
"DNS check for [
$myHost
] - SKIP: hostname -f returned a FQDN with less than 2 dots"
ph.exit
fi
# set default / override from command line params
typeset
-i
iWarnLimit
=
`
ph.getValueWithParam 300 w
"
$@
"
`
typeset
-i
iCriticalLimit
=
`
ph.getValueWithParam 1000 c
"
$@
"
`
rm
-f
$tmpfile
$infofile
2>/dev/null
typeset
-i
iMax
=
0
typeset
-i
iTime
=
0
typeset
-i
iCounter
=
0
typeset
-i
iNotReachable
=
0
# ----------------------------------------------------------------------
# MAIN
...
...
@@ -33,44 +54,45 @@ if [ "$1" = "-h" ]; then
exit
0
fi
# set default / override from command line params
typeset
-i
iWarnLimit
=
`
ph.getValueWithParam 300 w
"
$@
"
`
typeset
-i
iCriticalLimit
=
`
ph.getValueWithParam 1000 c
"
$@
"
`
rm
-f
$tmpfile
$infofile
2>/dev/null
typeset
-i
iMax
=
0
typeset
-i
iTime
=
0
for
mydns
in
`
grep
^nameserver /etc/resolv.conf |
awk
'{ print $2 } '
`
do
iCounter
=
$iCounter
+1
typeset
-i
iSrvMax
=
0
echo
""
>>
$infofile
#
echo "----------
`date`
$mydns " >>$infofile
echo
"----------
$iCounter
-
$mydns
"
>>
$infofile
# todo loop
for
i
in
`
seq
5
`
do
# echo "" >>$infofile
# echo "---------- `date` -- $mydns - $i" >>$infofile
(
time
nslookup
${
myHost
}
$mydns
)
>
$tmpfile
2>&1
iTime
=
`
cat
$tmpfile
|
grep
"^real.*m.*
\.
.*s"
|
cut
-f
2
-d
"m"
|
sed
"s#[
\.
s]##g"
|
sed
"s#^0*##g"
`
echo
"
$mydns
#
$i
>>>
$iTime
ms"
>>
$infofile
test
$iTime
-ge
$iWarnLimit
&&
cat
$tmpfile
>>
$infofile
test
$iTime
-gt
$iSrvMax
&&
iSrvMax
=
$iTime
done
label
=
`
echo
$mydns
|
sed
"s#
\.
#-#g"
`
ph.perfadd
"response-
$label
"
"
${
iSrvMax
}
"
test
$iSrvMax
-gt
$iMax
&&
iMax
=
$iSrvMax
>
/dev/tcp/
${
mydns
}
/53
>>
$infofile
2>&1
if
[
$?
-ne
0
]
;
then
iNotReachable
=
$iNotReachable
+1
test
$iCounter
-eq
1
&&
ph.setStatus critical
echo
"ERROR:
${
mydns
}
is not reachable on tcp 53"
>>
$infofile
else
for
i
in
`
seq
5
`
do
(
time
nslookup
${
myHost
}
$mydns
)
>
$tmpfile
2>&1
iTime
=
`
cat
$tmpfile
|
grep
"^real.*m.*
\.
.*s"
|
cut
-f
2
-d
"m"
|
sed
"s#[
\.
s]##g"
|
sed
"s#^0*##g"
`
echo
"
$mydns
#
$i
>>>
$iTime
ms"
>>
$infofile
test
$iTime
-ge
$iWarnLimit
&&
cat
$tmpfile
|
grep
-vE
"^(real|user|sys)"
>>
$infofile
test
$iTime
-gt
$iSrvMax
&&
iSrvMax
=
$iTime
done
echo
"max:
$iSrvMax
ms"
>>
$infofile
# --- set status
test
$iCounter
-eq
1
&&
ph.setStatusByLimit
$iSrvMax
$iWarnLimit
$iCriticalLimit
label
=
`
echo
$mydns
|
sed
"s#
\.
#-#g"
`
ph.perfadd
"response-
$label
"
"
${
iSrvMax
}
"
test
$iSrvMax
-gt
$iMax
&&
iMax
=
$iSrvMax
fi
test
$iCounter
-eq
1
&&
(
echo
" ^"
;
echo
" |"
;
echo
" +--- 1st nameserver is relevant for total status of the check. Limits are warning=
$iWarnLimit
and critical=
$iCriticalLimit
"
)
>>
$infofile
echo
""
>>
$infofile
done
# --- set status
ph.setStatusByLimit
$iMax
$iWarnLimit
$iCriticalLimit
ph.status
"DNS check - found maximum was
$iMax
ms"
ph.status
"DNS check
for
$myHost
- found maximum was
$iMax
ms
-
$iNotReachable
of
$iCounter
nameservers not reachable
"
cat
$infofile
rm
-f
$tmpfile
$infofile
...
...
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