1272850Shrs/*-
2272850Shrs * Copyright (c) 2010, Oracle America, Inc.
3272850Shrs *
4272850Shrs * Redistribution and use in source and binary forms, with or without
5272850Shrs * modification, are permitted provided that the following conditions are
6272850Shrs * met:
7272850Shrs *
8272850Shrs *     * Redistributions of source code must retain the above copyright
9272850Shrs *       notice, this list of conditions and the following disclaimer.
10272850Shrs *     * Redistributions in binary form must reproduce the above
11272850Shrs *       copyright notice, this list of conditions and the following
12272850Shrs *       disclaimer in the documentation and/or other materials
13272850Shrs *       provided with the distribution.
14272850Shrs *     * Neither the name of the "Oracle America, Inc." nor the names of its
15272850Shrs *       contributors may be used to endorse or promote products derived
16272850Shrs *       from this software without specific prior written permission.
17272850Shrs *
18272850Shrs *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19272850Shrs *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20272850Shrs *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21272850Shrs *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22272850Shrs *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23272850Shrs *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24272850Shrs *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25272850Shrs *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26272850Shrs *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27272850Shrs *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28272850Shrs *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29272850Shrs *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
301832Swollman */
311832Swollman
321832Swollman/*
331832Swollman * Gather statistics on remote machines
341832Swollman */
351832Swollman
361832Swollman#ifdef RPC_HDR
371832Swollman
381832Swollman%#ifndef FSCALE
391832Swollman%/*
401832Swollman% * Scale factor for scaled integers used to count load averages.
411832Swollman% */
421832Swollman%#define FSHIFT  8               /* bits to right of fixed binary point */
431832Swollman%#define FSCALE  (1<<FSHIFT)
441832Swollman%
451832Swollman%#endif /* ndef FSCALE */
461832Swollman
471832Swollman#else
481832Swollman
491832Swollman%#ifndef lint
501832Swollman%/*static char sccsid[] = "from: @(#)rstat.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
511832Swollman%/*static char sccsid[] = "from: @(#)rstat.x	2.2 88/08/01 4.0 RPCSRC";*/
521832Swollman%#endif /* not lint */
53114629Sobrien%#include <sys/cdefs.h>
54114629Sobrien%__FBSDID("$FreeBSD$");
551832Swollman
561832Swollman#endif /* def RPC_HDR */
571832Swollman
581832Swollmanconst RSTAT_CPUSTATES = 4;
591832Swollmanconst RSTAT_DK_NDRIVE = 4;
601832Swollman
611832Swollman/*
621832Swollman * GMT since 0:00, January 1, 1970
631832Swollman */
641832Swollmanstruct rstat_timeval {
651832Swollman	unsigned int tv_sec;	/* seconds */
661832Swollman	unsigned int tv_usec;	/* and microseconds */
671832Swollman};
681832Swollman
691832Swollmanstruct statstime {				/* RSTATVERS_TIME */
701832Swollman	int cp_time[RSTAT_CPUSTATES];
711832Swollman	int dk_xfer[RSTAT_DK_NDRIVE];
721832Swollman	unsigned int v_pgpgin;	/* these are cumulative sum */
731832Swollman	unsigned int v_pgpgout;
741832Swollman	unsigned int v_pswpin;
751832Swollman	unsigned int v_pswpout;
761832Swollman	unsigned int v_intr;
771832Swollman	int if_ipackets;
781832Swollman	int if_ierrors;
791832Swollman	int if_oerrors;
801832Swollman	int if_collisions;
811832Swollman	unsigned int v_swtch;
821832Swollman	int avenrun[3];         /* scaled by FSCALE */
831832Swollman	rstat_timeval boottime;
841832Swollman	rstat_timeval curtime;
851832Swollman	int if_opackets;
861832Swollman};
871832Swollman
881832Swollmanstruct statsswtch {			/* RSTATVERS_SWTCH */
891832Swollman	int cp_time[RSTAT_CPUSTATES];
901832Swollman	int dk_xfer[RSTAT_DK_NDRIVE];
911832Swollman	unsigned int v_pgpgin;	/* these are cumulative sum */
921832Swollman	unsigned int v_pgpgout;
931832Swollman	unsigned int v_pswpin;
941832Swollman	unsigned int v_pswpout;
951832Swollman	unsigned int v_intr;
961832Swollman	int if_ipackets;
971832Swollman	int if_ierrors;
981832Swollman	int if_oerrors;
991832Swollman	int if_collisions;
1001832Swollman	unsigned int v_swtch;
1011832Swollman	unsigned int avenrun[3];/* scaled by FSCALE */
1021832Swollman	rstat_timeval boottime;
1031832Swollman	int if_opackets;
1041832Swollman};
1051832Swollman
1061832Swollmanstruct stats {				/* RSTATVERS_ORIG */
1071832Swollman	int cp_time[RSTAT_CPUSTATES];
1081832Swollman	int dk_xfer[RSTAT_DK_NDRIVE];
1091832Swollman	unsigned int v_pgpgin;	/* these are cumulative sum */
1101832Swollman	unsigned int v_pgpgout;
1111832Swollman	unsigned int v_pswpin;
1121832Swollman	unsigned int v_pswpout;
1131832Swollman	unsigned int v_intr;
1141832Swollman	int if_ipackets;
1151832Swollman	int if_ierrors;
1161832Swollman	int if_oerrors;
1171832Swollman	int if_collisions;
1181832Swollman	int if_opackets;
1191832Swollman};
1201832Swollman
1211832Swollman
1221832Swollmanprogram RSTATPROG {
1231832Swollman	/*
1241832Swollman	 * Newest version includes current time and context switching info
1251832Swollman	 */
1261832Swollman	version RSTATVERS_TIME {
1271832Swollman		statstime
1281832Swollman		RSTATPROC_STATS(void) = 1;
1291832Swollman
1301832Swollman		unsigned int
1311832Swollman		RSTATPROC_HAVEDISK(void) = 2;
1321832Swollman	} = 3;
1331832Swollman	/*
1341832Swollman	 * Does not have current time
1351832Swollman	 */
1361832Swollman	version RSTATVERS_SWTCH {
1371832Swollman		statsswtch
1381832Swollman		RSTATPROC_STATS(void) = 1;
1391832Swollman
1401832Swollman		unsigned int
1411832Swollman		RSTATPROC_HAVEDISK(void) = 2;
1421832Swollman	} = 2;
1431832Swollman	/*
1441832Swollman	 * Old version has no info about current time or context switching
1451832Swollman	 */
1461832Swollman	version RSTATVERS_ORIG {
1471832Swollman		stats
1481832Swollman		RSTATPROC_STATS(void) = 1;
1491832Swollman
1501832Swollman		unsigned int
1511832Swollman		RSTATPROC_HAVEDISK(void) = 2;
1521832Swollman	} = 1;
1531832Swollman} = 100001;
154104311Salfred
155104311Salfred#ifdef RPC_HDR
156104311Salfred%
157104311Salfred%enum clnt_stat rstat(char *, struct statstime *);
158104311Salfred%int havedisk(char *);
159104311Salfred%
160104311Salfred#endif
161