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