Shashikant shah

Sunday 3 April 2016

Check Donwload speed on Linux server

#!/bin/bash
interface=eth1
speed_kbs=5100
path_tx="/sys/class/net/$interface/statistics/tx_bytes"
tmp="/tmp/LAN_status"
mailID="shashi.brain11@gmail.com"

$(rm -rf $tmp)
for time in 1 2 3;
do
        old_value=$(cat $path_tx)
        sleep 1
        new_value=$(cat $path_tx)

         TXBPS=$(expr $new_value - $old_value)
         TXKBPS=$(expr $TXBPS / 1024)

if [ $TXKBPS -gt $speed_kbs ];then
        $(echo "$TXKBPS" >> $tmp)
fi
done

if [ -f "$tmp" ];then
        count=$(wc -l < $tmp)
        echo "Donwload Speed Consume $TXKBPS kb/s on server " | mail -s "High Donwload speed used on server 100 " $mailID
fi

No comments:

Post a Comment