Skip to content

Commit

Permalink
Incorrect display of last_check field (#1075)
Browse files Browse the repository at this point in the history
Incorrect display of last_check field (#1075)
  • Loading branch information
wigor2206 authored Nov 2, 2024
1 parent 376dbb9 commit 7120dd5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-release-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ jobs:
- run: rm -rf ${{ env.repo_dir }}/${{ env.family }}/${{ env.release }}
- run: mkdir -p ${{ env.repo_dir }}/${{ env.family }}/${{ env.release }}
# if image defined by variable cr_image_version is not pullable aka does not exist it will be created and pushed
# only needed for fedora
- run: docker pull ${{ env.cr_image }}-${{ env.family }}-${{ env.cr_image_latest }}:${{ env.cr_image_version }} || /usr/bin/docker build -t ${{ env.cr_image }}-${{ env.family }}-${{ env.cr_image_latest }}:${{ env.cr_image_version }} -f build/docker/Dockerfile-${{ github.job }} .
- run: docker push ${{ env.cr_image }}-${{ env.family }}-${{ env.cr_image_latest }}:${{ env.cr_image_version }}
# copy *.rpm files into nagstamon-jekyll and create repodata
Expand Down
2 changes: 1 addition & 1 deletion Nagstamon/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class AppInfo(object):
contains app information previously located in GUI.py
"""
NAME = 'Nagstamon'
VERSION = '3.17-20241028'
VERSION = '3.17-20241102'
WEBSITE = 'https://nagstamon.de'
COPYRIGHT = '©2008-2024 Henri Wahl et al.'
COMMENTS = 'Nagios status monitor for your desktop'
Expand Down
18 changes: 14 additions & 4 deletions Nagstamon/Servers/IcingaDBWeb.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,14 @@ def _get_status(self):
self.new_hosts[host_name].status = self.STATES_MAPPING['hosts'][int(h['state']['soft_state'])]

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'])))
#self.new_hosts[host_name].last_check = datetime.datetime.fromtimestamp(int(float(h['state']['last_update'])))
utc_time = datetime.datetime.fromtimestamp(int(float(h['state']['last_update'])), tz=timezone.utc)
else:
self.new_hosts[host_name].last_check = datetime.datetime.fromisoformat(h['state']['last_update'])
#self.new_hosts[host_name].last_check = datetime.datetime.fromisoformat(h['state']['last_update'])
utc_time = datetime.datetime.fromisoformat(h['state']['last_update'])

local_time = utc_time.astimezone()
self.new_hosts[host_name].last_check = local_time.strftime("%Y-%m-%d %H:%M:%S") # format without microseconds and tz

self.new_hosts[host_name].attempt = "{}/{}".format(h['state']['check_attempt'],h['max_check_attempts'])
self.new_hosts[host_name].status_information = BeautifulSoup(str(h['state']['output']).replace('\n', ' ').strip(), 'html.parser').text
Expand Down Expand Up @@ -313,9 +318,14 @@ def _get_status(self):
self.new_hosts[host_name].services[service_name].status = self.STATES_MAPPING['services'][int(s['state']['soft_state'])]

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'])))
#self.new_hosts[host_name].services[service_name].last_check = datetime.datetime.fromtimestamp(int(float(s['state']['last_update'])))
utc_time = datetime.datetime.fromtimestamp(int(float(s['state']['last_update'])), tz=timezone.utc)
else:
self.new_hosts[host_name].services[service_name].last_check = datetime.datetime.fromisoformat(s['state']['last_update'])
#self.new_hosts[host_name].services[service_name].last_check = datetime.datetime.fromisoformat(s['state']['last_update'])
utc_time = datetime.datetime.fromisoformat(s['state']['last_update'])

local_time = utc_time.astimezone()
self.new_hosts[host_name].services[service_name].last_check = local_time.strftime("%Y-%m-%d %H:%M:%S") # format without microseconds and tz

self.new_hosts[host_name].services[service_name].attempt = "{}/{}".format(s['state']['check_attempt'],s['max_check_attempts'])
self.new_hosts[host_name].services[service_name].status_information = BeautifulSoup(str(s['state']['output']).replace('\n', ' ').strip(), 'html.parser').text
Expand Down
4 changes: 2 additions & 2 deletions build/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
nagstamon (3.17-20241028) unstable; urgency=low
nagstamon (3.17-20241102) unstable; urgency=low
* New upstream
- fix sound problem
- fix IncingaDBWeb

-- Henri Wahl <[email protected]> Mon, Oct 28 2024 08:00:00 +0200
-- Henri Wahl <[email protected]> Sat, Nov 02 2024 08:00:00 +0200

nagstamon (3.16.1) stable; urgency=low
* New upstream
Expand Down

0 comments on commit 7120dd5

Please sign in to comment.