xref: /titanic_51/usr/src/head/rpcsvc/rstat.x (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate %/*
23*7c478bd9Sstevel@tonic-gate % * Copyright (c) 1985, 1990, 1991 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate % */
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate %/* from rstat.x */
27*7c478bd9Sstevel@tonic-gate 
28*7c478bd9Sstevel@tonic-gate /*
29*7c478bd9Sstevel@tonic-gate  * Gather statistics on remote machines
30*7c478bd9Sstevel@tonic-gate  */
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef RPC_HDR
33*7c478bd9Sstevel@tonic-gate %
34*7c478bd9Sstevel@tonic-gate %#pragma ident	"%Z%%M%	%I%	%E% SMI"
35*7c478bd9Sstevel@tonic-gate %
36*7c478bd9Sstevel@tonic-gate %/*
37*7c478bd9Sstevel@tonic-gate % * Scale factor for scaled integers used to count load averages.
38*7c478bd9Sstevel@tonic-gate % */
39*7c478bd9Sstevel@tonic-gate %#ifndef	FSCALE
40*7c478bd9Sstevel@tonic-gate %#define	FSHIFT	8	/* bits to right of fixed binary point */
41*7c478bd9Sstevel@tonic-gate %#define	FSCALE	(1<<FSHIFT)
42*7c478bd9Sstevel@tonic-gate %#endif	/* ndef FSCALE */
43*7c478bd9Sstevel@tonic-gate %
44*7c478bd9Sstevel@tonic-gate %#ifndef DST_NONE
45*7c478bd9Sstevel@tonic-gate %#include <sys/time.h>		/* The time struct defined below is	*/
46*7c478bd9Sstevel@tonic-gate %#endif				/* meant to match struct timeval.	*/
47*7c478bd9Sstevel@tonic-gate %
48*7c478bd9Sstevel@tonic-gate %
49*7c478bd9Sstevel@tonic-gate %
50*7c478bd9Sstevel@tonic-gate %
51*7c478bd9Sstevel@tonic-gate %
52*7c478bd9Sstevel@tonic-gate %
53*7c478bd9Sstevel@tonic-gate #elif RPC_SVC
54*7c478bd9Sstevel@tonic-gate %
55*7c478bd9Sstevel@tonic-gate %/*
56*7c478bd9Sstevel@tonic-gate % *  Server side stub routines for the rstat daemon
57*7c478bd9Sstevel@tonic-gate % */
58*7c478bd9Sstevel@tonic-gate %
59*7c478bd9Sstevel@tonic-gate #elif RPC_CLNT
60*7c478bd9Sstevel@tonic-gate %
61*7c478bd9Sstevel@tonic-gate %/*
62*7c478bd9Sstevel@tonic-gate % *  Client side stub routines for the rstat daemon
63*7c478bd9Sstevel@tonic-gate % */
64*7c478bd9Sstevel@tonic-gate %
65*7c478bd9Sstevel@tonic-gate #elif RPC_XDR
66*7c478bd9Sstevel@tonic-gate %/*
67*7c478bd9Sstevel@tonic-gate % * XDR routines for the rstat daemon, rup and perfmeter.
68*7c478bd9Sstevel@tonic-gate % */
69*7c478bd9Sstevel@tonic-gate %
70*7c478bd9Sstevel@tonic-gate %/*
71*7c478bd9Sstevel@tonic-gate % * xdr_timeval was used in previous releases.
72*7c478bd9Sstevel@tonic-gate % */
73*7c478bd9Sstevel@tonic-gate %
74*7c478bd9Sstevel@tonic-gate %bool_t
75*7c478bd9Sstevel@tonic-gate %#ifdef __STDC__
76*7c478bd9Sstevel@tonic-gate %xdr_timeval(XDR *xdrs, struct timeval *tvp)
77*7c478bd9Sstevel@tonic-gate %#else /* K&R C */
78*7c478bd9Sstevel@tonic-gate %xdr_timeval(xdrs, tvp)
79*7c478bd9Sstevel@tonic-gate %	XDR *xdrs;
80*7c478bd9Sstevel@tonic-gate %	struct timeval *tvp;
81*7c478bd9Sstevel@tonic-gate %#endif /* K&R C */
82*7c478bd9Sstevel@tonic-gate %{
83*7c478bd9Sstevel@tonic-gate %	return (xdr_rstat_timeval(xdrs, (rstat_timeval *)tvp));
84*7c478bd9Sstevel@tonic-gate %}
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate %
87*7c478bd9Sstevel@tonic-gate #endif
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate const RSTAT_CPUSTATES = 4;
90*7c478bd9Sstevel@tonic-gate const RSTAT_DK_NDRIVE = 4;
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate /*
93*7c478bd9Sstevel@tonic-gate  * the cpu stat values
94*7c478bd9Sstevel@tonic-gate  */
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate const RSTAT_CPU_USER = 0;
97*7c478bd9Sstevel@tonic-gate const RSTAT_CPU_NICE = 1;
98*7c478bd9Sstevel@tonic-gate const RSTAT_CPU_SYS = 2;
99*7c478bd9Sstevel@tonic-gate const RSTAT_CPU_IDLE = 3;
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate /*
102*7c478bd9Sstevel@tonic-gate  * GMT since 0:00, January 1, 1970
103*7c478bd9Sstevel@tonic-gate  */
104*7c478bd9Sstevel@tonic-gate struct rstat_timeval {
105*7c478bd9Sstevel@tonic-gate 	int tv_sec;	/* seconds */
106*7c478bd9Sstevel@tonic-gate 	int tv_usec;	/* and microseconds */
107*7c478bd9Sstevel@tonic-gate };
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate struct statsvar {				/* RSTATVERS_VAR */
110*7c478bd9Sstevel@tonic-gate 	int cp_time<>; 		/* variable number of CPU states */
111*7c478bd9Sstevel@tonic-gate 	int dk_xfer<>;		/* variable number of disks */
112*7c478bd9Sstevel@tonic-gate 	unsigned v_pgpgin;	/* these are cumulative sum */
113*7c478bd9Sstevel@tonic-gate 	unsigned v_pgpgout;
114*7c478bd9Sstevel@tonic-gate 	unsigned v_pswpin;
115*7c478bd9Sstevel@tonic-gate 	unsigned v_pswpout;
116*7c478bd9Sstevel@tonic-gate 	unsigned v_intr;
117*7c478bd9Sstevel@tonic-gate 	int if_ipackets;
118*7c478bd9Sstevel@tonic-gate 	int if_ierrors;
119*7c478bd9Sstevel@tonic-gate 	int if_opackets;
120*7c478bd9Sstevel@tonic-gate 	int if_oerrors;
121*7c478bd9Sstevel@tonic-gate 	int if_collisions;
122*7c478bd9Sstevel@tonic-gate 	unsigned v_swtch;
123*7c478bd9Sstevel@tonic-gate 	int avenrun[3];
124*7c478bd9Sstevel@tonic-gate 	rstat_timeval boottime;
125*7c478bd9Sstevel@tonic-gate 	rstat_timeval curtime;
126*7c478bd9Sstevel@tonic-gate };
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate struct statstime {				/* RSTATVERS_TIME */
129*7c478bd9Sstevel@tonic-gate 	int cp_time[RSTAT_CPUSTATES];
130*7c478bd9Sstevel@tonic-gate 	int dk_xfer[RSTAT_DK_NDRIVE];
131*7c478bd9Sstevel@tonic-gate 	unsigned int v_pgpgin;	/* these are cumulative sum */
132*7c478bd9Sstevel@tonic-gate 	unsigned int v_pgpgout;
133*7c478bd9Sstevel@tonic-gate 	unsigned int v_pswpin;
134*7c478bd9Sstevel@tonic-gate 	unsigned int v_pswpout;
135*7c478bd9Sstevel@tonic-gate 	unsigned int v_intr;
136*7c478bd9Sstevel@tonic-gate 	int if_ipackets;
137*7c478bd9Sstevel@tonic-gate 	int if_ierrors;
138*7c478bd9Sstevel@tonic-gate 	int if_oerrors;
139*7c478bd9Sstevel@tonic-gate 	int if_collisions;
140*7c478bd9Sstevel@tonic-gate 	unsigned int v_swtch;
141*7c478bd9Sstevel@tonic-gate 	int avenrun[3];
142*7c478bd9Sstevel@tonic-gate 	rstat_timeval boottime;
143*7c478bd9Sstevel@tonic-gate 	rstat_timeval curtime;
144*7c478bd9Sstevel@tonic-gate 	int if_opackets;
145*7c478bd9Sstevel@tonic-gate };
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate program RSTATPROG {
148*7c478bd9Sstevel@tonic-gate         /*
149*7c478bd9Sstevel@tonic-gate          * Version 4 allows for variable number of disk and RSTAT_CPU states.
150*7c478bd9Sstevel@tonic-gate          */
151*7c478bd9Sstevel@tonic-gate 	version RSTATVERS_VAR {
152*7c478bd9Sstevel@tonic-gate 		statsvar
153*7c478bd9Sstevel@tonic-gate 		RSTATPROC_STATS (void) = 1;
154*7c478bd9Sstevel@tonic-gate 		unsigned int
155*7c478bd9Sstevel@tonic-gate 		RSTATPROC_HAVEDISK (void) = 2;
156*7c478bd9Sstevel@tonic-gate 	} = 4;
157*7c478bd9Sstevel@tonic-gate 	/*
158*7c478bd9Sstevel@tonic-gate 	 * Newest version includes current time and context switching info
159*7c478bd9Sstevel@tonic-gate 	 */
160*7c478bd9Sstevel@tonic-gate 	version RSTATVERS_TIME {
161*7c478bd9Sstevel@tonic-gate 		statstime
162*7c478bd9Sstevel@tonic-gate 		RSTATPROC_STATS(void) = 1;
163*7c478bd9Sstevel@tonic-gate 		unsigned int
164*7c478bd9Sstevel@tonic-gate 		RSTATPROC_HAVEDISK(void) = 2;
165*7c478bd9Sstevel@tonic-gate 	} = 3;
166*7c478bd9Sstevel@tonic-gate } = 100001;
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate #ifdef RPC_HDR
169*7c478bd9Sstevel@tonic-gate %
170*7c478bd9Sstevel@tonic-gate %#if defined(__STDC__) || defined(__cplusplus)
171*7c478bd9Sstevel@tonic-gate %enum clnt_stat rstat(char *, struct statstime *);
172*7c478bd9Sstevel@tonic-gate %int havedisk(char *);
173*7c478bd9Sstevel@tonic-gate %#else
174*7c478bd9Sstevel@tonic-gate %enum clnt_stat rstat();
175*7c478bd9Sstevel@tonic-gate %int havedisk();
176*7c478bd9Sstevel@tonic-gate %#endif
177*7c478bd9Sstevel@tonic-gate %
178*7c478bd9Sstevel@tonic-gate #endif
179