From 0b38df527b153fff9c90980e194fe49fcb0650ab Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Thu, 2 Nov 2023 15:53:52 +0100
Subject: [PATCH] fix quoting of perfdata in json

---
 icinga-cli.sh | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/icinga-cli.sh b/icinga-cli.sh
index 973b9df..b523605 100755
--- a/icinga-cli.sh
+++ b/icinga-cli.sh
@@ -22,11 +22,12 @@
 # 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  fix line breaks of sent output, shell check fixes
+# 2023-11-02  v0.18  ah  fix quoting of perfdata in json
 # ======================================================================
 
 
 _product="ICINGA PASSIVE CLIENT"
-_version="0.17"
+_version="0.18"
 _license="GNU GPL 3.0"
 _copyright='(c) Institute for Medical Education * University of Bern'
 
@@ -351,12 +352,12 @@ function processCheck(){
       #
       # --- extract performance data:
       #
-      if ! test -n "$outPerfdata" && echo "$outPerfdata" | grep "=[0-9\.]*;[0-9\.]*;[0-9\.]*;[0-9\.]*;" >/dev/null; then
-        _elog "WARNING - this does not look like performance data: $outPerfdata"
-        _elog "command was: $myFullscript $myparams"
-        _log "${_logPrefix} this does not look like performance data: $outPerfdata"
-        outPerfdata=""
-      fi
+      # if ! test -n "$outPerfdata" && echo "$outPerfdata" | grep "=[0-9\.]*;[0-9\.]*;[0-9\.]*;[0-9\.]*;" >/dev/null; then
+      #   _elog "WARNING - this does not look like performance data: $outPerfdata"
+      #   _elog "command was: $myFullscript $myparams"
+      #   _log "${_logPrefix} this does not look like performance data: $outPerfdata"
+      #   outPerfdata=""
+      # fi
       _log "${_logPrefix} check command finished with returncode $rc"
 
       _rc=$_rc+$rc
@@ -373,7 +374,7 @@ function processCheck(){
           ttl=$checkInterval                      \
           execution_start=$iTsStart               \
           execution_end=$iTsEnd                   \
-          performance_data="\"${outPerfdata}\""   \
+          performance_data="${outPerfdata}"   \
           plugin_output="""${_output}""" 
       )"
 
-- 
GitLab