summaryrefslogtreecommitdiffstats
path: root/krebs/3modules
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2021-01-21 17:29:01 +0100
committertv <tv@krebsco.de>2021-01-21 17:31:26 +0100
commit1cd73df0c8694f491d40f93a796ea58f150e88dc (patch)
treec5a6b066e0c76d917e86560f2f92a5dca07db149 /krebs/3modules
parente2ed72a7802b0620bb1388a901b34e5a5fdc8a26 (diff)
krebs.backup fping: select fastest by elapsed time
Diffstat (limited to 'krebs/3modules')
-rw-r--r--krebs/3modules/backup.nix8
1 files changed, 6 insertions, 2 deletions
diff --git a/krebs/3modules/backup.nix b/krebs/3modules/backup.nix
index c0b218c15..910324f3c 100644
--- a/krebs/3modules/backup.nix
+++ b/krebs/3modules/backup.nix
@@ -226,10 +226,14 @@ let
# XXX Is one ping enough to determine fastest address?
fastest-address = host: ''
- { ${pkgs.fping}/bin/fping </dev/null -a \
+ { ${pkgs.fping}/bin/fping </dev/null -a -e \
${concatMapStringsSep " " shell.escape
(mapAttrsToList (_: net: head net.aliases) host.nets)} \
- | ${pkgs.coreutils}/bin/head -1; }
+ | ${pkgs.gnused}/bin/sed -r 's/^(\S+) \(([0-9.]+) ms\)$/\2\t\1/' \
+ | ${pkgs.coreutils}/bin/sort -n \
+ | ${pkgs.coreutils}/bin/cut -f2 \
+ | ${pkgs.coreutils}/bin/head -n 1
+ }
'';
in out