From f6918c9c951bc489bc2d607a67dde9f9312c112e Mon Sep 17 00:00:00 2001 From: Andrii Ivanov Date: Wed, 23 Oct 2024 17:12:05 +0300 Subject: [PATCH 1/2] fix: resolve double URL encoding issue on macOS --- Nagstamon/Servers/IcingaDBWeb.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Nagstamon/Servers/IcingaDBWeb.py b/Nagstamon/Servers/IcingaDBWeb.py index 3befe002..ed4ed023 100644 --- a/Nagstamon/Servers/IcingaDBWeb.py +++ b/Nagstamon/Servers/IcingaDBWeb.py @@ -736,18 +736,26 @@ def open_monitor(self, host, service=''): print("Cannot find {}::{}. Skipping!".format(host, service)) return - # only type is important so do not care of service '' in case of host monitor + # Generate the base path for the URL + base_path = urllib.parse.urlparse(self.monitor_url).path + + # Handle URL for host monitoring if service == '': - url = '{0}/icingadb/hosts?host.state.is_problem=y&sort=host.state.severity#!{1}/icingadb/host?{2}'.format(self.monitor_url, - (urllib.parse.urlparse(self.monitor_url).path), - urllib.parse.urlencode( - {'name': self.hosts[host].real_name}).replace('+', ' ')) + url = '{0}/icingadb/hosts?host.state.is_problem=y&sort=host.state.severity#!{1}/icingadb/host?{2}'.format( + self.monitor_url, + base_path, + urllib.parse.urlencode({'name': self.hosts[host].real_name}, quote_via=quote) + ) else: - url = '{0}/icingadb/services?service.state.is_problem=y&sort=service.state.severity%20desc#!{1}/icingadb/service?{2}'.format(self.monitor_url, - (urllib.parse.urlparse(self.monitor_url).path), - urllib.parse.urlencode( - {'name': self.hosts[host].services[service].real_name, - 'host.name': self.hosts[host].real_name}).replace('+', ' ')) + # Handle URL for service monitoring + url = '{0}/icingadb/services?service.state.is_problem=y&sort=service.state.severity%20desc#!{1}/icingadb/service?{2}'.format( + self.monitor_url, + base_path, + urllib.parse.urlencode({ + 'name': self.hosts[host].services[service].real_name, + 'host.name': self.hosts[host].real_name + }, quote_via=urllib.parse.quote) + ) if conf.debug_mode: self.debug(server=self.get_name(), host=host, service=service, debug='[Open monitor] Open host/service monitor web page {0}'.format(url)) From f5a43c0e99e1a13cd8054d0f660e91288be2f1bc Mon Sep 17 00:00:00 2001 From: Andrii Ivanov Date: Fri, 25 Oct 2024 12:41:07 +0300 Subject: [PATCH 2/2] fix: resolve double URL encoding issue on macOS --- Nagstamon/Servers/IcingaDBWeb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nagstamon/Servers/IcingaDBWeb.py b/Nagstamon/Servers/IcingaDBWeb.py index ed4ed023..8340d7c4 100644 --- a/Nagstamon/Servers/IcingaDBWeb.py +++ b/Nagstamon/Servers/IcingaDBWeb.py @@ -744,7 +744,7 @@ def open_monitor(self, host, service=''): url = '{0}/icingadb/hosts?host.state.is_problem=y&sort=host.state.severity#!{1}/icingadb/host?{2}'.format( self.monitor_url, base_path, - urllib.parse.urlencode({'name': self.hosts[host].real_name}, quote_via=quote) + urllib.parse.urlencode({'name': self.hosts[host].real_name}, quote_via=urllib.parse.quote) ) else: # Handle URL for service monitoring