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