Skip to content

Commit b657c62

Browse files
committed
CP-308863: Count vGPU migrations
This metric represents the rate of VM migrations with vGPUs per second. The total count can be calculated as AVERAGE * seconds. For example, for one-day data granularity, the total count for one day is AVERAGE * 86400, in which 86400 is the seconds of one day. Signed-off-by: Ming Lu <[email protected]>
1 parent 6c16a2f commit b657c62

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

ocaml/xapi/message_forwarding.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2501,6 +2501,8 @@ 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+
if Db.VM.get_VGPUs ~__context ~self:vm <> [] then
2505+
Xapi_stats.incr_pool_vgpu_migration_count () ;
25042506
forward_vm_op ~local_fn ~__context ~vm ~remote_fn
25052507
)
25062508
) ;
@@ -2622,6 +2624,8 @@ functor
26222624
assert_can_migrate ~__context ~vm ~dest ~live ~vdi_map
26232625
~vif_map ~vgpu_map ~options
26242626
) ;
2627+
if vgpu_map <> [] then
2628+
Xapi_stats.incr_pool_vgpu_migration_count () ;
26252629
forward_migrate_send ()
26262630
)
26272631
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_rate"
57+
~description:"Number of vGPU migrations occurred per second"
58+
~value:(Rrd.VT_Int64 vgpu_migration_count) ~ty:Rrd.Absolute
59+
~default:true ~min:0. ~units:"migrations/s" ()
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)