xref: /onnv-gate/usr/src/cmd/wbem/provider/tools/rds/rdimpl.h (revision 0:68f95e015346)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_RDIMPL_H
28 #define	_RDIMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/sysmacros.h>
33 #include <sys/time.h>
34 #include <sys/types.h>
35 #include <procfs.h>
36 #include <setjmp.h>
37 #include <time.h>
38 #include <inttypes.h>
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 extern int monitor_start();
45 extern void monitor_stop();
46 extern int monitor_update();
47 extern void list_clear();
48 extern char *ltdb_file;
49 extern int mo; /* option flag for microstate accounting	*/
50 
51 /*
52  * FRC2PCT macro is used to convert 16-bit binary fractions in the range
53  * 0.0 to 1.0 with binary point to the right of the high order bit
54  * (i.e. 1.0 == 0x8000) to percentage value.
55  */
56 
57 #define	FRC2PCT(pp)	(((float)(pp))/0x8000*100)
58 
59 #define	TIME2NSEC(__t)\
60 (hrtime_t)(((hrtime_t)__t.tv_sec * (hrtime_t)NANOSEC) + (hrtime_t)__t.tv_nsec)
61 #define	TIME2SEC(__t)\
62 (hrtime_t)(__t.tv_sec)
63 
64 /*
65  * Possible list types
66  */
67 #define	LT_LWPS		0x0001
68 #define	LT_USERS	0x0002
69 #define	LT_TASKS	0x0004
70 #define	LT_PROJECTS	0x0008
71 #define	LT_PSETS	0x0010
72 #define	LT_SYS		0x0020
73 #define	LT_PROCESS	0x0040
74 
75 /*
76  * Default list sizes
77  */
78 #define	LS_LWPS		1024
79 #define	LS_PROCESSES	512
80 #define	LS_USERS	32
81 #define	LS_PROJECTS	16
82 #define	LS_PSETS	8
83 #define	LS_SYS		1
84 
85 /*
86  * Linked list of per-process or per-lwp statistics
87  */
88 typedef struct lwp_info {
89 	psinfo_t	*li_psinfo;	/* data read from psinfo file	*/
90 	lwpsinfo_t	*li_lwpsinfo;
91 	prusage_t	li_usage;	/* data read from usage file	*/
92 	int		li_alive;	/* flag for alive lwps	*/
93 	int		rlwpid;		/* id of the representative lwp	*/
94 
95 	double	li_usr;		/* user level CPU time		*/
96 	double	li_sys;		/* system call CPU time		*/
97 	double	li_ttime;	/* SystemTrapTime		*/
98 	double	li_tpftime;	/* TextPageFaultSleepTime	*/
99 	double	li_dpftime;	/* DataPageFaultSleepTime	*/
100 	double	li_kpftime;	/* SystemPageFaultSleepTime	*/
101 	double	li_lck;		/* user lock wait sleep time	*/
102 	double	li_slp;		/* all other sleep time		*/
103 	double	li_lat;		/* wait-cpu (latency) time	*/
104 	double	li_stime;	/* StoppedTime			*/
105 	ulong_t	li_minf;	/* MinorPageFaults		*/
106 	ulong_t	li_majf;	/* MajorPageFaults		*/
107 	ulong_t	li_nswap;	/* SwapOperations		*/
108 	ulong_t	li_inblk;	/* BlocksRead			*/
109 	ulong_t	li_oublk;	/* BlocksWritten		*/
110 	ulong_t	li_msnd;	/* MessagesSent			*/
111 	ulong_t	li_mrcv;	/* MessagesReceived		*/
112 	ulong_t	li_sigs;	/* SignalsReceived		*/
113 	ulong_t	li_vctx;	/* VoluntaryContextSwitches	*/
114 	ulong_t	li_ictx;	/* InvoluntaryContextSwitches 	*/
115 	ulong_t	li_scl;		/* SystemCallsMade		*/
116 	ulong_t	li_ioch;	/* CharacterIOUsage		*/
117 	ulong_t	li_hpsize;	/* process heap in byte		*/
118 	ulong_t	li_timestamp;   /* system clock time od this snapshot	*/
119 	struct lwp_info *li_next;	/* pointer to next lwp		*/
120 	struct lwp_info *li_prev;	/* pointer to previous lwp	*/
121 } lwp_info_t;
122 
123 typedef struct {
124 	char *nodename;
125 	char *name;
126 } sys_info_t;
127 
128 typedef struct {
129 	int  id;
130 	void *id_next;	/* pointer to next entry */
131 	void *id_prev;	/* pointer to previous entry */
132 } info_head_t;
133 
134 /*
135  * Linked list of collective per-uid, per-set, or per-projid statistics
136  */
137 typedef struct id_info {
138 
139 	int	id_alive;	/* flag for alive id	*/
140 	uint_t	id_pid;		/* user process id	*/
141 	uint_t	id_uid;		/* user id */
142 	uint_t	id_taskid;	/* task id */
143 	uint_t	id_projid;	/* project id */
144 	uint_t	id_psetid;	/* processor set to which lwp is bound */
145 
146 	double	id_usr;		/* UserModeTime */
147 	double	id_sys;		/* SystemModeTime */
148 	double	id_ttime;	/* SystemTrapTime */
149 	double	id_tpftime;	/* TextPageFaultSleepTime */
150 	double	id_dpftime;	/* DataPageFaultSleepTime */
151 	double	id_kpftime;	/* SystemPageFaultSleepTime */
152 	double	id_lck;		/* UserLockWaitSleepTime */
153 	double	id_slp;		/* OtherSleepTime */
154 	double	id_lat;		/* WaitCPUTime */
155 	double	id_stime;	/* StoppedTime */
156 	int64_t id_minf;	/* MinorPageFaults */
157 	int64_t id_majf;	/* MajorPageFaults */
158 	int64_t id_nswap;	/* SwapOperations */
159 	int64_t id_inblk;	/* BlocksRead */
160 	int64_t id_oublk;	/* BlocksWritten */
161 	int64_t id_msnd;	/* MessagesSent */
162 	int64_t id_mrcv;	/* MessagesReceived */
163 	int64_t id_sigs;	/* SignalsReceived */
164 	int64_t id_vctx;	/* VoluntaryContextSwitches */
165 	int64_t id_ictx;	/* InvoluntaryContextSwitches */
166 	int64_t id_scl;		/* SystemCallsMade */
167 	int64_t id_ioch;	/* CharacterIOUsage */
168 	int64_t id_hpsize;	/* ProcessHeapSize # pstatus */
169 	int64_t id_size;	/* ProcessVMSize	*/
170 	int64_t id_rssize;	/* ProcessResidentSetSize # psinfo */
171 	float	id_pctcpu;	/* PercentCPUTime # psinfo	*/
172 	float	id_pctmem;	/* PercentMemorySize # psinfo	*/
173 	int64_t id_time;	/* UserSystemModeTime		*/
174 	uint_t	id_nlwps;	/* NumThreads	# psinfo	*/
175 	uint_t	id_nproc;	/* number of processes		*/
176 	int64_t id_timestamp;
177 
178 	char	*id_name;
179 	int64_t	id_inpkg;	/* net input packets		*/
180 	int64_t	id_oupkg;	/* net output packets		*/
181 	uint_t		id_key;		/* sort key value 		*/
182 	struct id_info *id_next;	/* pointer to next entry	*/
183 	struct id_info *id_prev;	/* pointer to previous entry 	*/
184 } id_info_t;
185 
186 /*
187  * Per-list structure
188  */
189 typedef struct list {
190 	int		l_type;		/* list type */
191 	int		l_count;	/* number of entries in the list   */
192 	void		*l_head;	/* pointer to the head of the list */
193 	void		*l_tail;	/* pointer to the tail of the list */
194 	int		l_size;		/* number of allocated pointers */
195 	int		l_used;		/* number of used pointers	*/
196 	void		**l_ptrs;	/* pointer to an array of pointers */
197 } list_t;
198 
199 typedef struct swap_info {
200 	size_t	allocated; /* not free swap memory		*/
201 	size_t	reserved;  /* reserved  but not allocated swap memory in KB */
202 	size_t  available; /* available swap memory in KB	*/
203 	float   pctswap;   /* percentage of used swap		*/
204 } swap_info_t;
205 
206 #ifdef	__cplusplus
207 }
208 #endif
209 
210 #endif	/* _RDIMPL_H */
211