I want create a script, running in a cron to perform a task that if some OpenVZ machine has a high load, it will be rebooted.
To do, I need get the last value of the CPU load of each VM. I get with this command:
vzlist -o ctid,laverage > loads.txt
CTID LAVERAGE
1001 0.00/0.00/0.00
1002 0.58/0.62/0.56
1009 0.00/0.00/0.00
1060 0.01/0.05/0.07
1063 0.00/0.03/0.00
1066 0.00/0.00/0.00
1072 0.00/0.00/0.00
1083 11.18/5.89/2.35
Now, I want select the 3th load value to put in a variable.
I have tried this code:
cat loads.txt | while read line; do
echo ${line:15:4}
done
but I have a problem with the last line, because I get the value
/2.3
Can anybody help me to put in a variable the number after the last / ??
Thanks
Try: