Page History
Table of Contents | ||||
---|---|---|---|---|
|
You can trigger alerts and actions Alerts and Actions can be triggered in Uptime Infrastructure Monitor when an Element changes state. This is discussed in the Uptime Infrastructure Monitor UIM Administrator's Guide here: Alerts under Alerts and Actions. Several The following actions are available out - of - the - box:
- Log to File
...
- Recovery Script
...
- Windows Service
...
- SNMP trap
...
The Windows Service service action can Startstart, stop, Stop or Restart restart a Windows Service service identified by name. This is useful when you've created a Service Monitor service monitor using the Windows Service Check monitor to watch for a state change with a specific Windows Serviceservice. A typical scenario would be is to set a Critical Status status if a specified Windows Service service is Stoppedstopped. In this case, you can use the Windows Service service action in Uptime Infrastructure Monitor could be used UIM to automatically try to start the Windows Service service in an attempt to minimize service disruption.
The limitation to leveraging the Windows Service service action on an Action Profile action profile is that the Windows Service to be started service that you want to start must be identified by name. If you have a large number of Windows Services services that could drive an action, you will need to should create a new Action Profile action profile for each Windows Service and ensure service, and then make sure that you tie it to the correct Service Monitorservice monitor. In environments where the number of Windows Services services that fit this scenario is small, this works well. However, in larger environments where the number of Windows Services services that fit this scenario is large, it might be desirable to create a single Action Profile action profile that can restart any Windows Serviceservice.
This article explores how to restart any Windows Service service with an Action Profile action profile as an alternative to creating a specific Action Profile action profile for each Windows Serviceservice.
Create a service monitor
Start by creating a Service Monitor as follows:
...
To create a service monitor
- Select the Windows Service Check monitor.
...
Note You must match the Service Name to the Windows Service Display Name. This name
...
is leveraged later to select the Windows
...
service to start. Note that Microsoft has both a Display Name and a Service Name. We want the Display Name
...
, as shown in the following images.
- Complete the remainder of the Service Monitor window making sure that the Windows Service - Service Name is also the Display Name.
...
- Make sure to select options that allow you to raise a Critical
...
- alert when the
...
- service status is Stopped.
...
- Your
...
- service monitor settings should look
...
- the following example.
Create
...
a recovery script
We are going to leverage a Recovery Script recovery script in an Action Profile action profile to Start start the Windows Service. This will be a very simple script. We are going to service. You can leverage two key components built into Uptime Infrastructure MonitorUIM:
- First, the ability to create a script on the
...
- UIM monitoring station that directs a UIM Agent to perform an action. In fact, the
...
- monitor agent exposes a method to the UIM
...
- monitoring station to
...
- start a Windows service and you simply need to supply the Windows
...
- service name.
- Second, the use of
...
- recovery script variables (variables available when creating
...
- recovery scripts). These are variables handed
...
- in to our script by
...
- UIM.
Here is what the Recovery Script recovery script looks like:
Code Block | ||
---|---|---|
| ||
@ECHO OFF |
...
agentcmd.exe -s -p 9998 %UPTIME_HOSTNAME% svc_start \"%UPTIME_SERVICENAME%\" Changeme2 |
Some items to note:
%UPTIME_HOSTNAME%
is the name of the system raising the
...
- alert, also the system where you want to restart the Windows
...
- service.
%UPTIME_SERVICENAME%
is the name of the
...
- service monitor we created earlier. Note that this is why we needed the
...
- service monitor name to match the Windows
...
- service Display Name.
- The \
...
- may look strange, but this
...
- character makes sure that the whole Windows
...
- service name gets included regardless of spaces.
Changeme2
is the
...
- UIM monitor agent password in this environment, so note that your environment
...
- differs.
This script is saved to the Scripts directory on the Uptime Infrastructure Monitor Monitoring Station (defaultUIM monitoring station at the default location: C:\Program Files\uptime software\uptime\scripts).
For the sake of brevity we will skip the remaining details. However, however, if you want more information you can find it online, here . Here are two key articles: Creating an Action Profile Recovery Script (for the purposes of this article focus on the Monitoring Station Script).
- Creating an action profile recovery script
- Alert Profile and Action Profile Variables (
...
- In the main UIM documentation)
Create an action profile
Lastly, we need to tie the Service Monitor and Recovery Script service monitor and recovery script together in an Action Profile. Follow these steps:action profile.
To create an action profile
- Create a new
...
- action profile and
...
- give it a descriptive name.
- Populate the full path to the recovery script.
- Add the Service Monitor we created above.
It should look something like
...
- the following example:
Testing your work
The final test is to make sure that everything works as expected. Testing is as simple as stopping the Windows Service service from your Service Monitorservice monitor. You may want to adjust the Timing Settings on the Service Monitor service monitor to trigger the action sooner for the purposes of testing.
If you are familiar with Action Profiles action profiles, you may know that Uptime Infrastructure Monitor UIM has a built in Test Action Profile test action profile capability. However, that won't work in our case because the variables we are leveraging only get populated when a Service Monitor service monitor is triggered.
...
Important notes
The Windows Service will be started service starts in the security context of the Uptime Infrastructure Monitor UIM monitor agent running on the system where the Windows Service service is being started (, by default Local System)it is the local system.
This is not the only one way to accomplish this task, other viable options exist. You could create an Uptime Infrastructure Monitor Agent a UIM monitor agent side script to perform the recovery, . Or you could call a third-party tool from the recovery script to start the service, etc, etcamong other options.