diff --git a/monkey/infection_monkey/network_scanning/ping_scanner.py b/monkey/infection_monkey/network_scanning/ping_scanner.py index e286be2b2..66ae79b2a 100644 --- a/monkey/infection_monkey/network_scanning/ping_scanner.py +++ b/monkey/infection_monkey/network_scanning/ping_scanner.py @@ -80,4 +80,5 @@ def _build_ping_command(host: str, timeout: float): ping_count_flag = "-n" if "win32" == sys.platform else "-c" ping_timeout_flag = "-w" if "win32" == sys.platform else "-W" - return ["ping", ping_count_flag, "1", ping_timeout_flag, str(timeout), host] + # on older version of ping the timeout must be an integer, thus we use ceil + return ["ping", ping_count_flag, "1", ping_timeout_flag, str(math.ceil(timeout)), host] diff --git a/monkey/tests/unit_tests/infection_monkey/network_scanning/test_ping.py b/monkey/tests/unit_tests/infection_monkey/network_scanning/test_ping.py index 45cd523b4..37e365682 100644 --- a/monkey/tests/unit_tests/infection_monkey/network_scanning/test_ping.py +++ b/monkey/tests/unit_tests/infection_monkey/network_scanning/test_ping.py @@ -1,3 +1,4 @@ +import math import subprocess from unittest.mock import MagicMock @@ -172,4 +173,4 @@ def test_linux_timeout(assert_expected_timeout): timeout_flag = "-W" timeout = 1.42379 - assert_expected_timeout(timeout_flag, timeout, str(timeout)) + assert_expected_timeout(timeout_flag, timeout, str(math.ceil(timeout)))