diff --git a/collector/process.go b/collector/process.go index f3bc2b04..20c7ce52 100644 --- a/collector/process.go +++ b/collector/process.go @@ -177,6 +177,11 @@ type Win32_PerfRawData_PerfProc_Process struct { WorkingSetPrivate uint64 } +type WorkerProcess struct { + AppPoolName string + ProcessId uint32 +} + func (c *ProcessCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, error) { var dst []Win32_PerfRawData_PerfProc_Process q := queryAllWhere(&dst, c.queryWhereClause) @@ -184,6 +189,10 @@ func (c *ProcessCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Des return nil, err } + var dst_wp []WorkerProcess + q_wp := queryAll(&dst_wp) + wmi.QueryNamespace(q_wp, &dst_wp, "root\\WebAdministration") + for _, process := range dst { if process.Name == "_Total" { @@ -194,6 +203,13 @@ func (c *ProcessCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Des pid := strconv.FormatUint(uint64(process.IDProcess), 10) cpid := strconv.FormatUint(uint64(process.CreatingProcessID), 10) + for _, wp := range dst_wp { + if wp.ProcessId == process.IDProcess { + processName = strings.Join([]string{processName, wp.AppPoolName}, "_") + break + } + } + ch <- prometheus.MustNewConstMetric( c.StartTime, prometheus.GaugeValue,