I have some devices around that I need to access remotely. As they are behind nat (most of them) and non of them have a static public ip, I've solved the remote access by having all of them setup as a vpn client, using a mikrotik hAP as a vpn server. Most of the devices uses pptp. (Those that supports sstp or ovpn uses those.) And those that does not support any vpn at all are placed behind a mikrotik that handles the vpn for them.
As these devices mostly uses mobile internet connection, the connections aren't very stable. They loose connection often, and they reconnect almost as often. The problem here is the word "almost". Each device has its own username at the vpn server.
So, I created a down script to run on the vpn server. This script sends me an email every time one of the devices disconnects..... Suddenly I got like 25-30 mails like that every day! So, to not have to manually check if each of the devices had reconnected, I created UP script emailing me every time the devices had reconnected. That gives me 60 mails each day! And often the connect-mail comes before the disconnect mail. There's so many mails that I don't notice if one of them has not reconnected. If they don't reconnect within seconds, very often they reconnects after a few hours. (I'm guessing mobile signal may be affected by weather.)
Is there any way to make the down script wait for a little while (15 minutes or so) before sending the email. And if the user reconnects, don't send it at all? Similar for the up script - if the "wait" time since disconnect is not up, don't send the mail. I would like to be notified if a user is logged out for more than 15 minutes, and I would like to get another mail when/if the user reconnects after I've received the disconnect mail.