Skip to content

Commit

Permalink
[fix] Fixed iperf check execution if device connection not working #399
Browse files Browse the repository at this point in the history
- We need to check device_connection is_working just right after connect().
- because it may be possible that authentication (publickey) failed.
- or any other failure happened during connect().

Fixes #399
  • Loading branch information
Aryamanz29 committed Jun 23, 2022
1 parent 3918515 commit 016ea9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions openwisp_monitoring/check/classes/iperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ def check(self, store=True):
logger.warning(f'{device}: connection not properly set, Iperf skipped!')
return
device_connection.connect()
# We need to check device_connection is_working just right after connect().
# because it may be possible that authentication (publickey) failed.
# or any other failure happened during connect().
if not device_connection.is_working:
logger.warning(f'{device}: SSH connection is not working, Iperf skipped!')
return
servers = self._get_iperf_servers(device.organization.id)
command = f'iperf3 -c {servers[0]} -J'
res, exit_code = device_connection.connector_instance.exec_command(
Expand Down
5 changes: 3 additions & 2 deletions tests/openwisp2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
CELERY_BEAT_SCHEDULE = {
'run_checks': {
'task': 'openwisp_monitoring.check.tasks.run_checks',
'schedule': timedelta(minutes=5),
'schedule': timedelta(minutes=1),
'args': None,
'relative': True,
}
Expand Down Expand Up @@ -274,7 +274,8 @@
# Running on my local
# Some Public Iperf Servers : https://iperf.fr/iperf-servers.php#public-servers
# 'be63c4e5-a68a-4650-bfe8-733837edb8be': ['iperf.biznetnetworks.com'],
'a9734710-db30-46b0-a2fc-01f01046fe4f': ['speedtest.uztelecom.uz'],
# 'a9734710-db30-46b0-a2fc-01f01046fe4f': ['speedtest.uztelecom.uz'],
'a9734710-db30-46b0-a2fc-01f01046fe4f': ['192.168.5.109'],
# '<org-pk>': ['<ORG_IPERF_SERVER>']
}

Expand Down

0 comments on commit 016ea9f

Please sign in to comment.