First, thanks for the excellent plugin.
We have a few sites that are not getting a lot of traffic, this causes an issue for the plugin:
File "/usr/lib/nagios/plugins/check_unifi.py", line 297, in main() File "/usr/lib/nagios/plugins/check_unifi.py", line 293, in main fmt_output(check_site_stats(args)) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/nagios/plugins/check_unifi.py", line 228, in check_site_stats stats_wifi_exp = mean([item for item in ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/statistics.py", line 432, in mean raise StatisticsError('mean requires at least one data point') statistics.StatisticsError: mean requires at least one data point
If there are no data points, the mean calculation fails.
I've amended this with a try/catch, but maybe you see a more elegant solution:
Starting at line 227:
# Calculate WiFi Experiance
try:
stats_wifi_exp = mean([item for item in
[item.get('satisfaction')
for item in blob[1]['data']]
if item is not None])
except:
stats_wifi_exp = 100
Hey
First, thanks for the excellent plugin. We have a few sites that are not getting a lot of traffic, this causes an issue for the plugin:
File "/usr/lib/nagios/plugins/check_unifi.py", line 297, in main() File "/usr/lib/nagios/plugins/check_unifi.py", line 293, in main fmt_output(check_site_stats(args)) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/nagios/plugins/check_unifi.py", line 228, in check_site_stats stats_wifi_exp = mean([item for item in ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/statistics.py", line 432, in mean raise StatisticsError('mean requires at least one data point') statistics.StatisticsError: mean requires at least one data point
If there are no data points, the
mean
calculation fails.I've amended this with a try/catch, but maybe you see a more elegant solution:
Starting at line 227:
Thanks!