summaryrefslogtreecommitdiffstats
path: root/virt-top/virt_top_csv.ml
blob: ee6eb22464feed23f4db60da1efadd3db8ed9243 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(* 'top'-like tool for libvirt domains.
 *
 * This file contains all code which requires CSV support.
 *)

(* Output channel, or None if CSV output not enabled. *)
let chan = ref None ;;

Virt_top.csv_start :=
  fun filename ->
    chan := Some (open_out filename) ;;

Virt_top.csv_write :=
  fun row ->
    match !chan with
    | None -> ()			(* CSV output not enabled. *)
    | Some chan ->
	Csv.save_out chan [row];
	(* Flush the output to the file immediately because we don't
	 * explicitly close this file.
	 *)
	flush chan