Compartilhar via


SPHttpThrottleSettings.AddPerformanceMonitor Method (String, String, SPSystemPerformanceCounterRelativeInstance, Double , Boolean)

Adds to the PerformanceMonitors collection an object that holds data that is used at runtime to create a performance monitor whose instance name is the process name or the SharePoint Foundation Web application name.

Namespace:  Microsoft.SharePoint.Utilities
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
Public Sub AddPerformanceMonitor ( _
    category As String, _
    counter As String, _
    instanceEnum As SPSystemPerformanceCounterRelativeInstance, _
    buckets As Double(), _
    isASC As Boolean _
)
'Usage
Dim instance As SPHttpThrottleSettings
Dim category As String
Dim counter As String
Dim instanceEnum As SPSystemPerformanceCounterRelativeInstance
Dim buckets As Double()
Dim isASC As Boolean

instance.AddPerformanceMonitor(category, _
    counter, instanceEnum, buckets, isASC)
public void AddPerformanceMonitor(
    string category,
    string counter,
    SPSystemPerformanceCounterRelativeInstance instanceEnum,
    double[] buckets,
    bool isASC
)

Parameters

  • buckets
    Type: []

    An array of values that set the boundaries between ranges of counter values (“buckets”).

  • isASC
    Type: System.Boolean

    true to indicate that the values in get progressively larger with each successive member of the array (that is, they are ascending), false to indicate that they get smaller.

Exceptions

Exception Condition
ArgumentNullException

One of the parameters is a null reference (Nothing in Visual Basic) or an empty string.

InvalidOperationException

counter is not the name of an actual counter in the operating system.

Remarks

The buckets and isASC parameters must meet certain conditions:

  • The values of the elements in buckets must be well-ordered, either from smallest to largest or from largest to smallest.

  • isASC indicates the direction of the ordering in buckets.

  • The values in buckets must also be well-ordered from healthiest to least healthy. So buckets[0] is a healthier value than buckets[1] and the latter is a healthier value than buckets[2], and so on. Hence, buckets[buckets.Length-1] must always be the least healthy value in buckets.

A SPBucketHealthScoreCalculator object will translate any measured value into an integer from 0 to 10, depending on where the value falls in the ranges marked out by elements of buckets. Any value that is less than buckets[0] (or greater than it, if buckets is descending) is scored as a 0, which is the healthiest possible score. Any value that is greater than buckets[buckets.Length-1] (or less than it, if buckets is descending) is scored as a 10, which is the least healthy score. Other measured values will get a value from 1 to 9 depending on where they fall with respect to the values in buckets.

There is no point to having more than 10 elements in buckets because the ultimate health scores must be from 0 to 10 anyway.

Depending on what kind of performance is being measured, it is often appropriate for the values in buckets to scale exponentially.

AddPerformanceMonitor calls Update() internally, so your code does not need to call Update() following a call of AddPerformanceMonitor.

Examples

The following example is a declaration of an array that could be passed as a buckets parameter. In this case, the array specifies ranges of available memory, measured in megabytes.

double[] availableMemoryBuckets = new double[10]
                                  {1000.0, 500.0, 400.0, 300.0, 200.0,
                                    100.0,  80.0,  60.0,  40.0,  20.0};
Dim availableMemoryBuckets() As Double = {1000.0, 500.0, 400.0, 300.0, 200.0, 100.0, 80.0, 60.0, 40.0, 20.0}

See Also

Reference

SPHttpThrottleSettings Class

SPHttpThrottleSettings Members

AddPerformanceMonitor Overload

Microsoft.SharePoint.Utilities Namespace