Correct timestamp on alert for terminal mode

This commit is contained in:
nicolargo 2023-11-05 09:53:44 +01:00
parent af49f970e3
commit dbbdc34bf0
4 changed files with 6 additions and 3 deletions

View File

@ -1,3 +1,3 @@
FROM nicolargo/glances:latest as glancesminimal
FROM glances:local-alpine-minimal as glancesminimal
COPY glances.conf /glances/conf/glances.conf
CMD python -m glances -C /glances/conf/glances.conf $GLANCES_OPT

Binary file not shown.

View File

@ -10,6 +10,8 @@
"""Alert plugin."""
from datetime import datetime
from time import tzname
import pytz
from glances.logger import logger
from glances.events import glances_events
@ -211,8 +213,8 @@ class PluginModel(GlancesPluginModel):
# New line
ret.append(self.curse_new_line())
# Start
# TODO: Related to #2591, manege TZ in order to make it work inside containers
msg = str(datetime.fromtimestamp(alert[0]))
msg = str(datetime.fromtimestamp(alert[0],
tz=pytz.timezone(tzname[0] if tzname[0] else 'UTC')))
ret.append(self.curse_add_line(msg))
# Duration
if alert[1] > 0:

View File

@ -4,3 +4,4 @@ packaging
ujson<4; python_version >= "3.5" and python_version < "3.6"
ujson<5; python_version >= "3.6" and python_version < "3.7"
ujson>=5.4.0; python_version >= "3.7"
pytz