I read the bandwidth usage by ifstat
, which prints the download and upload into STDOUT
every second.
ifstat -i wlp7s0
wlp7s0
KB/s in KB/s out
1390.13 81.20
1039.14 74.05
1810.63 102.08
865.60 183.15
1272.91 274.19
1174.00 400.04
How can I run ifstat
in a bash script and read the values into variables for an if statement
to run a command if the values are smaller than an amount?
For example,
if [ $in -lt 100 ] && [ $out -lt 100 ]
then
echo Network is slow.
else
echo Network is fast.
fi
How can I read the output of ifstat
into $in
and $out
variables to check the if statement
every second?