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
9a57aed7
Commit
9a57aed7
authored
4 months ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
acheck_ssl: add IML header in help; add warning and critical level
parent
94904385
No related branches found
No related tags found
1 merge request
!297
Simple task/7546 icinga check für ablaufende gitlab tokens
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_ssl
+78
-46
78 additions, 46 deletions
check_ssl
with
78 additions
and
46 deletions
check_ssl
+
78
−
46
View file @
9a57aed7
...
...
@@ -18,17 +18,18 @@
# 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
# 2023-02-13 v1.2 <axel.hahn@unibe.ch> some shell fixes
# 2023-08-23 v1.3 <axel.hahn@unibe.ch> fix wrong exitcode to "critical"
# 2025-02-12 v1.4 <axel.hahn@unibe.ch> add IML header in help; add warning and critical level
# ======================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
self_APPNAME
=
$(
basename
$0
|
tr
[
:lower:]
[
:upper:]
)
self_APPVERSION
=
1.4
sDomain
=
iPort
=
443
iWarnDaysBefore
=
60
typeset
-i
iErrors
=
0
typeset
-i
iWarnings
=
0
...
...
@@ -40,13 +41,36 @@ sStatus=
# show help with syntax
function
showHelp
(){
echo
echo
-----
SSL Check v1.0
echo
echo
"SYNTAX:
$(
basename
$0
)
[domain] [[port]]"
echo
" domain - domain to verify the ssl vertificate from (required)"
echo
" port - port number to connect (default: 443)"
echo
_self
=
$(
basename
$0
)
cat
<<
EOH
$(
ph.showImlHelpHeader
)
Check if ssl certificate of a given domain is still valid.
You can check https or any other port of a ssl enabled service like LDAPS,
IMPAS and others.
You can customize the values for warning and critical level.
SYNTAX:
$_self
[options] DOMAIN [PORT]
OPTIONS
-w VALUE warning level for expiration in days (default: 28)
-c VALUE critical level for expiration in days (default: 7)
PARAMETERS
DOMAIN domain to verify the ssl vertificate from (required)
PORT optional: port number to connect (default: 443)
EXAMPLES
$_self
www.iml.unibe.ch 443
check https port 443
$_self
-w 30 -c 14 ldap.example.com 636
check ldaps port 636 and set custom warning and critical level
EOH
}
...
...
@@ -61,16 +85,25 @@ function showHelp(){
if
[
$#
-eq
0
]
;
then
showHelp
ph.abort
exit
0
fi
# --- start
sDomain
=
$1
if
[
!
-z
$2
]
;
then
iPort
=
$2
fi
# set default / override from command line params
typeset
-i
iWarnLimit
;
iWarnLimit
=
$(
ph.getValueWithParam 28 w
"
$@
"
)
typeset
-i
iCriticalLimit
;
iCriticalLimit
=
$(
ph.getValueWithParam 7 c
"
$@
"
)
sParams
=
"
$*
"
sP1
=
"
$(
rev
<<<
$sParams
|
cut
-f
2
-d
' '
| rev
)
"
sP2
=
"
$(
rev
<<<
$sParams
|
cut
-f
1
-d
' '
| rev
)
"
if
grep
-q
"^[0-9]*$"
<<<
$sP2
;
then
sDomain
=
$sP1
iPort
=
$sP2
else
sDomain
=
$sP2
fi
# --- try to connect
...
...
@@ -102,19 +135,18 @@ function showHelp(){
tsNow
=
$(
date
+%s
)
typeset
-i
iDaysLeft
=(
$tsTo
-
$tsNow
)
/60/60/24
# --- check date
if
[
${
tsFrom
}
-gt
${
tsNow
}
]
;
then
ph.setStatus
"critical"
ph.status
"certificate
${
sDomain
}
:
${
iPort
}
is not valid yet -
${
dateFrom
}
"
else
if
[
${
tsTo
}
-lt
${
tsNow
}
]
;
then
if
[
${
tsTo
}
-lt
${
tsNow
}
]||[
${
iDaysLeft
}
-le
$iCriticalLimit
]
;
then
ph.setStatus
"critical"
ph.status
"certificate
${
sDomain
}
:
${
iPort
}
is out of date -
${
dateTo
}
-
${
iDaysLeft
}
days"
else
# --- check close ending day
if
[
${
iDaysLeft
}
-lt
${
iWarn
DaysBefore
}
]
;
then
if
[
${
iDaysLeft
}
-lt
${
iWarn
Limit
}
]
;
then
ph.setStatus
"warning"
ph.status
"certificate
${
sDomain
}
:
${
iPort
}
is out of date -
${
dateTo
}
-
${
iDaysLeft
}
days"
else
...
...
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