From 2bc21aa63f23b1a94f7a23272c4b17feea3a936f Mon Sep 17 00:00:00 2001 From: Christian Dresel Date: Tue, 28 Dec 2021 07:50:04 +0100 Subject: [PATCH] fff-layer3: Add latency to nodewatcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch add the latency to the nodewatcher data. The target of the ping can configure in /etc/config/fff Example: config latency 'latency' option ipv4 'ff1.zbau.f3netze.de' option ipv6 'ff1.zbau.f3netze.de' if no target is set, no latency is send. Signed-off-by: Christian Dresel Acked-by: Fabian Bläse --- .../files/usr/lib/nodewatcher.d/90-latency.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 src/packages/fff/fff-layer3/files/usr/lib/nodewatcher.d/90-latency.sh diff --git a/src/packages/fff/fff-layer3/files/usr/lib/nodewatcher.d/90-latency.sh b/src/packages/fff/fff-layer3/files/usr/lib/nodewatcher.d/90-latency.sh new file mode 100755 index 00000000..1011235d --- /dev/null +++ b/src/packages/fff/fff-layer3/files/usr/lib/nodewatcher.d/90-latency.sh @@ -0,0 +1,19 @@ +#!/bin/sh +ipv4dest=$(uci -q get fff.latency.ipv4) +ipv6dest=$(uci -q get fff.latency.ipv6) +if [ -n "$ipv4dest" ] || [ -n "$ipv6dest" ] ; then + printf "" + + if [ -n "$ipv4dest" ] ; then + ipv4latency=$(ping -qc3 -4 $ipv4dest 2>&1 | awk -F'/' 'END{ print (/^round-trip/? $4:"0") }') + printf "$ipv4latency$ipv4dest" + fi + + if [ -n "$ipv6dest" ] ; then + ipv6latency=$(ping -qc3 -6 $ipv6dest 2>&1 | awk -F'/' 'END{ print (/^round-trip/? $4:"0") }') + printf "$ipv6latency$ipv6dest" + fi + + printf "" +fi +exit 0