Skip to content

Commit 0ddcfe0

Browse files
authored
RRD metrics: "runnable_any" and "runnable_vcpus" (#6615)
Squashed the history in PR #6612 together with the history in feature/vcpu-runnable.
2 parents 809bad5 + d355725 commit 0ddcfe0

File tree

1 file changed

+72
-15
lines changed

1 file changed

+72
-15
lines changed

ocaml/xcp-rrdd/bin/rrdp-cpu/rrdp_cpu.ml

Lines changed: 72 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module Process = Rrdd_plugin.Process (struct let name = "xcp-rrdd-cpu" end)
2020

2121
let xen_flag_complement = Int64.(shift_left 1L 63 |> lognot)
2222

23-
(* This function is used for getting vcpu stats of the VMs present on this host. *)
23+
(* This function is used for getting vCPU stats of the VMs present on this host. *)
2424
let dss_vcpus xc doms =
2525
List.fold_left
2626
(fun dss (dom, uuid, domid) ->
@@ -49,63 +49,119 @@ let dss_vcpus xc doms =
4949
in
5050
cpus (i + 1) (cputime_rrd :: dss)
5151
in
52-
(* Runstate info is per-domain rather than per-vcpu *)
52+
(* Runstate info is per-domain rather than per-vCPU *)
5353
let dss =
5454
let dom_cpu_time =
5555
Int64.(to_float @@ logand dom.Xenctrl.cpu_time xen_flag_complement)
5656
in
5757
let dom_cpu_time =
5858
dom_cpu_time /. (1.0e9 *. float_of_int dom.Xenctrl.nr_online_vcpus)
5959
in
60+
let ( ++ ) = Int64.add in
6061
try
61-
let ri = Xenctrl.domain_get_runstate_info xc domid in
62+
let ri = Xenctrl.Runstateinfo.V2.domain_get xc domid in
63+
let runnable_vcpus_ds =
64+
match ri.Xenctrl.Runstateinfo.V2.runnable with
65+
| 0L ->
66+
[]
67+
| _ ->
68+
[
69+
( Rrd.VM uuid
70+
, Ds.ds_make ~name:"runnable_vcpus" ~units:"(fraction)"
71+
~value:
72+
(Rrd.VT_Float
73+
(Int64.to_float ri.Xenctrl.Runstateinfo.V2.runnable
74+
/. 1.0e9
75+
)
76+
)
77+
~description:
78+
"Fraction of time that vCPUs of the domain are runnable"
79+
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
80+
)
81+
]
82+
in
6283
( Rrd.VM uuid
6384
, Ds.ds_make ~name:"runstate_fullrun" ~units:"(fraction)"
64-
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time0 /. 1.0e9))
65-
~description:"Fraction of time that all VCPUs are running"
85+
~value:
86+
(Rrd.VT_Float
87+
(Int64.to_float ri.Xenctrl.Runstateinfo.V2.time0 /. 1.0e9)
88+
)
89+
~description:"Fraction of time that all vCPUs are running"
6690
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
6791
)
6892
:: ( Rrd.VM uuid
6993
, Ds.ds_make ~name:"runstate_full_contention" ~units:"(fraction)"
70-
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time1 /. 1.0e9))
94+
~value:
95+
(Rrd.VT_Float
96+
(Int64.to_float ri.Xenctrl.Runstateinfo.V2.time1 /. 1.0e9)
97+
)
7198
~description:
72-
"Fraction of time that all VCPUs are runnable (i.e., \
99+
"Fraction of time that all vCPUs are runnable (i.e., \
73100
waiting for CPU)"
74101
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
75102
)
76103
:: ( Rrd.VM uuid
77104
, Ds.ds_make ~name:"runstate_concurrency_hazard"
78105
~units:"(fraction)"
79-
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time2 /. 1.0e9))
106+
~value:
107+
(Rrd.VT_Float
108+
(Int64.to_float ri.Xenctrl.Runstateinfo.V2.time2 /. 1.0e9)
109+
)
80110
~description:
81-
"Fraction of time that some VCPUs are running and some are \
111+
"Fraction of time that some vCPUs are running and some are \
82112
runnable"
83113
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
84114
)
85115
:: ( Rrd.VM uuid
86116
, Ds.ds_make ~name:"runstate_blocked" ~units:"(fraction)"
87-
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time3 /. 1.0e9))
117+
~value:
118+
(Rrd.VT_Float
119+
(Int64.to_float ri.Xenctrl.Runstateinfo.V2.time3 /. 1.0e9)
120+
)
88121
~description:
89-
"Fraction of time that all VCPUs are blocked or offline"
122+
"Fraction of time that all vCPUs are blocked or offline"
90123
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
91124
)
92125
:: ( Rrd.VM uuid
93126
, Ds.ds_make ~name:"runstate_partial_run" ~units:"(fraction)"
94-
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time4 /. 1.0e9))
127+
~value:
128+
(Rrd.VT_Float
129+
(Int64.to_float ri.Xenctrl.Runstateinfo.V2.time4 /. 1.0e9)
130+
)
95131
~description:
96-
"Fraction of time that some VCPUs are running, and some are \
132+
"Fraction of time that some vCPUs are running and some are \
97133
blocked"
98134
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
99135
)
100136
:: ( Rrd.VM uuid
101137
, Ds.ds_make ~name:"runstate_partial_contention"
102138
~units:"(fraction)"
103-
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time5 /. 1.0e9))
139+
~value:
140+
(Rrd.VT_Float
141+
(Int64.to_float ri.Xenctrl.Runstateinfo.V2.time5 /. 1.0e9)
142+
)
104143
~description:
105-
"Fraction of time that some VCPUs are runnable and some are \
144+
"Fraction of time that some vCPUs are runnable and some are \
106145
blocked"
107146
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
108147
)
148+
:: ( Rrd.VM uuid
149+
, Ds.ds_make ~name:"runnable_any" ~units:"(fraction)"
150+
~value:
151+
(Rrd.VT_Float
152+
(Int64.to_float
153+
(ri.Xenctrl.Runstateinfo.V2.time1
154+
++ ri.Xenctrl.Runstateinfo.V2.time2
155+
++ ri.Xenctrl.Runstateinfo.V2.time5
156+
)
157+
/. 1.0e9
158+
)
159+
)
160+
~description:
161+
"Fraction of time that at least one vCPU is runnable in the \
162+
domain"
163+
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
164+
)
109165
:: ( Rrd.VM uuid
110166
, Ds.ds_make
111167
~name:(Printf.sprintf "cpu_usage")
@@ -115,6 +171,7 @@ let dss_vcpus xc doms =
115171
~min:0.0 ~max:1.0 ()
116172
)
117173
:: dss
174+
@ runnable_vcpus_ds
118175
with _ -> dss
119176
in
120177
try cpus 0 dss with _ -> dss

0 commit comments

Comments
 (0)