From f0de509ded28b7264324b0233fe974abba2f5d15 Mon Sep 17 00:00:00 2001 From: ChaosCypher Date: Tue, 15 Jun 2021 15:43:15 -0400 Subject: [PATCH] add removal of down network interfaces --- bidir-traffic-check.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bidir-traffic-check.sh b/bidir-traffic-check.sh index 289aa80..2bc0df1 100755 --- a/bidir-traffic-check.sh +++ b/bidir-traffic-check.sh @@ -32,7 +32,7 @@ function getInterfaces () { fi } -# removes network interfaces that are in the ignore array +# removes network interfaces that are in the ignore array from the interfaces array function ignoreInterfaces() { if (( ${#IGNORE_INTERFACES[@]} >= 1 )); then for iface in "${IGNORE_INTERFACES[@]}"; do @@ -41,7 +41,16 @@ function ignoreInterfaces() { fi } -# function removeDownInterfaces () {} +# finds interfaces marked as down and removes them from the interfaces array +function removeDownInterfaces () { + for iface in "${INTERFACES[@]}"; do + if [[ -n "${iface}" ]]; then + if grep -q down "$iface/operstate"; then + INTERFACES=( "${INTERFACES[@]/*$iface/}" ) + fi + fi + done +} # function checkTraffic () { # } @@ -55,3 +64,4 @@ function ignoreInterfaces() { checkSudo getInterfaces ignoreInterfaces +removeDownInterfaces