mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-06 05:27:44 +03:00
ruff formatting
This commit is contained in:
parent
4e443520f9
commit
dbf41890f8
@ -12,8 +12,8 @@ from prometheus_client.core import (
|
|||||||
|
|
||||||
class CustomCollector(object):
|
class CustomCollector(object):
|
||||||
def __init__(self, _url):
|
def __init__(self, _url):
|
||||||
self.complete_stats = {} # Store complete stats data
|
self.complete_stats = {} # Store complete stats data
|
||||||
self.process_stats = {} # Keep for CPU processing
|
self.process_stats = {} # Keep for CPU processing
|
||||||
self.previous_event_id = None
|
self.previous_event_id = None
|
||||||
self.previous_event_start_time = None
|
self.previous_event_start_time = None
|
||||||
self.all_events = {}
|
self.all_events = {}
|
||||||
@ -53,7 +53,7 @@ class CustomCollector(object):
|
|||||||
def collect(self):
|
def collect(self):
|
||||||
# Work with a copy of the complete stats
|
# Work with a copy of the complete stats
|
||||||
stats = self.complete_stats.copy()
|
stats = self.complete_stats.copy()
|
||||||
|
|
||||||
# Create a local copy of CPU usages to work with
|
# Create a local copy of CPU usages to work with
|
||||||
cpu_usages = {}
|
cpu_usages = {}
|
||||||
try:
|
try:
|
||||||
@ -146,7 +146,14 @@ class CustomCollector(object):
|
|||||||
cpu_usages,
|
cpu_usages,
|
||||||
)
|
)
|
||||||
self.add_metric_process(
|
self.add_metric_process(
|
||||||
cpu_usages_metric, camera_stats, camera_name, "pid", "detect", "cpu", "Camera", cpu_usages
|
cpu_usages_metric,
|
||||||
|
camera_stats,
|
||||||
|
camera_name,
|
||||||
|
"pid",
|
||||||
|
"detect",
|
||||||
|
"cpu",
|
||||||
|
"Camera",
|
||||||
|
cpu_usages,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.add_metric_process(
|
self.add_metric_process(
|
||||||
@ -170,7 +177,14 @@ class CustomCollector(object):
|
|||||||
cpu_usages,
|
cpu_usages,
|
||||||
)
|
)
|
||||||
self.add_metric_process(
|
self.add_metric_process(
|
||||||
mem_usages, camera_stats, camera_name, "pid", "detect", "mem", "Camera", cpu_usages
|
mem_usages,
|
||||||
|
camera_stats,
|
||||||
|
camera_name,
|
||||||
|
"pid",
|
||||||
|
"detect",
|
||||||
|
"mem",
|
||||||
|
"Camera",
|
||||||
|
cpu_usages,
|
||||||
)
|
)
|
||||||
|
|
||||||
yield audio_dBFS
|
yield audio_dBFS
|
||||||
@ -252,7 +266,7 @@ class CustomCollector(object):
|
|||||||
stats["detectors"],
|
stats["detectors"],
|
||||||
detector_name,
|
detector_name,
|
||||||
"pid",
|
"pid",
|
||||||
"detect",
|
"detect",
|
||||||
"cpu",
|
"cpu",
|
||||||
"Detector",
|
"Detector",
|
||||||
cpu_usages,
|
cpu_usages,
|
||||||
@ -494,10 +508,10 @@ def update_metrics(stats):
|
|||||||
try:
|
try:
|
||||||
# Store the complete stats for later use by collect()
|
# Store the complete stats for later use by collect()
|
||||||
collector.complete_stats = stats.copy()
|
collector.complete_stats = stats.copy()
|
||||||
|
|
||||||
# For backwards compatibility
|
# For backwards compatibility
|
||||||
collector.process_stats = stats.copy()
|
collector.process_stats = stats.copy()
|
||||||
|
|
||||||
# No need to call collect() here - it will be called by get_metrics()
|
# No need to call collect() here - it will be called by get_metrics()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error updating metrics: {e}")
|
logging.error(f"Error updating metrics: {e}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user