Building Block: Health Rules
Published: May 2010
SharePoint Health Analyzer monitors the health of SharePoint Foundation throughout a server farm by applying a set of health rules. A health rule is executable code that is deployed in a compiled assembly at the server farm level and registered with SharePoint Health Analyzer. When a rule is registered, a timer job is created to run the rule. An item for the rule is then added to the Health Analyzer Rule list under Review rule definitions in the Monitoring section of Central Administration.
A number of health rules are included with SharePoint Foundation. You can create and deploy additional rules by writing code that uses the SharePoint Foundation object model.
The classes that you can use to create health rules are located in the Microsoft.SharePoint.Administration.Health namespace. The most important classes include the following:
SPHealthAnalysisRule - An abstract base class that provides a definition for a SharePoint Health Analyzer rule.
SPRepairableHealthAnalysisRule – An abstract base class that provides a definition for a SharePoint Health Analyzer rule that can repair an error automatically.
SPHealthAnalysisRuleAutomaticExecutionParameters – Encapsulates default parameters that can be used to run a SharePoint Health Analyzer rule automatically through the timer service.
A health rule is deployed in a compiled assembly and registered with the SharePoint Health Analyzer by a call to the RegisterRules(Assembly) method of the SPHealthAnalyzer class. A good place to call this method is in the event handler for the FeatureActivated event of an SPFeatureReceiver object. When a rule is registered, a timer job is created to run the rule by using default parameters that are specified by the rule's AutomaticExecutionParameters property.