Check Channel Status

Dear all,

i have configured two Asterisk servers and configured Dundi on both servers. The two servers have also an external trunk.
I would like to setup a “system” that checks the latency of the Dundi channel and if it is too high Asterisk forwards the call through the external trunk.

Is there any way to do to it? Which solution do you suggest?

Thanks and best regards,
Davide