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

Alerts showing different time than time plugin #2214

Closed
doopler opened this issue Dec 8, 2022 · 10 comments
Closed

Alerts showing different time than time plugin #2214

doopler opened this issue Dec 8, 2022 · 10 comments

Comments

@doopler
Copy link

doopler commented Dec 8, 2022

Describe the bug
warning or critical alerts displays time two hours before actual time

[Screenshots]
glances

Desktop (please complete the following information):

  • OS: Dietpi Debian 11
  • Glances Version Glances v3.3.0.4 with PsUtil v5.9.4
@nicolargo
Copy link
Owner

nicolargo commented Dec 12, 2022

Not reproduced on my computer with the latest Glances version (develop branch and 3.3.0.4):

image

Perhaps the issue came from the timezone... But in this case i should also have 1h of difference....

For maintainers, some issues related to the time zone: issue #1249 / #1337 / #1598

@nicolargo
Copy link
Owner

@doopler Can you provide the following information from a command line:

# python
>>> from datetime import datetime
>>> from time import tzname, strftime, mktime
>>> tzname
('CET', 'CEST')
>>> strftime('%Y-%m-%d %H:%M:%S %Z')
'2022-12-12 11:54:51 CET'
>>> datetime.fromtimestamp(mktime(datetime.now().timetuple())).strftime("%Y-%m-%d %H:%M:%S %Z")
'2022-12-12 11:54:53 '

Thanks !

@doopler
Copy link
Author

doopler commented Dec 13, 2022

Hi here is my info

>>> from datetime import datetime
>>> from time import tzname, strftime, mktime
>>> tzname
('IST', 'IDT')
>>> strftime('%Y-%m-%d %H:%M:%S %Z')
'2022-12-13 07:23:09 IST'
>>> datetime.fromtimestamp(mktime(datetime.now().timetuple())).strftime("%Y-%m-%d %H:%M:%S %Z")
'2022-12-13 07:23:28 '
>>>

@nicolargo
Copy link
Owner

@doopler can you test this issue with the latest version Glances 3.4.0.1 ?

@doopler
Copy link
Author

doopler commented May 18, 2023

yes of course. I'll keep you posted.
thanks

@doopler
Copy link
Author

doopler commented May 18, 2023

the bug is still present in v3.4.0.1 with PsUtil v5.9.5
Screenshot 2023-05-18 at 16 08 41

@nicolargo nicolargo changed the title alerts showing different time than Alerts showing different time than time plugin May 19, 2023
@nicolargo
Copy link
Owner

Create a GalncesDate method to deal with date:

Some tips:

>>> pytz.timezone('UTC')
<UTC>
>>> pytz.timezone('UTC')
<UTC>
>>> datetimepytz.timezone('UTC')
KeyboardInterrupt
>>> from datetime import datetime
>>> datetime.now()
datetime.datetime(2023, 10, 29, 10, 49, 14, 467967)
>>> datetime.now(tz=pytz.timezone('UTC'))
datetime.datetime(2023, 10, 29, 9, 50, 28, 924120, tzinfo=<UTC>)

@zuperjotmeil
Copy link

It seems that you need to add pytz library:
pip install pytz
or
apk add py3-tz

at least for me it works.

@zuperjotmeil
Copy link

apk add py3-tz py3-tzdata py3-tzlocal
This fix it for me

@nicolargo
Copy link
Owner

Another patch pushed on the develop branch.

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

No branches or pull requests

3 participants