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

fix line breaks of sent output

parent b84b89a2
No related branches found
No related tags found
1 merge request!30icinga client: fix line breaks of sent output
......@@ -21,6 +21,7 @@
# 2023-02-17 v0.14 ah add hostnamme into CFGSTORAGE
# 2023-02-17 v0.15 ah check inc_getconfig.sh exists and hostname -f has a value
# 2023-11-01 v0.16 ah generate json with "jo"
# 2023-11-02 v0.17 ah generate json with "jo"
# ======================================================================
......@@ -313,6 +314,8 @@ function processCheck(){
_log "${_logPrefix} INFO: every ${checkInterval} sec: ${checkCommand}"
local _outfile=${dir_data}/service__check__${checkName}__output.txt
local _output
local _FoundErrors
local _response=${dir_data}/service__check__${checkName}__icinga_response.txt
typeset -i local _rc=0
......@@ -361,12 +364,14 @@ function processCheck(){
_elog "${_logPrefix} $( ls -ld ${dir_data} $_outfile )"
exit 1
fi
test $rc -gt 0 && _FoundErrors+="Exitcode of check is $rc (greater zero).\n"
typeset -i local iTsEnd=`date +%s`
# outPerfdata=`grep '|' $_outfile | cut -f 2 -d '|'`
outPerfdata=`grep '|' $_outfile | rev | cut -f 1 -d '|' | rev`
_output="$( cat "$_outfile" )"
_echo
_echo -------- check output:
_echo $( cat "$_outfile" )
_echo "$_output"
iPipes=$( grep -o "|" < "$_outfile" | wc -l )
_echo "Pipe chars: $iPipes"
......@@ -397,7 +402,7 @@ function processCheck(){
commandAsJson="$(jq -nR --arg data """${myFullscript} $myparams""" '$data')"
outAsJson="$( jq -nR --arg data """${_output}""" '$data')"
local JSONPARAMS="
check_source=${MY_NAME}
......@@ -407,9 +412,8 @@ function processCheck(){
execution_start=$iTsStart
execution_end=$iTsEnd
performance_data="\"${outPerfdata}\""
plugin_output="\"$( cat "${_outfile}" )\""
"
plugin_output=$outAsJson
"
data=$( eval jo -p -d. $JSONPARAMS )
......@@ -434,6 +438,7 @@ function processCheck(){
else
_elog "${_logPrefix} rc=$rc - WARNING: $(http.getStatuscode) the check response was NOT sent to Icinga"
_rc=$_rc+1
_FoundErrors+="Response was not sent to Icinga."
_echo
_echo For Debugging:
_echo "$data"
......@@ -453,7 +458,7 @@ function processCheck(){
typeset -i local iCheckTime=$iCheckEnd-$iCheckStart
_log "${_logPrefix} finished after $iCheckTime sec with returncode $_rc"
test $_rc -eq 0 || (_echo; _echo " >>> Check ${checkName} was not OK. See Output block above!"; _echo; _echo)
test $_rc -eq 0 || (_echo; _echo "ERRORS: [${checkName}] $_FoundErrors"; _echo; _echo)
}
# ----------------------------------------------------------------------
# help
......@@ -546,6 +551,13 @@ function showVersion(){
. "$( dirname $0 )/inc_functions.sh"
if [ "$1" = "--version" ] || [ "$1" = "-v" ]; then
echo "$( basename $0) v$_version"
echo "$_license .. $_copyright"
exit 0
fi
_echo "
______________________________________________________________________________________
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment