Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix double URL encoding on macOS for IcingaDBWeb #1071

Merged
merged 5 commits into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions Nagstamon/Servers/IcingaDBWeb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down