如何创建具有三种状态的 SCOM 管理包监视器
How to create SCOM management pack monitor with three states
我开发与 SCOM 的集成。不过我是新手。
我已经创建了管理包 XML,它工作正常。
请查看以下管理包:
<ManagementPack xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ContentReadable="true">
<Manifest>
<Identity>
<ID>CloudMonix.ResourceMonitoring</ID>
<Version>1.0.0.0</Version>
</Identity>
<Name>CloudMonix Resource Monitoring Pack</Name>
<References>
<Reference Alias="System">
<ID>System.Library</ID>
<Version>7.5.8501.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="SystemCenter">
<ID>Microsoft.SystemCenter.Library</ID>
<Version>7.0.8437.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
</References>
</Manifest>
<TypeDefinitions>
<EntityTypes>
<ClassTypes>
<ClassType ID="CloudMonix.ResourceMonitoring.Resource" Accessibility="Public" Abstract="false" Base="System!System.Entity" Hosted="false" Singleton="false">
<Property ID="ResourceId" Type="string" Key="true" CaseSensitive="false" Length="256" MinLength="1" />
<Property ID="ResourceType" Type="string" Key="false" CaseSensitive="false" Length="256" MinLength="1" />
<Property ID="ResourceStatus" Type="string" Key="false" CaseSensitive="false" Length="256" MinLength="1" />
<Property ID="ResourceGroups" Type="string" Key="false" CaseSensitive="false" Length="1024" MinLength="1" />
</ClassType>
</ClassTypes>
</EntityTypes>
</TypeDefinitions>
<Presentation>
<Views>
<View ID="CloudMonix.ResourceMonitoring.MainView" Accessibility="Public" Enabled="true" Target="CloudMonix.ResourceMonitoring.Resource" TypeID="SystemCenter!Microsoft.SystemCenter.StateViewType" Visible="true">
<Category>Operations</Category>
<Criteria>
<InMaintenanceMode>false</InMaintenanceMode>
</Criteria>
<Presentation>
<ColumnInfo Index="0" SortIndex="0" Width="100" Grouped="false" Sorted="true" IsSortable="true" Visible="true" SortOrder="Descending">
<Name>State</Name>
<Id>CloudMonix.ResourceMonitoring.Resource</Id>
</ColumnInfo>
<ColumnInfo Index="1" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Type</Name>
<Id>ResourceType</Id>
</ColumnInfo>
<ColumnInfo Index="2" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Name</Name>
<Id>DisplayName</Id>
</ColumnInfo>
<ColumnInfo Index="3" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Status</Name>
<Id>ResourceStatus</Id>
</ColumnInfo>
<ColumnInfo Index="4" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Groups</Name>
<Id>ResourceGroups</Id>
</ColumnInfo>
</Presentation>
<Target />
</View>
</Views>
<Folders>
<Folder ID="CloudMonix.ResourceMonitoring.MainFolder" Accessibility="Public" ParentFolder="SystemCenter!Microsoft.SystemCenter.Monitoring.ViewFolder.Root" />
</Folders>
<FolderItems>
<FolderItem ElementID="CloudMonix.ResourceMonitoring.MainView" Folder="CloudMonix.ResourceMonitoring.MainFolder" />
</FolderItems>
</Presentation>
<LanguagePacks>
<LanguagePack ID="ENU" IsDefault="false">
<DisplayStrings>
<DisplayString ElementID="CloudMonix.ResourceMonitoring">
<Name>CloudMonix Resource Monitoring</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.MainFolder">
<Name>CloudMonix Folder</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.MainView">
<Name>CloudMonix Resource View</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource">
<Name>CloudMonix Resource</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceId">
<Name>Resource Id</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceType">
<Name>Resource Type</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceStatus">
<Name>Resource Status</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceGroups">
<Name>Resource Groups</Name>
<Description></Description>
</DisplayString>
</DisplayStrings>
</LanguagePack>
</LanguagePacks>
</ManagementPack>
我已经使用 SCOM SDK and ImportManagementPack 方法安装了这个管理包。
我还开发了入站连接器,如 example 中所述。
我可以使用我的连接器发送发现数据、性能指标和事件。而且效果很好。
导入成功结果如截图所示:
监控对象创建正确。
但是这些对象有 Not monitored
健康状态。
我的主要问题是如何改变健康状态?
我的健康状态逻辑很简单:
- 如果
Resource Status
(请查看屏幕截图和管理包 XML 中的这个 属性)属性 等于 Ready
,则健康状态为Success
.
- 如果
Resource Status
属性 等于 Down
那么健康状态是 Error
.
- 否则健康状况为
Not monitored
。
查阅了很多文档(here and here),发现需要创建monitor,monitor类型,改变Health State的表达式规则。
我还检查了 XML 个示例 here。
但我不明白如何定义我的表达式以及如何将必要的信息添加到管理包 XML 文件。
对我来说最好的答案是完整的 XML 实施我的逻辑表达式规则的例子。
提前致谢。
首先让我警告你,这不是通过可发现的 class 属性监视某些内容的合适方法。 SCOM 数据库的设计假设是所有配置属性都是静态的。比如说,磁盘大小或 CPU 数量不会经常变化。这样做会导致配置变动。详情请参考Kevin Holman的文章:https://blogs.technet.microsoft.com/kevinholman/2009/10/04/what-is-config-churn/
但是,您仍然可以这样做。请参考下面的 MP XML。主要思想是制作一个假脚本,将 class 属性 打包在 属性 包中,然后条件检测可以对其进行分析。
请注意,您不能将监视器明确设置为 "Not Initialized" 状态。只有在以下情况下才会初始化监视器:
- 刚刚创建。
- 退出维护模式。
监控工作流可以发送信号以将监控器设置为健康、警告或严重状态,但如果没有信号到来,则健康状态会保留其最后的状态。
另请注意,我使用了 2007 方案和对齐的引用,以及更改的别名。我没有测试过,但是编译没有错误。 ENU 现在是默认语言。
<ManagementPack ContentReadable="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Manifest>
<Identity>
<ID>CloudMonix.ResourceMonitoring</ID>
<Version>1.0.0.6</Version>
</Identity>
<Name>CloudMonix.ResourceMonitoring</Name>
<References>
<Reference Alias="SC">
<ID>Microsoft.SystemCenter.Library</ID>
<Version>6.1.7221.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="Windows">
<ID>Microsoft.Windows.Library</ID>
<Version>6.1.7221.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="Health">
<ID>System.Health.Library</ID>
<Version>6.1.7221.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="System">
<ID>System.Library</ID>
<Version>6.1.7221.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
</References>
</Manifest>
<TypeDefinitions>
<EntityTypes>
<ClassTypes>
<ClassType ID="CloudMonix.ResourceMonitoring.Resource" Accessibility="Public" Abstract="false" Base="System!System.Entity" Hosted="false" Singleton="false">
<Property ID="ResourceId" Type="string" Key="true" CaseSensitive="false" MinLength="1" Length="256" />
<Property ID="ResourceType" Type="string" Key="false" CaseSensitive="false" MinLength="1" Length="256" />
<Property ID="ResourceStatus" Type="string" Key="false" CaseSensitive="false" MinLength="1" Length="256" />
<Property ID="ResourceGroups" Type="string" Key="false" CaseSensitive="false" MinLength="1" Length="1024" />
</ClassType>
</ClassTypes>
</EntityTypes>
<ModuleTypes>
<DataSourceModuleType ID="CloudMonix.ResourceMonitoring.ResourceStatus.DataSource" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element minOccurs="1" name="IntervalSeconds" type="xsd:integer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<xsd:element minOccurs="0" name="SyncTime" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<xsd:element minOccurs="1" name="ResourceStatus" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" />
<OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string" />
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="DS_Scheduler" TypeID="System!System.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval Unit="Seconds">$Config/IntervalSeconds$</Interval>
<SyncTime>$Config/SyncTime$</SyncTime>
</SimpleReccuringSchedule>
<ExcludeDates />
</Scheduler>
</DataSource>
<ProbeAction ID="PA_PackageData" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagProbe">
<ScriptName>Set-PropertyBagWithValue.ps1</ScriptName>
<ScriptBody>
param($data)
$api = New-Object -comObject 'MOM.ScriptAPI'
$bag = $api.CreatePropertyBag()
$bag.AddValue("ResourceStatus", $data)
$bag
</ScriptBody>
<Parameters>
<Parameter>
<Name>data</Name>
<Value>$Config/ResourceStatus$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="PA_PackageData">
<Node ID="DS_Scheduler" />
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>
</ModuleTypes>
<MonitorTypes>
<UnitMonitorType ID="CloudMonix.ResourceMonitoring.ResourceStatus.MonitorType" Accessibility="Internal">
<MonitorTypeStates>
<MonitorTypeState ID="Ready" NoDetection="false" />
<MonitorTypeState ID="Down" NoDetection="false" />
</MonitorTypeStates>
<Configuration>
<xsd:element minOccurs="1" name="IntervalSeconds" type="xsd:integer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<xsd:element minOccurs="0" name="SyncTime" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<xsd:element minOccurs="1" name="ResourceStatus" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" />
<OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string" />
</OverrideableParameters>
<MonitorImplementation>
<MemberModules>
<DataSource ID="DS_ResourceStatus" TypeID="CloudMonix.ResourceMonitoring.ResourceStatus.DataSource">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime>$Config/SyncTime$</SyncTime>
<ResourceStatus>$Config/ResourceStatus$</ResourceStatus>
</DataSource>
<ConditionDetection ID="CD_Ready" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='ResourceStatus']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Ready</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="CD_Down" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='ResourceStatus']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Down</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="Ready">
<Node ID="CD_Ready">
<Node ID="DS_ResourceStatus" />
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="Down">
<Node ID="CD_Down">
<Node ID="DS_ResourceStatus" />
</Node>
</RegularDetection>
</RegularDetections>
</MonitorImplementation>
</UnitMonitorType>
</MonitorTypes>
</TypeDefinitions>
<Monitoring>
<Monitors>
<UnitMonitor ID="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor" Accessibility="Public" Enabled="true" Target="CloudMonix.ResourceMonitoring.Resource" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="CloudMonix.ResourceMonitoring.ResourceStatus.MonitorType" ConfirmDelivery="false">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Ready" MonitorTypeStateID="Ready" HealthState="Success" />
<OperationalState ID="Down" MonitorTypeStateID="Down" HealthState="Error" />
</OperationalStates>
<Configuration>
<IntervalSeconds>300</IntervalSeconds>
<SyncTime />
<ResourceStatus>$Target/Property[Type="CloudMonix.ResourceMonitoring.Resource"]/ResourceStatus$</ResourceStatus>
</Configuration>
</UnitMonitor>
</Monitors>
</Monitoring>
<Presentation>
<Views>
<View ID="CloudMonix.ResourceMonitoring.MainView" Accessibility="Public" Enabled="true" Target="CloudMonix.ResourceMonitoring.Resource" TypeID="SC!Microsoft.SystemCenter.StateViewType" Visible="true">
<Category>Operations</Category>
<Criteria>
<InMaintenanceMode>false</InMaintenanceMode>
</Criteria>
<Presentation>
<ColumnInfo Index="0" SortIndex="0" Width="100" Grouped="false" Sorted="true" IsSortable="true" Visible="true" SortOrder="Descending">
<Name>State</Name>
<Id>CloudMonix.ResourceMonitoring.Resource</Id>
</ColumnInfo>
<ColumnInfo Index="1" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Type</Name>
<Id>ResourceType</Id>
</ColumnInfo>
<ColumnInfo Index="2" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Name</Name>
<Id>DisplayName</Id>
</ColumnInfo>
<ColumnInfo Index="3" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Status</Name>
<Id>ResourceStatus</Id>
</ColumnInfo>
<ColumnInfo Index="4" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Groups</Name>
<Id>ResourceGroups</Id>
</ColumnInfo>
</Presentation>
<Target />
</View>
</Views>
<Folders>
<Folder ID="CloudMonix.ResourceMonitoring.MainFolder" Accessibility="Public" ParentFolder="SC!Microsoft.SystemCenter.Monitoring.ViewFolder.Root" />
</Folders>
<FolderItems>
<FolderItem ElementID="CloudMonix.ResourceMonitoring.MainView" Folder="CloudMonix.ResourceMonitoring.MainFolder" />
</FolderItems>
<StringResources>
<StringResource ID="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor.AlertMessage" />
</StringResources>
</Presentation>
<LanguagePacks>
<LanguagePack ID="ENU" IsDefault="true">
<DisplayStrings>
<DisplayString ElementID="CloudMonix.ResourceMonitoring">
<Name>CloudMonix Resource Monitoring</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.MainFolder">
<Name>CloudMonix Folder</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.MainView">
<Name>CloudMonix Resource View</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource">
<Name>CloudMonix Resource</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceId">
<Name>Resource Id</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceType">
<Name>Resource Type</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceStatus">
<Name>Resource Status</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceGroups">
<Name>Resource Groups</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor">
<Name>Resource Status Unit Monitor</Name>
<Description>Resource Status Unit Monitor</Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor.AlertMessage">
<Name>Alert</Name>
<Description>Alert</Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor" SubElementID="Ready">
<Name>Ready</Name>
<Description>Ready</Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor" SubElementID="Down">
<Name>Down</Name>
<Description>Down</Description>
</DisplayString>
</DisplayStrings>
<KnowledgeArticles></KnowledgeArticles>
</LanguagePack>
</LanguagePacks>
</ManagementPack>
我开发与 SCOM 的集成。不过我是新手。
我已经创建了管理包 XML,它工作正常。
请查看以下管理包:
<ManagementPack xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ContentReadable="true">
<Manifest>
<Identity>
<ID>CloudMonix.ResourceMonitoring</ID>
<Version>1.0.0.0</Version>
</Identity>
<Name>CloudMonix Resource Monitoring Pack</Name>
<References>
<Reference Alias="System">
<ID>System.Library</ID>
<Version>7.5.8501.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="SystemCenter">
<ID>Microsoft.SystemCenter.Library</ID>
<Version>7.0.8437.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
</References>
</Manifest>
<TypeDefinitions>
<EntityTypes>
<ClassTypes>
<ClassType ID="CloudMonix.ResourceMonitoring.Resource" Accessibility="Public" Abstract="false" Base="System!System.Entity" Hosted="false" Singleton="false">
<Property ID="ResourceId" Type="string" Key="true" CaseSensitive="false" Length="256" MinLength="1" />
<Property ID="ResourceType" Type="string" Key="false" CaseSensitive="false" Length="256" MinLength="1" />
<Property ID="ResourceStatus" Type="string" Key="false" CaseSensitive="false" Length="256" MinLength="1" />
<Property ID="ResourceGroups" Type="string" Key="false" CaseSensitive="false" Length="1024" MinLength="1" />
</ClassType>
</ClassTypes>
</EntityTypes>
</TypeDefinitions>
<Presentation>
<Views>
<View ID="CloudMonix.ResourceMonitoring.MainView" Accessibility="Public" Enabled="true" Target="CloudMonix.ResourceMonitoring.Resource" TypeID="SystemCenter!Microsoft.SystemCenter.StateViewType" Visible="true">
<Category>Operations</Category>
<Criteria>
<InMaintenanceMode>false</InMaintenanceMode>
</Criteria>
<Presentation>
<ColumnInfo Index="0" SortIndex="0" Width="100" Grouped="false" Sorted="true" IsSortable="true" Visible="true" SortOrder="Descending">
<Name>State</Name>
<Id>CloudMonix.ResourceMonitoring.Resource</Id>
</ColumnInfo>
<ColumnInfo Index="1" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Type</Name>
<Id>ResourceType</Id>
</ColumnInfo>
<ColumnInfo Index="2" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Name</Name>
<Id>DisplayName</Id>
</ColumnInfo>
<ColumnInfo Index="3" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Status</Name>
<Id>ResourceStatus</Id>
</ColumnInfo>
<ColumnInfo Index="4" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Groups</Name>
<Id>ResourceGroups</Id>
</ColumnInfo>
</Presentation>
<Target />
</View>
</Views>
<Folders>
<Folder ID="CloudMonix.ResourceMonitoring.MainFolder" Accessibility="Public" ParentFolder="SystemCenter!Microsoft.SystemCenter.Monitoring.ViewFolder.Root" />
</Folders>
<FolderItems>
<FolderItem ElementID="CloudMonix.ResourceMonitoring.MainView" Folder="CloudMonix.ResourceMonitoring.MainFolder" />
</FolderItems>
</Presentation>
<LanguagePacks>
<LanguagePack ID="ENU" IsDefault="false">
<DisplayStrings>
<DisplayString ElementID="CloudMonix.ResourceMonitoring">
<Name>CloudMonix Resource Monitoring</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.MainFolder">
<Name>CloudMonix Folder</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.MainView">
<Name>CloudMonix Resource View</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource">
<Name>CloudMonix Resource</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceId">
<Name>Resource Id</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceType">
<Name>Resource Type</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceStatus">
<Name>Resource Status</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceGroups">
<Name>Resource Groups</Name>
<Description></Description>
</DisplayString>
</DisplayStrings>
</LanguagePack>
</LanguagePacks>
</ManagementPack>
我已经使用 SCOM SDK and ImportManagementPack 方法安装了这个管理包。
我还开发了入站连接器,如 example 中所述。
我可以使用我的连接器发送发现数据、性能指标和事件。而且效果很好。
导入成功结果如截图所示:
监控对象创建正确。
但是这些对象有 Not monitored
健康状态。
我的主要问题是如何改变健康状态?
我的健康状态逻辑很简单:
- 如果
Resource Status
(请查看屏幕截图和管理包 XML 中的这个 属性)属性 等于Ready
,则健康状态为Success
. - 如果
Resource Status
属性 等于Down
那么健康状态是Error
. - 否则健康状况为
Not monitored
。
查阅了很多文档(here and here),发现需要创建monitor,monitor类型,改变Health State的表达式规则。
我还检查了 XML 个示例 here。
但我不明白如何定义我的表达式以及如何将必要的信息添加到管理包 XML 文件。
对我来说最好的答案是完整的 XML 实施我的逻辑表达式规则的例子。
提前致谢。
首先让我警告你,这不是通过可发现的 class 属性监视某些内容的合适方法。 SCOM 数据库的设计假设是所有配置属性都是静态的。比如说,磁盘大小或 CPU 数量不会经常变化。这样做会导致配置变动。详情请参考Kevin Holman的文章:https://blogs.technet.microsoft.com/kevinholman/2009/10/04/what-is-config-churn/
但是,您仍然可以这样做。请参考下面的 MP XML。主要思想是制作一个假脚本,将 class 属性 打包在 属性 包中,然后条件检测可以对其进行分析。
请注意,您不能将监视器明确设置为 "Not Initialized" 状态。只有在以下情况下才会初始化监视器:
- 刚刚创建。
- 退出维护模式。
监控工作流可以发送信号以将监控器设置为健康、警告或严重状态,但如果没有信号到来,则健康状态会保留其最后的状态。
另请注意,我使用了 2007 方案和对齐的引用,以及更改的别名。我没有测试过,但是编译没有错误。 ENU 现在是默认语言。
<ManagementPack ContentReadable="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Manifest>
<Identity>
<ID>CloudMonix.ResourceMonitoring</ID>
<Version>1.0.0.6</Version>
</Identity>
<Name>CloudMonix.ResourceMonitoring</Name>
<References>
<Reference Alias="SC">
<ID>Microsoft.SystemCenter.Library</ID>
<Version>6.1.7221.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="Windows">
<ID>Microsoft.Windows.Library</ID>
<Version>6.1.7221.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="Health">
<ID>System.Health.Library</ID>
<Version>6.1.7221.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="System">
<ID>System.Library</ID>
<Version>6.1.7221.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
</References>
</Manifest>
<TypeDefinitions>
<EntityTypes>
<ClassTypes>
<ClassType ID="CloudMonix.ResourceMonitoring.Resource" Accessibility="Public" Abstract="false" Base="System!System.Entity" Hosted="false" Singleton="false">
<Property ID="ResourceId" Type="string" Key="true" CaseSensitive="false" MinLength="1" Length="256" />
<Property ID="ResourceType" Type="string" Key="false" CaseSensitive="false" MinLength="1" Length="256" />
<Property ID="ResourceStatus" Type="string" Key="false" CaseSensitive="false" MinLength="1" Length="256" />
<Property ID="ResourceGroups" Type="string" Key="false" CaseSensitive="false" MinLength="1" Length="1024" />
</ClassType>
</ClassTypes>
</EntityTypes>
<ModuleTypes>
<DataSourceModuleType ID="CloudMonix.ResourceMonitoring.ResourceStatus.DataSource" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element minOccurs="1" name="IntervalSeconds" type="xsd:integer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<xsd:element minOccurs="0" name="SyncTime" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<xsd:element minOccurs="1" name="ResourceStatus" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" />
<OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string" />
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="DS_Scheduler" TypeID="System!System.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval Unit="Seconds">$Config/IntervalSeconds$</Interval>
<SyncTime>$Config/SyncTime$</SyncTime>
</SimpleReccuringSchedule>
<ExcludeDates />
</Scheduler>
</DataSource>
<ProbeAction ID="PA_PackageData" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagProbe">
<ScriptName>Set-PropertyBagWithValue.ps1</ScriptName>
<ScriptBody>
param($data)
$api = New-Object -comObject 'MOM.ScriptAPI'
$bag = $api.CreatePropertyBag()
$bag.AddValue("ResourceStatus", $data)
$bag
</ScriptBody>
<Parameters>
<Parameter>
<Name>data</Name>
<Value>$Config/ResourceStatus$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="PA_PackageData">
<Node ID="DS_Scheduler" />
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>
</ModuleTypes>
<MonitorTypes>
<UnitMonitorType ID="CloudMonix.ResourceMonitoring.ResourceStatus.MonitorType" Accessibility="Internal">
<MonitorTypeStates>
<MonitorTypeState ID="Ready" NoDetection="false" />
<MonitorTypeState ID="Down" NoDetection="false" />
</MonitorTypeStates>
<Configuration>
<xsd:element minOccurs="1" name="IntervalSeconds" type="xsd:integer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<xsd:element minOccurs="0" name="SyncTime" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<xsd:element minOccurs="1" name="ResourceStatus" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" />
<OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string" />
</OverrideableParameters>
<MonitorImplementation>
<MemberModules>
<DataSource ID="DS_ResourceStatus" TypeID="CloudMonix.ResourceMonitoring.ResourceStatus.DataSource">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime>$Config/SyncTime$</SyncTime>
<ResourceStatus>$Config/ResourceStatus$</ResourceStatus>
</DataSource>
<ConditionDetection ID="CD_Ready" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='ResourceStatus']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Ready</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="CD_Down" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='ResourceStatus']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Down</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="Ready">
<Node ID="CD_Ready">
<Node ID="DS_ResourceStatus" />
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="Down">
<Node ID="CD_Down">
<Node ID="DS_ResourceStatus" />
</Node>
</RegularDetection>
</RegularDetections>
</MonitorImplementation>
</UnitMonitorType>
</MonitorTypes>
</TypeDefinitions>
<Monitoring>
<Monitors>
<UnitMonitor ID="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor" Accessibility="Public" Enabled="true" Target="CloudMonix.ResourceMonitoring.Resource" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="CloudMonix.ResourceMonitoring.ResourceStatus.MonitorType" ConfirmDelivery="false">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Ready" MonitorTypeStateID="Ready" HealthState="Success" />
<OperationalState ID="Down" MonitorTypeStateID="Down" HealthState="Error" />
</OperationalStates>
<Configuration>
<IntervalSeconds>300</IntervalSeconds>
<SyncTime />
<ResourceStatus>$Target/Property[Type="CloudMonix.ResourceMonitoring.Resource"]/ResourceStatus$</ResourceStatus>
</Configuration>
</UnitMonitor>
</Monitors>
</Monitoring>
<Presentation>
<Views>
<View ID="CloudMonix.ResourceMonitoring.MainView" Accessibility="Public" Enabled="true" Target="CloudMonix.ResourceMonitoring.Resource" TypeID="SC!Microsoft.SystemCenter.StateViewType" Visible="true">
<Category>Operations</Category>
<Criteria>
<InMaintenanceMode>false</InMaintenanceMode>
</Criteria>
<Presentation>
<ColumnInfo Index="0" SortIndex="0" Width="100" Grouped="false" Sorted="true" IsSortable="true" Visible="true" SortOrder="Descending">
<Name>State</Name>
<Id>CloudMonix.ResourceMonitoring.Resource</Id>
</ColumnInfo>
<ColumnInfo Index="1" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Type</Name>
<Id>ResourceType</Id>
</ColumnInfo>
<ColumnInfo Index="2" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Name</Name>
<Id>DisplayName</Id>
</ColumnInfo>
<ColumnInfo Index="3" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Status</Name>
<Id>ResourceStatus</Id>
</ColumnInfo>
<ColumnInfo Index="4" SortIndex="-1" Width="100" Grouped="false" Sorted="false" IsSortable="true" Visible="true" SortOrder="Ascending">
<Name>Resource Groups</Name>
<Id>ResourceGroups</Id>
</ColumnInfo>
</Presentation>
<Target />
</View>
</Views>
<Folders>
<Folder ID="CloudMonix.ResourceMonitoring.MainFolder" Accessibility="Public" ParentFolder="SC!Microsoft.SystemCenter.Monitoring.ViewFolder.Root" />
</Folders>
<FolderItems>
<FolderItem ElementID="CloudMonix.ResourceMonitoring.MainView" Folder="CloudMonix.ResourceMonitoring.MainFolder" />
</FolderItems>
<StringResources>
<StringResource ID="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor.AlertMessage" />
</StringResources>
</Presentation>
<LanguagePacks>
<LanguagePack ID="ENU" IsDefault="true">
<DisplayStrings>
<DisplayString ElementID="CloudMonix.ResourceMonitoring">
<Name>CloudMonix Resource Monitoring</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.MainFolder">
<Name>CloudMonix Folder</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.MainView">
<Name>CloudMonix Resource View</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource">
<Name>CloudMonix Resource</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceId">
<Name>Resource Id</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceType">
<Name>Resource Type</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceStatus">
<Name>Resource Status</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.Resource" SubElementID="ResourceGroups">
<Name>Resource Groups</Name>
<Description></Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor">
<Name>Resource Status Unit Monitor</Name>
<Description>Resource Status Unit Monitor</Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor.AlertMessage">
<Name>Alert</Name>
<Description>Alert</Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor" SubElementID="Ready">
<Name>Ready</Name>
<Description>Ready</Description>
</DisplayString>
<DisplayString ElementID="CloudMonix.ResourceMonitoring.ResourceStatus.UnitMonitor" SubElementID="Down">
<Name>Down</Name>
<Description>Down</Description>
</DisplayString>
</DisplayStrings>
<KnowledgeArticles></KnowledgeArticles>
</LanguagePack>
</LanguagePacks>
</ManagementPack>