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.
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.
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]
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
26 #ifndef _ZONESTAT_IMPL_H
27 #define _ZONESTAT_IMPL_H
31 #include <sys/priv_const.h>
40 #define ZS_PSET_DEFAULT PS_NONE
41 #define ZS_PSET_MULTI PS_MYID
42 #define ZS_PSET_ERROR PS_QUERY
44 #define ZS_DOOR_PATH "/etc/svc/volatile/zonestat_door"
46 #define ZSD_CMD_READ 1
47 #define ZSD_CMD_CONNECT 2
48 #define ZSD_CMD_NEW_ZONE 3
50 /* The following read commands are unimplemented */
51 #define ZSD_CMD_READ_TIME 3
52 #define ZSD_CMD_READ_SET 4
53 #define ZSD_CMD_READ_SET_TIME 5
55 #define ZSD_STATUS_OK 0
56 #define ZSD_STATUS_VERSION_MISMATCH 1
57 #define ZSD_STATUS_PERMISSION 2
58 #define ZSD_STATUS_INTERNAL_ERROR 3
60 #define TIMESTRUC_ADD_NANOSEC(ts, nsec) \
62 (ts).tv_sec += (time_t)((nsec) / NANOSEC); \
63 (ts).tv_nsec += (long)((nsec) % NANOSEC); \
64 if ((ts).tv_nsec > NANOSEC) { \
65 (ts).tv_sec += (ts).tv_nsec / NANOSEC; \
66 (ts).tv_nsec = (ts).tv_nsec % NANOSEC; \
70 #define TIMESTRUC_ADD_TIMESTRUC(ts, add) \
72 (ts).tv_sec += (add).tv_sec; \
73 (ts).tv_nsec += (add).tv_nsec; \
74 if ((ts).tv_nsec > NANOSEC) { \
75 (ts).tv_sec += (ts).tv_nsec / NANOSEC; \
76 (ts).tv_nsec = (ts).tv_nsec % NANOSEC; \
80 #define TIMESTRUC_DELTA(delta, new, old) \
82 (delta).tv_sec = (new).tv_sec - (old).tv_sec; \
83 (delta).tv_nsec = (new).tv_nsec - (old).tv_nsec;\
84 if ((delta).tv_nsec < 0) { \
85 delta.tv_nsec += NANOSEC; \
88 if ((delta).tv_sec < 0) { \
94 typedef struct zs_system
{
96 uint64_t zss_ram_total
;
97 uint64_t zss_ram_kern
;
98 uint64_t zss_ram_zones
;
100 uint64_t zss_locked_kern
;
101 uint64_t zss_locked_zones
;
103 uint64_t zss_vm_total
;
104 uint64_t zss_vm_kern
;
105 uint64_t zss_vm_zones
;
107 uint64_t zss_swap_total
;
108 uint64_t zss_swap_used
;
110 timestruc_t zss_cpu_total_time
;
111 timestruc_t zss_cpu_usage_kern
;
112 timestruc_t zss_cpu_usage_zones
;
114 uint64_t zss_processes_max
;
115 uint64_t zss_lwps_max
;
116 uint64_t zss_shm_max
;
117 uint64_t zss_shmids_max
;
118 uint64_t zss_semids_max
;
119 uint64_t zss_msgids_max
;
120 uint64_t zss_lofi_max
;
122 uint64_t zss_processes
;
131 uint64_t zss_ncpus_online
;
135 struct zs_pset_zone
{
137 list_node_t zspz_next
;
138 struct zs_pset
*zspz_pset
;
139 struct zs_zone
*zspz_zone
;
140 zoneid_t zspz_zoneid
;
142 hrtime_t zspz_hrstart
;
143 uint_t zspz_intervals
;
145 uint64_t zspz_cpu_shares
;
148 timestruc_t zspz_cpu_usage
;
155 zs_usage_t
*zsctl_start
;
159 list_node_t zsz_next
;
160 struct zs_system
*zsz_system
;
161 char zsz_name
[ZS_ZONENAME_MAX
];
162 char zsz_pool
[ZS_POOLNAME_MAX
];
163 char zsz_pset
[ZS_PSETNAME_MAX
];
168 hrtime_t zsz_hrstart
;
169 uint_t zsz_intervals
;
172 uint64_t zsz_cpu_shares
;
173 uint64_t zsz_cpu_cap
;
174 uint64_t zsz_ram_cap
;
176 uint64_t zsz_locked_cap
;
178 uint64_t zsz_cpus_online
;
179 timestruc_t zsz_cpu_usage
;
180 timestruc_t zsz_pset_time
;
181 timestruc_t zsz_cap_time
;
182 timestruc_t zsz_share_time
;
184 uint64_t zsz_usage_ram
;
185 uint64_t zsz_usage_locked
;
186 uint64_t zsz_usage_vm
;
188 uint64_t zsz_processes_cap
;
189 uint64_t zsz_lwps_cap
;
190 uint64_t zsz_shm_cap
;
191 uint64_t zsz_shmids_cap
;
192 uint64_t zsz_semids_cap
;
193 uint64_t zsz_msgids_cap
;
194 uint64_t zsz_lofi_cap
;
196 uint64_t zsz_processes
;
207 list_node_t zsp_next
;
208 char zsp_name
[ZS_PSETNAME_MAX
];
212 hrtime_t zsp_hrstart
;
213 uint_t zsp_intervals
;
219 int64_t zsp_importance
;
222 uint64_t zsp_cpu_shares
;
223 timestruc_t zsp_total_time
;
224 timestruc_t zsp_usage_kern
;
225 timestruc_t zsp_usage_zones
;
228 list_t zsp_usage_list
;
233 hrtime_t zsu_hrstart
;
237 uint_t zsu_intervals
;
242 zs_system_t
*zsu_system
;
243 list_t zsu_zone_list
;
244 list_t zsu_pset_list
;
247 struct zs_usage_set
{
248 struct zs_usage
*zsus_total
;
249 struct zs_usage
*zsus_avg
;
250 struct zs_usage
*zsus_high
;
257 union zsp_value_union
{
258 char zsv_string
[ZS_PSETNAME_MAX
];
268 typedef struct zs_usage_cache
{
272 zs_usage_t
*zsuc_usage
;
280 #endif /* _ZONESTAT_IMPL_H */