A common requirement for more complex MP’s is cookdown.
Cookdown is a concept where multiple workflows run on a healthservice, and share a common datasource. When cookdown works properly, the datasource will only execute once, even when called by multiple workflows. This saves precious resources, as these are commonly script datasources and can consume significant resources when executed.
A good description is documented here: Management Pack Authoring – Cookdown
I posted a quick and simple script based example of when a script runs to collect data, and both a rule and a monitor share the script. In this example, we are counting files in a folder. The script counts the files and outputs the value in a propertybag. The monitor compares the propertybag value against a threshold, while the rule simply collects the value and maps it as performance data.
You can download the example here: Demo.Cookdown SCOM Management Pack
Some key points to remember with cookdown:
1. Ensure the multiple workflows do not pass ANY different parameters to the script datasource. If the parameters are different, cookdown will likely be broken.
2. On monitors, ensure: ConfirmDelivery=”false” When ConfirmDelivery=”true” this will often break cookdown for monitors.