Monitoring Extensions

Although this is not a FreePbx issue I wonder if someone on this forum might be able to help. I am looking for a way to monitor selected extensions (say every ten minutes) and to send an email if any of them go offline and perhaps an email when any of them come on line. I have googled around but could not find anything.