Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You can determine the overall health or status of a site, in Configuration Manager, by inspecting the SMS_SummarizerSiteStatus
object Status
property. The Status
property has three possible values:
Value | Description |
---|---|
0 | The site is healthy. |
1 | The site has warning conditions. |
2 | The site has error conditions. |
SMS_SummarizerSiteStatus
is an example of a Configuration Manager summarizer. For more information, see SMS_SummarizerSiteStatus server WMI class.
To determine a site's health
Set up a connection to the SMS Provider. For more information, see SMS Provider fundamentals.
Get the
SMS_SummarizerSiteStatus
object by using the Configuration Manager site code.Inspect the
SMS_SummarizerSiteStatus
objectStatus
property to determine the site status
Example
The following example determines the health of the site code supplied in the parameter siteCode
.
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Sub ShowSiteHealth(connection, siteCode)
Dim siteHealth
Dim health
On Error Resume Next
' Get the site status summarizer.
Set siteHealth = connection.Get("SMS_SummarizerSiteStatus.SiteCode='" & siteCode & "'")
If Err.Number<>0 Then
Wscript.Echo "Couldn't get site health"
Exit Sub
End If
' Display the site health.
health="Health for site " + siteCode + " "
Select Case siteHealth.Status
Case 0
heath = health + "is OK"
Case 1
health = health + "has warnings"
Case 2
health = health + "is critical"
Case Else
health = health + "is not known"
End Select
Wscript.Echo health
End Sub
public void ShowSiteHealth(WqlConnectionManager connection, string siteCode)
{
try
{
IResultObject siteHealth = connection.GetInstance(@"SMS_SummarizerSiteStatus.SiteCode='" + siteCode + "'");
Console.Write("Health for site {0}", siteCode);
switch (siteHealth["Status"].IntegerValue)
{
case 0:
Console.WriteLine("is OK");
break;
case 1:
Console.WriteLine("has warnings");
break;
case 2:
Console.WriteLine("is critical");
break;
default:
Console.WriteLine("is not known");
break;
}
}
catch (SmsException e)
{
Console.WriteLine("Failed to show site status: " + e.Message);
}
}
The example method has the following parameters:
Parameter | Type | Description |
---|---|---|
connection |
- Managed: WqlConnectionManager - VBScript: SWbemServices |
A valid connection to the SMS Provider. For more information, see SMS Provider fundamentals. |
siteCode |
- Managed: String - VBScript: String |
A valid task Configuration Manager site code |
Compiling the Code
This C# example requires:
Namespaces
System
System.Collections.Generic
System.Text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
Assembly
adminui.wqlqueryengine
microsoft.configurationmanagement.managementprovider
Robust Programming
For more information about error handling, see About Configuration Manager Errors.
.NET Framework Security
For more information about securing Configuration Manager applications, see Configuration Manager role-based administration.