Update /health endpoint to be in local timezone

This commit is contained in:
Matthias
2022-01-28 07:57:43 +01:00
parent e72c3ec19f
commit 15d5389564
6 changed files with 14 additions and 8 deletions

View File

@@ -386,3 +386,4 @@ class SysInfo(BaseModel):
class Health(BaseModel):
last_process: datetime
last_process_ts: int

View File

@@ -10,6 +10,7 @@ from typing import Any, Dict, List, Optional, Tuple, Union
import arrow
import psutil
from dateutil.relativedelta import relativedelta
from dateutil.tz import tzlocal
from numpy import NAN, inf, int64, mean
from pandas import DataFrame
@@ -1031,7 +1032,10 @@ class RPC:
"ram_pct": psutil.virtual_memory().percent
}
def _health(self) -> Dict[str, str]:
def _health(self) -> Dict[str, Union[str, int]]:
last_p = self._freqtrade.last_process
return {
'last_process': str(self._freqtrade.last_process)
'last_process': str(last_p),
'last_process_loc': last_p.astimezone(tzlocal()).strftime(DATETIME_PRINT_FORMAT),
'last_process_ts': int(last_p.timestamp()),
}

View File

@@ -1319,8 +1319,7 @@ class Telegram(RPCHandler):
"""
try:
health = self._rpc._health()
message = f"Last process: `{health['last_process']}`"
logger.debug(message)
message = f"Last process: `{health['last_process_loc']}`"
self._send_msg(message)
except RPCException as e:
self._send_msg(str(e))