我正在编写一个程序,它使用.NET性能计数器来获取特定进程的CPU,内存和网络使用情况.
例如,要获取CPU和内存数据Explorer,我创建如下性能计数器:
PerformanceCounter PC = new PerformanceCounter();
PC.CategoryName = "Process";
PC.CounterName = "% Processor Time";
PC.InstanceName = "Explorer";
PerformanceCounter PC = new PerformanceCounter();
PC.CategoryName = "Process";
PC.CounterName = "Working Set - Private";
PC.InstanceName = "Explorer";
Run Code Online (Sandbox Code Playgroud)
不幸的是,Process没有属性categoryName允许我获得该进程的网络使用.我可以使用网络接口categoryName来获取任何特定NIC上的整体网络使用情况,但无法将其隔离到任何给定的进程.