本文件已封存並已停止維護。

Monitor Performance Data

更新日期: 2009年6月

適用於: Operations Manager 2007 R2

This topic describes data collection and guides you through the process of collecting performance-based data on a monitored system.

Performance Data Collection

There are circumstances in which it is appropriate to collect data as reference information when troubleshooting or performing capacity planning. This data can be accessed by using monitors and alerts to report current status. This data can also be collected over a longer period of time for historical analysis by using a rule. This topic describes how to report immediate changes in performance by using a monitor and alert. The following sections within this topic describe how to collect this performance data and store it to evaluate results over a period of time.

Sample Performance Script

To simulate performance, the Bash script SampleAppPerf.sh is run. This script simulates application performance by creating a random number to standard output. This script is only for demonstrating rules and monitoring.

The script contains the following:


#!/bin/bash

number=$RANDOM
echo $number

A random value from 0 to 32767 is assigned to the variable number and then value is sent to standard output. The script is located in the \tmp directory on the UNIX-based or Linux-based computer that is being monitored.

Unit Monitor

A Unit Monitor is created to monitor the performance data simulated by SampleAppPerf.sh. The Parent monitor ID is SystemHealth!System.Health.PerformanceState, and it defines the collection of monitors that are used in the performance dependency monitor that is described in the Collect and View Performance Data topic. The Type ID is Microsoft.SCX.Authoring.Guide.SampleAppPerf.Threshold.MonitorType and is defined in the Unit Monitor Type in a later code example. The alert message is defined, and it generates an alert in an error state. The monitor attempts to self-resolve if a recovery task is defined. There are two states; either the application is over threshold or underthreshold. The threshold is set to 30000. The interval is set to run the monitor, and therefore the script, every 30 seconds.


       <UnitMonitor ID="Microsoft.SCX.Authoring.Guide.SampleAppPerf.Monitor" Accessibility="Public" Enabled="true" Target="Microsoft.SCX.Sample.Application" ParentMonitorID="SystemHealth!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Microsoft.SCX.Authoring.Guide.SampleAppPerf.Threshold.MonitorType" ConfirmDelivery="false">
        <Category>PerformanceHealth</Category>
        <AlertSettings AlertMessage="Microsoft.SCX.Authoring.Guide.SampleAppPerf.AlertMessage">
          <AlertOnState>Error</AlertOnState>
          <AutoResolve>true</AutoResolve>
          <AlertPriority>Normal</AlertPriority>
          <AlertSeverity>Error</AlertSeverity>
        </AlertSettings>
        <OperationalStates>
          <OperationalState ID="OverThreshold" MonitorTypeStateID="OverThreshold" HealthState="Error" />
          <OperationalState ID="UnderThreshold" MonitorTypeStateID="UnderThreshold" HealthState="Success" />
        </OperationalStates>
        <Configuration>
          <IntervalSeconds>30</IntervalSeconds>
          <TargetSystem>$Target/Host/Property[Type="Unix!Microsoft.Unix.Computer"]/NetworkName$</TargetSystem>
          <Command>sh /tmp/SampleAppPerf.sh</Command>
          <ObjectName>SampleApp</ObjectName>
          <CounterName>SampleValue</CounterName>
          <InstanceName>$Target/Property[Type="Microsoft.SCX.Sample.Application"]/DisplayName$</InstanceName>
          <Value>$Data///*[local-name()="StdOut"]$</Value>
          <Threshold>30000</Threshold>
        </Configuration>
      </UnitMonitor>

In the Microsoft.SCX.Authoring.Guide.xml file that you created earlier, insert the preceding XML in the <Monitors> subsection under the <Monitoring> section.

Add the UnitMonitorType

As in earlier monitors, all the attributes for this monitor are defined within Configuration, and the Modifiable attributes are defined in OverrideableParameters.Again, there is a scheduler to determine when to run the monitor and a ProbeAction to execute the monitor. The $Config/Command$ takes the value that is passed in from Microsoft.SCX.Authoring.Guide.SampleAppPerf.Monitor and defined as Overrideable in the <Configuration> subsection. The Condition is the check that is performed in each of the Regular Detections. The Regular Detection actions are executed from deepest-level node to the top-level node. You should determine what the hash value is for the script and verify whether it matches the hash code that you expect.


      <UnitMonitorType ID="Microsoft.SCX.Authoring.Guide.SampleAppPerf.Threshold.MonitorType" Accessibility="Public">
        <MonitorTypeStates>
          <MonitorTypeState ID="UnderThreshold" NoDetection="false" />
          <MonitorTypeState ID="OverThreshold" NoDetection="false" />
        </MonitorTypeStates>
        <Configuration>
          <xsd:element name="IntervalSeconds" type="xsd:integer" />
          <xsd:element name="TargetSystem" type="xsd:string" />
          <xsd:element name="Command" type="xsd:string" />
          <xsd:element name="ObjectName" type="xsd:string" />
          <xsd:element name="CounterName" type="xsd:string" />
          <xsd:element name="InstanceName" type="xsd:string" />
          <xsd:element name="Value" type="xsd:string" />
          <xsd:element name="Threshold" type="xsd:double" />
        </Configuration>
        <OverrideableParameters>
          <OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" />
          <OverrideableParameter ID="Threshold" Selector="$Config/Threshold$" ParameterType="double" />
        </OverrideableParameters>
        <MonitorImplementation>
          <MemberModules>
            <DataSource ID="DS" TypeID="Microsoft.SCX.Authoring.Guide.ScriptBased.PerfCounterProvider">
              <IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
              <TargetSystem>$Config/TargetSystem$</TargetSystem>
              <Uri>http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem?__cimnamespace=root/scx</Uri>
              <Selector />
              <InvokeAction>ExecuteCommand</InvokeAction>
              <Input><![CDATA[ <p:ExecuteCommand_INPUT xmlns:p="http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem"><p:command>$Config/Command$</p:command><p:timeout>10</p:timeout></p:ExecuteCommand_INPUT> ]]></Input>
              <ObjectName>$Config/ObjectName$</ObjectName>
              <CounterName>$Config/CounterName$</CounterName>
              <InstanceName>$Config/InstanceName$</InstanceName>
              <Value>$Config/Value$</Value>
            </DataSource>
            <ConditionDetection ID="CDUnderThreshold" TypeID="System!System.ExpressionFilter">
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="Double">Value</XPathQuery>
                  </ValueExpression>
                  <Operator>Less</Operator>
                  <ValueExpression>
                    <Value Type="Double">$Config/Threshold$</Value>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
            </ConditionDetection>
            <ConditionDetection ID="CDOverThreshold" TypeID="System!System.ExpressionFilter">
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="Double">Value</XPathQuery>
                  </ValueExpression>
                  <Operator>GreaterEqual</Operator>
                  <ValueExpression>
                    <Value Type="Double">$Config/Threshold$</Value>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
            </ConditionDetection>
          </MemberModules>
          <RegularDetections>
            <RegularDetection MonitorTypeStateID="UnderThreshold">
              <Node ID="CDUnderThreshold">
                <Node ID="DS" />
              </Node>
            </RegularDetection>
            <RegularDetection MonitorTypeStateID="OverThreshold">
              <Node ID="CDOverThreshold">
                <Node ID="DS" />
              </Node>
            </RegularDetection>
          </RegularDetections>
        </MonitorImplementation>
      </UnitMonitorType>

In the Microsoft.SCX.Authoring.Guide.xml file that you created earlier, insert the preceding XML in the <UnitMonitorType> subsection under the <MonitorTypes> section.

Add Data Source Type

In the Unit Monitor Type definition, <DataSource> references a <DataSourceModuleType> that is named Microsoft.Unix.Microsoft.SCX.Authoring.Guide.ScriptBased.PerfCounterProvider, which must be defined.

All the attributes in <DataSourceModuleType> are defined within <Configuration>. There are two attributes that can be changed. These modifiable attributes are defined in <OverrideableParameters> and are <IntervalSeconds> and <SyncTime>. Recall from the preceding discovery definition that <IntervalSeconds> is given a value of 30 seconds and <SyncTime> is left empty. Initial values for <OverrideableParameters> are set in the <Configuration> subsection in <UnitMonitor>. <OverrideableParameters> can also be modified through the Operations console.

Because this is a performance monitor, you must make sure that the output is of the correct type. The last line before the closing tag, </DataSourceModuleType>, is an <OutputType> subsection that is defined as SystemPerf!System.Performance.Data.


     <DataSourceModuleType ID="Microsoft.SCX.Authoring.Guide.ScriptBased.PerfCounterProvider" Accessibility="Public" Batching="false">
        <Configuration>
          <xsd:element name="IntervalSeconds" type="xsd:integer" />
          <xsd:element name="TargetSystem" type="xsd:string" />
          <xsd:element name="Uri" type="xsd:string" />
          <xsd:element name="Selector" type="xsd:string" minOccurs="0" maxOccurs="1" />
          <xsd:element name="InvokeAction" type="xsd:string" />
          <xsd:element name="Input" type="xsd:string" />
          <xsd:element name="SyncTime" type="xsd:string" minOccurs="0" maxOccurs="1" />
          <xsd:element name="ObjectName" type="xsd:string" />
          <xsd:element name="CounterName" type="xsd:string" />
          <xsd:element name="InstanceName" type="xsd:string" />
          <xsd:element name="Value" type="xsd:string" />
        </Configuration>
        <OverrideableParameters>
          <OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" />
          <OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string" />
        </OverrideableParameters>
        <ModuleImplementation Isolation="Any">
          <Composite>
            <MemberModules>
              <!--Schedule when the Probe event occurs-->
              <DataSource ID="Scheduler" TypeID="System!System.SimpleScheduler">
                <IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
                <SyncTime>$Config/SyncTime$</SyncTime>
              </DataSource>
              <!--Invoke the Probe Action-->
              <ProbeAction ID="Invoke" TypeID="Unix!Microsoft.Unix.WSMan.Invoke.ProbeAction">
                <TargetSystem>$Config/TargetSystem$</TargetSystem>
                <Uri>$Config/Uri$</Uri>
                <Selector>$Config/Selector$</Selector>
                <InvokeAction>$Config/InvokeAction$</InvokeAction>
                <Input>$Config/Input$</Input>
              </ProbeAction>
              <!--Map how to handle retrieved data-->
              <ConditionDetection ID="Mapper" TypeID="SystemPerf!System.Performance.DataGenericMapper">
                <ObjectName>$Config/ObjectName$</ObjectName>
                <CounterName>$Config/CounterName$</CounterName>
                <InstanceName>$Config/InstanceName$</InstanceName>
                <Value>$Config/Value$</Value>
              </ConditionDetection>
            </MemberModules>
            <!--Describe order to execute above Modules, most deeply nested node executes first.-->
            <Composition>
              <Node ID="Mapper">
                <Node ID="Invoke">
                  <Node ID="Scheduler" />
                </Node>
              </Node>
            </Composition>
          </Composite>
        </ModuleImplementation>
        <OutputType>SystemPerf!System.Performance.Data</OutputType>
      </DataSourceModuleType>

In the Microsoft.SCX.Authoring.Guide.xml file that you created earlier, insert the preceding XML in the <ModuleTypes> section.

Add Language Pack Strings

All strings associated with the sample application performance are defined as follows:


        <DisplayString ElementID="Microsoft.SCX.Authoring.Guide.SampleAppPerf.AlertMessage">
          <Name>Sample App Performance Alert</Name>
          <Description>Application is not healthy</Description>
        </DisplayString>
        <DisplayString ElementID="Microsoft.SCX.Authoring.Guide.SampleAppPerf.Monitor">
          <Name>Sample App Perf Monitor</Name>
          <Description />
        </DisplayString>
        <DisplayString ElementID="Microsoft.SCX.Authoring.Guide.SampleAppPerf.Monitor" SubElementID="OverThreshold">
          <Name>Over Threshold</Name>
          <Description />
        </DisplayString>
        <DisplayString ElementID="Microsoft.SCX.Authoring.Guide.SampleAppPerf.Monitor" SubElementID="UnderThreshold">
          <Name>Under Threshold</Name>
          <Description />
        </DisplayString>

In the Microsoft.SCX.Authoring.Guide.xml file that you created earlier, insert the preceding XML in the <DisplayStrings> subsection under the <Language> section.

Add a Task

Additionally, a task is added that checks the application performance at any time and in addition to the regular checks that are performed by the monitor.


      <Task ID="Microsoft.SCX.Authoring.Guide.GetSampleAppPerf.Task" Accessibility="Internal" Enabled="true" Target="Unix!Microsoft.Unix.Computer" Timeout="300" Remotable="true">
        <Category>Maintenance</Category>
        <ProbeAction ID="RunScript" TypeID="Unix!Microsoft.Unix.WSMan.Invoke.ProbeAction">
          <TargetSystem>$Target/Property[Type="Unix!Microsoft.Unix.Computer"]/PrincipalName$</TargetSystem>
          <Uri>http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem?__cimnamespace=root/scx</Uri>
          <Selector />
          <InvokeAction>ExecuteCommand</InvokeAction>
          <Input><![CDATA[ <p:ExecuteCommand_INPUT xmlns:p="http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem"><p:command>sh /tmp/SampleAppPerf.sh</p:command><p:timeout>10</p:timeout></p:ExecuteCommand_INPUT> ]]></Input>
        </ProbeAction>
      </Task>

In the Microsoft.SCX.Authoring.Guide.xml file that you created earlier, insert the preceding XML in the <Tasks> subsection under the <Monitoring> section.


        <DisplayString ElementID="Microsoft.SCX.Authoring.Guide.GetSampleAppPerf.Task">
          <Name>Get Sample App Perf</Name>
          <Description />
        </DisplayString>

In the Microsoft.SCX.Authoring.Guide.xml file that you created earlier, insert the preceding XML in the <DisplayStrings> subsection under the <Language> section.

Observe Performance

If you want to observe the performance task, go to the Operations console, open a Diagram View of the computer that is being monitored and then run the Get Sample App Perf Task. The results are reported for a single execution of the task.

To observe the ongoing monitoring of performance

  1. In the Diagram View, right-click Microsoft.SCX.Sample.Application.

  2. Select Health Explorer.

  3. Expand the Performance node. Notice that there is now a Sample App Perf Monitor.

Because the data is not being stored, there is no view to observe the data over time. The Collect and View Performance Data topic describes the rule that makes it possible to record data over time.

顯示: