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
bf46d529
Commit
bf46d529
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
journallog: update sudo command; set v1.0
parent
3e88dade
No related branches found
No related tags found
1 merge request
!188
journallog: update sudo command; set v1.0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
check_journallog
+17
-14
17 additions, 14 deletions
check_journallog
docs/20_Checks/check_journallog.md
+2
-2
2 additions, 2 deletions
docs/20_Checks/check_journallog.md
with
19 additions
and
16 deletions
check_journallog
+
17
−
14
View file @
bf46d529
...
@@ -9,11 +9,12 @@
...
@@ -9,11 +9,12 @@
#
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# 2023-10-12 v0.1 <axel.hahn@unibe.ch> initial version
# 2023-10-12 v0.1 <axel.hahn@unibe.ch> initial version
# 2023-10-13 v1.0 <axel.hahn@unibe.ch> update sudo command; set v1.0
# ======================================================================
# ======================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
.
$(
dirname
$0
)
/inc_pluginfunctions
export
self_APPVERSION
=
0.1
export
self_APPVERSION
=
1.0
tmpfile
=
/tmp/last_journallog_line_
${
USER
}
.txt
tmpfile
=
/tmp/last_journallog_line_
${
USER
}
.txt
...
@@ -29,6 +30,7 @@ $( ph.showImlHelpHeader )
...
@@ -29,6 +30,7 @@ $( ph.showImlHelpHeader )
Show number of lines in journallog per min.
Show number of lines in journallog per min.
A strong change of the written lines per min COULD indicate a problem.
A strong change of the written lines per min COULD indicate a problem.
It requires sudo permission on /bin/journalctl
The status is ...
The status is ...
- unknown - if journalctl is not available
- unknown - if journalctl is not available
...
@@ -84,21 +86,24 @@ typeset -i iCriticalLimit=$( ph.getValueWithParam 0 c "$@")
...
@@ -84,21 +86,24 @@ typeset -i iCriticalLimit=$( ph.getValueWithParam 0 c "$@")
lastLine
=
$(
cat
"
$tmpfile
"
2>/dev/null
)
lastLine
=
$(
cat
"
$tmpfile
"
2>/dev/null
)
if
[
-z
"
$lastLine
"
]
;
then
if
[
-z
"
$lastLine
"
]
;
then
ph.setStatus unknown
ph.setStatus unknown
ph.status
"Initializing ... storing last line of jorunallog ..."
if
!
sudo
-n
journalctl
--version
>
/dev/null 2>&1
;
then
journalctl
-n
1 |
tail
-1
>
"
$tmpfile
"
ph.status
"User
$USER
has sudo permissions to execute journalctl."
ph.exit
else
#
# 1st run: initialize
#
ph.status
"Initializing ... storing last line of jorunallog ..."
sudo
-n
journalctl
-n
1 |
tail
-1
>
"
$tmpfile
"
fi
else
else
# mydate is "Okt 12 16:23:36"
# Remark: parsing of date from journallog entry can fail because of
# mydate=$( cut -f 1-3 -d " " <<< "$lastLine" )
# language specific monthes or no date on multi line entries
# Thats why we take the timestamp of the tmpfile
# what works:
# date -d "12 sec ago" +"%Y-%m-%d %H:%I:%S"
# date -d "Oct 12 14:24:04" +"%Y-%m-%d %H:%M:%S"
typeset
-i
iAge
;
iAge
=
$(
ph.getFileAge
"
$tmpfile
"
)
typeset
-i
iAge
;
iAge
=
$(
ph.getFileAge
"
$tmpfile
"
)
# ts=$( date -d "${mydate}" +"%Y-%m-%d %H:%M:%S" )
ts
=
$(
date
-d
"
${
iAge
}
sec ago"
+
"%Y-%m-%d %H:%M:%S"
)
ts
=
$(
date
-d
"
${
iAge
}
sec ago"
+
"%Y-%m-%d %H:%M:%S"
)
data
=
$(
sudo
journalctl
--since
"
$ts
"
)
data
=
$(
sudo
-n
journalctl
--since
"
$ts
"
)
# detect last seen position and count lines from there
# detect last seen position and count lines from there
typeset
-i
iTotal
;
iTotal
=
$(
wc
-l
<<<
"
$data
"
)
typeset
-i
iTotal
;
iTotal
=
$(
wc
-l
<<<
"
$data
"
)
...
@@ -132,8 +137,6 @@ else
...
@@ -132,8 +137,6 @@ else
fi
fi
# cat "$tmpfile"
ph.exit
ph.exit
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
docs/20_Checks/check_journallog.md
+
2
−
2
View file @
bf46d529
...
@@ -20,7 +20,7 @@ icingaclient ALL=(ALL) NOPASSWD: /bin/journalctl
...
@@ -20,7 +20,7 @@ icingaclient ALL=(ALL) NOPASSWD: /bin/journalctl
______________________________________________________________________
______________________________________________________________________
CHECK_JOURNALLOG
CHECK_JOURNALLOG
v
0.1
v
1.0
(c) Institute for Medical Education - University of Bern
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
Licence: GNU GPL 3
...
@@ -30,6 +30,7 @@ ______________________________________________________________________
...
@@ -30,6 +30,7 @@ ______________________________________________________________________
Show number of lines in journallog per min.
Show number of lines in journallog per min.
A strong change of the written lines per min COULD indicate a problem.
A strong change of the written lines per min COULD indicate a problem.
It requires sudo permission on /bin/journalctl
The status is ...
The status is ...
- unknown - if journalctl is not available
- unknown - if journalctl is not available
...
@@ -61,7 +62,6 @@ EXAMPLES:
...
@@ -61,7 +62,6 @@ EXAMPLES:
Set warning level to 100 written lines per min but
Set warning level to 100 written lines per min but
no critical limit. This check then never will send a
no critical limit. This check then never will send a
critical status.
critical status.
```
```
## Examples
## Examples
...
...
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