From 8e749f6aee36a9a51424e0d14f4ee794aef5b671 Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Thu, 29 Nov 2018 20:22:43 -0500 Subject: [PATCH] Bro - Add cron for checking PL --- salt/common/telegraf/scripts/broloss.sh | 15 ++++++++++----- salt/common/telegraf/scripts/suriloss.sh | 16 ++++++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/salt/common/telegraf/scripts/broloss.sh b/salt/common/telegraf/scripts/broloss.sh index ea5e305a1..a7bec4dc1 100644 --- a/salt/common/telegraf/scripts/broloss.sh +++ b/salt/common/telegraf/scripts/broloss.sh @@ -5,8 +5,13 @@ declare RESULT=($BROLOG) CURRENTDROP=${RESULT[3]} PASTDROP=${RESULT[9]} DROPPED=$(($CURRENTDROP - $PASTDROP)) -CURRENTPACKETS=${RESULT[5]} -PASTPACKETS=${RESULT[11]} -TOTAL=$(($CURRENTPACKETS - $PASTPACKETS)) -LOSS=$(echo $DROPPED $TOTAL / p | dc) -echo "brodrop drop=$LOSS" +if [ $DROPPED == 0 ]; then + LOSS=0 + echo "brodrop drop=0" +else + CURRENTPACKETS=${RESULT[5]} + PASTPACKETS=${RESULT[11]} + TOTAL=$(($CURRENTPACKETS - $PASTPACKETS)) + LOSS=$(echo $DROPPED $TOTAL / p | dc) + echo "brodrop drop=$LOSS" +fi diff --git a/salt/common/telegraf/scripts/suriloss.sh b/salt/common/telegraf/scripts/suriloss.sh index 8ad84ef7c..acfb8c214 100644 --- a/salt/common/telegraf/scripts/suriloss.sh +++ b/salt/common/telegraf/scripts/suriloss.sh @@ -9,13 +9,17 @@ if [ $CHECKIT == 2 ]; then CURRENTDROP=${RESULT[4]} PASTDROP=${RESULT[14]} DROPPED=$(($CURRENTDROP - $PASTDROP)) + if [ $DROPPED == 0 ]; then + LOSS=0 + echo "suridrop drop=0" + else + CURRENTPACKETS=${RESULT[9]} + PASTPACKETS=${RESULT[19]} + TOTAL=$(($CURRENTPACKETS - $PASTPACKETS)) - CURRENTPACKETS=${RESULT[9]} - PASTPACKETS=${RESULT[19]} - TOTAL=$(($CURRENTPACKETS - $PASTPACKETS)) - - LOSS=$(echo $DROPPED $TOTAL / p | dc) - echo "suridrop drop=$LOSS" + LOSS=$(echo $DROPPED $TOTAL / p | dc) + echo "suridrop drop=$LOSS" + fi else echo "suridrop drop=0" fi