I have a terminal services server that runs instances of a thick-client application and serves them up to users via RemoteApp. In order to do some capacity planning I would like to continuously log some performance counter data such as CPU usage, disk I/o, memory usage, etc, and see how it scales with the number of active sessions. Is there some kind of performance counter I can set up that counts up the number of active processes matching a particular name or path so that I can add that to a performance counter log and gather some data so that I can correlate # users vs resource usage?
Count instances of application using Windows Performance Counters
performance-counters
Related Solutions
Which performance counters matter the most, when judging server load?
Almost all of them , but you should probably start with CPU %,Private working sets and IOPS.
is it a performance concern if one leaves such data-collectors running indefinitely?
Yes mainly I/O , memory ,cpu , disk space. Mostly in that order.
I will not know when the server will experience slow performance, so I need the logs there so that I can check them out
Now you are getting somewhere. You need to do a short of root cause analysis.
Before you do that, this is where a replica of your production (your testing environment) should be bench-marked,tortured,killed and then post-mortem'ed , so that you'll never have to experience that on production.
Performance can mean a bazillion different things. You set the bar to what bad or good performance is and that depends on your services and your SLA's. MS has a very good document about performance counters
If you don't know what's causing your performance issues, you can start by isolating your services and debugging them one by one. Are you running a web server? Check your CPU first. Are you running a database, check your IOPS, and so on.
Obviously, I will not know when the server will experience slow performance, so I need the logs there so that I can check them out
Generally you need to have at least the following triplet: Monitoring,Alerting and log aggregation.
Performance counters do an excellent job but they only offer the latter. That's why you need some alerting(e.g. Nagios) with some constant monitoring (e.g cacti,munin).
The asterisk stands for "All Instances," which includes _Total where applicable.
Perfmon is probably the easiest place to look at the counters and see what's available on your system.
From the documentation for typeperf:
•Counter path format
The general format for counter paths is as follows: [\\Computer]\object[parent/instance#index]\counter] where:
The parent, instance, index, and counter components of the format may contain either a valid name or a wildcard character. The computer, parent, instance, and index components are not necessary for all counters.
You determine the counter paths to use based on the counter itself. For example, the LogicalDisk object has an instance index, so you must provide the #index or a wildcard. Therefore, you could use the following format:
\LogicalDisk(*/*#*)\*
In comparison, the Process object does not require an instance index. Therefore, you could use the following format:
\Process(*)\ID Process
The following is a list of the possible formats: ◦ \\machine\object(parent/instance#index)\counter
◦ \\machine\object(parent/instance)\counter
◦ \\machine\object(instance#index)\counter
◦ \\machine\object(instance)\counter
◦ \\machine\object\counter
◦ \object(parent/instance#index)\counter
◦ \object(parent/instance)\counter
◦ \object(instance#index)\counter
◦ \object(instance)\counter
◦ \object\counter
Edit: Oh, and don't forget to check out Get-Counter in Powershell:
PS C:\> (Get-Counter -ListSet Memory).Paths
\Memory\Page Faults/sec
\Memory\Available Bytes
\Memory\Committed Bytes
\Memory\Commit Limit
\Memory\Write Copies/sec
\Memory\Transition Faults/sec
\Memory\Cache Faults/sec
\Memory\Demand Zero Faults/sec
\Memory\Pages/sec
\Memory\Pages Input/sec
...
The second command gets the path names that include "cache".
PS C:\> (Get-Counter -ListSet Memory).Paths | Where {$_ -like "*Cache*"}
\Memory\Cache Faults/sec
\Memory\Cache Bytes
\Memory\Cache Bytes Peak
\Memory\System Cache Resident Bytes
\Memory\Standby Cache Reserve Bytes
\Memory\Standby Cache Normal Priority Bytes
\Memory\Standby Cache Core Bytes
Best Answer
There isn't an inbuilt performance counter that will do any kind of "pattern matching" on names. (Performance counters don't really work that way-- they don't take any kind of "input" parameter. They're just outputs.)
The "Processes" object tracks all running processes. I'd log the Processes object and parse the output to get a count of processes.
If each remote desktop session can be assumed to be running one instance of the application you could just track the "Active Sessions" counter in the "Terminal Services" object.