ia64/xen-unstable

view tools/xenstat/libxenstat/src/xenstat.h @ 6440:9404574350ce

Cache the Xen version in the xenstat_handle, since it should never change.
Use a collector and new flag for Xen version information, to avoid the
extra hypercall if the caller does not want the information.
Reference the xenstat_handle in the xenstat_node for ease of access
later, and update collectors accordingly.
Signed-off-by: Josh Triplett <josht@us.ibm.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Fri Aug 26 08:48:59 2005 +0000 (2005-08-26)
parents af7251014caf
children 9312a3e8a6f8
line source
1 /* libxenstat: statistics-collection library for Xen
2 * Copyright (C) International Business Machines Corp., 2005
3 * Authors: Josh Triplett <josht@us.ibm.com>
4 * Judy Fischbach <jfisch@us.ibm.com>
5 * David Hendricks <dhendrix@us.ibm.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 */
18 /* libxenstat API */
20 /* Opaque handles */
21 typedef struct xenstat_handle xenstat_handle;
22 typedef struct xenstat_domain xenstat_domain;
23 typedef struct xenstat_node xenstat_node;
24 typedef struct xenstat_vcpu xenstat_vcpu;
25 typedef struct xenstat_network xenstat_network;
27 /* Initialize the xenstat library. Returns a handle to be used with
28 * subsequent calls to the xenstat library, or NULL if an error occurs. */
29 xenstat_handle *xenstat_init();
31 /* Release the handle to libxc, free resources, etc. */
32 void xenstat_uninit(xenstat_handle * handle);
34 /* Flags for types of information to collect in xenstat_get_node */
35 #define XENSTAT_VCPU 0x1
36 #define XENSTAT_NETWORK 0x2
37 #define XENSTAT_XEN_VERSION 0x4
38 #define XENSTAT_ALL (XENSTAT_VCPU|XENSTAT_NETWORK|XENSTAT_XEN_VERSION)
40 /* Get all available information about a node */
41 xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags);
43 /* Free the information */
44 void xenstat_free_node(xenstat_node * node);
46 /*
47 * Node functions - extract information from a xenstat_node
48 */
50 /* Get information about the domain with the given domain ID */
51 xenstat_domain *xenstat_node_domain(xenstat_node * node,
52 unsigned int domid);
54 /* Get the domain with the given index; used to loop over all domains. */
55 xenstat_domain *xenstat_node_domain_by_index(xenstat_node * node,
56 unsigned index);
58 /* Get xen version of the node */
59 const char *xenstat_node_xen_version(xenstat_node * node);
61 /* Get amount of total memory on a node */
62 unsigned long long xenstat_node_tot_mem(xenstat_node * node);
64 /* Get amount of free memory on a node */
65 unsigned long long xenstat_node_free_mem(xenstat_node * node);
67 /* Find the number of domains existing on a node */
68 unsigned int xenstat_node_num_domains(xenstat_node * node);
70 /* Find the number of CPUs existing on a node */
71 unsigned int xenstat_node_num_cpus(xenstat_node * node);
73 /* Get information about the CPU speed */
74 unsigned long long xenstat_node_cpu_hz(xenstat_node * node);
76 /*
77 * Domain functions - extract information from a xenstat_domain
78 */
80 /* Get the domain ID for this domain */
81 unsigned xenstat_domain_id(xenstat_domain * domain);
83 /* Get information about how much CPU time has been used */
84 unsigned long long xenstat_domain_cpu_ns(xenstat_domain * domain);
86 /* Find the number of VCPUs allocated to a domain */
87 unsigned int xenstat_domain_num_vcpus(xenstat_domain * domain);
89 /* Get the VCPU handle to obtain VCPU stats */
90 xenstat_vcpu *xenstat_domain_vcpu(xenstat_domain * domain,
91 unsigned int vcpu);
93 /* Find the current memory reservation for this domain */
94 unsigned long long xenstat_domain_cur_mem(xenstat_domain * domain);
96 /* Find the maximum memory reservation for this domain */
97 unsigned long long xenstat_domain_max_mem(xenstat_domain * domain);
99 /* Find the domain's SSID */
100 unsigned int xenstat_domain_ssid(xenstat_domain * domain);
102 /* Get domain states */
103 unsigned int xenstat_domain_dying(xenstat_domain * domain);
104 unsigned int xenstat_domain_crashed(xenstat_domain * domain);
105 unsigned int xenstat_domain_shutdown(xenstat_domain * domain);
106 unsigned int xenstat_domain_paused(xenstat_domain * domain);
107 unsigned int xenstat_domain_blocked(xenstat_domain * domain);
108 unsigned int xenstat_domain_running(xenstat_domain * domain);
110 /* Get the number of networks for a given domain */
111 unsigned int xenstat_domain_num_networks(xenstat_domain *);
113 /* Get the network handle to obtain network stats */
114 xenstat_network *xenstat_domain_network(xenstat_domain * domain,
115 unsigned int network);
117 /*
118 * VCPU functions - extract information from a xenstat_vcpu
119 */
121 /* Get VCPU usage */
122 unsigned long long xenstat_vcpu_ns(xenstat_vcpu * vcpu);
125 /*
126 * Network functions - extract information from a xenstat_network
127 */
129 /* Get the ID for this network */
130 unsigned int xenstat_network_id(xenstat_network * network);
132 /* Get the number of receive bytes for this network */
133 unsigned long long xenstat_network_rbytes(xenstat_network * network);
135 /* Get the number of receive packets for this network */
136 unsigned long long xenstat_network_rpackets(xenstat_network * network);
138 /* Get the number of receive errors for this network */
139 unsigned long long xenstat_network_rerrs(xenstat_network * network);
141 /* Get the number of receive drops for this network */
142 unsigned long long xenstat_network_rdrop(xenstat_network * network);
144 /* Get the number of transmit bytes for this network */
145 unsigned long long xenstat_network_tbytes(xenstat_network * network);
147 /* Get the number of transmit packets for this network */
148 unsigned long long xenstat_network_tpackets(xenstat_network * network);
150 /* Get the number of transmit errors for this network */
151 unsigned long long xenstat_network_terrs(xenstat_network * network);
153 /* Get the number of transmit drops for this network */
154 unsigned long long xenstat_network_tdrop(xenstat_network * network);