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