Latency trigger

Hello,
I need to do a script that, if a ping to an host is high, launch a script.

Is it possible?

Thanks,
Mario