Hi,
I developed a script which finally originates a similar output:
net0:up,Tx=475198bps,Rx=31009bps net1:up,Tx=39596bps,Rx=35678bps
Of course the figures change and also the amount of interfaces (ex: could be more then net0 and net1). This is done automatically.
The next step i'm trying to achieve is to extract these figures and compare them with a value. if the figures are larger then the value then i originate an output like:
net0 Tx is higher then the threshold
However i cannot understand how to make the script intelligent enough to output which receive is (transmit OR receive is higher then the threshold specified AND also which interface or interfaces
I tried to use the for loop like:
TX=`sed 's/:up//g' test.txt | sed 's/bps//g' | awk -F',' '{print$2}' | cut -c4-`
RX=`sed 's/:up//g' test.txt | sed 's/bps//g' | awk -F',' '{print$3}' | cut -c4-`
for tx in $TX
do
if [[ $tx -gt 9 ]]; then
INT=`grep $tx test.txt | awk -F',' '{print$1}' | cut -f1 -d":"`
echo -n "$INT tx is higher then usual "
fi
done
for rx in $RX
do
if [[ $rx -ge 0 ]]; then
INT=`grep $rx test.txt | awk -F',' '{print$1}' | cut -f1 -d":"`
echo -n "$INT rx is higher then usual "
fi
done
But with this scenario i cannot make an efficient output that i might know that for example both Tx/Rx are high or one of the interfaces has a high Tx.
What i'm trying to achieve is an output similar to this:
The following interfaces has high Tx usage: net0
The following interfaces has both high Tx/Rx usage: net0 net1
The script developed is in bash.
Could you kindly give me some hints?
Rgds,
Matthew