+ ] in
+
+ (* The domains.
+ *
+ * Sort them by ID so that the list of relatively stable. Ignore
+ * inactive domains.
+ *)
+ let doms = List.filter_map (
+ function
+ | _, Inactive -> None (* Ignore inactive domains. *)
+ | name, Active rd -> Some (name, rd)
+ ) doms in
+ let cmp (_, { rd_domid = rd_domid1 }) (_, { rd_domid = rd_domid2 }) =
+ compare rd_domid1 rd_domid2
+ in
+ let doms = List.sort ~cmp doms in
+
+ let string_of_int64_option = Option.map_default Int64.to_string "" in
+
+ let domain_fields = List.map (
+ fun (domname, rd) ->
+ [ string_of_int rd.rd_domid; domname;
+ string_of_float rd.rd_cpu_time; string_of_float rd.rd_percent_cpu;
+ string_of_int64_option rd.rd_block_rd_reqs;
+ string_of_int64_option rd.rd_block_wr_reqs;
+ string_of_int64_option rd.rd_net_rx_bytes;
+ string_of_int64_option rd.rd_net_tx_bytes; ]
+ ) doms in
+ let domain_fields = List.flatten domain_fields in
+
+ (!csv_write) (summary_fields @ domain_fields)