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
3e88dade
Commit
3e88dade
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
fix date time handling
parent
51fe96cd
Branches
Branches containing commit
No related tags found
1 merge request
!187
fix date time handling
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_journallog
+14
-5
14 additions, 5 deletions
check_journallog
with
14 additions
and
5 deletions
check_journallog
+
14
−
5
View file @
3e88dade
...
...
@@ -85,15 +85,21 @@ lastLine=$( cat "$tmpfile" 2>/dev/null )
if
[
-z
"
$lastLine
"
]
;
then
ph.setStatus unknown
ph.status
"Initializing ... storing last line of jorunallog ..."
journalctl
-n
1
>
"
$tmpfile
"
journalctl
-n
1
|
tail
-1
>
"
$tmpfile
"
else
ts
=
$(
cut
-f
1-3
-d
" "
<<<
"
$lastLine
"
)
# 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"
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
"
)
# for next run: insert last handled line
tail
-1
<<<
"
$data
"
>
"
$tmpfile
"
# detect last seen position and count lines from there
typeset
-i
iTotal
;
iTotal
=
$(
wc
-l
<<<
"
$data
"
)
typeset
-i
iFrom
;
iFrom
=
$(
grep
-Fn
"
$lastLine
"
<<<
"
$data
"
|
head
-1
|
cut
-f
1
-d
':'
)
...
...
@@ -121,6 +127,9 @@ else
echo
"Limits:
$sLimits
"
echo
"Raw data: Found
$iLines
new line(s) in the last
$iAge
sec"
# for next run: insert last handled line
test
$iLines
-gt
0
&&
tail
-1
<<<
"
$data
"
>
"
$tmpfile
"
fi
# cat "$tmpfile"
...
...
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