Script to check connection

Hello,

i need script that ping google ( 8.8.8.8 ) and at the moment that what no longer happens, the “distance” of my interface (ether 2.15) change.

Anyone can help me?

Thanks

Use Netwatch!