mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 17:25:22 +03:00
Add latest version to stats in mqtt and http
This commit is contained in:
parent
923d07b1a4
commit
43c4e477bc
@ -2,9 +2,11 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
from urllib.error import URLError
|
||||||
import psutil
|
import psutil
|
||||||
import shutil
|
import shutil
|
||||||
import os
|
import os
|
||||||
|
from urllib.request import urlopen
|
||||||
|
|
||||||
from frigate.config import FrigateConfig
|
from frigate.config import FrigateConfig
|
||||||
from frigate.const import RECORD_DIR, CLIPS_DIR, CACHE_DIR
|
from frigate.const import RECORD_DIR, CLIPS_DIR, CACHE_DIR
|
||||||
@ -13,11 +15,25 @@ from frigate.version import VERSION
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def get_latest_version() -> str:
|
||||||
|
try:
|
||||||
|
raw = urlopen('https://api.github.com/repos/blakeblackshear/frigate/releases/latest')
|
||||||
|
response = json.load(raw)
|
||||||
|
|
||||||
|
if response:
|
||||||
|
return response.get("tag_name", "unknown").replace("v", "")
|
||||||
|
else:
|
||||||
|
return "unknown"
|
||||||
|
except URLError:
|
||||||
|
return "unknown"
|
||||||
|
|
||||||
|
|
||||||
def stats_init(camera_metrics, detectors):
|
def stats_init(camera_metrics, detectors):
|
||||||
stats_tracking = {
|
stats_tracking = {
|
||||||
"camera_metrics": camera_metrics,
|
"camera_metrics": camera_metrics,
|
||||||
"detectors": detectors,
|
"detectors": detectors,
|
||||||
"started": int(time.time()),
|
"started": int(time.time()),
|
||||||
|
"latest_frigate_version": get_latest_version(),
|
||||||
}
|
}
|
||||||
return stats_tracking
|
return stats_tracking
|
||||||
|
|
||||||
@ -83,6 +99,7 @@ def stats_snapshot(stats_tracking):
|
|||||||
stats["service"] = {
|
stats["service"] = {
|
||||||
"uptime": (int(time.time()) - stats_tracking["started"]),
|
"uptime": (int(time.time()) - stats_tracking["started"]),
|
||||||
"version": VERSION,
|
"version": VERSION,
|
||||||
|
"latest_version": stats_tracking["latest_frigate_version"],
|
||||||
"storage": {},
|
"storage": {},
|
||||||
"temperatures": get_temperatures(),
|
"temperatures": get_temperatures(),
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user