Skip to content

Commit e84977c

Browse files
committed
CP-308863: Count vGPU migrations
The total count can be calculated as AVERAGE * number of samples. For example, for one-day data granularity, the total count of one day is AVERAGE * (86400 / 5), in which 86400 is the seconds of one day and 5 is the interval (in seconds) of data update. Another example is for one day's data (86400 / 5 = 17280) samples, only one sample is valid as 10, other 17279 samples are invalid or missing. Then the AVERAGE will be 10 * ( 1 / 17280) and the total count is 10 as expected. Signed-off-by: Ming Lu <[email protected]>
1 parent 070b953 commit e84977c

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

ocaml/xapi/message_forwarding.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2501,6 +2501,10 @@ functor
25012501
let snapshot = Db.VM.get_record ~__context ~self:vm in
25022502
reserve_memory_for_vm ~__context ~vm ~host ~snapshot
25032503
~host_op:`vm_migrate (fun () ->
2504+
Db.VM.get_VGPUs ~__context ~self:vm
2505+
|> List.iter (fun _ ->
2506+
Xapi_stats.incr_pool_vgpu_migration_count ()
2507+
) ;
25042508
forward_vm_op ~local_fn ~__context ~vm ~remote_fn
25052509
)
25062510
) ;
@@ -2622,6 +2626,10 @@ functor
26222626
assert_can_migrate ~__context ~vm ~dest ~live ~vdi_map
26232627
~vif_map ~vgpu_map ~options
26242628
) ;
2629+
vgpu_map
2630+
|> List.iter (fun _ ->
2631+
Xapi_stats.incr_pool_vgpu_migration_count ()
2632+
) ;
26252633
forward_migrate_send ()
26262634
)
26272635
in

ocaml/xapi/xapi_stats.ml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ module D = Debug.Make (struct let name = "xapi_stats" end)
1616

1717
let with_lock = Xapi_stdext_threads.Threadext.Mutex.execute
1818

19+
let pool_vgpu_migration_count : int Atomic.t = Atomic.make 0
20+
21+
let incr_pool_vgpu_migration_count () = Atomic.incr pool_vgpu_migration_count
22+
1923
let generate_master_stats ~__context =
2024
let session_count =
2125
Db.Session.get_all ~__context |> List.length |> Int64.of_int
@@ -44,7 +48,23 @@ let generate_master_stats ~__context =
4448
~min:0.0 ~units:"sessions/s" ()
4549
)
4650
in
47-
[session_count_ds; task_count_ds; session_count_change_ds]
51+
let vgpu_migration_count =
52+
Atomic.exchange pool_vgpu_migration_count 0 |> Int64.of_int
53+
in
54+
let vgpu_migration_count_ds =
55+
( Rrd.Host
56+
, Ds.ds_make ~name:"pool_vgpu_migration_count"
57+
~description:"Number of vGPU migrations occurred since last update"
58+
~value:(Rrd.VT_Int64 vgpu_migration_count) ~ty:Rrd.Absolute
59+
~default:true ~min:0. ~units:"count" ()
60+
)
61+
in
62+
[
63+
session_count_ds
64+
; task_count_ds
65+
; session_count_change_ds
66+
; vgpu_migration_count_ds
67+
]
4868

4969
let gc_debug = ref true
5070

ocaml/xapi/xapi_stats.mli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ val start : unit -> unit
1818

1919
val stop : unit -> unit
2020
(** Stop the stats reporting thread. *)
21+
22+
val incr_pool_vgpu_migration_count : unit -> unit
23+
(** Increments the pool_vgpu_migration_count by 1 . *)

0 commit comments

Comments
 (0)