1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright (c) 2023 Robin Jarry 3 4CPU_TOTAL = "total_cycles" 5CPU_BUSY = "busy_cycles" 6 7 8def info() -> "dict[Name, tuple[Description, Type]]": 9 return { 10 CPU_TOTAL: ("Total number of CPU cycles.", "counter"), 11 CPU_BUSY: ("Number of busy CPU cycles.", "counter"), 12 } 13 14 15def metrics(sock: "TelemetrySocket") -> "list[tuple[Name, Value, Labels]]": 16 out = [] 17 for lcore_id in sock.cmd("/eal/lcore/list"): 18 lcore = sock.cmd("/eal/lcore/info", lcore_id) 19 cpu = ",".join(str(c) for c in lcore.get("cpuset", [])) 20 total = lcore.get("total_cycles") 21 busy = lcore.get("busy_cycles", 0) 22 if not (cpu and total): 23 continue 24 labels = {"cpu": cpu, "numa": lcore.get("socket", 0)} 25 out += [ 26 (CPU_TOTAL, total, labels), 27 (CPU_BUSY, busy, labels), 28 ] 29 return out 30