Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
checkmk-formula
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
salt
checkmk-formula
Commits
d6160dd5
Commit
d6160dd5
authored
2 years ago
by
Jan Philipp Timme
Browse files
Options
Downloads
Patches
Plain Diff
Add plugin to monitor os release expiry
parent
00e9308d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
checkmk/custom-files/local/monitor-os-expiry
+52
-0
52 additions, 0 deletions
checkmk/custom-files/local/monitor-os-expiry
checkmk/generic/monitor-os-expiry.sls
+7
-0
7 additions, 0 deletions
checkmk/generic/monitor-os-expiry.sls
with
59 additions
and
0 deletions
checkmk/custom-files/local/monitor-os-expiry
0 → 100644
+
52
−
0
View file @
d6160dd5
#!/bin/bash
# WARN if less than this amount of days is left on the os release
CONFIG_WARN_DAYS_LEFT
=
180
# CRIT if less than this amount of days is left on the os release
CONFIG_CRIT_DAYS_LEFT
=
90
# Fetch current time
NOW
=
$(
date
+%s
)
# Fetch an easy matchable string that represents the current OS version
OS
=
$(
lsb_release
-i
-r
|
cut
-f
2 |
tr
'\n'
' '
)
# Initialize expiredate with marker for unknown OS
expiredate
=
-1
# Use bash regex to match OS, assign expiredate in format of "YYYY-MM-DD"
# NOTE: You have to use [[:space:]] to match spaces because, you know, bash.
if
[[
$OS
=
~ ^Debian[[:space:]]9
]]
;
then
expiredate
=
"2022-06-30"
elif
[[
$OS
=
~ ^Debian[[:space:]]10
]]
;
then
expiredate
=
"2024-06-30"
elif
[[
$OS
=
~ ^Debian[[:space:]]11
]]
;
then
expiredate
=
"2026-06-30"
elif
[[
$OS
=
~ ^Ubuntu[[:space:]]18
\.
04
]]
;
then
expiredate
=
"2023-04-30"
elif
[[
$OS
=
~ ^Ubuntu[[:space:]]20
\.
04
]]
;
then
expiredate
=
"2025-04-30"
elif
[[
$OS
=
~ ^CentOS[[:space:]]7
]]
;
then
expiredate
=
"2024-06-30"
fi
# If OS is not handled yet ...
if
[[
"
$expiredate
"
==
"-1"
]]
;
then
# ... report an error, so a dev can extend the plugin
echo
"3 OS-Expiry - Unknown OS '
$OS
', please extend agent plugin 'monitor-os-expiry'!"
else
# otherwise, calculate remaining days for OS and report accordingly.
os_expire_timestamp
=
$(
date
-d
"
$expiredate
"
+%s
)
remaining_seconds
=
$((
$os_expire_timestamp
-
$NOW
))
remaining_days
=
$((
$remaining_seconds
/
86400
))
# Default is OK, gets overridden by WARN, then by CRIT
checkmk_status
=
"0"
if
[[
$remaining_days
-le
$CONFIG_WARN_DAYS_LEFT
]]
;
then
checkmk_status
=
"1"
fi
if
[[
$remaining_days
-le
$CONFIG_CRIT_DAYS_LEFT
]]
;
then
checkmk_status
=
"2"
fi
echo
"
$checkmk_status
OS-Expiry -
$remaining_days
days remaining for
$OS
)"
fi
\ No newline at end of file
This diff is collapsed.
Click to expand it.
checkmk/generic/monitor-os-expiry.sls
0 → 100644
+
7
−
0
View file @
d6160dd5
hsh_checkmk_monitor_os_expiry_plugin:
file.managed:
- name: /usr/lib/check_mk_agent/local/monitor-os-expiry
- source: salt://checkmk/custom-files/local/monitor-os-expiry
- mode: 755
- user: root
- group: root
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