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
0ce33ddf
Commit
0ce33ddf
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
add check_journallog
parent
6e7b34be
No related branches found
No related tags found
1 merge request
!185
add check_journallog
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_journallog
+130
-0
130 additions, 0 deletions
check_journallog
with
130 additions
and
0 deletions
check_journallog
0 → 100755
+
130
−
0
View file @
0ce33ddf
#!/bin/bash
# ======================================================================
#
# Check count of written entries in journallog
#
# requirements:
# - journalctl
#
# ----------------------------------------------------------------------
# 2023-10-12 v0.1 <axel.hahn@unibe.ch> initial version
# ======================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
export
self_APPVERSION
=
0.1
tmpfile
=
/tmp/last_journallog_line_
${
USER
}
.txt
# ----------------------------------------------------------------------
# FUNCTIONS
# ----------------------------------------------------------------------
# show help text
function
showHelp
(){
local
_self
;
_self
=
$(
basename
$0
)
cat
<<
EOF
$(
ph.showImlHelpHeader
)
Show number of lines in journallog per min.
A strong change of the written lines per min COULD indicate a problem.
The status is ...
- unknown - if journalctl is not available
- if the script is started the 1st time and stores the last
line of the journallog
- ok - when showing written tnries per min
- warning/ critical - when giving -c and -w parameter values
This plugin sends performancedata.
SYNTAX:
$_self
[-h] [-w WARN_LIMIT] [-c CRITICAL_LIMIT]
OPTIONS:
-h this help
-w VALUE warning level (default: 0)
-c VALUE critical level (default: 0)
PARAMETERS:
None.
EXAMPLES:
$_self
show count of newly written log entries
$_self
-w 100 -c 200
Set warning level to 100 written lines per min and
critical to 200.
$_self
-w 100
Set warning level to 100 written lines per min but
no critical limit. This check then never will send a
critical status.
EOF
}
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
# handle params
ph.hasParamoption
"h"
"
$@
"
;
bOptHelp
=
$?
if
[
$bOptHelp
-eq
0
]
;
then
showHelp
exit
0
fi
ph.require journalctl
typeset
-i
iWarnLimit
=
$(
ph.getValueWithParam 0 w
"
$@
"
)
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
>
"
$tmpfile
"
else
ts
=
$(
cut
-f
1-3
-d
" "
<<<
"
$lastLine
"
)
typeset
-i
iAge
;
iAge
=
$(
ph.getFileAge
"
$tmpfile
"
)
data
=
$(
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
':'
)
typeset
-i
iLines
;
iLines
=
$iTotal
-
$iFrom
typeset
-i
iLinespermin
;
iLinespermin
=
$iLines
*
60/
$iAge
if
[
$iWarnLimit
-gt
0
-a
$iWarnLimit
-le
$iLinespermin
]
;
then
ph.setStatus
"warning"
fi
if
[
$iCriticalLimit
-gt
0
-a
$iCriticalLimit
-le
$iLinespermin
]
;
then
ph.setStatus
"critical"
fi
ph.perfadd
"lines-per-min"
"
${
iLinespermin
}
"
# output
ph.status
"Journallog stored
$iLinespermin
lines per min"
sLimits
=
""
test
$iWarnLimit
-gt
0
&&
sLimits+
=
"WARNING at
$iWarnLimit
"
test
$iWarnLimit
-gt
0
||
sLimits+
=
"No warning level"
sLimits+
=
"; "
test
$iCriticalLimit
-gt
0
&&
sLimits+
=
"CRITICAL at
$iCriticalLimit
"
test
$iCriticalLimit
-gt
0
||
sLimits+
=
"No critical level "
echo
"Limits:
$sLimits
"
# echo "Found $iLines new line(s) in the last $iAge sec"
fi
# cat "$tmpfile"
ph.exit
# ----------------------------------------------------------------------
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