mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Add latest frigate version to stats endpoints (#3038)
* Add latest version to stats in mqtt and http * Update json to include new field * Update to use requests * Don't use incorrect exception
This commit is contained in:
parent
35bd1de5ba
commit
58c32857d3
@ -110,7 +110,8 @@ Sample response:
|
||||
"service": {
|
||||
/* Uptime in seconds */
|
||||
"uptime": 10,
|
||||
"version": "0.8.0-8883709",
|
||||
"version": "0.10.1-8883709",
|
||||
"latest_version": "0.10.1",
|
||||
/* Storage data in MB for important locations */
|
||||
"storage": {
|
||||
"/media/frigate/clips": {
|
||||
|
@ -5,6 +5,7 @@ import time
|
||||
import psutil
|
||||
import shutil
|
||||
import os
|
||||
import requests
|
||||
|
||||
from frigate.config import FrigateConfig
|
||||
from frigate.const import RECORD_DIR, CLIPS_DIR, CACHE_DIR
|
||||
@ -13,11 +14,22 @@ from frigate.version import VERSION
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_latest_version() -> str:
|
||||
request = requests.get('https://api.github.com/repos/blakeblackshear/frigate/releases/latest')
|
||||
response = request.json()
|
||||
|
||||
if request.ok and response:
|
||||
return response.get("tag_name", "unknown").replace("v", "")
|
||||
else:
|
||||
return "unknown"
|
||||
|
||||
|
||||
def stats_init(camera_metrics, detectors):
|
||||
stats_tracking = {
|
||||
"camera_metrics": camera_metrics,
|
||||
"detectors": detectors,
|
||||
"started": int(time.time()),
|
||||
"latest_frigate_version": get_latest_version(),
|
||||
}
|
||||
return stats_tracking
|
||||
|
||||
@ -83,6 +95,7 @@ def stats_snapshot(stats_tracking):
|
||||
stats["service"] = {
|
||||
"uptime": (int(time.time()) - stats_tracking["started"]),
|
||||
"version": VERSION,
|
||||
"latest_version": stats_tracking["latest_frigate_version"],
|
||||
"storage": {},
|
||||
"temperatures": get_temperatures(),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user