xref: /openbsd/lib/librpcsvc/rstat.x (revision 404b540a)
1 /*	$OpenBSD: rstat.x,v 1.4 2004/01/17 12:32:11 deraadt Exp $	*/
2 
3 /*
4  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5  * unrestricted use provided that this legend is included on all tape
6  * media and as a part of the software program in whole or part.  Users
7  * may copy or modify Sun RPC without charge, but are not authorized
8  * to license or distribute it to anyone else except as part of a product or
9  * program developed by the user.
10  *
11  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14  *
15  * Sun RPC is provided with no support and without any obligation on the
16  * part of Sun Microsystems, Inc. to assist in its use, correction,
17  * modification or enhancement.
18  *
19  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21  * OR ANY PART THEREOF.
22  *
23  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24  * or profits or other special, indirect and consequential damages, even if
25  * Sun has been advised of the possibility of such damages.
26  *
27  * Sun Microsystems, Inc.
28  * 2550 Garcia Avenue
29  * Mountain View, California  94043
30  */
31 
32 /*
33  * Gather statistics on remote machines
34  */
35 
36 #ifdef RPC_HDR
37 
38 %#ifndef FSCALE
39 %/*
40 % * Scale factor for scaled integers used to count load averages.
41 % */
42 %#define FSHIFT	8		/* bits to right of fixed binary point */
43 %#define FSCALE	(1<<FSHIFT)
44 %
45 %#endif /* ndef FSCALE */
46 
47 #else
48 
49 %#ifndef lint
50 %/*static char sccsid[] = "from: @(#)rstat.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
51 %/*static char sccsid[] = "from: @(#)rstat.x	2.2 88/08/01 4.0 RPCSRC";*/
52 %static char rcsid[] = "$OpenBSD: rstat.x,v 1.4 2004/01/17 12:32:11 deraadt Exp $";
53 %#endif /* not lint */
54 
55 #endif /* def RPC_HDR */
56 
57 const CPUSTATES = 4;
58 const DK_NDRIVE = 4;
59 
60 /*
61  * GMT since 0:00, January 1, 1970
62  */
63 struct rstat_timeval {
64 	unsigned int tv_sec;	/* seconds */
65 	unsigned int tv_usec;	/* and microseconds */
66 };
67 
68 struct statstime {				/* RSTATVERS_TIME */
69 	int cp_time[CPUSTATES];
70 	int dk_xfer[DK_NDRIVE];
71 	unsigned int v_pgpgin;	/* these are cumulative sum */
72 	unsigned int v_pgpgout;
73 	unsigned int v_pswpin;
74 	unsigned int v_pswpout;
75 	unsigned int v_intr;
76 	int if_ipackets;
77 	int if_ierrors;
78 	int if_oerrors;
79 	int if_collisions;
80 	unsigned int v_swtch;
81 	int avenrun[3];		/* scaled by FSCALE */
82 	rstat_timeval boottime;
83 	rstat_timeval curtime;
84 	int if_opackets;
85 };
86 
87 struct statsswtch {			/* RSTATVERS_SWTCH */
88 	int cp_time[CPUSTATES];
89 	int dk_xfer[DK_NDRIVE];
90 	unsigned int v_pgpgin;	/* these are cumulative sum */
91 	unsigned int v_pgpgout;
92 	unsigned int v_pswpin;
93 	unsigned int v_pswpout;
94 	unsigned int v_intr;
95 	int if_ipackets;
96 	int if_ierrors;
97 	int if_oerrors;
98 	int if_collisions;
99 	unsigned int v_swtch;
100 	unsigned int avenrun[3];/* scaled by FSCALE */
101 	rstat_timeval boottime;
102 	int if_opackets;
103 };
104 
105 struct stats {				/* RSTATVERS_ORIG */
106 	int cp_time[CPUSTATES];
107 	int dk_xfer[DK_NDRIVE];
108 	unsigned int v_pgpgin;	/* these are cumulative sum */
109 	unsigned int v_pgpgout;
110 	unsigned int v_pswpin;
111 	unsigned int v_pswpout;
112 	unsigned int v_intr;
113 	int if_ipackets;
114 	int if_ierrors;
115 	int if_oerrors;
116 	int if_collisions;
117 	int if_opackets;
118 };
119 
120 
121 program RSTATPROG {
122 	/*
123 	 * Newest version includes current time and context switching info
124 	 */
125 	version RSTATVERS_TIME {
126 		statstime
127 		RSTATPROC_STATS(void) = 1;
128 
129 		unsigned int
130 		RSTATPROC_HAVEDISK(void) = 2;
131 	} = 3;
132 	/*
133 	 * Does not have current time
134 	 */
135 	version RSTATVERS_SWTCH {
136 		statsswtch
137 		RSTATPROC_STATS(void) = 1;
138 
139 		unsigned int
140 		RSTATPROC_HAVEDISK(void) = 2;
141 	} = 2;
142 	/*
143 	 * Old version has no info about current time or context switching
144 	 */
145 	version RSTATVERS_ORIG {
146 		stats
147 		RSTATPROC_STATS(void) = 1;
148 
149 		unsigned int
150 		RSTATPROC_HAVEDISK(void) = 2;
151 	} = 1;
152 } = 100001;
153