1 | /* |
---|
2 | * Copyright (c) 2006-2007, XenSource Inc. |
---|
3 | * |
---|
4 | * This library is free software; you can redistribute it and/or |
---|
5 | * modify it under the terms of the GNU Lesser General Public |
---|
6 | * License as published by the Free Software Foundation; either |
---|
7 | * version 2.1 of the License, or (at your option) any later version. |
---|
8 | * |
---|
9 | * This library is distributed in the hope that it will be useful, |
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
12 | * Lesser General Public License for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU Lesser General Public |
---|
15 | * License along with this library; if not, write to the Free Software |
---|
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef XEN_HOST_METRICS_H |
---|
20 | #define XEN_HOST_METRICS_H |
---|
21 | |
---|
22 | #include <xen/api/xen_common.h> |
---|
23 | #include <xen/api/xen_host_metrics_decl.h> |
---|
24 | |
---|
25 | |
---|
26 | /* |
---|
27 | * The host_metrics class. |
---|
28 | * |
---|
29 | * The metrics associated with a host. |
---|
30 | */ |
---|
31 | |
---|
32 | |
---|
33 | /** |
---|
34 | * Free the given xen_host_metrics. The given handle must have been |
---|
35 | * allocated by this library. |
---|
36 | */ |
---|
37 | extern void |
---|
38 | xen_host_metrics_free(xen_host_metrics host_metrics); |
---|
39 | |
---|
40 | |
---|
41 | typedef struct xen_host_metrics_set |
---|
42 | { |
---|
43 | size_t size; |
---|
44 | xen_host_metrics *contents[]; |
---|
45 | } xen_host_metrics_set; |
---|
46 | |
---|
47 | /** |
---|
48 | * Allocate a xen_host_metrics_set of the given size. |
---|
49 | */ |
---|
50 | extern xen_host_metrics_set * |
---|
51 | xen_host_metrics_set_alloc(size_t size); |
---|
52 | |
---|
53 | /** |
---|
54 | * Free the given xen_host_metrics_set. The given set must have been |
---|
55 | * allocated by this library. |
---|
56 | */ |
---|
57 | extern void |
---|
58 | xen_host_metrics_set_free(xen_host_metrics_set *set); |
---|
59 | |
---|
60 | |
---|
61 | typedef struct xen_host_metrics_record |
---|
62 | { |
---|
63 | xen_host_metrics handle; |
---|
64 | char *uuid; |
---|
65 | int64_t memory_total; |
---|
66 | int64_t memory_free; |
---|
67 | time_t last_updated; |
---|
68 | } xen_host_metrics_record; |
---|
69 | |
---|
70 | /** |
---|
71 | * Allocate a xen_host_metrics_record. |
---|
72 | */ |
---|
73 | extern xen_host_metrics_record * |
---|
74 | xen_host_metrics_record_alloc(void); |
---|
75 | |
---|
76 | /** |
---|
77 | * Free the given xen_host_metrics_record, and all referenced values. |
---|
78 | * The given record must have been allocated by this library. |
---|
79 | */ |
---|
80 | extern void |
---|
81 | xen_host_metrics_record_free(xen_host_metrics_record *record); |
---|
82 | |
---|
83 | |
---|
84 | typedef struct xen_host_metrics_record_opt |
---|
85 | { |
---|
86 | bool is_record; |
---|
87 | union |
---|
88 | { |
---|
89 | xen_host_metrics handle; |
---|
90 | xen_host_metrics_record *record; |
---|
91 | } u; |
---|
92 | } xen_host_metrics_record_opt; |
---|
93 | |
---|
94 | /** |
---|
95 | * Allocate a xen_host_metrics_record_opt. |
---|
96 | */ |
---|
97 | extern xen_host_metrics_record_opt * |
---|
98 | xen_host_metrics_record_opt_alloc(void); |
---|
99 | |
---|
100 | /** |
---|
101 | * Free the given xen_host_metrics_record_opt, and all referenced |
---|
102 | * values. The given record_opt must have been allocated by this library. |
---|
103 | */ |
---|
104 | extern void |
---|
105 | xen_host_metrics_record_opt_free(xen_host_metrics_record_opt *record_opt); |
---|
106 | |
---|
107 | |
---|
108 | typedef struct xen_host_metrics_record_set |
---|
109 | { |
---|
110 | size_t size; |
---|
111 | xen_host_metrics_record *contents[]; |
---|
112 | } xen_host_metrics_record_set; |
---|
113 | |
---|
114 | /** |
---|
115 | * Allocate a xen_host_metrics_record_set of the given size. |
---|
116 | */ |
---|
117 | extern xen_host_metrics_record_set * |
---|
118 | xen_host_metrics_record_set_alloc(size_t size); |
---|
119 | |
---|
120 | /** |
---|
121 | * Free the given xen_host_metrics_record_set, and all referenced |
---|
122 | * values. The given set must have been allocated by this library. |
---|
123 | */ |
---|
124 | extern void |
---|
125 | xen_host_metrics_record_set_free(xen_host_metrics_record_set *set); |
---|
126 | |
---|
127 | |
---|
128 | |
---|
129 | typedef struct xen_host_metrics_record_opt_set |
---|
130 | { |
---|
131 | size_t size; |
---|
132 | xen_host_metrics_record_opt *contents[]; |
---|
133 | } xen_host_metrics_record_opt_set; |
---|
134 | |
---|
135 | /** |
---|
136 | * Allocate a xen_host_metrics_record_opt_set of the given size. |
---|
137 | */ |
---|
138 | extern xen_host_metrics_record_opt_set * |
---|
139 | xen_host_metrics_record_opt_set_alloc(size_t size); |
---|
140 | |
---|
141 | /** |
---|
142 | * Free the given xen_host_metrics_record_opt_set, and all referenced |
---|
143 | * values. The given set must have been allocated by this library. |
---|
144 | */ |
---|
145 | extern void |
---|
146 | xen_host_metrics_record_opt_set_free(xen_host_metrics_record_opt_set *set); |
---|
147 | |
---|
148 | |
---|
149 | /** |
---|
150 | * Get a record containing the current state of the given host_metrics. |
---|
151 | */ |
---|
152 | extern bool |
---|
153 | xen_host_metrics_get_record(xen_session *session, xen_host_metrics_record **result, xen_host_metrics host_metrics); |
---|
154 | |
---|
155 | |
---|
156 | /** |
---|
157 | * Get a reference to the host_metrics instance with the specified |
---|
158 | * UUID. |
---|
159 | */ |
---|
160 | extern bool |
---|
161 | xen_host_metrics_get_by_uuid(xen_session *session, xen_host_metrics *result, char *uuid); |
---|
162 | |
---|
163 | |
---|
164 | /** |
---|
165 | * Get the uuid field of the given host_metrics. |
---|
166 | */ |
---|
167 | extern bool |
---|
168 | xen_host_metrics_get_uuid(xen_session *session, char **result, xen_host_metrics host_metrics); |
---|
169 | |
---|
170 | |
---|
171 | /** |
---|
172 | * Get the memory/total field of the given host_metrics. |
---|
173 | */ |
---|
174 | extern bool |
---|
175 | xen_host_metrics_get_memory_total(xen_session *session, int64_t *result, xen_host_metrics host_metrics); |
---|
176 | |
---|
177 | |
---|
178 | /** |
---|
179 | * Get the memory/free field of the given host_metrics. |
---|
180 | */ |
---|
181 | extern bool |
---|
182 | xen_host_metrics_get_memory_free(xen_session *session, int64_t *result, xen_host_metrics host_metrics); |
---|
183 | |
---|
184 | |
---|
185 | /** |
---|
186 | * Get the last_updated field of the given host_metrics. |
---|
187 | */ |
---|
188 | extern bool |
---|
189 | xen_host_metrics_get_last_updated(xen_session *session, time_t *result, xen_host_metrics host_metrics); |
---|
190 | |
---|
191 | |
---|
192 | /** |
---|
193 | * Return a list of all the host_metrics instances known to the system. |
---|
194 | */ |
---|
195 | extern bool |
---|
196 | xen_host_metrics_get_all(xen_session *session, struct xen_host_metrics_set **result); |
---|
197 | |
---|
198 | |
---|
199 | #endif |
---|