fix bandwidth stats

main
Rhys Bailey 2024-03-11 23:20:53 +11:00
parent 54bec9c602
commit 9b4af20584
1 changed files with 25 additions and 26 deletions

View File

@ -109,6 +109,31 @@ class CustomCollector(object):
yield process_fps yield process_fps
yield skipped_fps yield skipped_fps
# bandwidth stats
bandwidth_usages = GaugeMetricFamily('frigate_bandwidth_usages_kBps', 'bandwidth usages kilobytes per second', labels=['pid', 'name', 'process', 'cmdline'])
try:
for b_pid, b_stats in stats['bandwidth_usages'].items():
label = [b_pid] # pid label
try:
n = stats['cpu_usages'][b_pid]['cmdline']
for p_name, p_stats in stats['processes'].items():
if str(p_stats['pid']) == b_pid:
n = p_name
break
# new frigate:0.13.0-beta3 stat 'cmdline'
label.append(n) # name label
label.append(stats['cpu_usages'][b_pid]['cmdline']) # process label
label.append(stats['cpu_usages'][b_pid]['cmdline']) # cmdline label
add_metric(bandwidth_usages, label, b_stats, 'bandwidth')
except KeyError:
pass
except KeyError:
pass
yield bandwidth_usages
# detector stats # detector stats
try: try:
yield GaugeMetricFamily('frigate_detection_total_fps', yield GaugeMetricFamily('frigate_detection_total_fps',
@ -260,32 +285,6 @@ class CustomCollector(object):
yield storage_total yield storage_total
yield storage_used yield storage_used
# bandwidth stats
bandwidth_usages = GaugeMetricFamily('frigate_bandwidth_usages_kBps', 'bandwidth usages kilobytes per second', labels=['pid', 'name', 'process', 'type', 'cmdline'])
try:
for b_pid, b_stats in stats['bandwidth_usages'].items():
label = [b_pid] # pid label
try:
n = stats['cpu_usages'][b_pid]['cmdline']
for p_name, p_stats in stats['processes'].items():
if str(p_stats['pid']) == b_pid:
n = p_name
break
# new frigate:0.13.0-beta3 stat 'cmdline'
label.append(n) # name label
label.append(stats['cpu_usages'][b_pid]['cmdline']) # process label
label.append('Other') # type label
label.append(stats['cpu_usages'][b_pid]['cmdline']) # cmdline label
add_metric(bandwidth_usages, label, b_stats, 'bandwidth')
except KeyError:
pass
except KeyError:
pass
yield bandwidth_usages
# count events # count events
events = [] events = []
try: try: