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
Merge requests
!195
fs_errors - harden sudo command execution
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
fs_errors - harden sudo command execution
6723-sudo
into
master
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Hahn Axel (hahn)
requested to merge
6723-sudo
into
master
1 year ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
d1ffd8f3
1 commit,
1 year ago
1 file
+
14
−
10
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
check_fs_errors
+
14
−
10
Options
@@ -11,12 +11,13 @@
# 2021-03-23 v1.0 <axel.hahn@iml.unibe.ch>
# 2021-03-30 v1.1 <axel.hahn@iml.unibe.ch> max age of detected errors: since yesterday (commented)
# 2023-07-27 v1.2 <axel.hahn@unibe.ch> shell fixes; update help page
# 2023-10-20 v1.3 <axel.hahn@unibe.ch> harden sudo command execution
# ======================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
export
self_APPVERSION
=
1.
2
export
self_APPVERSION
=
1.
3
# ----------------------------------------------------------------------
@@ -52,7 +53,7 @@ EOF
# ----------------------------------------------------------------------
# --- check required tools
#
ph.require
bc top
ph.require
journalctl
# --- check param -h
@@ -67,19 +68,22 @@ esac
# ----- MAKE CHECK
if
!
sudo
-n
journalctl
--since
today
-k
-n
1 2>&1
>
/dev/null
;
then
ph.abort
"UNKNOWN: No sudo permissions to execute journalctl."
fi
# sincedate=$( date +%Y-%m-%d --date 'yesterday' )
# out=$( sudo /bin/journalctl --since $sincedate | grep 'kernel: ' | grep -v 'check_fs_errors' | grep -E '(error|fail)' | grep 'inconsistent' )
out
=
$(
sudo
/bin/journalctl |
grep
'kernel: '
|
grep
-v
'check_fs_errors'
|
grep
-E
'(error|fail)'
|
grep
'inconsistent'
)
test
!
-z
"
$out
"
&&
ph.setStatus
"critical"
out
=
$(
sudo
-n
/bin/journalctl
-k
--since
yesterday |
grep
'kernel: '
|
grep
-v
'check_fs_errors'
|
grep
-E
'(error|fail)'
|
grep
'inconsistent'
)
# ----- OUTPUT
ph.status
"check if kernel logs inconsistency messages"
echo
"
$out
"
# ----- CLEANUP AND BYE!
if
[
-n
"
$out
"
]
;
then
ph.setStatus
"critical"
ph.status
"kernel logs show inconsistency messages (since yesteray)"
echo
"
$out
"
else
ph.status
"No inconsistency messages"
fi
ph.exit
Loading