Skip to content

Commit

Permalink
Attempt to fix the issue: (#1029)
Browse files Browse the repository at this point in the history
AttributeError with Icinga DB 1.2.0 / Icinga DB Web 1.1.2 #1028
Nagstamon Error: AttributeError: 'bool' object has no attribute 'replace'

Co-authored-by: Topi6 <[email protected]>
  • Loading branch information
ScHcSII and Topi6 authored May 3, 2024
1 parent bafe23f commit da6b4e7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Nagstamon/Servers/IcingaDBWeb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
self.new_hosts[host_name].scheduled_downtime = bool(int(h['state']['in_downtime'] or 0))

# extra Icinga properties to solve https://github.com/HenriWahl/Nagstamon/issues/192
Expand Down Expand Up @@ -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))
self.new_hosts[host_name].services[service_name].scheduled_downtime = bool(int(s['state']['in_downtime'] or 0))
self.new_hosts[host_name].services[service_name].unreachable = not bool(int(s['state']['is_reachable'] or 0))

Expand Down

0 comments on commit da6b4e7

Please sign in to comment.