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
98567f3b
Commit
98567f3b
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
ssl_certs: shell fixes; shorten perfdata label
parent
4ffc1e1c
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_ssl_certs
+14
-8
14 additions, 8 deletions
check_ssl_certs
with
14 additions
and
8 deletions
check_ssl_certs
+
14
−
8
View file @
98567f3b
...
@@ -11,9 +11,10 @@
...
@@ -11,9 +11,10 @@
#
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# 2021-10-06 v0.1 <axel.hahn@iml.unibe.ch> initial version
# 2021-10-06 v0.1 <axel.hahn@iml.unibe.ch> initial version
# 2022-03-16 v0.2 <axel.hahn@iml.unibe.ch> shell fixes; shorten perfdata label
# ======================================================================
# ======================================================================
.
`
dirname
$0
`
/inc_pluginfunctions
.
$(
dirname
$0
)
/inc_pluginfunctions
typeset
-i
iWarn
=
14
typeset
-i
iWarn
=
14
typeset
-i
iCrit
=
5
typeset
-i
iCrit
=
5
...
@@ -27,6 +28,9 @@ fullstatus=""
...
@@ -27,6 +28,9 @@ fullstatus=""
filelist
=
"/etc/ssl/certs/*.cert.cer"
filelist
=
"/etc/ssl/certs/*.cert.cer"
# remove dommain in label in performance data
myDomain
=
".iml.unibe.ch"
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# functions
# functions
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
...
@@ -45,7 +49,7 @@ Check locally installed SSL client certificates and warn if the
...
@@ -45,7 +49,7 @@ Check locally installed SSL client certificates and warn if the
expiration date comes closer.
expiration date comes closer.
SYNTAX:
SYNTAX:
`
basename
$0
`
[-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-f "FILELIST"]
$(
basename
$0
)
[-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-f "FILELIST"]
OPTIONS:
OPTIONS:
...
@@ -64,11 +68,11 @@ PARAMETERS:
...
@@ -64,11 +68,11 @@ PARAMETERS:
EXAMPLE:
EXAMPLE:
`
basename
$0
`
-f "/etc/ssl/certs/*example.com.*.cer /somewhere/else/*.cer"
$(
basename
$0
)
-f "/etc/ssl/certs/*example.com.*.cer /somewhere/else/*.cer"
Set 2 folders where to find the client certificates.
Set 2 folders where to find the client certificates.
They are seperated by space and both use * for globbing
They are seperated by space and both use * for globbing
`
basename
$0
`
-w 30 -c 3
$(
basename
$0
)
-w 30 -c 3
Overide the warning and critical level.
Overide the warning and critical level.
EOF
EOF
...
@@ -95,9 +99,9 @@ ph.require openssl
...
@@ -95,9 +99,9 @@ ph.require openssl
# --- override from command line params
# --- override from command line params
filelist
=
`
ph.getValueWithParam
"
$filelist
"
f
"
$@
"
`
filelist
=
$(
ph.getValueWithParam
"
$filelist
"
f
"
$@
"
)
iWarn
=
`
ph.getValueWithParam
$iWarn
w
"
$@
"
`
iWarn
=
$(
ph.getValueWithParam
$iWarn
w
"
$@
"
)
iCrit
=
`
ph.getValueWithParam
$iCrit
c
"
$@
"
`
iCrit
=
$(
ph.getValueWithParam
$iCrit
c
"
$@
"
)
# ----- check cert files
# ----- check cert files
...
@@ -114,6 +118,8 @@ do
...
@@ -114,6 +118,8 @@ do
iCounter
=
$iCounter
+1
iCounter
=
$iCounter
+1
data
=
$(
openssl x509
-noout
-text
-in
$mycert
2>/dev/null
)
data
=
$(
openssl x509
-noout
-text
-in
$mycert
2>/dev/null
)
mySubject
=
$(
echo
"
$data
"
|
grep
"Subject:
\
CN
\
=
\
"
|
grep
-v
","
|
cut
-f
2-
-d
"="
|
cut
-c
2-
)
mySubject
=
$(
echo
"
$data
"
|
grep
"Subject:
\
CN
\
=
\
"
|
grep
-v
","
|
cut
-f
2-
-d
"="
|
cut
-c
2-
)
mySubject2
=
"
${
mySubject
//
${
myDomain
}}
"
if
[
-z
"
$mySubject
"
]
;
then
if
[
-z
"
$mySubject
"
]
;
then
bHasWarning
=
true
bHasWarning
=
true
fullstatus
=
"
${
fullstatus
}
fullstatus
=
"
${
fullstatus
}
...
@@ -142,7 +148,7 @@ do
...
@@ -142,7 +148,7 @@ do
fi
fi
shortstatus
=
"
${
shortstatus
}${
result
}
${
mySubject
}
[
${
iLeft
}
d] ; "
shortstatus
=
"
${
shortstatus
}${
result
}
${
mySubject
}
[
${
iLeft
}
d] ; "
fullstatus
=
"
${
fullstatus
}
fullstatus
=
"
${
fullstatus
}
----- [
$iCounter
of
$iTotal
]
${
mySubject
}
- expires in
$iLeft
days
----- [
$iCounter
of
$iTotal
]
${
mySubject
}
- expires in
$iLeft
days
$mySubject2
$(
echo
"
$data
"
|
grep
-E
"(DNS:|Issuer:|Not
\
|Subject:)"
|
sed
's#^\ *##g'
)
$(
echo
"
$data
"
|
grep
-E
"(DNS:|Issuer:|Not
\
|Subject:)"
|
sed
's#^\ *##g'
)
File:
$mycert
File:
$mycert
"
"
...
...
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