Skip to content

fix(pidstat): Busy-CPU/NonBusy-CPU need class=throughput and default-aggregation=sum #66

Description

@atheurer

Bug

Same root cause as #65, but in process_pidstat (around line 514) instead of process_mpstat.

desc = {"source": "pidstat", "class": "percentage", "default-aggregation": "avg"}
fields = {"usr": ..., "system": ..., "guest": ..., "wait": ...}

for field_name, val in fields.items():
    names = {"cmd": command, "pid": pid, "type": field_name}
    desc["type"] = "NonBusy-CPU" if field_name == "wait" else "Busy-CPU"
    sample = {"end": time_ms, "value": val / 100}
    metrics.log_sample("pidstat", desc, names, sample)

usr, system, guest (mapped to Busy-CPU) and wait (mapped to NonBusy-CPU) are mutually-exclusive per-process CPU time slices, identical in structure to mpstat's per-CPU type breakdown. Collapsing across the type breakout with avg produces the same kind of wrong result as #65 — e.g. a process that's 100% usr + 0% system + 0% guest would show as ~33% Busy-CPU instead of 100%.

Fix

desc["type"] = "NonBusy-CPU" if field_name == "wait" else "Busy-CPU"
desc["class"] = "throughput"
desc["default-aggregation"] = "sum"

Matches the pattern used by sar-net (class: "throughput", default-aggregation: "sum") and the revised fix proposed in #65.

Related

Companion bug to #65 (mpstat), same file (sysstat-post-process.py).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions