На помощь приходит fping, который есть в почти любом репозитории. fping - это версия ping заточенная под использование в скриптах.
Вот пример его работы при пинге Яндекса сотней пакетов (дефисы будут означать, что ответ не получен):
fping -C 100 -q ya.ru
ya.ru : 62.43 61.16 61.66 61.86 61.61 61.94 62.17 61.52 61.38 61.22 61.88 61.15 61.51 61.96 61.23 61.33 61.60 61.87 62.06 61.28 60.91 61.02 61.62 61.79 61.04 61.17 62.05 63.16 61.76 60.92 62.13 61.45 61.36 61.17 64.97 61.35 61.57 61.80 62.23 62.67 62.03 61.54 61.57 61.67 62.13 61.28 61.12 61.79 61.64 61.56 61.58 61.87 61.23 62.13 61.06 61.66 61.72 61.67 61.81 61.77 61.84 61.35 61.27 61.34 61.71 62.01 61.57 61.81 62.91 62.35 62.41 61.53 62.20 61.87 61.25 61.47 61.97 70.70 61.67 61.49 61.52 61.56 62.72 61.27 61.28 61.90 61.78 62.12 61.44 62.68 61.97 61.55 61.06 61.00 61.75 63.16 62.72 61.42 61.26 62.00
Также можно убрать "тихий режим" посредством отключения флага -q и получить следующую, более читаемую человеком выдачу:
fping -C 10 ya.ru
ya.ru : [0], 96 bytes, 61.4 ms (61.4 avg, 0% loss)
ya.ru : [1], 96 bytes, 62.5 ms (62.0 avg, 0% loss)
ya.ru : [2], 96 bytes, 61.7 ms (61.9 avg, 0% loss)
ya.ru : [3], 96 bytes, 61.0 ms (61.6 avg, 0% loss)
ya.ru : [4], 96 bytes, 62.3 ms (61.8 avg, 0% loss)
ya.ru : [5], 96 bytes, 61.3 ms (61.7 avg, 0% loss)
ya.ru : [6], 96 bytes, 61.5 ms (61.7 avg, 0% loss)
ya.ru : [7], 96 bytes, 62.4 ms (61.8 avg, 0% loss)
ya.ru : [8], 96 bytes, 62.3 ms (61.8 avg, 0% loss)
ya.ru : [9], 96 bytes, 61.7 ms (61.8 avg, 0% loss)
ya.ru : 61.45 62.55 61.76 61.03 62.31 61.32 61.57 62.41 62.32 61.77
Также есть возможность пинговать несколько узлов одновременно:
fping -C 10 -q ya.ru google.com
ya.ru : 61.33 61.05 61.13 61.40 61.78 61.52 61.69 61.27 62.33 61.39
google.com : 17.12 16.80 17.59 17.38 17.13 17.52 17.08 16.87 17.69 17.09
В читаемом режиме это будет так:
fping -C 10 ya.ru google.com
google.com : [0], 92 bytes, 16.7 ms (16.7 avg, 0% loss)
ya.ru : [0], 96 bytes, 61.5 ms (61.5 avg, 0% loss)
google.com : [1], 92 bytes, 17.7 ms (17.2 avg, 0% loss)
ya.ru : [1], 96 bytes, 61.4 ms (61.4 avg, 0% loss)
google.com : [2], 92 bytes, 16.9 ms (17.1 avg, 0% loss)
ya.ru : [2], 96 bytes, 61.0 ms (61.3 avg, 0% loss)
google.com : [3], 92 bytes, 16.3 ms (16.9 avg, 0% loss)
ya.ru : [3], 96 bytes, 62.0 ms (61.5 avg, 0% loss)
google.com : [4], 92 bytes, 16.1 ms (16.7 avg, 0% loss)
ya.ru : [4], 96 bytes, 61.3 ms (61.4 avg, 0% loss)
google.com : [5], 92 bytes, 16.2 ms (16.7 avg, 0% loss)
ya.ru : [5], 96 bytes, 61.3 ms (61.4 avg, 0% loss)
google.com : [6], 92 bytes, 16.7 ms (16.7 avg, 0% loss)
ya.ru : [6], 96 bytes, 61.5 ms (61.4 avg, 0% loss)
google.com : [7], 92 bytes, 16.8 ms (16.7 avg, 0% loss)
ya.ru : [7], 96 bytes, 61.0 ms (61.4 avg, 0% loss)
google.com : [8], 92 bytes, 16.1 ms (16.6 avg, 0% loss)
ya.ru : [8], 96 bytes, 62.1 ms (61.5 avg, 0% loss)
google.com : [9], 92 bytes, 16.7 ms (16.6 avg, 0% loss)
ya.ru : [9], 96 bytes, 61.5 ms (61.5 avg, 0% loss)
ya.ru : 61.56 61.43 61.08 62.03 61.35 61.38 61.51 61.05 62.12 61.52
google.com : 16.77 17.76 16.96 16.35 16.12 16.28 16.72 16.87 16.15 16.79
No comments:
Post a Comment
Note: only a member of this blog may post a comment.