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 8823581
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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
3 changes: 2 additions & 1 deletion tests/openwisp2/settings.py
Original file line number Diff line number Diff line change
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 8823581

Please sign in to comment.