In SMA there are long running runbooks which monitor or trigger other runbooks. These runbooks run in a loop and finish never. 
Because these runbooks are important to monitor, this sample MP contains a PowerShell alert rule which queries the SMA DB and checks if there is at least one instance running,
if not an alert is generated. This should provide you a starting point for further development and adjustents in your environment. 
For more details check the blog post