it's not part of network manager - but network manager uses 'ifupdown' to connect the internet, and ifupdown let you run scripts on connecting (turning interface up) or disconnecting (turning the interface down)
all you should do is to put your script in one of the following directories under /etc/network/:
if-pre-up.d/ - to be run before connecting
if-up.d/ - to be run after getting connected
if-down.d/ - to be run before disconnecting
if-post-down.d/ - to be run after getting disconnected
it does not do the exact thing i were looking for - as it do not detect problems and run the script only afterward - but since I do not care for the script to be run more times - i've put it in
if-pre-up.d, so it runs before each time I connect the internet.