Forum Discussion
I've always been told that LM doesn't have the ability to take any action based on an alert. If there's a way to have LM issue a Start Service command, when it sees that one has stopped, I'd love to know how to do that.
In which scenario?
The first I was talking about is taking the action in the datasource. For example, you have a Powershell datasource that checks to see if a windows service is running and if it's not, it restarts the service. I see your point that it isn't really based on an alert, but it's still doable and I've used it in basic situations to pretty good success. You could create an alert about restarting the service if you wanted to track restarts. If you go this route, I'd recommend you check server uptime (you don't want to re-start the service if the server was just rebooted and it hasn't been up long enough for the service to start).
The second would be to create an alert rule and an integration (specific alerts send to a specific integration). The integration is either a http or email delivery. You'd need to code the endpoint for the integration to take an action based on the alert. For example, a lambda function in AWS.
Hope this helps. I'm sure you'll get other good (probably better) feedback.
Cheers!
- Kelemvor2 months agoExpert
Oh. So I could make a PowerShell source that would be a script to check if the service was running, and start it if it wasn't, all within the script. So LM wouldn't be doing anything other than running the check every X minutes. The script would get the status of the service and run a start if it wasn't working?
That's a near idea. Are there docs on how to create a PowerShell DataSource? hmm.
- befuddled2 months agoNeophyte
Yep. I've done pretty much exactly that in some places. LM would run the check every X minutes, check to see if the service is running, and return a value (e.g. 1) if it is running. If it is not running, it would attempt to restart the service and then check if it was successful, etc. You could also read in from a custom property which services you cared about.
There is a very knowledgeable user who posts a lot here (@Stuart Weenig). This is a link to his github where he does pretty much what we're talking about. Hope I'm not breaking any rules by posting it. Service_restart- Kelemvor2 months agoExpert
I just tried importing the file and got an error about an Applies To Function or something.
Any ideas?
Related Content
- 8 days ago