-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Added WiFi Clients check to monitor AP load or inactivity
This new monitoring check generates alerts based on the number of WiFi clients connected to an access point. It supports two alert types: - **Maximum WiFi Clients**: Triggers when the total number of connected clients exceeds a predefined threshold, helping identify overloaded access points. - **Minimum WiFi Clients**: Triggers when an access point has zero clients for a prolonged period, indicating potential hardware issues or poor placement. The check is disabled by default. It can be enabled by changing the `OPENWISP_MONITORING_AUTO_WIFI_CLIENTS_CHECK` setting or added manually from the device page. A snooze schedule setting allows suppression of alerts during scheduled maintenance or holiday periods.
- Loading branch information
Showing
18 changed files
with
903 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from datetime import datetime | ||
|
||
from django.core.checks import Error, register | ||
|
||
from . import settings as app_settings | ||
|
||
|
||
@register() | ||
def check_wifi_clients_snooze_schedule(app_configs, **kwargs): | ||
errors = [] | ||
setting_name = 'OPENWISP_MONITORING_WIFI_CLIENTS_CHECK_SNOOZE_SCHEDULE' | ||
schedule = app_settings.WIFI_CLIENTS_CHECK_SNOOZE_SCHEDULE | ||
|
||
if not isinstance(schedule, (list, tuple)): | ||
errors.append( | ||
Error( | ||
'Invalid schedule format', | ||
hint='Schedule must be a list of date-time ranges', | ||
obj=setting_name, | ||
) | ||
) | ||
return errors | ||
|
||
for item in schedule: | ||
if not isinstance(item, (list, tuple)) or len(item) != 2: | ||
errors.append( | ||
Error( | ||
f'Invalid schedule entry format: {item}', | ||
hint='Each schedule entry must be a pair of start and end times', | ||
obj=setting_name, | ||
) | ||
) | ||
continue | ||
|
||
start, end = item | ||
if not isinstance(start, str) or not isinstance(end, str): | ||
errors.append( | ||
Error( | ||
f'Invalid time format: {item}', | ||
hint='Use format "MM-DD HH:MM", "MM-DD", or "HH:MM"', | ||
obj=setting_name, | ||
) | ||
) | ||
continue | ||
|
||
try: | ||
# Check if both are time format (HH:MM) | ||
if '-' not in start and '-' not in end: | ||
datetime.strptime(start, '%H:%M') | ||
datetime.strptime(end, '%H:%M') | ||
# Check if both are date format (MM-DD) | ||
elif ':' not in start and ':' not in end: | ||
datetime.strptime(start, '%m-%d') | ||
datetime.strptime(end, '%m-%d') | ||
# Check if both are date-time format (MM-DD HH:MM) | ||
elif len(start.split()) == 2 and len(end.split()) == 2: | ||
datetime.strptime(start, '%m-%d %H:%M') | ||
datetime.strptime(end, '%m-%d %H:%M') | ||
else: | ||
errors.append( | ||
Error( | ||
f'Inconsistent format: {item}', | ||
hint='Both start and end must be in the same format (either both time or both date)', | ||
obj=setting_name, | ||
) | ||
) | ||
except ValueError: | ||
errors.append( | ||
Error( | ||
f'Invalid date-time format: {item}', | ||
hint='Use format "MM-DD HH:MM", "MM-DD", or "HH:MM"', | ||
obj=setting_name, | ||
) | ||
) | ||
|
||
return errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .config_applied import ConfigApplied # noqa | ||
from .iperf3 import Iperf3 # noqa | ||
from .ping import Ping # noqa | ||
from .wifi_clients import WifiClients # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.