One of the most commonly used modules to monitors web application, beside the custom script based ones, is the Web Application Url Probe, defined in the Web Application Library that comes with SCOM.
Beside their multiple functionality and flexibility, sometimes, we require to expand these kind of implementation to be more suitable to customers that used vpn, remote sites, etc, scenarios that could affect the request execution, and not necessary means a failure in the web application itself.
For those types of monitors, we will require to implement a consecutive sample condition inside the current monitors, like the Status code, Unreachable, Error Failure or Context March criteria.
This code provide a sample how to implement this along with other previous features I already described in previous post.
As you can see here we are using a Condition Detection module, where the only property used for this action is the Event Display Number. The Total interval seconds, is the value used as a windows to evaluate the samples and the Consecutive Samples is the number of execution the web request will be evaluated. All these configurations are required to establish new state for the monitor.
In this sample the Interval for each web request used in each sample is 60 seconds, the number of samples is 3 and the total interval is 180 seconds. This mean that the state of the monitor will be evaluated for 3 minutes before the state changed.
All these parameters can be overridden to set more appropriate values according to the scenario that you would like to monitor.
Is important to include this consolidate condition in the correct step for the implementation workflow, otherwise it will not work as expected.
Here is the way it was defined in this sample:
When the monitor evaluates the state according to the previous condition the context will be presented like this:
You can see here that the initial and ending samples times are presented here along with the info, so this provide more detailed information for the user.
The sample code is available here: