-
-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Added check for WiFi Clients #623
Open
pandafy
wants to merge
18
commits into
master
Choose a base branch
from
wifi-client-check
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2bcb4d9
[feature] Added check for WiFi Clients
pandafy 36cfe74
[docs] Added docs
pandafy e4be79b
[chores] Fixed reference
pandafy c16f2c2
[req-changes] Changed "Client" > "Clients"
pandafy b6ab994
[skip ci][docs] Use single quotes
pandafy 179cbd2
[fix] Fixed time clause of InfluxQL query
pandafy eb6b66b
[revert][docs] Use single quotes
pandafy ddf6c4d
[fix] Improved Influxdb client's read method
pandafy ccaea8d
[fix] Fixed tolerance for min WiFi Clients alert
pandafy be57f52
[req-change] Allowed skipping check for time range
pandafy c976fb6
[req-changes] Modified logic for snoozing WiFi Clients check
pandafy 1ef1505
[chores] Added check for OPENWISP_MONITORING_WIFI_CLIENTS_CHECK_SNOOZ…
pandafy 0fc683e
[req-change] Changed evaluation criteria for WifiClients checks
pandafy d5b98b1
[chores] Added WifiClients to the celertybeat schedule
pandafy cfb0792
[change] Don't execute test for devices in critical health status
pandafy 9e50ba8
[req-changes] Fixed WifiClient check for sending alerts
pandafy b596049
[skip ci][req-changes] Updated docs
pandafy f664010
Merge branch 'master' into wifi-client-check
nemesifier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,6 +297,93 @@ check when running on multiple servers. Make sure it is always greater | |
than the total iperf3 check time, i.e. greater than the TCP + UDP test | ||
time. By default, it is set to **600 seconds (10 mins)**. | ||
|
||
.. _openwisp_monitoring_auto_wifi_clients_check: | ||
|
||
``OPENWISP_MONITORING_AUTO_WIFI_CLIENTS_CHECK`` | ||
----------------------------------------------- | ||
|
||
============ ========= | ||
**type**: ``bool`` | ||
**default**: ``False`` | ||
============ ========= | ||
|
||
This setting allows you to choose whether :ref:`WiFi Clients | ||
<wifi_clients_check>` checks should be created automatically for newly | ||
registered devices. It's disabled by default. | ||
|
||
.. _openwisp_monitoring_wifi_clients_check_snooze_schedule: | ||
|
||
``OPENWISP_MONITORING_WIFI_CLIENTS_CHECK_SNOOZE_SCHEDULE`` | ||
---------------------------------------------------------- | ||
|
||
============ ======== | ||
**type**: ``list`` | ||
**default**: ``[]`` | ||
============ ======== | ||
|
||
This setting allows you to configure date-time ranges when the :ref:`WiFi | ||
Clients <wifi_clients_check>` check should not be executed. The date-time | ||
ranges should be in the format ``(start_datetime, end_datetime)`` where | ||
both date-time are in the format ``MM-DD HH:MM`` (24 hours). Both start | ||
date and end date are inclusive. You can omit the date or time part as | ||
needed. | ||
|
||
E.g.: | ||
|
||
.. code-block:: python | ||
|
||
OPENWISP_MONITORING_WIFI_CLIENTS_CHECK_SNOOZE_SCHEDULE = [ | ||
# Date ranges spanning across months | ||
("12-24", "01-05"), | ||
# Single-day exclusion | ||
("01-26", "01-26"), | ||
# Daily exclusion between specific times | ||
("22:00", "06:00"), | ||
# Specific date and time range exclusion | ||
("08-15 12:00", "08-15 14:00"), | ||
] | ||
|
||
.. note:: | ||
|
||
**Date or Time Omission**: | ||
|
||
- If you omit the date, the time range will be considered for | ||
**every day**. | ||
- If you omit the time, the exclusion will apply to the **entire | ||
day**. | ||
|
||
.. _openwisp_monitoring_wifi_clients_max_check_interval: | ||
|
||
``OPENWISP_MONITORING_WIFI_CLIENTS_MAX_CHECK_INTERVAL`` | ||
------------------------------------------------------- | ||
|
||
============ ================== | ||
**type**: ``int`` | ||
**default**: ``5`` (in minutes) | ||
============ ================== | ||
|
||
Time period in minutes used by :ref:`WiFi Clients checks | ||
<wifi_clients_check>` to monitor the maximum number of connected clients. | ||
|
||
This determines how far back the check looks when evaluating the maximum | ||
client threshold. | ||
|
||
.. _openwisp_monitoring_wifi_clients_min_check_interval: | ||
|
||
``OPENWISP_MONITORING_WIFI_CLIENTS_MIN_CHECK_INTERVAL`` | ||
------------------------------------------------------- | ||
|
||
============ ============================ | ||
**type**: ``int`` | ||
**default**: ``4320`` (3 days in minutes) | ||
============ ============================ | ||
|
||
Time period in minutes used by :ref:`WiFi Clients checks | ||
<wifi_clients_check>` to monitor the minimum number of connected clients. | ||
|
||
This determines how far back the check looks when evaluating the minimum | ||
clients threshold. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here and we can spend a few words on why this is a lot higher. |
||
|
||
.. _openwisp_monitoring_auto_charts: | ||
|
||
``OPENWISP_MONITORING_AUTO_CHARTS`` | ||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this sentence is not really human friendly.
I think we should explain that we look for clients which have connected between now and the interval of minutes specified there of something like that.