If you have deployed agents to your machines and have no WMI/SNMP polling for your servers. Also if you are struggling with executing external program to restart a service. Moreover, If you are getting errors such as code 1 or 2 or others when following the following procedures.
and
or you are seeing the result of you trigger action as successful but still the services are not restarting: Follow the following manual process:
1) Go through the following link first: it tells you more about how to create a custom script
Using the Linux Agent communication as an Alert Action to kick off script
2) Create a new template : This template will then restart a service on machines when assigned to nodes.
3) Add a component (service) you want to monitor (you can do it for windows and also there is a template for Linux)
4) I personally created a VBS script. USE CHATGPT if you are struggling like i did
The script was as follow:
' VBScript to restart Active Directory Domain Services if it's down (without server name)
Dim objService
Dim serviceName
' Service details
serviceName = "Active Directory Domain Services"
' Create a WMI object to interact with the local computer
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
' Get the service object for the Active Directory Domain Services
Set objService = objWMIService.ExecQuery("Select * from Win32_Service where Name = '" & serviceName & "'")
' Loop through the results (should be only one service in this case)
For Each service In objService
' If the service is not running, restart it
If service.State <> "Running" Then
' Restart the service (Stop and Start)
service.StopService
WScript.Sleep 2000 ' Wait 2 seconds before starting the service again
service.StartService
WScript.Echo "Active Directory Domain Services restarted successfully"
Else
WScript.Echo "Active Directory Domain Services is already running"
End If
Next
5) Submit the script in your template and create the template (Remember the template ID)- You will later use it in your alert trigger action
6) Go to your main orion server and copy the script from this link to your server. (the link has an attachment in it-just download it and then edit the line 35, 36, 37 as follow) Or see the attachment to this Post
Using the Linux Agent communication as an Alert Action to kick off script
7) Now lets Create an Alert: to use the Template if the service goes down, it should restart.
i used the following text in the "network path to external program"
C:\windows\system32\windowspowershell\v1.0\powershell.exe -ExecutionPolicy unrestricted -command "C:\Scripts\Solarwindscript.ps1 '${N=SwisEntity;M=Application.Node.NodeID}' '281"
the path is actually using 281 as my template ID and the C:\Scripts as the location of script on orion server.
Submit the alert setup and every time the service “active directory domain services” goes down, it should restart itself.
Remember to approve any changes you make from the Orion database
Thank the guy Chad who came up with this Idea like 5 years ago :) I spent 2 hours with orion customer service to figure out why are the services not restarting and its still a mystery.