Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#424 #426 #406 #435 #416 #391 #443

Added Iperf3 check to perform active measurements of the maximum achievable bandwidth.

Closes #385
Closes #390
Closes #398
Closes #399
Closes #406
Closes #405
Closes #412
Closes #414
Closes #417
Closes #418
Closes #422
Closes #424
Closes #426
Closes #406
Closes #435
Closes #416
Closes #391
Closes #443

Signed-off-by: Aryaman <[email protected]>
Co-authored-by: Federico Capoano <[email protected]>
Co-authored-by: Gagan Deep <[email protected]>
  • Loading branch information
nemesifier and pandafy committed Oct 20, 2022
1 parent 6b4621a commit d2a7dc8
Show file tree
Hide file tree
Showing 38 changed files with 4,218 additions and 80 deletions.
552 changes: 547 additions & 5 deletions README.rst

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions openwisp_monitoring/check/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ def _connect_signals(self):
sender=load_model('config', 'Device'),
dispatch_uid='auto_config_check',
)
if app_settings.AUTO_IPERF3:
from .base.models import auto_iperf3_check_receiver

post_save.connect(
auto_iperf3_check_receiver,
sender=load_model('config', 'Device'),
dispatch_uid='auto_iperf3_check',
)
44 changes: 43 additions & 1 deletion openwisp_monitoring/check/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
from jsonfield import JSONField

from openwisp_monitoring.check import settings as app_settings
from openwisp_monitoring.check.tasks import auto_create_config_check, auto_create_ping
from openwisp_monitoring.check.tasks import (
auto_create_config_check,
auto_create_iperf3_check,
auto_create_ping,
)
from openwisp_utils.base import TimeStampedEditableModel

from ...utils import transaction_on_commit
Expand Down Expand Up @@ -50,6 +54,13 @@ class Meta:
abstract = True
unique_together = ('name', 'object_id', 'content_type')

permissions = (
('add_check_inline', 'Can add check inline'),
('change_check_inline', 'Can change check inline'),
('delete_check_inline', 'Can delete check inline'),
('view_check_inline', 'Can view check inline'),
)

def __str__(self):
if not self.object_id or not self.content_type:
return self.name
Expand All @@ -60,6 +71,14 @@ def __str__(self):
def clean(self):
self.check_instance.validate()

def full_clean(self, *args, **kwargs):
# The name of the check will be the same as the
# 'check_type' chosen by the user when the
# name field is empty (useful for CheckInline)
if not self.name:
self.name = self.get_check_type_display()
return super().full_clean(*args, **kwargs)

@cached_property
def check_class(self):
"""
Expand All @@ -81,6 +100,11 @@ def perform_check(self, store=True):
"""
return self.check_instance.check(store=True)

def perform_check_delayed(self, duration=0):
from ..tasks import perform_check

perform_check.apply_async(args=[self.id], countdown=duration)


def auto_ping_receiver(sender, instance, created, **kwargs):
"""
Expand Down Expand Up @@ -116,3 +140,21 @@ def auto_config_check_receiver(sender, instance, created, **kwargs):
object_id=str(instance.pk),
)
)


def auto_iperf3_check_receiver(sender, instance, created, **kwargs):
"""
Implements OPENWISP_MONITORING_AUTO_IPERF3
The creation step is executed in the background
"""
# we need to skip this otherwise this task will be executed
# every time the configuration is requested via checksum
if not created:
return
transaction_on_commit(
lambda: auto_create_iperf3_check.delay(
model=sender.__name__.lower(),
app_label=sender._meta.app_label,
object_id=str(instance.pk),
)
)
1 change: 1 addition & 0 deletions openwisp_monitoring/check/classes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .config_applied import ConfigApplied # noqa
from .iperf3 import Iperf3 # noqa
from .ping import Ping # noqa
Loading

0 comments on commit d2a7dc8

Please sign in to comment.