Windows get performance counter




















When talking about an instance , a counter value might sometimes be called a counter or a value. It might be helpful to relate performance counter terms to more familiar spreadsheet terms. A counterset is like a table. A counter is like a column. An instance is like a row. A counter value is like a cell in the table. Single-instance countersets always contain data for exactly one instance.

This is common for countersets that report system-global statistics. For example, Windows has a built-in single-instance counterset named "Memory" that reports on global memory usage.

Multi-instance countersets contain data for a variable number of instances. This is common for countersets that report about entities within the system. For example, Windows has a built-in multi-instance counterset named "Processor Information" that reports one instance for each installed CPU.

Consumers will periodically collect and record the data from a provider's counterset. For example, the consumer might collect data once per second or once per minute. The data collected is called a sample. A sample consists of timestamps along with the data for instances of the counterset.

The data for each instance includes the instance name string and a set of counter values integers, one value for each counter in the counterset. Instance names should normally be unique within a sample, i. Some older providers do not follow this rule, so consumers must be able to tolerate non-unique instance names.

Instance names are not case-sensitive, so instances should not have names that differ only in case. For backwards-compatibility reasons, the "Process" counterset returns non-unique instance names based on the EXE filename. This can cause confusing results, especially when a process with a non-unique name starts up or shuts down, as this will typically result in data glitches due to incorrect matching of instance names between samples. Consumers of the "Process" counterset must be able to tolerate these non-unique instance names and the resulting data glitches.

Instance names must be stable across samples, i. Each counter has a type. The counter type indicates the type of the counter's raw value either unsigned bit integer or unsigned bit integer. The counter type also indicates what the counter's raw value represents, which determines how the raw value should be processed to generate useful statistics. While some counter types are simple and have a raw value that is directly useful, many counter types require additional processing to create a useful formatted value.

To produce the formatted value, some counter types require raw values from two samples, some counter types require timestamps, and some counter types require raw values from multiple counters. For example:. Where-Object uses a script block to compare each objects value against a specified value of CookedValue is a variable for the current object in the pipeline.

Counters with a CookedValue that is less than 20 are displayed. This example shows how to sort performance counter data. The example finds the processes on the computer that are using the most processor time during the sample.

Format-Table uses the Property parameter to select the columns for the output. Specifies one computer name or a comma-separated array of remote computer names. To get performance counter data from the local computer, exclude the ComputerName parameter. For output such as a ListSet that contains the MachineName column, a dot. Get-Counter doesn't rely on PowerShell remoting. You can use the ComputerName parameter even if your computer isn't configured to run remote commands.

Samples are obtained every second for each specified performance counter. Use the SampleInterval parameter to increase the interval between continuous samples.

Specifies the path to one or more counter paths. Paths are input as a comma-separated array, a variable, or values from a text file. You can send counter path strings down the pipeline to Get-Counter. If the counter path doesn't include the computer name, Get-Counter uses the local computer. Lists the performance counter sets on the computers. Enter one name or a comma-separated string of counter set names. You can send counter set names down the pipeline.

To get a counter sets formatted counter paths, use the ListSet parameter. The Paths and PathsWithInstances properties of each counter set contain the individual counter paths formatted as a string.

You can save the counter path strings in a variable or use the pipeline to send the string to another Get-Counter command. Specifies the number of samples to get from each specified performance counter. To get a constant stream of samples, use the Continuous parameter. If the MaxSamples parameter isn't specified, Get-Counter only gets one sample for each specified counter.

To collect a large data set, run Get-Counter as a PowerShell background job. Specifies the number of seconds between samples for each specified performance counter. If the SampleInterval parameter isn't specified, Get-Counter uses a one-second interval. String [ ].

CounterSet, Microsoft. PerformanceCounterSampleSet, Microsoft. To view an object's properties, send the output down the pipeline to Get-Member. The object types that are output are as follows:. ListSet parameter: Microsoft. Counter parameter: Microsoft. This constructor requires that the category contain a single instance. Initializes a new, read-only instance of the PerformanceCounter class and associates it with the specified system or custom performance counter and category instance on the local computer.

Initializes a new, read-only instance of the PerformanceCounter class and associates it with the specified system or custom performance counter and category instance, on the specified computer.

Specifies the size, in bytes, of the global memory shared by performance counters. The default size is , bytes. Gets the IContainer that contains the Component.

Gets or sets the name of the performance counter that is associated with this PerformanceCounter instance. Gets a value that indicates whether the Component is currently in design mode. Gets the list of event handlers that are attached to this Component.

Gets or sets a value indicating whether this PerformanceCounter instance is in read-only mode. Gets or sets the ISite of the Component. Begins the initialization of a PerformanceCounter instance used on a form or by another component. The initialization occurs at runtime. Closes the performance counter and frees all the resources allocated by this performance counter instance. Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

Releases all resources used by the Component. Releases the unmanaged resources used by the Component and optionally releases the managed resources. Ends the initialization of a PerformanceCounter instance that is used on a form or by another component.

Retrieves the current lifetime service object that controls the lifetime policy for this instance. Returns an object that represents a service provided by the Component or by its Container. Gets the Type of the current instance.

Increments or decrements the value of the associated performance counter by a specified amount through an efficient atomic operation.

Creates a shallow copy of the current Object. Creates a shallow copy of the current MarshalByRefObject object. Deletes the category instance specified by the PerformanceCounter object InstanceName property. Returns a String containing the name of the Component , if any. This method should not be overridden. Occurs when the component is disposed by a call to the Dispose method.

Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Performance Counter Class Reference Is this page helpful? Please rate your experience Yes No.

Any additional feedback? Namespace: System. Diagnostics Assembly: System. Represents a Windows NT performance counter component.

Important In versions 1.



0コメント

  • 1000 / 1000