Skip to content
This repository has been archived by the owner on Apr 19, 2021. It is now read-only.

Commit

Permalink
fix netsniff-ng packet loss info
Browse files Browse the repository at this point in the history
  • Loading branch information
weslambert committed Jun 20, 2018
1 parent 6f47a2c commit 162844b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bin/sostat
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,21 @@ if [ -d /nsm/sensor_data ] && [ $NUM_INTERFACES -gt 0 ]; then
fi
echo
echo "-------------------------------------------------------------------------"
if ls /var/log/nsm/*/netsniff-ng.log > /dev/null 2>&1; then
if ls /var/log/nsm/*/netsniff-ng.log > /dev/null 2>&1; then
echo
echo "${underline}Netsniff-NG${normal}:"
for i in /var/log/nsm/*/netsniff-ng.log;
do
if grep -q -e "-[1-9]*)" "$i"; then
echo
echo "This may take a second..."
echo
RCVD=()
DRPD=()
IFS=".(+"
while read -ra line;
for line in `cat "$i"`;
do
#echo $line
for word in "${line[@]}";
do
if [[ $word =~ ')' ]]; then
Expand All @@ -277,7 +280,7 @@ if [ -d /nsm/sensor_data ] && [ $NUM_INTERFACES -gt 0 ]; then
TOT_RCVD=`echo $rcvd_sum`

IFS="-"
while read -ra line;
for line in `cat "$i"`
do
for word in "${line[@]}";
do
Expand All @@ -289,18 +292,18 @@ if [ -d /nsm/sensor_data ] && [ $NUM_INTERFACES -gt 0 ]; then

IFS='+' drpd_sum=$(echo "scale=1;${DRPD[*]}"|bc)
TOT_DRPD=`echo $drpd_sum`
TOT_PKTS=`echo 'scale=2; '$TOT_DRPD'+'$TOT_RCVD''|bc`
TOT_PKTS=`echo 'scale=2; '$TOT_DRPD'+'$TOT_RCVD''|bc`
DRPD_PCT=`echo 'scale=2; '$TOT_DRPD'*100/'$TOT_PKTS''|bc`
echo
echo Percentage of packets dropped:
echo
echo $i " -- " $DRPD_PCT
echo
echo $i " -- " $DRPD_PCT
echo
else
echo
echo "0 Loss"
fi
done
done
fi
echo
header "PF_RING"
Expand Down

0 comments on commit 162844b

Please sign in to comment.