diff options
author | rjones@localhost <rjones@localhost> | 2007-08-30 17:38:09 +0100 |
---|---|---|
committer | rjones@localhost <rjones@localhost> | 2007-08-30 17:38:09 +0100 |
commit | a8b837d5018c488a130fcbea425904817a862210 (patch) | |
tree | 44fc8f4a58d6e1651053c4c40d32b3816add43fa /virt-top/virt_top_csv.ml | |
download | virt-top-a8b837d5018c488a130fcbea425904817a862210.tar.gz virt-top-a8b837d5018c488a130fcbea425904817a862210.tar.xz virt-top-a8b837d5018c488a130fcbea425904817a862210.zip |
Initial import from CVS.
Diffstat (limited to 'virt-top/virt_top_csv.ml')
-rw-r--r-- | virt-top/virt_top_csv.ml | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/virt-top/virt_top_csv.ml b/virt-top/virt_top_csv.ml new file mode 100644 index 0000000..71bb79e --- /dev/null +++ b/virt-top/virt_top_csv.ml @@ -0,0 +1,29 @@ +(* 'top'-like tool for libvirt domains. + * $Id: virt_top_csv.ml,v 1.1 2007/08/23 11:09:19 rjones Exp $ + * + * This file contains all code which requires CSV support. + *) + +open ExtList + +module C = Libvirt.Connect +module D = Libvirt.Domain +module N = Libvirt.Network + +(* 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 |