1
0
Fork 0

Adding upstream version 1.34.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-24 07:26:29 +02:00
parent e393c3af3f
commit 4978089aab
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4963 changed files with 677545 additions and 0 deletions

View file

@ -0,0 +1,51 @@
//go:build linux
package kernel
import (
"fmt"
"time"
"github.com/prometheus/procfs"
"github.com/influxdata/telegraf"
)
// Gather PSI metrics
func (k *Kernel) gatherPressure(acc telegraf.Accumulator) error {
for _, resource := range []string{"cpu", "memory", "io"} {
now := time.Now()
psiStats, err := k.procfs.PSIStatsForResource(resource)
if err != nil {
return fmt.Errorf("failed to read %s pressure: %w", resource, err)
}
stats := map[string]*procfs.PSILine{
"some": psiStats.Some,
"full": psiStats.Full,
}
for _, typ := range []string{"some", "full"} {
if resource == "cpu" && typ == "full" {
// resource=cpu,type=full is omitted because it is always zero
continue
}
tags := map[string]string{
"resource": resource,
"type": typ,
}
stat := stats[typ]
acc.AddCounter("pressure", map[string]interface{}{
"total": stat.Total,
}, tags, now)
acc.AddGauge("pressure", map[string]interface{}{
"avg10": stat.Avg10,
"avg60": stat.Avg60,
"avg300": stat.Avg300,
}, tags, now)
}
}
return nil
}