尝试使用 powershell 性能计数器,它们有很多功能......
可以在此处找到 power shell 命令(import-counter)的方式指南。
http://ss64.com/ps/
我在下面添加了一些示例代码,供您查看它们是如何调用的:
private static void LoadBLG(string CounterPath)
{
PowerShell ps = PowerShell.Create();
ps.AddCommand("import-counter");
ps.AddArgument(CounterPath);
Console.WriteLine(CounterPath);
Console.WriteLine("------------------------");
foreach (PSObject result in ps.Invoke())
{
if (result.ImmediateBaseObject is PerformanceCounterSampleSet)
{
PerformanceCounterSampleSet Counters = result.ImmediateBaseObject as PerformanceCounterSampleSet;
foreach (PerformanceCounterSample sample in Counters.CounterSamples)
Console.WriteLine("{0,-20}{1}",
sample.Path, sample.RawValue);
}
} // End foreach.
祝你好运马修