Skip to content

Commit c5060a1

Browse files
committed
CP-44533 Add running vCPU and running domain of host into rrdd
Signed-off-by: Lunfan Zhang <Lunfan.Zhang@cloud.com>
1 parent 01dfc98 commit c5060a1

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

ocaml/xcp-rrdd/bin/rrdd/xcp_rrdd.ml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,11 @@ let dss_loadavg () =
359359
)
360360
]
361361

362+
let count_running_domain domains =
363+
List.fold_left
364+
(fun count (dom, _, _) -> if dom.Xenctrl.running then count + 1 else count)
365+
0 domains
366+
362367
let dss_hostload xc domains =
363368
let physinfo = Xenctrl.physinfo xc in
364369
let pcpus = physinfo.Xenctrl.nr_cpus in
@@ -379,6 +384,8 @@ let dss_hostload xc domains =
379384
)
380385
0 domains
381386
in
387+
let running_domains = count_running_domain domains in
388+
382389
let load_per_cpu = float_of_int load /. float_of_int pcpus in
383390
[
384391
( Rrd.Host
@@ -390,6 +397,18 @@ let dss_hostload xc domains =
390397
~value:(Rrd.VT_Float load_per_cpu) ~min:0.0 ~ty:Rrd.Gauge ~default:true
391398
()
392399
)
400+
; ( Rrd.Host
401+
, Ds.ds_make ~name:"running_vcpus" ~units:"(vcpus)"
402+
~description:"The total number of running vCPU per host"
403+
~value:(Rrd.VT_Int64 (Int64.of_int load))
404+
~min:0.0 ~ty:Rrd.Gauge ~default:true ()
405+
)
406+
; ( Rrd.Host
407+
, Ds.ds_make ~name:"running_domains" ~units:"(domains)"
408+
~description:"The total number of running domain per host"
409+
~value:(Rrd.VT_Int64 (Int64.of_int running_domains))
410+
~min:0.0 ~ty:Rrd.Gauge ~default:true ()
411+
)
393412
]
394413

395414
(*****************************************************)
@@ -579,11 +598,7 @@ let scan path =
579598

580599
let mem_available () =
581600
let* size, kb = scan "/proc/meminfo" in
582-
match kb with
583-
| "kB" ->
584-
ok Int64.(mul size 1024L)
585-
| _ ->
586-
res_error "unexpected unit: %s" kb
601+
match kb with "kB" -> ok size | _ -> res_error "unexpected unit: %s" kb
587602

588603
let dss_mem_vms doms =
589604
List.fold_left

0 commit comments

Comments
 (0)