1 /* libxenstat: statistics-collection library for Xen 2 * Copyright (C) International Business Machines Corp., 2005 3 * Authors: Josh Triplett <josh@kernel.org> 4 * Judy Fischbach <jfisch@cs.pdx.edu> 5 * David Hendricks <cro_marmot@comcast.net> 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 */ 17 18 /* libxenstat API */ 19 20 #ifndef XENSTAT_H 21 #define XENSTAT_H 22 23 /* Opaque handles */ 24 typedef struct xenstat_handle xenstat_handle; 25 typedef struct xenstat_domain xenstat_domain; 26 typedef struct xenstat_node xenstat_node; 27 typedef struct xenstat_vcpu xenstat_vcpu; 28 typedef struct xenstat_network xenstat_network; 29 typedef struct xenstat_vbd xenstat_vbd; 30 typedef struct xenstat_tmem xenstat_tmem; 31 32 /* Initialize the xenstat library. Returns a handle to be used with 33 * subsequent calls to the xenstat library, or NULL if an error occurs. */ 34 xenstat_handle *xenstat_init(void); 35 36 /* Release the handle to libxc, free resources, etc. */ 37 void xenstat_uninit(xenstat_handle * handle); 38 39 /* Flags for types of information to collect in xenstat_get_node */ 40 #define XENSTAT_VCPU 0x1 41 #define XENSTAT_NETWORK 0x2 42 #define XENSTAT_XEN_VERSION 0x4 43 #define XENSTAT_VBD 0x8 44 #define XENSTAT_ALL (XENSTAT_VCPU|XENSTAT_NETWORK|XENSTAT_XEN_VERSION|XENSTAT_VBD) 45 46 /* Get all available information about a node */ 47 xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags); 48 49 /* Free the information */ 50 void xenstat_free_node(xenstat_node * node); 51 52 /* 53 * Node functions - extract information from a xenstat_node 54 */ 55 56 /* Get information about the domain with the given domain ID */ 57 xenstat_domain *xenstat_node_domain(xenstat_node * node, 58 unsigned int domid); 59 60 /* Get the domain with the given index; used to loop over all domains. */ 61 xenstat_domain *xenstat_node_domain_by_index(xenstat_node * node, 62 unsigned index); 63 64 /* Get xen version of the node */ 65 const char *xenstat_node_xen_version(xenstat_node * node); 66 67 /* Get amount of total memory on a node */ 68 unsigned long long xenstat_node_tot_mem(xenstat_node * node); 69 70 /* Get amount of free memory on a node */ 71 unsigned long long xenstat_node_free_mem(xenstat_node * node); 72 73 /* Get amount of tmem freeable memory (in MiB) on a node */ 74 long xenstat_node_freeable_mb(xenstat_node * node); 75 76 /* Find the number of domains existing on a node */ 77 unsigned int xenstat_node_num_domains(xenstat_node * node); 78 79 /* Find the number of CPUs existing on a node */ 80 unsigned int xenstat_node_num_cpus(xenstat_node * node); 81 82 /* Get information about the CPU speed */ 83 unsigned long long xenstat_node_cpu_hz(xenstat_node * node); 84 85 /* 86 * Domain functions - extract information from a xenstat_domain 87 */ 88 89 /* Get the domain ID for this domain */ 90 unsigned xenstat_domain_id(xenstat_domain * domain); 91 92 /* Set the domain name for the domain */ 93 char *xenstat_domain_name(xenstat_domain * domain); 94 95 /* Get information about how much CPU time has been used */ 96 unsigned long long xenstat_domain_cpu_ns(xenstat_domain * domain); 97 98 /* Find the number of VCPUs allocated to a domain */ 99 unsigned int xenstat_domain_num_vcpus(xenstat_domain * domain); 100 101 /* Get the VCPU handle to obtain VCPU stats */ 102 xenstat_vcpu *xenstat_domain_vcpu(xenstat_domain * domain, 103 unsigned int vcpu); 104 105 /* Find the current memory reservation for this domain */ 106 unsigned long long xenstat_domain_cur_mem(xenstat_domain * domain); 107 108 /* Find the maximum memory reservation for this domain */ 109 unsigned long long xenstat_domain_max_mem(xenstat_domain * domain); 110 111 /* Find the domain's SSID */ 112 unsigned int xenstat_domain_ssid(xenstat_domain * domain); 113 114 /* Get domain states */ 115 unsigned int xenstat_domain_dying(xenstat_domain * domain); 116 unsigned int xenstat_domain_crashed(xenstat_domain * domain); 117 unsigned int xenstat_domain_shutdown(xenstat_domain * domain); 118 unsigned int xenstat_domain_paused(xenstat_domain * domain); 119 unsigned int xenstat_domain_blocked(xenstat_domain * domain); 120 unsigned int xenstat_domain_running(xenstat_domain * domain); 121 122 /* Get the number of networks for a given domain */ 123 unsigned int xenstat_domain_num_networks(xenstat_domain *); 124 125 /* Get the network handle to obtain network stats */ 126 xenstat_network *xenstat_domain_network(xenstat_domain * domain, 127 unsigned int network); 128 129 /* Get the number of VBDs for a given domain */ 130 unsigned int xenstat_domain_num_vbds(xenstat_domain *); 131 132 /* Get the VBD handle to obtain VBD stats */ 133 xenstat_vbd *xenstat_domain_vbd(xenstat_domain * domain, 134 unsigned int vbd); 135 136 /* Get the tmem information for a given domain */ 137 xenstat_tmem *xenstat_domain_tmem(xenstat_domain * domain); 138 139 /* 140 * VCPU functions - extract information from a xenstat_vcpu 141 */ 142 143 /* Get VCPU usage */ 144 unsigned int xenstat_vcpu_online(xenstat_vcpu * vcpu); 145 unsigned long long xenstat_vcpu_ns(xenstat_vcpu * vcpu); 146 147 148 /* 149 * Network functions - extract information from a xenstat_network 150 */ 151 152 /* Get the ID for this network */ 153 unsigned int xenstat_network_id(xenstat_network * network); 154 155 /* Get the number of receive bytes for this network */ 156 unsigned long long xenstat_network_rbytes(xenstat_network * network); 157 158 /* Get the number of receive packets for this network */ 159 unsigned long long xenstat_network_rpackets(xenstat_network * network); 160 161 /* Get the number of receive errors for this network */ 162 unsigned long long xenstat_network_rerrs(xenstat_network * network); 163 164 /* Get the number of receive drops for this network */ 165 unsigned long long xenstat_network_rdrop(xenstat_network * network); 166 167 /* Get the number of transmit bytes for this network */ 168 unsigned long long xenstat_network_tbytes(xenstat_network * network); 169 170 /* Get the number of transmit packets for this network */ 171 unsigned long long xenstat_network_tpackets(xenstat_network * network); 172 173 /* Get the number of transmit errors for this network */ 174 unsigned long long xenstat_network_terrs(xenstat_network * network); 175 176 /* Get the number of transmit drops for this network */ 177 unsigned long long xenstat_network_tdrop(xenstat_network * network); 178 179 /* 180 * VBD functions - extract information from a xen_vbd 181 */ 182 183 /* Get the back driver type for Virtual Block Device */ 184 unsigned int xenstat_vbd_type(xenstat_vbd * vbd); 185 186 /* Get the device number for Virtual Block Device */ 187 unsigned int xenstat_vbd_dev(xenstat_vbd * vbd); 188 189 /* Get the number of OO/RD/WR requests for vbd */ 190 unsigned long long xenstat_vbd_oo_reqs(xenstat_vbd * vbd); 191 unsigned long long xenstat_vbd_rd_reqs(xenstat_vbd * vbd); 192 unsigned long long xenstat_vbd_wr_reqs(xenstat_vbd * vbd); 193 unsigned long long xenstat_vbd_rd_sects(xenstat_vbd * vbd); 194 unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd); 195 196 /* 197 * Tmem functions - extract tmem information 198 */ 199 unsigned long long xenstat_tmem_curr_eph_pages(xenstat_tmem *tmem); 200 unsigned long long xenstat_tmem_succ_eph_gets(xenstat_tmem *tmem); 201 unsigned long long xenstat_tmem_succ_pers_puts(xenstat_tmem *tmem); 202 unsigned long long xenstat_tmem_succ_pers_gets(xenstat_tmem *tmem); 203 204 #endif /* XENSTAT_H */ 205