mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-07 11:06:36 +00:00
time: windows_time_clock_frequency_adjustment_ppb_total -> windows_time_clock_frequency_adjustment_ppb and add windows_time_clock_frequency_adjustment metric for Win2016 (#1910)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <github@jkroepke.de>
(cherry picked from commit d6196c5c6b)
This commit is contained in:
committed by
Jan-Otto Kröpke
parent
a56e1ac71a
commit
6f0209ddb7
@@ -22,8 +22,9 @@ Matching is case-sensitive.
|
|||||||
## Metrics
|
## Metrics
|
||||||
|
|
||||||
| Name | Description | Type | Labels |
|
| Name | Description | Type | Labels |
|
||||||
|-----------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|------------|
|
|----------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|------------|
|
||||||
| `windows_time_clock_frequency_adjustment_ppb_total` | Total adjustment made to the local system clock frequency by W32Time in parts per billion (PPB) units. 1 PPB adjustment implies the system clock was adjusted at a rate of 1 nanosecond per second (1 ns/s). The smallest possible adjustment can vary and is expected to be in the order of 100's of PPB. | counter | None |
|
| `windows_time_clock_frequency_adjustment` | Adjustment made to the local system clock frequency by W32Time in parts per billion (PPB) units. 1 PPB adjustment implies the system clock was adjusted at a rate of 1 nanosecond per second (1 ns/s). The smallest possible adjustment can vary and is expected to be in the order of 100's of PPB. | gauge | None |
|
||||||
|
| `windows_time_clock_frequency_adjustment_ppb` | Adjustment made to the local system clock frequency by W32Time in parts per billion (PPB) units. 1 PPB adjustment implies the system clock was adjusted at a rate of 1 nanosecond per second (1 ns/s). The smallest possible adjustment can vary and is expected to be in the order of 100's of PPB. | gauge | None |
|
||||||
| `windows_time_computed_time_offset_seconds` | The absolute time offset between the system clock and the chosen time source, as computed by the W32Time service in microseconds. When a new valid sample is available, the computed time is updated with the time offset indicated by the sample. This time is the actual time offset of the local clock. W32Time initiates clock correction by using this offset and updates the computed time in between samples with the remaining time offset that needs to be applied to the local clock. Clock accuracy can be tracked by using this performance counter with a low polling interval (for example, 256 seconds or less) and looking for the counter value to be smaller than the desired clock accuracy limit. | gauge | None |
|
| `windows_time_computed_time_offset_seconds` | The absolute time offset between the system clock and the chosen time source, as computed by the W32Time service in microseconds. When a new valid sample is available, the computed time is updated with the time offset indicated by the sample. This time is the actual time offset of the local clock. W32Time initiates clock correction by using this offset and updates the computed time in between samples with the remaining time offset that needs to be applied to the local clock. Clock accuracy can be tracked by using this performance counter with a low polling interval (for example, 256 seconds or less) and looking for the counter value to be smaller than the desired clock accuracy limit. | gauge | None |
|
||||||
| `windows_time_ntp_client_time_sources` | Active number of NTP Time sources being used by the client. This is a count of active, distinct IP addresses of time servers that are responding to this client's requests. | gauge | None |
|
| `windows_time_ntp_client_time_sources` | Active number of NTP Time sources being used by the client. This is a count of active, distinct IP addresses of time servers that are responding to this client's requests. | gauge | None |
|
||||||
| `windows_time_ntp_round_trip_delay_seconds` | Total roundtrip delay experienced by the NTP client in receiving a response from the server for the most recent request, in seconds. This is the time elapsed on the NTP client between transmitting a request to the NTP server and receiving a valid response from the server. | gauge | None |
|
| `windows_time_ntp_round_trip_delay_seconds` | Total roundtrip delay experienced by the NTP client in receiving a response from the server for the most recent request, in seconds. This is the time elapsed on the NTP client between transmitting a request to the NTP server and receiving a valid response from the server. | gauge | None |
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Microsoft/hcsshim/osversion"
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/kernel32"
|
"github.com/prometheus-community/windows_exporter/internal/headers/kernel32"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
@@ -58,9 +59,12 @@ type Collector struct {
|
|||||||
perfDataCollector *pdh.Collector
|
perfDataCollector *pdh.Collector
|
||||||
perfDataObject []perfDataCounterValues
|
perfDataObject []perfDataCounterValues
|
||||||
|
|
||||||
|
ppbCounterPresent bool
|
||||||
|
|
||||||
currentTime *prometheus.Desc
|
currentTime *prometheus.Desc
|
||||||
timezone *prometheus.Desc
|
timezone *prometheus.Desc
|
||||||
clockFrequencyAdjustmentPPBTotal *prometheus.Desc
|
clockFrequencyAdjustment *prometheus.Desc
|
||||||
|
clockFrequencyAdjustmentPPB *prometheus.Desc
|
||||||
computedTimeOffset *prometheus.Desc
|
computedTimeOffset *prometheus.Desc
|
||||||
ntpClientTimeSourceCount *prometheus.Desc
|
ntpClientTimeSourceCount *prometheus.Desc
|
||||||
ntpRoundTripDelay *prometheus.Desc
|
ntpRoundTripDelay *prometheus.Desc
|
||||||
@@ -125,6 +129,9 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/prometheus-community/windows_exporter/issues/1891
|
||||||
|
c.ppbCounterPresent = osversion.Build() >= osversion.LTSC2019
|
||||||
|
|
||||||
c.currentTime = prometheus.NewDesc(
|
c.currentTime = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "current_timestamp_seconds"),
|
prometheus.BuildFQName(types.Namespace, Name, "current_timestamp_seconds"),
|
||||||
"OperatingSystem.LocalDateTime",
|
"OperatingSystem.LocalDateTime",
|
||||||
@@ -137,9 +144,15 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
[]string{"timezone"},
|
[]string{"timezone"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
c.clockFrequencyAdjustmentPPBTotal = prometheus.NewDesc(
|
c.clockFrequencyAdjustment = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "clock_frequency_adjustment_ppb_total"),
|
prometheus.BuildFQName(types.Namespace, Name, "clock_frequency_adjustment"),
|
||||||
"Total adjustment made to the local system clock frequency by W32Time in Parts Per Billion (PPB) units.",
|
"This value reflects the adjustment made to the local system clock frequency by W32Time in nominal clock units. This counter helps visualize the finer adjustments being made by W32time to synchronize the local clock.",
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
c.clockFrequencyAdjustmentPPB = prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(types.Namespace, Name, "clock_frequency_adjustment_ppb"),
|
||||||
|
"This value reflects the adjustment made to the local system clock frequency by W32Time in Parts Per Billion (PPB) units. 1 PPB adjustment imples the system clock was adjusted at a rate of 1 nanosecond per second. The smallest possible adjustment can vary and can be expected to be in the order of 100's of PPB. This counter helps visualize the finer actions being taken by W32time to synchronize the local clock.",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
@@ -232,14 +245,23 @@ func (c *Collector) collectTime(ch chan<- prometheus.Metric) error {
|
|||||||
func (c *Collector) collectNTP(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectNTP(ch chan<- prometheus.Metric) error {
|
||||||
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect VM Memory metrics: %w", err)
|
return fmt.Errorf("failed to collect time metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.clockFrequencyAdjustmentPPBTotal,
|
c.clockFrequencyAdjustment,
|
||||||
prometheus.CounterValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].ClockFrequencyAdjustmentPPBTotal,
|
c.perfDataObject[0].ClockFrequencyAdjustment,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if c.ppbCounterPresent {
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.clockFrequencyAdjustmentPPB,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
c.perfDataObject[0].ClockFrequencyAdjustmentPPB,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.computedTimeOffset,
|
c.computedTimeOffset,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
package time
|
package time
|
||||||
|
|
||||||
type perfDataCounterValues struct {
|
type perfDataCounterValues struct {
|
||||||
ClockFrequencyAdjustmentPPBTotal float64 `perfdata:"Clock Frequency Adjustment (ppb)"`
|
ClockFrequencyAdjustment float64 `perfdata:"Clock Frequency Adjustment"`
|
||||||
|
ClockFrequencyAdjustmentPPB float64 `perfdata:"Clock Frequency Adjustment (ppb)" perfdata_min_build:"17763"`
|
||||||
ComputedTimeOffset float64 `perfdata:"Computed Time Offset"`
|
ComputedTimeOffset float64 `perfdata:"Computed Time Offset"`
|
||||||
NTPClientTimeSourceCount float64 `perfdata:"NTP Client Time Source Count"`
|
NTPClientTimeSourceCount float64 `perfdata:"NTP Client Time Source Count"`
|
||||||
NTPRoundTripDelay float64 `perfdata:"NTP Roundtrip Delay"`
|
NTPRoundTripDelay float64 `perfdata:"NTP Roundtrip Delay"`
|
||||||
|
|||||||
@@ -20,10 +20,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"slices"
|
"slices"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/Microsoft/hcsshim/osversion"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
@@ -151,7 +153,18 @@ func NewCollectorWithReflection(resultType CounterType, object string, instances
|
|||||||
|
|
||||||
var counterHandle pdhCounterHandle
|
var counterHandle pdhCounterHandle
|
||||||
|
|
||||||
|
//nolint:nestif
|
||||||
if ret := AddEnglishCounter(handle, counterPath, 0, &counterHandle); ret != ErrorSuccess {
|
if ret := AddEnglishCounter(handle, counterPath, 0, &counterHandle); ret != ErrorSuccess {
|
||||||
|
if ret == CstatusNoCounter {
|
||||||
|
if minOSBuildTag, ok := f.Tag.Lookup("perfdata_min_build"); ok {
|
||||||
|
if minOSBuild, err := strconv.Atoi(minOSBuildTag); err == nil {
|
||||||
|
if uint16(minOSBuild) > osversion.Build() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
errs = append(errs, fmt.Errorf("failed to add counter %s: %w", counterPath, NewPdhError(ret)))
|
errs = append(errs, fmt.Errorf("failed to add counter %s: %w", counterPath, NewPdhError(ret)))
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -427,8 +427,10 @@ windows_service_state{name="Themes",state="stopped"} 0
|
|||||||
# TYPE windows_tcp_segments_total counter
|
# TYPE windows_tcp_segments_total counter
|
||||||
# HELP windows_textfile_mtime_seconds Unixtime mtime of textfiles successfully read.
|
# HELP windows_textfile_mtime_seconds Unixtime mtime of textfiles successfully read.
|
||||||
# TYPE windows_textfile_mtime_seconds gauge
|
# TYPE windows_textfile_mtime_seconds gauge
|
||||||
# HELP windows_time_clock_frequency_adjustment_ppb_total Total adjustment made to the local system clock frequency by W32Time in Parts Per Billion (PPB) units.
|
# HELP windows_time_clock_frequency_adjustment This value reflects the adjustment made to the local system clock frequency by W32Time in nominal clock units. This counter helps visualize the finer adjustments being made by W32time to synchronize the local clock.
|
||||||
# TYPE windows_time_clock_frequency_adjustment_ppb_total counter
|
# TYPE windows_time_clock_frequency_adjustment gauge
|
||||||
|
# HELP windows_time_clock_frequency_adjustment_ppb This value reflects the adjustment made to the local system clock frequency by W32Time in Parts Per Billion (PPB) units. 1 PPB adjustment imples the system clock was adjusted at a rate of 1 nanosecond per second. The smallest possible adjustment can vary and can be expected to be in the order of 100's of PPB. This counter helps visualize the finer actions being taken by W32time to synchronize the local clock.
|
||||||
|
# TYPE windows_time_clock_frequency_adjustment_ppb gauge
|
||||||
# HELP windows_time_computed_time_offset_seconds Absolute time offset between the system clock and the chosen time source, in seconds
|
# HELP windows_time_computed_time_offset_seconds Absolute time offset between the system clock and the chosen time source, in seconds
|
||||||
# TYPE windows_time_computed_time_offset_seconds gauge
|
# TYPE windows_time_computed_time_offset_seconds gauge
|
||||||
# HELP windows_time_current_timestamp_seconds OperatingSystem.LocalDateTime
|
# HELP windows_time_current_timestamp_seconds OperatingSystem.LocalDateTime
|
||||||
|
|||||||
Reference in New Issue
Block a user