5b71b31a6da2482e63323184bffe90a8808e47db
[virt-top.git] / virt-top / virt_top_utils.mli
1 (* 'top'-like tool for libvirt domains.
2    (C) Copyright 2007-2009 Richard W.M. Jones, Red Hat Inc.
3    http://libvirt.org/
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19    This file contains utility functions.
20 *)
21
22 (* Filename concatenation. *)
23 val (//) : string -> string -> string
24
25 (* failwithf is a printf-like version of failwith. *)
26 val failwithf : ('a, unit, string, 'b) format4 -> 'a
27
28 (* Read a configuration file as a list of (lineno, key, value) pairs.
29  * If the config file is missing this returns an empty list.
30  *)
31 val read_config_file : string -> (int * string * string) list
32
33 (* Pad or truncate a string to a fixed width. *)
34 val pad : int -> string -> string
35
36 (* Int64 operators for convenience. *)
37 val (+^) : int64 -> int64 -> int64
38 val (-^) : int64 -> int64 -> int64
39 val ( *^ ) : int64 -> int64 -> int64
40 val (/^) : int64 -> int64 -> int64
41
42 (* Utility functions for formating numbers as short strings. *)
43 module Show : sig
44   val percent : float -> string
45   val int64_option : int64 option -> string
46   val int64 : int64 -> string
47   val time : int64 -> string
48 end
49
50 (* Helpers for manipulating block_stats & interface_stats. *)
51 open Libvirt.Domain
52
53 val sum_block_stats : block_stats list -> block_stats
54 val diff_block_stats : block_stats -> block_stats -> block_stats
55
56 val sum_interface_stats : interface_stats list -> interface_stats
57 val diff_interface_stats : interface_stats -> interface_stats -> interface_stats