Send email if route active

Hello, I’ve got a router with an LTE dongle for backup.

The router has two default routes. One (primary) with check-gateway=ping. And a secondary pointing toward the LTE gateway.

I’m trying to come up with a script that will check if the primary default route is active, And if it isn’t. It sends an email. This primary route is commented “VZ”. All of the failover portion works. I’m just looking for a way to alert us when it’s currently on the LTE backup. And this seems like the best way.

Can anyone point me in the right direction on how to write a script that does this?

Do you connect to a static IP on the other end of the LTE, or is it a dynamic one?

It’s dynamic on both the primary circuit, And the LTE backup (LTE is via a ppp client). Which is why I think monitoring which route is active, And emailing based on that is the best method.