Monitor Item Action Script
Monitor Item Action Script
To see more information about the different monitor item types, see the 'Monitor Item Types' page.
An Action Script can be added to a Monitor Item, no matter what kind of Monitor Item Type it is.
The Action Script will be executed, when a monitor goes into state Error.
Preconditions
- For an monitor to be able to execute a Action Script, the Monitor Service User must be a member of the local Administrator Group.
- In link, on the Monitor Items Page, there is a button called Show action script, that you need if you want to use this Action Script feature.
If you don't see the Show action script - Button, it is because you don't have the Monitor View ActionScript permission.
Case 1 - Ping Monitor with Action Script
Go to an existing Monitor (Monitor(hover)→click Monitor Config→choose a monitor→ click Show selected monitor items).
Here you see an Show action script - Button.
.
If you don't see the Show action script - Button, it is because you don't have the Monitor View ActionScript permission.
Click on Show action script - Button.
There are three input fields on the 'Monitor Item Action Script' page.
Header Buttons [1]
Refresh
Click here to refresh the page details.
Action Buttons [2]
Edit
Click this to start editing the monitor item action script. All previously locked fields will become available to edit. When you are done editing, press the 'Save' button. Press 'Cancel' to abort and cancel your changes.
Delete
Press this to delete the currently opened monitor item action script. A prompt will be shown asking you to confirm your choice.
Fields [3]
Action script
In this field you enter the Powershell script that you want run, when the monitor item initially fails. After the script is executed, the monitor item is checked again. The status of the second monitor item check is logged and no further processing is done. The script is meant to attempt to fix the problem that is detected with the monitor item.
Script Arguments
It's possible to pass arguments to the Powershell script. These arguments should be defined as dynamic fields for the monitor plugin and the argument name in the script should match the field name. E.g. for the Ping plugin you can pass the ping address to the script using the following line in the script: Param($address)
Max. executions within a sequence
We don't want to let the Action Script run to often. There must be limit. If the Action Script get tiggered all the time, there must be problem more serious problem, that needs to be solved. If we have a Action Script, that restarts a service, we would let the script do that to often.
Here we have a configuration, where we eg. can say that the Script can be runned 3 times out of 12 monitor checks.
Specifies how many times, within a sequence, this script is allowed to run. As an example, say that the monitor item runs every five minutes, you could define a sequence to have a length of 12, which would mean that a sequence is one hour (12 times 5 minutes). Setting the max. executions to 3 would ensure that this script is only executed on the first three failures with every hour, thereby reducing the number of times a fix is attempted. In other words:
Sequence length
Specifies the length of a sequence (in number of times).
Case 2 - Printer Spooler Service Check Monitor with Action Script
We have setup a Windows Service Check Monitor.
This monitor is monitoring the Printer Spooler Service. If the Printer Spooler Service stops, the monitor change status to Error.
If the Printer Spooler Service stops, we what to restart the service with a Power shell Script:
Get-Service *spool* | restart-Service;
This will happens if the Printer Spooler Service is stopped.
- The Printer Spooler Service is stopped and til monitor will raise an error, but before the monitor changes the status to Error, it will check if there is a Action Script
- Yes, there is a Action script, and the monitor will therefore run the script
- The Action Script will make the Printer Spooler Service run again
- After the Action Scrips returns, the monitor will do its check again, and this time it will not raise an error
- The result is therefore, that the monitor fixed the problem and never went into status Error.
- I the log of the monitor, you see that there has been raised an error, but it was fixed. It looks like this:
Content on this page: