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": {
|
"service": {
|
||||||
/* Uptime in seconds */
|
/* Uptime in seconds */
|
||||||
"uptime": 10,
|
"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 data in MB for important locations */
|
||||||
"storage": {
|
"storage": {
|
||||||
"/media/frigate/clips": {
|
"/media/frigate/clips": {
|
||||||
|
@ -5,6 +5,7 @@ import time
|
|||||||
import psutil
|
import psutil
|
||||||
import shutil
|
import shutil
|
||||||
import os
|
import os
|
||||||
|
import requests
|
||||||
|
|
||||||
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 +14,22 @@ from frigate.version import VERSION
|
|||||||
logger = logging.getLogger(__name__)
|
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):
|
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 +95,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