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