From 5db78f9490ad507e91b8e420036b189aa461c032 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Mon, 11 Oct 2021 13:19:13 +0200 Subject: [PATCH] check writable response file; output with _log instead of echo --- icinga-cli.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/icinga-cli.sh b/icinga-cli.sh index fa23402..5fe128b 100755 --- a/icinga-cli.sh +++ b/icinga-cli.sh @@ -314,19 +314,19 @@ function processCheck(){ eval $myFullscript $myparams > $_outfile rc=$? if [ ! -w $_outfile ]; then - echo "ERROR: file $_outfile is not writable. Maybe the setup is inclomplete or someone created a file as root... just guessing." - ls -ld ${dir_data} $_outfile - exit 1 + _log "${_logPrefix} ERROR: output file $_outfile is not writable." + _log "${_logPrefix} $( ls -ld ${dir_data} $_outfile )" + exit 1 fi typeset -i local iTsEnd=`date +%s` - outPerfdata=`grep '|' $_outfile | cut -f 2 -d '|'` + # outPerfdata=`grep '|' $_outfile | cut -f 2 -d '|'` echo echo -------- check output: cat $_outfile echo - echo -------- extracted performance data: - echo $outPerfdata - echo + # echo -------- extracted performance data: + # echo $outPerfdata + # echo _log "${_logPrefix} check command finished with returncode $rc" _rc=$_rc+$rc @@ -359,6 +359,11 @@ function processCheck(){ echo POST actions/process-check-result?service=${myHost}!${slot} "$data" _APIcall POST actions/process-check-result?service=${myHost}!${slot} "$data" http.responseExport "$_response" + if [ ! -w "$_response" ]; then + _log "${_logPrefix} ERROR: responsefile $_response is not writable." + _log "${_logPrefix} $( ls -ld ${dir_data} $_response )" + exit 1 + fi # --- check if data were sent successfully # fgrep "HTTP/1.1 200" ${_response} >/dev/null -- GitLab