On my machine, I have two SQL instances (Instance A and Instance B). If i had only one SQL instance, I could get the resource usage like CPU for example by using the process name i.e
var cpu = new PerformanceCounter("Process", "% Processor Time", myProccessName, true);
However, in case of two SQL instances, although they have two different process ID, the process name for both of them is the same 'sqlserver'
Finding the process ID is easy, how can I use the PerformanceCounter to return the cpu/ram value based on the process ID?
Any other way I can use to get the CPU/RAM usage of all SQL instances installed on the same machine?