From 47d7e92ec34303a8da471fd1c26106f606e5a150 Mon Sep 17 00:00:00 2001 From: Nikolay Pelov Date: Fri, 27 Jan 2023 01:47:21 +0200 Subject: [PATCH] Revert check for CPUAccounting property. Signed-off-by: Nikolay Pelov --- systemd/systemd.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/systemd/systemd.go b/systemd/systemd.go index b6d42fb..7ef2326 100644 --- a/systemd/systemd.go +++ b/systemd/systemd.go @@ -609,6 +609,18 @@ func (c *Collector) collectUnitCPUUsageMetrics(unitType string, conn *dbus.Conn, return nil } + propCPUAcct, err := conn.GetUnitTypePropertyContext(c.ctx, unit.Name, unitType, "CPUAccounting") + if err != nil { + return errors.Wrapf(err, errGetPropertyMsg, "CPUAccounting") + } + cpuAcct, ok := propCPUAcct.Value.Value().(bool) + if !ok { + return errors.Errorf(errConvertStringPropertyMsg, "CPUAccounting", propCPUAcct.Value.Value()) + } + if !cpuAcct { + return nil + } + cpuUsage, err := NewCPUUsage(cgSubpath, c.logger) if err != nil { if unitType == "Socket" {