common_metrics.py 956 B

12345678910111213141516171819
  1. # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
  2. from metric import (d_ratio, Event, Metric, MetricGroup)
  3. def Cycles() -> MetricGroup:
  4. cyc_k = Event("cpu\\-cycles:kHh") # exclude user and guest
  5. cyc_g = Event("cpu\\-cycles:G") # exclude host
  6. cyc_u = Event("cpu\\-cycles:uH") # exclude kernel, hypervisor and guest
  7. cyc = cyc_k + cyc_g + cyc_u
  8. return MetricGroup("lpm_cycles", [
  9. Metric("lpm_cycles_total", "Total number of cycles", cyc, "cycles"),
  10. Metric("lpm_cycles_user", "User cycles as a percentage of all cycles",
  11. d_ratio(cyc_u, cyc), "100%"),
  12. Metric("lpm_cycles_kernel", "Kernel cycles as a percentage of all cycles",
  13. d_ratio(cyc_k, cyc), "100%"),
  14. Metric("lpm_cycles_guest", "Hypervisor guest cycles as a percentage of all cycles",
  15. d_ratio(cyc_g, cyc), "100%"),
  16. ], description="cycles breakdown per privilege level (users, kernel, guest)")