xref: /titanic_52/usr/src/lib/libzonestat/common/zonestat.h (revision 2c2d21e98a95cba5687ec6574c974a5c6c4a6adb)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef _ZONESTAT_H
27 #define	_ZONESTAT_H
28 
29 
30 
31 #include <limits.h>
32 #include <sys/types.h>
33 #include <sys/time.h>
34 #include <sys/param.h>
35 #include <sys/pset.h>
36 #include <sys/zone.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #define	ZS_IPTYPE_SHARED	1
43 #define	ZS_IPTYPE_EXCLUSIVE	2
44 
45 #define	ZS_CPUTYPE_DEFAULT_PSET	1
46 #define	ZS_CPUTYPE_POOL_PSET	2
47 #define	ZS_CPUTYPE_PSRSET_PSET	3
48 #define	ZS_CPUTYPE_DEDICATED	4
49 
50 
51 #define	ZS_LIMIT_NONE			(UINT64_MAX)
52 #define	ZS_PCT_NONE			(UINT_MAX)
53 #define	ZS_SHARES_UNLIMITED		(UINT16_MAX)
54 
55 #define	ZS_ZONENAME_MAX			ZONENAME_MAX
56 #define	ZS_PSETNAME_MAX			(1024 + 1)
57 #define	ZS_POOLNAME_MAX			(1024 + 1)
58 
59 #define	ZS_RESOURCE_TYPE_TIME		1
60 #define	ZS_RESOURCE_TYPE_COUNT		2
61 #define	ZS_RESOURCE_TYPE_BYTES		3
62 
63 #define	ZS_LIMIT_TYPE_TIME		1
64 #define	ZS_LIMIT_TYPE_COUNT		2
65 #define	ZS_LIMIT_TYPE_BYTES		3
66 
67 #define	ZS_PROP_TYPE_STRING		1
68 #define	ZS_PROP_TYPE_TIME		2
69 #define	ZS_PROP_TYPE_UINT64		3
70 #define	ZS_PROP_TYPE_INT64		4
71 #define	ZS_PROP_TYPE_UINT		5
72 #define	ZS_PROP_TYPE_INT		6
73 #define	ZS_PROP_TYPE_DOUBLE		7
74 
75 #define	ZS_SCHED_TS			0x1
76 #define	ZS_SCHED_IA			0x2
77 #define	ZS_SCHED_RT			0x4
78 #define	ZS_SCHED_FX			0x8
79 #define	ZS_SCHED_FX_60			0x10
80 #define	ZS_SCHED_FSS			0x20
81 #define	ZS_SCHED_CONFLICT		0x40
82 
83 #define	ZS_RESOURCE_PROP_CPU_TOTAL	1
84 #define	ZS_RESOURCE_PROP_CPU_ONLINE	2
85 #define	ZS_RESOURCE_PROP_CPU_LOAD_1MIN	3
86 #define	ZS_RESOURCE_PROP_CPU_LOAD_5MIN	4
87 #define	ZS_RESOURCE_PROP_CPU_LOAD_15MIN	5
88 
89 #define	ZS_RESOURCE_CPU			1
90 #define	ZS_RESOURCE_RAM_RSS		2
91 #define	ZS_RESOURCE_RAM_LOCKED		3
92 #define	ZS_RESOURCE_VM			4
93 #define	ZS_RESOURCE_DISK_SWAP		5
94 #define	ZS_RESOURCE_LWPS		6
95 #define	ZS_RESOURCE_PROCESSES		7
96 #define	ZS_RESOURCE_SHM_MEMORY		8
97 #define	ZS_RESOURCE_SHM_IDS		9
98 #define	ZS_RESOURCE_SEM_IDS		10
99 #define	ZS_RESOURCE_MSG_IDS		11
100 #define	ZS_RESOURCE_LOFI		12
101 
102 #define	ZS_USER_ALL			1
103 #define	ZS_USER_KERNEL			2
104 #define	ZS_USER_ZONES			3
105 #define	ZS_USER_FREE			4
106 
107 #define	ZS_LIMIT_CPU			1
108 #define	ZS_LIMIT_CPU_SHARES		2
109 #define	ZS_LIMIT_RAM_RSS		3
110 #define	ZS_LIMIT_RAM_LOCKED		4
111 #define	ZS_LIMIT_VM			5
112 #define	ZS_LIMIT_LWPS			6
113 #define	ZS_LIMIT_PROCESSES		7
114 #define	ZS_LIMIT_SHM_MEMORY		8
115 #define	ZS_LIMIT_SHM_IDS		9
116 #define	ZS_LIMIT_MSG_IDS		10
117 #define	ZS_LIMIT_SEM_IDS		11
118 #define	ZS_LIMIT_LOFI			12
119 
120 #define	ZS_ZONE_PROP_NAME		1
121 #define	ZS_ZONE_PROP_ID			2
122 #define	ZS_ZONE_PROP_IPTYPE		3
123 #define	ZS_ZONE_PROP_CPUTYPE		4
124 #define	ZS_ZONE_PROP_DEFAULT_SCHED	5
125 #define	ZS_ZONE_PROP_SCHEDULERS		6
126 #define	ZS_ZONE_PROP_CPU_SHARES		7
127 #define	ZS_ZONE_PROP_POOLNAME		8
128 #define	ZS_ZONE_PROP_PSETNAME		9
129 #define	ZS_ZONE_PROP_UPTIME		10
130 #define	ZS_ZONE_PROP_BOOTTIME		11
131 
132 #define	ZS_PSET_PROP_NAME		1
133 #define	ZS_PSET_PROP_ID			2
134 #define	ZS_PSET_PROP_CPUTYPE		3
135 #define	ZS_PSET_PROP_SIZE		4
136 #define	ZS_PSET_PROP_ONLINE		5
137 #define	ZS_PSET_PROP_MIN		6
138 #define	ZS_PSET_PROP_MAX		7
139 #define	ZS_PSET_PROP_CPU_SHARES		8
140 #define	ZS_PSET_PROP_SCHEDULERS		9
141 #define	ZS_PSET_PROP_CREATETIME		10
142 #define	ZS_PSET_PROP_LOAD_1MIN		11
143 #define	ZS_PSET_PROP_LOAD_5MIN		12
144 #define	ZS_PSET_PROP_LOAD_15MIN		13
145 
146 #define	ZS_PZ_PROP_SCHEDULERS	1
147 #define	ZS_PZ_PROP_CPU_SHARES	2
148 #define	ZS_PZ_PROP_CPU_CAP	4
149 
150 #define	ZS_COMPUTE_USAGE_INTERVAL	1
151 #define	ZS_COMPUTE_USAGE_TOTAL		2
152 #define	ZS_COMPUTE_USAGE_AVERAGE	3
153 #define	ZS_COMPUTE_USAGE_HIGH		4
154 
155 #define	ZS_COMPUTE_SET_TOTAL		1
156 #define	ZS_COMPUTE_SET_AVERAGE		2
157 #define	ZS_COMPUTE_SET_HIGH		3
158 
159 #define	ZS_PZ_PCT_PSET		1
160 #define	ZS_PZ_PCT_CPU_CAP	2
161 #define	ZS_PZ_PCT_PSET_SHARES	3
162 #define	ZS_PZ_PCT_CPU_SHARES	4
163 
164 
165 /* Per-client handle to libzonestat */
166 typedef struct zs_ctl zs_ctl_t;
167 
168 /*
169  * These usage structure contains the system's utilization (overall, zones,
170  * psets, memory) at a given point in time.
171  */
172 typedef struct zs_usage zs_usage_t;
173 
174 /*
175  * The usage set is for computations on multiple usage structures to describe
176  * a range of time.
177  */
178 typedef struct zs_usage_set zs_usage_set_t;
179 
180 /*
181  * The following structures desribe each zone, pset, and each zone's usage
182  * of each pset.  Each usage structure (above) contains lists of these that
183  * can be traversed.
184  */
185 typedef struct zs_zone zs_zone_t;
186 typedef struct zs_pset zs_pset_t;
187 typedef struct zs_pset_zone zs_pset_zone_t;
188 
189 /*
190  * Opaque structure for properties.
191  */
192 typedef struct zs_property zs_property_t;
193 
194 
195 /* functions for opening/closing a handle for reading current usage */
196 zs_ctl_t *zs_open();
197 void zs_close(zs_ctl_t *);
198 
199 /* function for reading current resource usage */
200 zs_usage_t *zs_usage_read(zs_ctl_t *);
201 
202 /* functions for manimulating usage data: zs_usage */
203 zs_usage_t *zs_usage_compute(zs_usage_t *, zs_usage_t *, zs_usage_t *, int);
204 void zs_usage_free(zs_usage_t *);
205 
206 /* functions for manipulating sets of usage data: zs_usage_set */
207 zs_usage_set_t *zs_usage_set_alloc();
208 void zs_usage_set_free(zs_usage_set_t *);
209 int zs_usage_set_add(zs_usage_set_t *, zs_usage_t *);
210 int zs_usage_set_count(zs_usage_set_t *);
211 zs_usage_t *zs_usage_set_compute(zs_usage_set_t *, int);
212 
213 /* functions for overall system resources: zs_resource */
214 void zs_resource_property(zs_usage_t *, int, int, zs_property_t *);
215 int zs_resource_type(int);
216 uint64_t zs_resource_total_uint64(zs_usage_t *, int);
217 uint64_t zs_resource_used_uint64(zs_usage_t *, int, int);
218 uint64_t zs_resource_used_zone_uint64(zs_zone_t *, int);
219 void zs_resource_total_time(zs_usage_t *, int, timestruc_t *);
220 void zs_resource_used_time(zs_usage_t *, int, int, timestruc_t *);
221 void zs_resource_used_zone_time(zs_zone_t *, int, timestruc_t *);
222 uint_t zs_resource_used_pct(zs_usage_t *, int, int);
223 uint_t zs_resource_used_zone_pct(zs_zone_t *, int);
224 
225 /* functions for individual zone usage: zs_zone */
226 int zs_zone_list(zs_usage_t *, zs_zone_t **, int);
227 zs_zone_t *zs_zone_first(zs_usage_t *);
228 zs_zone_t *zs_zone_next(zs_usage_t *, zs_zone_t *);
229 void zs_zone_property(zs_zone_t *, int, zs_property_t *);
230 int zs_zone_limit_type(int);
231 uint64_t zs_zone_limit_uint64(zs_zone_t *, int);
232 uint64_t zs_zone_limit_used_uint64(zs_zone_t *, int);
233 void zs_zone_limit_time(zs_zone_t *, int, timestruc_t *);
234 void zs_zone_limit_used_time(zs_zone_t *, int, timestruc_t *);
235 uint_t zs_zone_limit_used_pct(zs_zone_t *, int);
236 
237 /* functions for individual psets: zs_pset_list */
238 int zs_pset_list(zs_usage_t *, zs_pset_t **, int);
239 zs_pset_t *zs_pset_first(zs_usage_t *);
240 zs_pset_t *zs_pset_next(zs_usage_t *, zs_pset_t *);
241 void zs_pset_property(zs_pset_t *, int, zs_property_t *);
242 void zs_pset_total_time(zs_pset_t *, timestruc_t *);
243 uint64_t zs_pset_total_cpus(zs_pset_t *);
244 void zs_pset_used_time(zs_pset_t *, int, timestruc_t *);
245 uint64_t zs_pset_used_cpus(zs_pset_t *, int);
246 uint_t zs_pset_used_pct(zs_pset_t *, int);
247 
248 /* functions for a pset's per-zone usage: zs_pset_zone */
249 int zs_pset_zone_list(zs_pset_t *, zs_pset_zone_t **, int);
250 zs_pset_zone_t *zs_pset_zone_first(zs_pset_t *);
251 zs_pset_zone_t *zs_pset_zone_next(zs_pset_t *, zs_pset_zone_t *);
252 zs_zone_t *zs_pset_zone_get_zone(zs_pset_zone_t *);
253 zs_pset_t *zs_pset_zone_get_pset(zs_pset_zone_t *);
254 void zs_pset_zone_property(zs_pset_zone_t *, int, zs_property_t *);
255 void zs_pset_zone_used_time(zs_pset_zone_t *, timestruc_t *);
256 uint64_t zs_pset_zone_used_cpus(zs_pset_zone_t *);
257 uint_t zs_pset_zone_used_pct(zs_pset_zone_t *, int);
258 
259 /* functions for accessing properties */
260 zs_property_t *zs_property_alloc();
261 size_t zs_property_size();
262 void zs_property_free(zs_property_t *);
263 int zs_property_type(zs_property_t *);
264 int zs_property_id(zs_property_t *);
265 char *zs_property_string(zs_property_t *);
266 double zs_property_double(zs_property_t *);
267 void zs_property_time(zs_property_t *, timestruc_t *);
268 uint64_t zs_property_uint64(zs_property_t *);
269 int64_t zs_property_int64(zs_property_t *);
270 uint_t zs_property_uint(zs_property_t *);
271 int zs_property_int(zs_property_t *);
272 
273 #ifdef __cplusplus
274 }
275 #endif
276 
277 #endif	/* _ZONESTAT_H */
278