Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2.8 KiB
Process collector
The collector reads all processes with one
NtQuerySystemInformation(SystemProcessInformation) call, not with the perflib
Process or PDH Process V2 counter sets. The perflib provider (perfproc) reads
the same kernel data, so the metric values must stay identical to the Process
counter set. There is no counter-set selection; --collector.process.counter-version
and Config.CounterVersion were removed.
- Process names follow the perflib instance names: the image name without a
case-insensitive
.exesuffix, other extensions such as.scrare kept, and PID 0 isIdle. Users' include and exclude expressions depend on these names. - The
windows_process_infolabels (owner, command line, process group ID) needOpenProcessand are cached by PID and creation time, because Windows reuses PIDs. The creation time of the opened handle is compared with the snapshot, so a PID reused between the snapshot and the lookup is not attributed to the old process. Failed lookups are not cached and retry on the next scrape; access-denied results are cached as empty labels. - Read the snapshot buffer with bounds checks against the returned length, and
keep it 8-byte aligned (
[]uint64backing array).
To check value parity after changes, compare the snapshot against the Process
counter set by PID in a temporary test, for example with
pdh.NewCollector(..., pdh.CounterTypeRaw, "Process", pdh.InstancesAll), including
processes with names like a.b.exe and tool.scr. Run it as a standard user
too: neither data source needs administrator rights.
IIS application pools
IIS application pool names (--collector.process.iis) come from two sources.
- Primary: the
-ap "<pool>"argument of eachw3wpcommand line, read withNtQueryInformationProcess(ProcessCommandLineInformation). It needs onlyPROCESS_QUERY_LIMITED_INFORMATIONand Windows 8.1 or Server 2012 R2. - Fallback:
WorkerProcessinroot\WebAdministration, used only when it answered duringBuildand a command line can't be read or has no-ap. It needs the optional IIS Management Scripts and Tools feature (Web-Scripting-Tools), and asks WAS through RSCA on every query. splitCommandLinefollowsCommandLineToArgvW.FuzzSplitCommandLinecompares it withwindows.DecomposeCommandLine; run it after parser changes withgo test -run '^$' -fuzz FuzzSplitCommandLine ./internal/collector/process/.- Without IIS,
TestCollectorWorkerProcessCommandLinestarts a suspended copy of the test binary namedw3wp.exeto check the published label. The IIS tests compare against WMI when available and against theIIS APPPOOL\<pool>process owner. - Don't create or change IIS application pools on a development machine to test edge cases; use suspended processes with crafted command lines.