Skip to content

Commit

Permalink
[chores] Added more descriptive log warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Aryamanz29 committed Jun 24, 2022
1 parent f83d3c6 commit fcb0224
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions openwisp_monitoring/check/classes/iperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ def check(self, store=True):
device = self.related_object
device_connection = self._get_device_connection(device)
if not device_connection:
logger.warning(f'{device}: connection not properly set, Iperf skipped!')
logger.warning(
f'"DeviceConnection is not properly set for "{device}", iperf check 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!')
# The DeviceConnection could fail if the management tunnel is down.
if not device_connection.connect():
logger.warning(
f'Failed to get a working DeviceConnection for "{device}", iperf check skipped!'
)
return
servers = self._get_iperf_servers(device.organization.id)
command = f'iperf3 -c {servers[0]} -J'
Expand Down

0 comments on commit fcb0224

Please sign in to comment.