Sub topic 17
Performance Monitor and Resource Monitor
This chapter assumes you can open Task Manager and read its Performance tab. It also assumes you know what CPU, RAM, disk, and network usage mean. Task Manager shows what is happening now. Performance Monitor and Resource Monitor go further: one records counters over time, and the other shows which process is using which resource.
Two tools, two jobs
| Tool | Launch | Main purpose | Time frame |
|---|---|---|---|
| Resource Monitor | `resmon` | Find which process, file, or connection is using CPU, memory, disk, or network | Live, with a short rolling graph |
| Performance Monitor | `perfmon` | Graph and log specific counters, and compare them to a baseline | Live or recorded over hours or days |
On the exam, "which program is hammering the disk right now?" points to Resource Monitor. "Is the server slower than it was last month?" points to Performance Monitor.
Resource Monitor
You can open Resource Monitor three ways: run resmon, run perfmon /res, or click Open Resource Monitor on Task Manager's Performance tab. It has five tabs.
- Overview shows all four resources side by side, each with a graph and a process list.
- CPU lists processes with their CPU use. It also shows services and associated handles and modules.
- Memory lists processes with their memory use. A bar shows physical memory split into Hardware Reserved, In Use, Modified, Standby, and Free.
- Disk shows the files being read or written, which process owns them, and the response time.
- Network shows per-process traffic, TCP connections, and listening ports.
Useful techniques
- Tick the checkbox next to a process. Every tab then filters to that process, so you can see its files, connections, and memory together.
- Right-click a process that has stopped responding and choose Analyze Wait Chain. If it is waiting on another process, that process is shown. You can end the blocker instead of the whole application.
- Use the Network tab's Listening Ports list to spot a service that is accepting connections unexpectedly.
- Use the Hard Faults/sec graph on the Memory tab. A hard fault means Windows had to read a page from the page file on disk because it was not in RAM. Constant high values with little free memory point to a RAM shortage.
Performance Monitor
Performance Monitor is a Microsoft Management Console snap-in. You can also reach it from Computer Management under System Tools > Performance. It has three parts.
- Performance Monitor is the live graph. You add counters with the green plus button.
- Data Collector Sets are saved groups of counters, traces, and settings that run on demand or on a schedule. Windows ships with built-in sets such as System Diagnostics and System Performance, and you can create your own.
- Reports hold the output of data collector sets, including the System Diagnostics report with its warnings.
Objects, counters, and instances
A counter belongs to a performance object. Some counters have instances. For example, \PhysicalDisk(0 C:)\Avg. Disk Queue Length names the object PhysicalDisk, the instance disk 0, and the counter itself.
| Counter | Healthy sign | Problem sign |
|---|---|---|
| `\Processor(_Total)\% Processor Time` | Spikes, with an average well below 80% | Stays near 100% |
| `\Memory\Available MBytes` | Hundreds of MB free | Near zero |
| `\Memory\Pages/sec` | Low, with occasional bursts | Constantly high |
| `\PhysicalDisk(_Total)\Avg. Disk Queue Length` | Under about 2 per spindle | Stays higher |
| `\Network Interface(*)\Bytes Total/sec` | Well under link speed | Near link speed |
These thresholds are rules of thumb, not fixed limits. The useful comparison is against a baseline.
Baselines
A baseline is a recording of normal behavior taken when the system is healthy. When a user later says "it got slow," you record again and compare the two sets. Without a baseline you can only guess whether 70% CPU is unusual for that machine.
Command-line access
You can read and record counters from Command Prompt. Run these from an elevated prompt.
perfmon
perfmon /res
resmon
typeperf "\Processor(_Total)\% Processor Time" -si 2 -sc 5
logman create counter Baseline -c "\Processor(_Total)\% Processor Time" "\Memory\Available MBytes" -si 15 -o C:\PerfLogs\Baseline
logman start Baseline
logman stop Baselinetypeperf prints a counter every 2 seconds (-si) for 5 samples (-sc). logman create counter defines a data collector set that samples every 15 seconds. logman start and logman stop begin and end the recording, and the log is written to C:\PerfLogs. A user must be an administrator, or a member of the Performance Log Users group, to create and run collector sets.
Choosing between them
Common mistakes
- Reading one reading as a verdict. A brief 100% CPU spike is normal. Look at sustained values.
- Blaming the disk without checking memory. Heavy paging produces disk activity that looks like a disk problem, so check Hard Faults/sec and Available MBytes first.
- Forgetting that Resource Monitor only shows the present. Intermittent problems need a data collector set.
- Running tools without elevation. Some process details and collector set creation need administrator rights.
Exercise
A technician says a file server has been slow since last week. Which tool and which prior recording let the technician show whether disk and memory use have actually changed?
Show answer
Performance Monitor, using a data collector set to record counters such as PhysicalDisk Avg. Disk Queue Length and Memory Available MBytes. The technician compares the new recording to the baseline taken when the server was healthy.
Exercise
An application is frozen and Task Manager shows no unusual CPU use. Which Resource Monitor feature can show whether it is waiting on another process?
Show answer
Analyze Wait Chain. Right-click the frozen process in Resource Monitor and choose it. The result names the process being waited on, which you can then end.
Exercise
Which command-line tool prints a performance counter every 2 seconds for 5 samples, and which switches set those values?
Show answer
typeperf, with -si 2 for the sample interval in seconds and -sc 5 for the sample count.