Trigger/Event on Reachable/Unreachable Peer

My goal is to be able to generate reports to determine when certain extensions are reachable and unreachable. I’d like to store this information in a DB so that it’ll be easy to lookup. So far, my best option is to write a script that will peridically parse through the logs looking up when extesnions become reachable and unreachable, but I don’t particularly care for going the “polling” route.

Are there any triggers or events that I can tie into when an extension’s reachability changes, for instance, have Asterisk kick off a command or script when an extension becomes reachable or unreachable?