Help with script please

Dear as they are, I need if you can guide me in a project I want to do, I have several branches with Mikrotik, in each I have contracted an MPLS link, a dedicated link or ADSL with which I create a VPN to have backup in case the MPLS fail, what I would like to do are automatic tests of the functioning of the links. I wanted to know if you can make a script that generates a file with tests, that makes a tracert to verify that it is coming out through the MPLS interface, after the MPLS interface goes out so that everything goes through the VPN link and generates a new tracert and that I sent the file to an Email address and that I again raise the MPLS interface.
This is feasible, it is very complicated to do.

regards

Sounds doable. I would suggest to hire a MT consultant for the implementation.