@@ -20,7 +20,7 @@ module Process = Rrdd_plugin.Process (struct let name = "xcp-rrdd-cpu" end)
20
20
21
21
let xen_flag_complement = Int64. (shift_left 1L 63 |> lognot)
22
22
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. *)
24
24
let dss_vcpus xc doms =
25
25
List. fold_left
26
26
(fun dss (dom , uuid , domid ) ->
@@ -49,63 +49,119 @@ let dss_vcpus xc doms =
49
49
in
50
50
cpus (i + 1 ) (cputime_rrd :: dss)
51
51
in
52
- (* Runstate info is per-domain rather than per-vcpu *)
52
+ (* Runstate info is per-domain rather than per-vCPU *)
53
53
let dss =
54
54
let dom_cpu_time =
55
55
Int64. (to_float @@ logand dom.Xenctrl. cpu_time xen_flag_complement)
56
56
in
57
57
let dom_cpu_time =
58
58
dom_cpu_time /. (1.0e9 *. float_of_int dom.Xenctrl. nr_online_vcpus)
59
59
in
60
+ let ( ++ ) = Int64. add in
60
61
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
62
83
( Rrd. VM uuid
63
84
, 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"
66
90
~ty: Rrd. Derive ~default: false ~min: 0.0 ~max: 1.0 ()
67
91
)
68
92
:: ( Rrd. VM uuid
69
93
, 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
+ )
71
98
~description:
72
- " Fraction of time that all VCPUs are runnable (i.e., \
99
+ " Fraction of time that all vCPUs are runnable (i.e., \
73
100
waiting for CPU)"
74
101
~ty: Rrd. Derive ~default: false ~min: 0.0 ~max: 1.0 ()
75
102
)
76
103
:: ( Rrd. VM uuid
77
104
, Ds. ds_make ~name: " runstate_concurrency_hazard"
78
105
~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
+ )
80
110
~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 \
82
112
runnable"
83
113
~ty: Rrd. Derive ~default: false ~min: 0.0 ~max: 1.0 ()
84
114
)
85
115
:: ( Rrd. VM uuid
86
116
, 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
+ )
88
121
~description:
89
- " Fraction of time that all VCPUs are blocked or offline"
122
+ " Fraction of time that all vCPUs are blocked or offline"
90
123
~ty: Rrd. Derive ~default: false ~min: 0.0 ~max: 1.0 ()
91
124
)
92
125
:: ( Rrd. VM uuid
93
126
, 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
+ )
95
131
~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 \
97
133
blocked"
98
134
~ty: Rrd. Derive ~default: false ~min: 0.0 ~max: 1.0 ()
99
135
)
100
136
:: ( Rrd. VM uuid
101
137
, Ds. ds_make ~name: " runstate_partial_contention"
102
138
~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
+ )
104
143
~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 \
106
145
blocked"
107
146
~ty: Rrd. Derive ~default: false ~min: 0.0 ~max: 1.0 ()
108
147
)
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
+ )
109
165
:: ( Rrd. VM uuid
110
166
, Ds. ds_make
111
167
~name: (Printf. sprintf " cpu_usage" )
@@ -115,6 +171,7 @@ let dss_vcpus xc doms =
115
171
~min: 0.0 ~max: 1.0 ()
116
172
)
117
173
:: dss
174
+ @ runnable_vcpus_ds
118
175
with _ -> dss
119
176
in
120
177
try cpus 0 dss with _ -> dss
0 commit comments