mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-27 07:06:35 +00:00
process: negative values with windows_process_start_time (#1857)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -76,6 +76,8 @@ type Collector struct {
|
|||||||
poolBytes *prometheus.Desc
|
poolBytes *prometheus.Desc
|
||||||
priorityBase *prometheus.Desc
|
priorityBase *prometheus.Desc
|
||||||
privateBytes *prometheus.Desc
|
privateBytes *prometheus.Desc
|
||||||
|
// Deprecated: Use start_time_seconds_timestamp instead
|
||||||
|
startTimeOld *prometheus.Desc
|
||||||
startTime *prometheus.Desc
|
startTime *prometheus.Desc
|
||||||
threadCount *prometheus.Desc
|
threadCount *prometheus.Desc
|
||||||
virtualBytes *prometheus.Desc
|
virtualBytes *prometheus.Desc
|
||||||
@@ -214,8 +216,15 @@ func (c *Collector) Build(logger *slog.Logger, miSession *mi.Session) error {
|
|||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
c.startTime = prometheus.NewDesc(
|
c.startTimeOld = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "start_time"),
|
prometheus.BuildFQName(types.Namespace, Name, "start_time"),
|
||||||
|
"DEPRECATED: Use start_time_seconds_timestamp instead",
|
||||||
|
[]string{"process", "process_id"},
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
|
||||||
|
c.startTime = prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(types.Namespace, Name, "start_time_seconds_timestamp"),
|
||||||
"Time of process start.",
|
"Time of process start.",
|
||||||
[]string{"process", "process_id"},
|
[]string{"process", "process_id"},
|
||||||
nil,
|
nil,
|
||||||
|
|||||||
@@ -141,6 +141,13 @@ func (c *Collector) collectWorkerV1() {
|
|||||||
name, pidString,
|
name, pidString,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.startTimeOld,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
data.ElapsedTime,
|
||||||
|
name, pidString,
|
||||||
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.handleCount,
|
c.handleCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
@@ -134,10 +135,19 @@ func (c *Collector) collectWorkerV2() {
|
|||||||
name, pidString, parentPID, strconv.Itoa(int(processGroupID)), processOwner, cmdLine,
|
name, pidString, parentPID, strconv.Itoa(int(processGroupID)), processOwner, cmdLine,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
startTime := float64(time.Now().Unix() - int64(data.ElapsedTime))
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.startTimeOld,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
startTime,
|
||||||
|
name, pidString,
|
||||||
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.startTime,
|
c.startTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.ElapsedTime,
|
startTime,
|
||||||
name, pidString,
|
name, pidString,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ func (c *Collector) collectWorkerRaw() {
|
|||||||
case PERF_ELAPSED_TIME:
|
case PERF_ELAPSED_TIME:
|
||||||
dv.Index(index).
|
dv.Index(index).
|
||||||
Field(counter.FieldIndexValue).
|
Field(counter.FieldIndexValue).
|
||||||
SetFloat(float64((item.RawValue.FirstValue - WindowsEpoch) / counter.Frequency))
|
SetFloat(float64((item.RawValue.SecondValue - item.RawValue.FirstValue) / counter.Frequency))
|
||||||
case PERF_100NSEC_TIMER, PERF_PRECISION_100NS_TIMER:
|
case PERF_100NSEC_TIMER, PERF_PRECISION_100NS_TIMER:
|
||||||
dv.Index(index).
|
dv.Index(index).
|
||||||
Field(counter.FieldIndexValue).
|
Field(counter.FieldIndexValue).
|
||||||
|
|||||||
Reference in New Issue
Block a user