Skip to content

Commit

Permalink
CA-400860: make CPU and netdev RRDD plugins pick up changes in domains (
Browse files Browse the repository at this point in the history
#6067)

When these metrics were collected internally, Xenctrl was queried every
5 seconds. After being split into plugins, they started querying domains
(and other information) only on startup, so couldn't pick up new VMs and
report their metrics without restarting.
  • Loading branch information
lindig authored Oct 21, 2024
2 parents daa9938 + 99b8ad6 commit f1d892f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
7 changes: 4 additions & 3 deletions ocaml/xcp-rrdd/bin/rrdp-cpu/rrdp_cpu.ml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ let dss_hostload xc domains =
)
]

let generate_cpu_ds_list xc domains () =
let generate_cpu_ds_list xc () =
let _, domains, _ = Xenctrl_lib.domain_snapshot xc in
dss_pcpus xc @ dss_vcpus xc domains @ dss_loadavg () @ dss_hostload xc domains

let _ =
Expand All @@ -236,8 +237,8 @@ let _ =
(* Share one page per PCPU and dom each *)
let physinfo = Xenctrl.physinfo xc in
let shared_page_count = physinfo.Xenctrl.nr_cpus + List.length domains in

(* TODO: Can run out of pages if a lot of domains are added at runtime *)
Process.main_loop ~neg_shift:0.5
~target:(Reporter.Local shared_page_count) ~protocol:Rrd_interface.V2
~dss_f:(generate_cpu_ds_list xc domains)
~dss_f:(generate_cpu_ds_list xc)
)
20 changes: 10 additions & 10 deletions ocaml/xcp-rrdd/bin/rrdp-netdev/rrdp_netdev.ml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ let transform_taps devs =
)
newdevnames

let generate_netdev_dss doms () =
let generate_netdev_dss () =
let _, doms, _ =
Xenctrl.with_intf (fun xc -> Xenctrl_lib.domain_snapshot xc)
in

let uuid_of_domid domains domid =
let _, uuid, _ =
try List.find (fun (_, _, domid') -> domid = domid') domains
Expand Down Expand Up @@ -265,12 +269,8 @@ let generate_netdev_dss doms () =
@ dss

let _ =
Xenctrl.with_intf (fun xc ->
let _, domains, _ = Xenctrl_lib.domain_snapshot xc in
Process.initialise () ;
(* Share one page per virtual NIC - documentation specifies max is 512 *)
let shared_page_count = 512 in
Process.main_loop ~neg_shift:0.5
~target:(Reporter.Local shared_page_count) ~protocol:Rrd_interface.V2
~dss_f:(generate_netdev_dss domains)
)
Process.initialise () ;
(* Share one page per virtual NIC - documentation specifies max is 512 *)
let shared_page_count = 512 in
Process.main_loop ~neg_shift:0.5 ~target:(Reporter.Local shared_page_count)
~protocol:Rrd_interface.V2 ~dss_f:generate_netdev_dss

0 comments on commit f1d892f

Please sign in to comment.