xref: /onnv-gate/usr/src/head/rpcsvc/rstat.x (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 (c) 1985, 1990, 1991 by Sun Microsystems, Inc.
24*0Sstevel@tonic-gate % */
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate %/* from rstat.x */
27*0Sstevel@tonic-gate 
28*0Sstevel@tonic-gate /*
29*0Sstevel@tonic-gate  * Gather statistics on remote machines
30*0Sstevel@tonic-gate  */
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifdef RPC_HDR
33*0Sstevel@tonic-gate %
34*0Sstevel@tonic-gate %#pragma ident	"%Z%%M%	%I%	%E% SMI"
35*0Sstevel@tonic-gate %
36*0Sstevel@tonic-gate %/*
37*0Sstevel@tonic-gate % * Scale factor for scaled integers used to count load averages.
38*0Sstevel@tonic-gate % */
39*0Sstevel@tonic-gate %#ifndef	FSCALE
40*0Sstevel@tonic-gate %#define	FSHIFT	8	/* bits to right of fixed binary point */
41*0Sstevel@tonic-gate %#define	FSCALE	(1<<FSHIFT)
42*0Sstevel@tonic-gate %#endif	/* ndef FSCALE */
43*0Sstevel@tonic-gate %
44*0Sstevel@tonic-gate %#ifndef DST_NONE
45*0Sstevel@tonic-gate %#include <sys/time.h>		/* The time struct defined below is	*/
46*0Sstevel@tonic-gate %#endif				/* meant to match struct timeval.	*/
47*0Sstevel@tonic-gate %
48*0Sstevel@tonic-gate %
49*0Sstevel@tonic-gate %
50*0Sstevel@tonic-gate %
51*0Sstevel@tonic-gate %
52*0Sstevel@tonic-gate %
53*0Sstevel@tonic-gate #elif RPC_SVC
54*0Sstevel@tonic-gate %
55*0Sstevel@tonic-gate %/*
56*0Sstevel@tonic-gate % *  Server side stub routines for the rstat daemon
57*0Sstevel@tonic-gate % */
58*0Sstevel@tonic-gate %
59*0Sstevel@tonic-gate #elif RPC_CLNT
60*0Sstevel@tonic-gate %
61*0Sstevel@tonic-gate %/*
62*0Sstevel@tonic-gate % *  Client side stub routines for the rstat daemon
63*0Sstevel@tonic-gate % */
64*0Sstevel@tonic-gate %
65*0Sstevel@tonic-gate #elif RPC_XDR
66*0Sstevel@tonic-gate %/*
67*0Sstevel@tonic-gate % * XDR routines for the rstat daemon, rup and perfmeter.
68*0Sstevel@tonic-gate % */
69*0Sstevel@tonic-gate %
70*0Sstevel@tonic-gate %/*
71*0Sstevel@tonic-gate % * xdr_timeval was used in previous releases.
72*0Sstevel@tonic-gate % */
73*0Sstevel@tonic-gate %
74*0Sstevel@tonic-gate %bool_t
75*0Sstevel@tonic-gate %#ifdef __STDC__
76*0Sstevel@tonic-gate %xdr_timeval(XDR *xdrs, struct timeval *tvp)
77*0Sstevel@tonic-gate %#else /* K&R C */
78*0Sstevel@tonic-gate %xdr_timeval(xdrs, tvp)
79*0Sstevel@tonic-gate %	XDR *xdrs;
80*0Sstevel@tonic-gate %	struct timeval *tvp;
81*0Sstevel@tonic-gate %#endif /* K&R C */
82*0Sstevel@tonic-gate %{
83*0Sstevel@tonic-gate %	return (xdr_rstat_timeval(xdrs, (rstat_timeval *)tvp));
84*0Sstevel@tonic-gate %}
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate %
87*0Sstevel@tonic-gate #endif
88*0Sstevel@tonic-gate 
89*0Sstevel@tonic-gate const RSTAT_CPUSTATES = 4;
90*0Sstevel@tonic-gate const RSTAT_DK_NDRIVE = 4;
91*0Sstevel@tonic-gate 
92*0Sstevel@tonic-gate /*
93*0Sstevel@tonic-gate  * the cpu stat values
94*0Sstevel@tonic-gate  */
95*0Sstevel@tonic-gate 
96*0Sstevel@tonic-gate const RSTAT_CPU_USER = 0;
97*0Sstevel@tonic-gate const RSTAT_CPU_NICE = 1;
98*0Sstevel@tonic-gate const RSTAT_CPU_SYS = 2;
99*0Sstevel@tonic-gate const RSTAT_CPU_IDLE = 3;
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate /*
102*0Sstevel@tonic-gate  * GMT since 0:00, January 1, 1970
103*0Sstevel@tonic-gate  */
104*0Sstevel@tonic-gate struct rstat_timeval {
105*0Sstevel@tonic-gate 	int tv_sec;	/* seconds */
106*0Sstevel@tonic-gate 	int tv_usec;	/* and microseconds */
107*0Sstevel@tonic-gate };
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate struct statsvar {				/* RSTATVERS_VAR */
110*0Sstevel@tonic-gate 	int cp_time<>; 		/* variable number of CPU states */
111*0Sstevel@tonic-gate 	int dk_xfer<>;		/* variable number of disks */
112*0Sstevel@tonic-gate 	unsigned v_pgpgin;	/* these are cumulative sum */
113*0Sstevel@tonic-gate 	unsigned v_pgpgout;
114*0Sstevel@tonic-gate 	unsigned v_pswpin;
115*0Sstevel@tonic-gate 	unsigned v_pswpout;
116*0Sstevel@tonic-gate 	unsigned v_intr;
117*0Sstevel@tonic-gate 	int if_ipackets;
118*0Sstevel@tonic-gate 	int if_ierrors;
119*0Sstevel@tonic-gate 	int if_opackets;
120*0Sstevel@tonic-gate 	int if_oerrors;
121*0Sstevel@tonic-gate 	int if_collisions;
122*0Sstevel@tonic-gate 	unsigned v_swtch;
123*0Sstevel@tonic-gate 	int avenrun[3];
124*0Sstevel@tonic-gate 	rstat_timeval boottime;
125*0Sstevel@tonic-gate 	rstat_timeval curtime;
126*0Sstevel@tonic-gate };
127*0Sstevel@tonic-gate 
128*0Sstevel@tonic-gate struct statstime {				/* RSTATVERS_TIME */
129*0Sstevel@tonic-gate 	int cp_time[RSTAT_CPUSTATES];
130*0Sstevel@tonic-gate 	int dk_xfer[RSTAT_DK_NDRIVE];
131*0Sstevel@tonic-gate 	unsigned int v_pgpgin;	/* these are cumulative sum */
132*0Sstevel@tonic-gate 	unsigned int v_pgpgout;
133*0Sstevel@tonic-gate 	unsigned int v_pswpin;
134*0Sstevel@tonic-gate 	unsigned int v_pswpout;
135*0Sstevel@tonic-gate 	unsigned int v_intr;
136*0Sstevel@tonic-gate 	int if_ipackets;
137*0Sstevel@tonic-gate 	int if_ierrors;
138*0Sstevel@tonic-gate 	int if_oerrors;
139*0Sstevel@tonic-gate 	int if_collisions;
140*0Sstevel@tonic-gate 	unsigned int v_swtch;
141*0Sstevel@tonic-gate 	int avenrun[3];
142*0Sstevel@tonic-gate 	rstat_timeval boottime;
143*0Sstevel@tonic-gate 	rstat_timeval curtime;
144*0Sstevel@tonic-gate 	int if_opackets;
145*0Sstevel@tonic-gate };
146*0Sstevel@tonic-gate 
147*0Sstevel@tonic-gate program RSTATPROG {
148*0Sstevel@tonic-gate         /*
149*0Sstevel@tonic-gate          * Version 4 allows for variable number of disk and RSTAT_CPU states.
150*0Sstevel@tonic-gate          */
151*0Sstevel@tonic-gate 	version RSTATVERS_VAR {
152*0Sstevel@tonic-gate 		statsvar
153*0Sstevel@tonic-gate 		RSTATPROC_STATS (void) = 1;
154*0Sstevel@tonic-gate 		unsigned int
155*0Sstevel@tonic-gate 		RSTATPROC_HAVEDISK (void) = 2;
156*0Sstevel@tonic-gate 	} = 4;
157*0Sstevel@tonic-gate 	/*
158*0Sstevel@tonic-gate 	 * Newest version includes current time and context switching info
159*0Sstevel@tonic-gate 	 */
160*0Sstevel@tonic-gate 	version RSTATVERS_TIME {
161*0Sstevel@tonic-gate 		statstime
162*0Sstevel@tonic-gate 		RSTATPROC_STATS(void) = 1;
163*0Sstevel@tonic-gate 		unsigned int
164*0Sstevel@tonic-gate 		RSTATPROC_HAVEDISK(void) = 2;
165*0Sstevel@tonic-gate 	} = 3;
166*0Sstevel@tonic-gate } = 100001;
167*0Sstevel@tonic-gate 
168*0Sstevel@tonic-gate #ifdef RPC_HDR
169*0Sstevel@tonic-gate %
170*0Sstevel@tonic-gate %#if defined(__STDC__) || defined(__cplusplus)
171*0Sstevel@tonic-gate %enum clnt_stat rstat(char *, struct statstime *);
172*0Sstevel@tonic-gate %int havedisk(char *);
173*0Sstevel@tonic-gate %#else
174*0Sstevel@tonic-gate %enum clnt_stat rstat();
175*0Sstevel@tonic-gate %int havedisk();
176*0Sstevel@tonic-gate %#endif
177*0Sstevel@tonic-gate %
178*0Sstevel@tonic-gate #endif
179