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

date string issue #962

Closed
sebek72 opened this issue Aug 28, 2023 · 20 comments
Closed

date string issue #962

sebek72 opened this issue Aug 28, 2023 · 20 comments

Comments

@sebek72
Copy link

sebek72 commented Aug 28, 2023

Having issues with the latest 20230808 build.

monitor type: icingaDBWEB
backend:
icingaweb2.11.4+ (build from master from August)
icingadb 1.1.0
icingadb-web (master, pre 1.1.0)

DEBUG: 2023-08-28 12:37:00.660402 NEW PROD Start rechecking all DEBUG: 2023-08-28 12:37:02.245729 NEW PROD Refreshing all hosts and services DEBUG: 2023-08-28 12:37:02.876868 NEW PROD FetchURL: http://10.55.32.212:8080/icingadb/hosts?host.state.is_problem=y&host.state.state_type=hard&columns=host.state.last_update&format=json CGI Data: None ERROR: 2023-08-28 12:37:02.987765 NEW PROD Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/Nagstamon/Servers/IcingaDBWeb.py", line 211, in _get_status self.new_hosts[host_name].last_check = datetime.datetime.fromtimestamp(int(float(h['state']['last_update']))) ValueError: could not convert string to float: '2023-08-25T07:02:14.894+00:00'

P.S: older icingaweb2 (no icingadb) works ok.

@HenriWahl
Copy link
Owner

@jr-timme any idea?

@jr-timme
Copy link
Contributor

We don't build the Icinga packages ourselves, we're currently running the latest Versions from the Icinga Debian repository:

icingadb:
  Installed: 1.1.1-1+debian11
  Candidate: 1.1.1-1+debian11
  Version table:
 *** 1.1.1-1+debian11 500
        500 https://packages.icinga.com/debian icinga-bullseye/main amd64 Packages
        
icingadb-web:
  Installed: 1.0.2-1+debian11
  Candidate: 1.0.2-1+debian11
  Version table:
 *** 1.0.2-1+debian11 500
        500 https://packages.icinga.com/debian icinga-bullseye/main amd64 Packages

icingaweb2:
  Installed: 2.11.4-1+debian11
  Candidate: 2.11.4-1+debian11
  Version table:
 *** 2.11.4-1+debian11 500
        500 https://packages.icinga.com/debian icinga-bullseye/main amd64 Packages

So I can't really speak to the Master Branch version but with the versions from the official repository the icingadb module returns the last_update field as Milliseconds since the Unix Epoch, e.g.,

[...]
    "state": {
      [...]
      "last_update": "1695295061.506",
[...]

I don't really have any deeper knowledge of the Icinga Code, but it looks to me as that is still the case in the master Branch:
https://github.com/Icinga/icingadb/blob/c20f066bd87528960ec095c2e6fd88d014156b6c/pkg/icingadb/v1/state.go#L25
https://github.com/Icinga/icingadb/blob/c20f066bd87528960ec095c2e6fd88d014156b6c/schema/pgsql/schema.sql#L436
https://github.com/Icinga/icingadb/blob/c20f066bd87528960ec095c2e6fd88d014156b6c/schema/mysql/schema.sql#L322

How the icingaweb2 version could change that I don't know.

@sebek72 did you change anything in regard to the timestamps, so that they are already formatted instead of in Milliseconds since the Unix Epoch?

@sebek72
Copy link
Author

sebek72 commented Sep 22, 2023

Hi. Thanks for the feedback. I would not know where to change that :)
I tried to install previous icinga stack versions to see if there is an instance where this works (btw my icinga is deployed via docker), but also with 2.1.12 (with icingadb 1.1.0) it behaves the same.

mariadb output seems to be fine
MariaDB [icingadb]> SELECT last_update from service_state; +---------------+ | last_update | +---------------+ | 1695289781960 | | 1695289782390 | | 1695289782160 | | 1695289782661 |

@jr-timme
Copy link
Contributor

Could you check the raw json output, just to make sure that the date there is already formatted?

curl -v -l -b cookies.txt -c cookies.txt "http://10.55.32.212:8080/icingadb/hosts?host.state.is_problem=y&host.state.state_type=hard&columns=host.state.last_update&format=json" | jq

cookies can either be exported from a browser or generated through another curl in which you authenticate yourself

@sebek72
Copy link
Author

sebek72 commented Sep 22, 2023

This is the json output:

"last_update":"2023-09-21T09:49:38.753+00:00","last_state_change":"1970-01-01T00:00:00.000+00:00", "next_check":"2023-09-21T09:49:59.838+00:00", "next_update":"2023-09-21T09:50:21.846+00:00",

Update:
Also tried now with icingaweb2.12.0 (released) same output

@mzac
Copy link

mzac commented Oct 30, 2023

Just tired the update and still getting an error:

image

@DeadHunter
Copy link
Contributor

Sorry.. missed the host part. Working on it!

HenriWahl added a commit that referenced this issue Oct 31, 2023
fixed issue with date string in new icingadb version for host objects #962
HenriWahl pushed a commit that referenced this issue Oct 31, 2023
fix should be backwards compatible
fixed #962
@mzac
Copy link

mzac commented Nov 1, 2023

Sorry.. missed the host part. Working on it!

It works now thanks!

@sebek72
Copy link
Author

sebek72 commented Nov 3, 2023

I updated and now have a new issue.
ERROR: 2023-11-03 07:07:01.376042 NEW PROD Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/Nagstamon/Servers/IcingaDBWeb.py", line 214, in _get_status self.new_hosts[host_name].last_check = datetime.datetime.fromisoformat(h['state']['last_update']) AttributeError: type object 'datetime.datetime' has no attribute 'fromisoformat'

https://stackoverflow.com/questions/60266554/type-object-datetime-datetime-has-no-attribute-fromisoformat
Using EL8 platform where python3.6 is the default version available

@HenriWahl
Copy link
Owner

@sebek72 well, maybe the easiest fix is an update to EL9? Even Python 3.7 is out there for a while.

I saw that you can install python38, python39, python3.11 even in EL8 - maybe try it this way?

@HenriWahl
Copy link
Owner

@sebek72 how do you get it running at all? Looks like you need to do some special moves anyway?

@sebek72
Copy link
Author

sebek72 commented Nov 4, 2023

I will check how to use different python in EL8 (I took the EL8 src rpm and changed the spec file to re-create the EL8 rpm).
Now I also created a Debian docker image with embedded nagstamon to make it more portable.

Dockerfile

FROM debian:bullseye-slim

RUN ["bash", "-exo", "pipefail", "-c", "export DEBIAN_FRONTEND=noninteractive; apt-get update; apt-get install --no-install-{recommends,suggests} -y wget python3 python3-{pkg-resources,bs4,lxml,requests,requests-kerberos,psutil,pyqt5,keyring,ewmh,pyqt5.qtsvg,pyqt5.qtmultimedia,dbus.mainloop.pyqt5,dateutil} libqt5gui5 libqt5multimedia5-plugins sound-icons; apt-get clean; rm -vrf /var/lib/apt/lists/*; wget https://github.com/HenriWahl/Nagstamon/releases/download/latest/nagstamon_3.13-20231031_all.deb; dpkg -i nagstamon_3.13-20231031_all.deb; rm -rf nagstamon*"]

I am able to start it on MacOS (with XQuartz: https://gist.github.com/cschiewek/246a244ba23da8b9f0e7b11a68bf3285, for audio it is a bit tricky (with pulse audio), but on linux it should be more straightforward).

docker run -ti -e DISPLAY=host.docker.internal:0 -v /tmp/.X11-unix:/tmp/.X11-unix IMAGENAME:TAG nagstamon

@HenriWahl
Copy link
Owner

Hi @sebek72 - there is also a native binary for macOS - just in case.
Maybe you could find a way to update the currently outdated Flatpak package of Nagstamon at https://flathub.org/apps/de.ifw_dresden.nagstamon? I tried but failed hardly.

@HenriWahl
Copy link
Owner

Hi @sebek72 - just out of curiosity: did you try with https://github.com/mviereck/x11docker already? Looks like another solution.

@sebek72
Copy link
Author

sebek72 commented Nov 7, 2023

I know about it, but still need to test, thanks. Flatpak is something that I will not pursue ;)

HenriWahl pushed a commit that referenced this issue Nov 17, 2023
fix should be backwards compatible
fixed #962
@magenbrot
Copy link

Hi! Thank you for the work and the fix. Is it possible to release this any time soon?

@HenriWahl
Copy link
Owner

HenriWahl commented Nov 17, 2023

It is available as testing release 3.13-20231117 right now.

@sebek72
Copy link
Author

sebek72 commented Dec 4, 2023

Kinda in a dead lock....if I use python3.6 for EL8 I can create and run the rpm...but then have a fromisoformat issue (newer python needed).
If I try to use python3.8 then the keyring package (is not found. the installed one is for python3.6: https://rhel.pkgs.org/8/epel-x86_64/python3-keyring-21.5.0-2.el8.noarch.rpm.html).
I cannot find an alternative one.
Is there a way to get EL8 (Alma or Rocky) rpm for nagstamon like for other platforms?

@sebek72
Copy link
Author

sebek72 commented Dec 5, 2023

I have managed to create an el8 rpm using python3.8 But still have the date issue
File "/usr/lib/python3.8/site-packages/Nagstamon/Servers/IcingaDBWeb.py", line 214, in _get_status self.new_hosts[host_name].last_check = datetime.datetime.fromisoformat(h['state']['last_update']) AttributeError: type object 'datetime.datetime' has no attribute 'fromisoformat'

pip3 list | grep date
isodate 0.6.0
python-dateutil 2.8.2

@HenriWahl
Copy link
Owner

@sebek72 due to missing dependencies there was just added EL9 support.

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

No branches or pull requests

6 participants