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
539fedc7
Commit
539fedc7
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
fix broken pipe in journallog
parent
34e3e59f
No related branches found
No related tags found
1 merge request
!175
fix broken pipe in journallog
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/20_Checks/inc_pluginfunctions.md
+17
-0
17 additions, 0 deletions
docs/20_Checks/inc_pluginfunctions.md
inc_pluginfunctions
+17
-1
17 additions, 1 deletion
inc_pluginfunctions
with
34 additions
and
1 deletion
docs/20_Checks/inc_pluginfunctions.md
+
17
−
0
View file @
539fedc7
...
@@ -389,6 +389,23 @@ if [ $iWarnLimit -gt 0 -a $iCriticalLimit -gt 0 ]; then
...
@@ -389,6 +389,23 @@ if [ $iWarnLimit -gt 0 -a $iCriticalLimit -gt 0 ]; then
fi
fi
```
```
### ph.showtimer
Show a time in seconds and milliseconds since start (since source of inc_pluginfunctions.sh).
You can use it to show an execution time.
Syntax:
```
text
ph.showtimer
```
It has no parameters.
```
shell
2.410 sec
```
### ph.status
### ph.status
Show the current status (set by
``ph.setStatus``
) as Text.
Show the current status (set by
``ph.setStatus``
) as Text.
...
...
This diff is collapsed.
Click to expand it.
inc_pluginfunctions
+
17
−
1
View file @
539fedc7
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
# 2023-08-24 v1.12 <axel.hahn@unibe.ch> toUnit got 3rd param for count of digits after "."
# 2023-08-24 v1.12 <axel.hahn@unibe.ch> toUnit got 3rd param for count of digits after "."
# 2023-08-30 v1.13 <axel.hahn@unibe.ch> reverse return code in ph.hasParamoption to unix like return codes: 0=true; <>0 = false
# 2023-08-30 v1.13 <axel.hahn@unibe.ch> reverse return code in ph.hasParamoption to unix like return codes: 0=true; <>0 = false
# 2023-09-05 v1.14 <axel.hahn@unibe.ch> ph.require - show error below status line
# 2023-09-05 v1.14 <axel.hahn@unibe.ch> ph.require - show error below status line
# 2023-09-14 v1.15 <axel.hahn@unibe.ch> add ph.showtimer; fix broken pipe messages in journallog
# ======================================================================
# ======================================================================
...
@@ -51,6 +52,8 @@ typeset -i ph_cfg__EXIT_UNKNOWN=3
...
@@ -51,6 +52,8 @@ typeset -i ph_cfg__EXIT_UNKNOWN=3
typeset
-i
ph_cfg__EXIT_CODE
typeset
-i
ph_cfg__EXIT_CODE
ph_timer_start
=
$(
date
+%s.%N
)
declare
ph_perfdatafile
=
declare
ph_perfdatafile
=
# abort a check and exit with status "unknown"
# abort a check and exit with status "unknown"
...
@@ -72,6 +75,19 @@ function ph.require(){
...
@@ -72,6 +75,19 @@ function ph.require(){
fi
fi
}
}
# get time in sec and milliseconds since start
# no parameter is required
function
ph.showtimer
(){
local
timer_end
;
timer_end
=
$(
date
+%s.%N
)
local
totaltime
;
totaltime
=
$(
awk
"BEGIN {print
$timer_end
-
$ph_timer_start
}"
)
local
sec_time
;
sec_time
=
$(
echo
"
$totaltime
"
|
cut
-f
1
-d
"."
)
test
-z
"
$sec_time
"
&&
sec_time
=
0
local
ms_time
;
ms_time
=
$(
echo
"
$totaltime
"
|
cut
-f
2
-d
"."
|
cut
-c
1-3
)
echo
"
$sec_time
.
$ms_time
sec"
}
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# exit a check plugin
# exit a check plugin
function
ph.exit
(){
function
ph.exit
(){
...
@@ -311,7 +327,7 @@ function ph.toUnit(){
...
@@ -311,7 +327,7 @@ function ph.toUnit(){
local
_dots
local
_dots
test
$_digits
-gt
0
&&
_dots
=
$(
yes
"."
|
head
-
$_digits
|
tr
-d
"
\n
"
)
test
$_digits
-gt
0
&&
_dots
=
$(
yes
"."
2>/dev/null
|
head
-
$_digits
|
tr
-d
"
\n
"
)
test
$_digits
-gt
0
&&
_bc+
=
" -l | grep -o '.*
\\
.
${
_dots
}
'"
test
$_digits
-gt
0
&&
_bc+
=
" -l | grep -o '.*
\\
.
${
_dots
}
'"
echo
"
$(
echo
"
$_value
"
|
tr
-d
"[:alpha:]"
)
*
${
_multiply
}
/
$_divisor
"
|
eval
"
$_bc
"
|
sed
"s#^
\.
#0.#"
echo
"
$(
echo
"
$_value
"
|
tr
-d
"[:alpha:]"
)
*
${
_multiply
}
/
$_divisor
"
|
eval
"
$_bc
"
|
sed
"s#^
\.
#0.#"
...
...
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