Skip to content

Commit

Permalink
Fixing 4d3a851 that was using isnumeric on float
Browse files Browse the repository at this point in the history
  • Loading branch information
Tontonitch authored Nov 13, 2023
1 parent a9f40f5 commit 5ff59a0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Nagstamon/Servers/IcingaDBWeb.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def _get_status(self):
else:
self.new_hosts[host_name].status = self.STATES_MAPPING['hosts'][int(h['state']['soft_state'])]

if h['state']['last_update'].isnumeric(): # new version of icingadb doesnt return unix timestamp
if h['state']['last_update'].replace(".", "").isnumeric(): # new version of icingadb doesnt return unix timestamp
self.new_hosts[host_name].last_check = datetime.datetime.fromtimestamp(int(float(h['state']['last_update'])))
else:
self.new_hosts[host_name].last_check = datetime.datetime.fromisoformat(h['state']['last_update'])
Expand Down Expand Up @@ -237,7 +237,7 @@ def _get_status(self):
# extra duration needed for calculation
self.new_hosts[host_name].duration = 'n/a'
if h['state']['last_state_change'] is not None:
if h['state']['last_state_change'].isnumeric(): # new version of icingadb doesnt return unix timestamp
if h['state']['last_state_change'].replace(".", "").isnumeric(): # new version of icingadb doesnt return unix timestamp
duration = datetime.datetime.now() - datetime.datetime.fromtimestamp(int(float(h['state']['last_state_change'])))
else:
last_state_change = datetime.datetime.fromisoformat(h['state']['last_state_change'])
Expand Down Expand Up @@ -311,7 +311,7 @@ def _get_status(self):
else:
self.new_hosts[host_name].services[service_name].status = self.STATES_MAPPING['services'][int(s['state']['soft_state'])]

if s['state']['last_update'].isnumeric(): # new version of icingadb doesnt return unix timestamp
if s['state']['last_update'].replace(".", "").isnumeric(): # new version of icingadb doesnt return unix timestamp
self.new_hosts[host_name].services[service_name].last_check = datetime.datetime.fromtimestamp(int(float(s['state']['last_update'])))
else:
self.new_hosts[host_name].services[service_name].last_check = datetime.datetime.fromisoformat(s['state']['last_update'])
Expand Down Expand Up @@ -344,7 +344,7 @@ def _get_status(self):
# extra duration needed for calculation
self.new_hosts[host_name].services[service_name].duration = 'n/a'
if s['state']['last_state_change'] is not None:
if s['state']['last_update'].isnumeric(): # new version of icingadb doesnt return unix timestamp
if s['state']['last_update'].replace(".", "").isnumeric(): # new version of icingadb doesnt return unix timestamp
duration = datetime.datetime.now() - datetime.datetime.fromtimestamp(int(float(s['state']['last_state_change'])))
else:
last_state_change = datetime.datetime.fromisoformat(s['state']['last_state_change'])
Expand Down

0 comments on commit 5ff59a0

Please sign in to comment.