Log domain data to CSV file.
[virt-top.git] / virt-top / virt_top_csv.ml
1 (* 'top'-like tool for libvirt domains.
2  * $Id: virt_top_csv.ml,v 1.1 2007/08/23 11:09:19 rjones Exp $
3  *
4  * This file contains all code which requires CSV support.
5  *)
6
7 open ExtList
8
9 module C = Libvirt.Connect
10 module D = Libvirt.Domain
11 module N = Libvirt.Network
12
13 (* Output channel, or None if CSV output not enabled. *)
14 let chan = ref None ;;
15
16 Virt_top.csv_start :=
17   fun filename ->
18     chan := Some (open_out filename) ;;
19
20 Virt_top.csv_write :=
21   fun row ->
22     match !chan with
23     | None -> ()                        (* CSV output not enabled. *)
24     | Some chan ->
25         Csv.save_out chan [row];
26         (* Flush the output to the file immediately because we don't
27          * explicitly close this file.
28          *)
29         flush chan