I had made a small bash script by which pps from a interface can be calculated. Once the incoming pps reach a desired limit then it executes a command.
I am getting an error while running the script can someone please help me
This is the script
#!/bin/bash
INTERVAL="1" # update interval in seconds
LIMIT="3000" # Limit in KB/S
URL1="http://1.1.1.1/abcd.php"
IFS=( ens3 ) # Interface names
while true
do
for i in "${IFS[@]}"
do
R1=$(cat /sys/class/net/$i/statistics/rx_packets)
T1=$(cat /sys/class/net/$i/statistics/tx_packets)
sleep $INTERVAL
R2=$(cat /sys/class/net/$i/statistics/rx_packets)
T2=$(cat /sys/class/net/$i/statistics/tx_packets)
TBPS=$(expr $T2 - $T1)
RBPS=$(expr $R2 - $R1)
echo "Incoming $i: $RKBPS pps || Outgoing $i: $TKBPS pps"
if (( $RKBPS > $LIMIT )); then
# Incoming Limit Exceeded
#bash $URL1
#sleep 10
curl $URL1
sleep 320
fi
done
done
Error I am getting as below
Incoming ens3: pps || Outgoing ens3: pps
./s.sh: line 22: ((: > 3000 : syntax error: operand expected (error token is "> 3000 ")
Incoming ens3: pps || Outgoing ens3: pps
./s.sh: line 22: ((: > 3000 : syntax error: operand expected (error token is "> 3000 ")
Incoming ens3: pps || Outgoing ens3: pps
./s.sh: line 22: ((: > 3000 : syntax error: operand expected (error token is "> 3000 ")
Incoming ens3: pps || Outgoing ens3: pps
./s.sh: line 22: ((: > 3000 : syntax error: operand expected (error token is "> 3000 ")
Incoming ens3: pps || Outgoing ens3: pps
./s.sh: line 22: ((: > 3000 : syntax error: operand expected (error token is "> 3000 ")
Incoming ens3: pps || Outgoing ens3: pps
./s.sh: line 22: ((: > 3000 : syntax error: operand expected (error token is "> 3000 ")
Incoming ens3: pps || Outgoing ens3: pps
./s.sh: line 22: ((: > 3000 : syntax error: operand expected (error token is "> 3000 ")
Incoming ens3: pps || Outgoing ens3: pps
./s.sh: line 22: ((: > 3000 : syntax error: operand expected (error token is "> 3000 ")
Incoming ens3: pps || Outgoing ens3: pps
./s.sh: line 22: ((: > 3000 : syntax error: operand expected (error token is "> 3000 ")
can someone please help me. T.I.A