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

fix broken pipe in journallog

parent 34e3e59f
No related branches found
No related tags found
1 merge request!175fix broken pipe in journallog
...@@ -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.
......
...@@ -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.#"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment