Skip to content
Snippets Groups Projects
Commit 27cb77bf authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch '6683-parametrize-snmp_printer_wrapper' into 'master'

journallog: update sudo command; set v1.0

See merge request !188
parents bb2aff31 bf46d529
No related branches found
No related tags found
1 merge request!188journallog: update sudo command; set v1.0
......@@ -9,11 +9,12 @@
#
# ----------------------------------------------------------------------
# 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
export self_APPVERSION=0.1
export self_APPVERSION=1.0
tmpfile=/tmp/last_journallog_line_${USER}.txt
......@@ -29,6 +30,7 @@ $( ph.showImlHelpHeader )
Show number of lines in journallog per min.
A strong change of the written lines per min COULD indicate a problem.
It requires sudo permission on /bin/journalctl
The status is ...
- unknown - if journalctl is not available
......@@ -84,21 +86,24 @@ typeset -i iCriticalLimit=$( ph.getValueWithParam 0 c "$@")
lastLine=$( cat "$tmpfile" 2>/dev/null )
if [ -z "$lastLine" ]; then
ph.setStatus unknown
ph.status "Initializing ... storing last line of jorunallog ..."
journalctl -n 1 | tail -1 > "$tmpfile"
if ! sudo -n journalctl --version >/dev/null 2>&1; then
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
# mydate is "Okt 12 16:23:36"
# mydate=$( cut -f 1-3 -d " " <<< "$lastLine" )
# 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"
# Remark: parsing of date from journallog entry can fail because of
# language specific monthes or no date on multi line entries
# Thats why we take the timestamp of the 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" )
data=$( sudo journalctl --since "$ts" )
data=$( sudo -n journalctl --since "$ts" )
# detect last seen position and count lines from there
typeset -i iTotal; iTotal=$( wc -l <<< "$data" )
......@@ -132,8 +137,6 @@ else
fi
# cat "$tmpfile"
ph.exit
# ----------------------------------------------------------------------
......@@ -20,7 +20,7 @@ icingaclient ALL=(ALL) NOPASSWD: /bin/journalctl
______________________________________________________________________
CHECK_JOURNALLOG
v0.1
v1.0
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
......@@ -30,6 +30,7 @@ ______________________________________________________________________
Show number of lines in journallog per min.
A strong change of the written lines per min COULD indicate a problem.
It requires sudo permission on /bin/journalctl
The status is ...
- unknown - if journalctl is not available
......@@ -61,7 +62,6 @@ EXAMPLES:
Set warning level to 100 written lines per min but
no critical limit. This check then never will send a
critical status.
```
## Examples
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment