From 98c9c1b0d6d7f261f26a58a7561b2f7b63fd6c1a Mon Sep 17 00:00:00 2001 From: Benoit Poulet Date: Tue, 26 Sep 2023 17:14:18 +0200 Subject: [PATCH] Fixes for Nag. 3.13 and Centreon 23.04 --- Nagstamon/Servers/Centreon/CentreonAPI.py | 27 ++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Nagstamon/Servers/Centreon/CentreonAPI.py b/Nagstamon/Servers/Centreon/CentreonAPI.py index ee50a635c..eee1343b6 100644 --- a/Nagstamon/Servers/Centreon/CentreonAPI.py +++ b/Nagstamon/Servers/Centreon/CentreonAPI.py @@ -78,7 +78,7 @@ def init_config(self): # check if any error occured errors_occured = self.check_for_error(data, error, status_code) - if errors_occured is not False: + if errors_occured is not None: return (errors_occured) self.centreon_version_major = int(data["web"]["major"]) @@ -95,8 +95,10 @@ def init_config(self): # RestAPI version if self.centreon_version_major == 21: self.restapi_version = "latest" - else: + elif self.centreon_version_major == 22: self.restapi_version = "v22.04" + else: + self.restapi_version = "v23.04" if conf.debug_mode is True: self.Debug(server='[' + self.get_name() + ']', debug='Centreon API version used : ' + self.restapi_version) @@ -160,7 +162,7 @@ def get_token(self): # check if any error occured errors_occured = self.check_for_error(data, error, status_code) - if errors_occured is not False: + if errors_occured is not None: return (errors_occured) token = data["security"]["token"] @@ -195,7 +197,7 @@ def GetHost(self, host): # check if any error occured errors_occured = self.check_for_error(data, error, status_code) - if errors_occured is not False: + if errors_occured is not None: return (errors_occured) fqdn = str(data["result"][0]["fqdn"]) @@ -230,7 +232,7 @@ def get_host_and_service_id(self, host, service=''): # check if any error occured errors_occured = self.check_for_error(data, error, status_code) - if errors_occured is not False: + if errors_occured is not None: return (errors_occured) host_id = data["result"][0]["id"] @@ -264,7 +266,7 @@ def get_host_and_service_id(self, host, service=''): # check if any error occured errors_occured = self.check_for_error(data, error, status_code) - if errors_occured is not False: + if errors_occured is not None: return (errors_occured) if host == "Meta_Services": @@ -334,7 +336,7 @@ def _get_status(self): # check if any error occured errors_occured = self.check_for_error(data, error, status_code) - if errors_occured is not False: + if errors_occured is not None: return (errors_occured) if data["meta"]["total"] == 0: @@ -391,7 +393,7 @@ def _get_status(self): # check if any error occured errors_occured = self.check_for_error(data, error, status_code) - if errors_occured is not False: + if errors_occured is not None: return (errors_occured) if data["meta"]["total"] == 0: @@ -549,6 +551,15 @@ def _set_recheck(self, host, service): ] } + # This new parameter was added in 23.04 + if self.restapi_version == "v23.04": + property_to_add = { + "check": { + "is_forced": True + } + } + rechecks.update(property_to_add) + try: # Host if service == '':