mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-25 22:26:37 +00:00
adfs: Implement PDH collector (#1656)
This commit is contained in:
@@ -2,29 +2,29 @@ package cpu
|
||||
|
||||
// Processor performance counters.
|
||||
const (
|
||||
C1TimeSeconds = "% C1 Time"
|
||||
C2TimeSeconds = "% C2 Time"
|
||||
C3TimeSeconds = "% C3 Time"
|
||||
C1TransitionsTotal = "C1 Transitions/sec"
|
||||
C2TransitionsTotal = "C2 Transitions/sec"
|
||||
C3TransitionsTotal = "C3 Transitions/sec"
|
||||
ClockInterruptsTotal = "Clock Interrupts/sec"
|
||||
DPCsQueuedTotal = "DPCs Queued/sec"
|
||||
DPCTimeSeconds = "% DPC Time"
|
||||
IdleBreakEventsTotal = "Idle Break Events/sec"
|
||||
IdleTimeSeconds = "% Idle Time"
|
||||
InterruptsTotal = "Interrupts/sec"
|
||||
InterruptTimeSeconds = "% Interrupt Time"
|
||||
ParkingStatus = "Parking Status"
|
||||
PerformanceLimitPercent = "% Performance Limit"
|
||||
PriorityTimeSeconds = "% Priority Time"
|
||||
PrivilegedTimeSeconds = "% Privileged Time"
|
||||
PrivilegedUtilitySeconds = "% Privileged Utility"
|
||||
ProcessorFrequencyMHz = "Processor Frequency"
|
||||
ProcessorPerformance = "% Processor Performance"
|
||||
ProcessorTimeSeconds = "% Processor Time"
|
||||
ProcessorUtilityRate = "% Processor Utility"
|
||||
UserTimeSeconds = "% User Time"
|
||||
c1TimeSeconds = "% C1 Time"
|
||||
c2TimeSeconds = "% C2 Time"
|
||||
c3TimeSeconds = "% C3 Time"
|
||||
c1TransitionsTotal = "C1 Transitions/sec"
|
||||
c2TransitionsTotal = "C2 Transitions/sec"
|
||||
c3TransitionsTotal = "C3 Transitions/sec"
|
||||
clockInterruptsTotal = "Clock Interrupts/sec"
|
||||
dpcQueuedPerSecond = "DPCs Queued/sec"
|
||||
dpcTimeSeconds = "% DPC Time"
|
||||
idleBreakEventsTotal = "Idle Break Events/sec"
|
||||
idleTimeSeconds = "% Idle Time"
|
||||
interruptsTotal = "Interrupts/sec"
|
||||
interruptTimeSeconds = "% Interrupt Time"
|
||||
parkingStatus = "Parking Status"
|
||||
performanceLimitPercent = "% Performance Limit"
|
||||
priorityTimeSeconds = "% Priority Time"
|
||||
privilegedTimeSeconds = "% Privileged Time"
|
||||
privilegedUtilitySeconds = "% Privileged Utility"
|
||||
processorFrequencyMHz = "Processor Frequency"
|
||||
processorPerformance = "% Processor Performance"
|
||||
processorTimeSeconds = "% Processor Time"
|
||||
processorUtilityRate = "% Processor Utility"
|
||||
userTimeSeconds = "% User Time"
|
||||
)
|
||||
|
||||
type perflibProcessorInformation struct {
|
||||
|
||||
@@ -78,29 +78,29 @@ func (c *Collector) Close(_ *slog.Logger) error {
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||
if utils.PDHEnabled() {
|
||||
counters := []string{
|
||||
C1TimeSeconds,
|
||||
C2TimeSeconds,
|
||||
C3TimeSeconds,
|
||||
C1TransitionsTotal,
|
||||
C2TransitionsTotal,
|
||||
C3TransitionsTotal,
|
||||
ClockInterruptsTotal,
|
||||
DPCsQueuedTotal,
|
||||
DPCTimeSeconds,
|
||||
IdleBreakEventsTotal,
|
||||
IdleTimeSeconds,
|
||||
InterruptsTotal,
|
||||
InterruptTimeSeconds,
|
||||
ParkingStatus,
|
||||
PerformanceLimitPercent,
|
||||
PriorityTimeSeconds,
|
||||
PrivilegedTimeSeconds,
|
||||
PrivilegedUtilitySeconds,
|
||||
ProcessorFrequencyMHz,
|
||||
ProcessorPerformance,
|
||||
ProcessorTimeSeconds,
|
||||
ProcessorUtilityRate,
|
||||
UserTimeSeconds,
|
||||
c1TimeSeconds,
|
||||
c2TimeSeconds,
|
||||
c3TimeSeconds,
|
||||
c1TransitionsTotal,
|
||||
c2TransitionsTotal,
|
||||
c3TransitionsTotal,
|
||||
clockInterruptsTotal,
|
||||
dpcQueuedPerSecond,
|
||||
dpcTimeSeconds,
|
||||
idleBreakEventsTotal,
|
||||
idleTimeSeconds,
|
||||
interruptsTotal,
|
||||
interruptTimeSeconds,
|
||||
parkingStatus,
|
||||
performanceLimitPercent,
|
||||
priorityTimeSeconds,
|
||||
privilegedTimeSeconds,
|
||||
privilegedUtilitySeconds,
|
||||
processorFrequencyMHz,
|
||||
processorPerformance,
|
||||
processorTimeSeconds,
|
||||
processorUtilityRate,
|
||||
userTimeSeconds,
|
||||
}
|
||||
|
||||
var err error
|
||||
@@ -396,119 +396,119 @@ func (c *Collector) collectPDH(ch chan<- prometheus.Metric) error {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cStateSecondsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[C1TimeSeconds].FirstValue,
|
||||
coreData[c1TimeSeconds].FirstValue,
|
||||
core, "c1",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cStateSecondsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[C2TimeSeconds].FirstValue,
|
||||
coreData[c2TimeSeconds].FirstValue,
|
||||
core, "c2",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cStateSecondsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[C3TimeSeconds].FirstValue,
|
||||
coreData[c3TimeSeconds].FirstValue,
|
||||
core, "c3",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[IdleTimeSeconds].FirstValue,
|
||||
coreData[idleTimeSeconds].FirstValue,
|
||||
core, "idle",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[InterruptTimeSeconds].FirstValue,
|
||||
coreData[interruptTimeSeconds].FirstValue,
|
||||
core, "interrupt",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[DPCTimeSeconds].FirstValue,
|
||||
coreData[dpcTimeSeconds].FirstValue,
|
||||
core, "dpc",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[PrivilegedTimeSeconds].FirstValue,
|
||||
coreData[privilegedTimeSeconds].FirstValue,
|
||||
core, "privileged",
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[UserTimeSeconds].FirstValue,
|
||||
coreData[userTimeSeconds].FirstValue,
|
||||
core, "user",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.interruptsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[InterruptsTotal].FirstValue,
|
||||
coreData[interruptsTotal].FirstValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.dpcsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[DPCsQueuedTotal].FirstValue,
|
||||
coreData[dpcQueuedPerSecond].FirstValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.clockInterruptsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[ClockInterruptsTotal].FirstValue,
|
||||
coreData[clockInterruptsTotal].FirstValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.idleBreakEventsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData[IdleBreakEventsTotal].FirstValue,
|
||||
coreData[idleBreakEventsTotal].FirstValue,
|
||||
core,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.parkingStatus,
|
||||
prometheus.GaugeValue,
|
||||
coreData[ParkingStatus].FirstValue,
|
||||
coreData[parkingStatus].FirstValue,
|
||||
core,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorFrequencyMHz,
|
||||
prometheus.GaugeValue,
|
||||
coreData[ProcessorFrequencyMHz].FirstValue,
|
||||
coreData[processorFrequencyMHz].FirstValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorPerformance,
|
||||
prometheus.CounterValue,
|
||||
coreData[ProcessorPerformance].FirstValue,
|
||||
coreData[processorPerformance].FirstValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorMPerf,
|
||||
prometheus.CounterValue,
|
||||
coreData[ProcessorPerformance].SecondValue,
|
||||
coreData[processorPerformance].SecondValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorRTC,
|
||||
prometheus.CounterValue,
|
||||
coreData[ProcessorUtilityRate].SecondValue,
|
||||
coreData[processorUtilityRate].SecondValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorUtility,
|
||||
prometheus.CounterValue,
|
||||
coreData[ProcessorUtilityRate].FirstValue,
|
||||
coreData[processorUtilityRate].FirstValue,
|
||||
core,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorPrivilegedUtility,
|
||||
prometheus.CounterValue,
|
||||
coreData[PrivilegedUtilitySeconds].FirstValue,
|
||||
coreData[privilegedUtilitySeconds].FirstValue,
|
||||
core,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user