src: Include <libxml/parser.h>
[virt-top.git] / src / collect.mli
1 (* 'top'-like tool for libvirt domains.
2    (C) Copyright 2007-2017 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
20 (* Hook for [Opt_xml] to override (if present). *)
21 val parse_device_xml :
22   (int -> [ `R ] Libvirt.Domain.t -> string list * string list) ref
23
24 (* Intermediate "domain + stats" structure that we use to collect
25  * everything we know about a domain within the collect function.
26  *)
27 type rd_domain = Inactive | Active of rd_active
28 and rd_active = {
29   rd_domid : int;                       (* Domain ID. *)
30   rd_domuuid : Libvirt.uuid;            (* Domain UUID. *)
31   rd_dom : [`R] Libvirt.Domain.t;       (* Domain object. *)
32   rd_info : Libvirt.Domain.info;        (* Domain CPU info now. *)
33   rd_block_stats : (string * Libvirt.Domain.block_stats) list;
34                                         (* Domain block stats now. *)
35   rd_interface_stats : (string * Libvirt.Domain.interface_stats) list;
36                                         (* Domain net stats now. *)
37   rd_prev_info : Libvirt.Domain.info option; (* Domain CPU info previously. *)
38   rd_prev_block_stats : (string * Libvirt.Domain.block_stats) list;
39                                         (* Domain block stats prev. *)
40   rd_prev_interface_stats : (string * Libvirt.Domain.interface_stats) list;
41                                         (* Domain interface stats prev. *)
42   (* The following are since the last slice, or 0 if cannot be calculated: *)
43   rd_cpu_time : float;                  (* CPU time used in nanoseconds. *)
44   rd_percent_cpu : float;               (* CPU time as percent of total. *)
45   rd_mem_bytes : int64;                 (* Memory usage in bytes *)
46   rd_mem_percent: int64;                (* Memory usage as percent of total *)
47   (* The following are since the last slice, or None if cannot be calc'd: *)
48   rd_block_rd_reqs : int64 option;      (* Number of block device read rqs. *)
49   rd_block_wr_reqs : int64 option;      (* Number of block device write rqs. *)
50   rd_block_rd_bytes : int64 option;     (* Number of bytes block device read *)
51   rd_block_wr_bytes : int64 option;     (* Number of bytes block device write *)
52   rd_net_rx_bytes : int64 option;       (* Number of bytes received. *)
53   rd_net_tx_bytes : int64 option;       (* Number of bytes transmitted. *)
54 }
55
56 type stats = {
57   rd_doms : (string * rd_domain) list;  (* List of domains. *)
58   rd_time : float;
59   rd_printable_time : string;
60   rd_nr_pcpus : int;
61   rd_total_cpu : float;
62   rd_total_cpu_per_pcpu : float;
63   rd_totals : (int * int * int * int * int * int * int * int * int * float *
64                  int64 * int64);
65 }
66
67 type pcpu_stats = {
68   rd_pcpu_doms : (int * string * int *
69                   Libvirt.Domain.vcpu_info array * int64 array array *
70                   int64 array array * string * int) list;
71   rd_pcpu_pcpus : int64 array array array;
72   rd_pcpu_pcpus_cpu_time : float array
73 }
74
75 val collect : Types.setup -> stats
76 (** Collect statistics. *)
77
78 val collect_pcpu : stats -> pcpu_stats
79 (** Used in PCPUDisplay mode only, this returns extra per-PCPU stats. *)
80
81 val clear_pcpu_display_data : unit -> unit
82 (** Clear the cache of pcpu_usages used by PCPUDisplay display_mode
83     when we switch back to TaskDisplay mode. *)