1 (* List CPU stats for a domain.
2 * Usage: get_cpu_stats domain
8 module C = Libvirt.Connect
9 module D = Libvirt.Domain
10 module N = Libvirt.Network
14 if Array.length Sys.argv <> 2 then (
15 eprintf "error: get_cpu_stats domain\n";
18 let domname = Sys.argv.(1) in
20 let conn = C.connect_auth_readonly (C.get_auth_default ()) in
24 let info = C.get_node_info conn in
25 C.maxcpus_of_node_info info in
29 let dom = D.lookup_by_name conn domname in
30 D.get_cpu_stats dom in
39 | D.TypedFieldInt32 i -> printf "%ld" i
40 | D.TypedFieldUInt32 i -> printf "%ld" i
41 | D.TypedFieldInt64 i -> printf "%Ld" i
42 | D.TypedFieldUInt64 i -> printf "%Ld" i
43 | D.TypedFieldFloat f -> printf "%g" f
44 | D.TypedFieldBool b -> printf "%b" b
45 | D.TypedFieldString s -> printf "%S" s
50 Libvirt.Virterror err ->
51 eprintf "error: %s\n" (Libvirt.Virterror.to_string err)
54 (* Run the garbage collector which is a good way to check for
55 * memory corruption errors and reference counting issues in libvirt.