From 03d3fde717873d5558baf9b7c06f5200ba7b4e5f Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Tue, 17 Dec 2024 11:14:08 +0100
Subject: [PATCH] reduce one log line per check

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

diff --git a/icinga-cli.sh b/icinga-cli.sh
index 60ef01f..3bd3d8e 100755
--- a/icinga-cli.sh
+++ b/icinga-cli.sh
@@ -295,6 +295,7 @@ function processCheck(){
 
   local iTsEnd;   typeset -i iTsEnd
   local iTsStart; typeset -i iTsStart
+  local httpcode; 
 
   iCheckStart=$(_getUnixTs)
 
@@ -392,7 +393,7 @@ function processCheck(){
 
       slot="$(_getName4Svcathost ${checkName} | sed 's# #%20#g')"
 
-      _log "${_logPrefix} starting POST of data to monitoring server"
+      # _log "${_logPrefix} starting POST of data to monitoring server"
       _echo POST actions/process-check-result?service=${MY_NAME}!${slot} "$data"
       _APIcall POST actions/process-check-result?service=${MY_NAME}!${slot} "$data"
       http.responseExport "$_response"
@@ -403,13 +404,13 @@ function processCheck(){
       fi
 
       # --- check if data were sent successfully
+      httpcode=$(http.getStatuscode)
       if http.isOk >/dev/null; then
-        _log "${_logPrefix} rc=$rc - OK, response was sent to Icinga"
+        _log "${_logPrefix} Icinga: $httpcode - POST of data was OK"
       else
-        local httpcode; httpcode=$(http.getStatuscode)
         _rc=$_rc+1
         case $httpcode in
-          404) _FoundErrors+="Icinga response $httpcode: host or service check was not created in Icinga yet ... " ;;
+          404) _FoundErrors+="Icinga: $httpcode: host or service check was not created in Icinga yet ... " ;;
           *)   _FoundErrors+="Icinga response was not sent to Icinga: $httpcode ... " ;;
         esac
         _echo
-- 
GitLab