scripting based on data rates.

I have two internet connections I1 and I2 on a mikrotik router and a network which access internet through I1 by default…
I want to run a script such that,it monitors the rate on I1 continuously and when the data rate through I1 becomes less then a certain limit, it should switch the connection and let the network use I2 …
And if rate exceeds the limit then it should switch to the default one-I1.

I m a beginner , please help…
thanx…

I think that using PCC would be do a better use of both links:

http://wiki.mikrotik.com/wiki/Manual:PCC#Application_Example_-_Load_Balancing