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

Type issue #1029

Merged
merged 1 commit into from
May 3, 2024
Merged

Conversation

ScHcSII
Copy link
Contributor

@ScHcSII ScHcSII commented Apr 16, 2024

Hi

Attempt to fix the issue:
AttributeError with Icinga DB 1.2.0 / Icinga DB Web 1.1.2 #1028 Nagstamon Error: AttributeError: 'bool' object has no attribute 'replace'

First pull request ever so please review carefully.
Slightly modified two lines, my nagstamon works after the changes.

AttributeError with Icinga DB 1.2.0 / Icinga DB Web 1.1.2 HenriWahl#1028
Nagstamon Error: AttributeError: 'bool' object has no attribute 'replace'
@@ -220,7 +220,8 @@ def _get_status(self):
self.new_hosts[host_name].notifications_disabled = not int(h.get('notifications_enabled') or '0')
self.new_hosts[host_name].flapping = bool(int(h['state']['is_flapping'] or 0))
#s['state']['is_acknowledged'] can be null, 0, 1, or 'sticky'
self.new_hosts[host_name].acknowledged = bool(int(h['state']['is_acknowledged'].replace('sticky', '1') or 0))
#self.new_hosts[host_name].acknowledged = bool(int(h['state']['is_acknowledged'].replace('sticky', '1') or 0))
self.new_hosts[host_name].acknowledged = h['state']['is_acknowledged'] if isinstance(h['state']['is_acknowledged'], (bool)) else bool(int(h['state']['is_acknowledged'].replace('sticky', '1') or 0))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it work with bool instead of (bool) too?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me with the correction from @HenriWahl

@@ -323,7 +324,8 @@ def _get_status(self):
self.new_hosts[host_name].services[service_name].notifications_disabled = not int(s.get('notifications_enabled') or '0')
self.new_hosts[host_name].services[service_name].flapping = bool(int(s['state']['is_flapping'] or 0))
#s['state']['is_acknowledged'] can be null, 0, 1, or 'sticky'
self.new_hosts[host_name].services[service_name].acknowledged = bool(int(s['state']['is_acknowledged'].replace('sticky', '1') or 0))
#self.new_hosts[host_name].services[service_name].acknowledged = bool(int(s['state']['is_acknowledged'].replace('sticky', '1') or 0))
self.new_hosts[host_name].services[service_name].acknowledged = s['state']['is_acknowledged'] if isinstance(s['state']['is_acknowledged'], (bool)) else bool(int(s['state']['is_acknowledged'].replace('sticky', '1') or 0))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. 😄

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. 😄

@HenriWahl HenriWahl changed the base branch from master to fix_icinga_type_issue May 3, 2024 15:38
@HenriWahl HenriWahl merged commit da6b4e7 into HenriWahl:fix_icinga_type_issue May 3, 2024
@HenriWahl
Copy link
Owner

Please check latest release 3.15-20240503.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants