1130803Smarcel/*- 2130803Smarcel * Copyright (c) 2010, Oracle America, Inc. 3130803Smarcel * 4130803Smarcel * Redistribution and use in source and binary forms, with or without 5130803Smarcel * modification, are permitted provided that the following conditions are 6130803Smarcel * met: 7130803Smarcel * 8130803Smarcel * * Redistributions of source code must retain the above copyright 9130803Smarcel * notice, this list of conditions and the following disclaimer. 10130803Smarcel * * Redistributions in binary form must reproduce the above 11130803Smarcel * copyright notice, this list of conditions and the following 12130803Smarcel * disclaimer in the documentation and/or other materials 13130803Smarcel * provided with the distribution. 14130803Smarcel * * Neither the name of the "Oracle America, Inc." nor the names of its 15130803Smarcel * contributors may be used to endorse or promote products derived 16130803Smarcel * from this software without specific prior written permission. 17130803Smarcel * 18130803Smarcel * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19130803Smarcel * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20130803Smarcel * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21130803Smarcel * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22130803Smarcel * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23130803Smarcel * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24130803Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 25130803Smarcel * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26130803Smarcel * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27130803Smarcel * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28130803Smarcel * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29130803Smarcel * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30130803Smarcel */ 31130803Smarcel 32130803Smarcel/* 33130803Smarcel * Gather statistics on remote machines 34130803Smarcel */ 35130803Smarcel 36130803Smarcel#ifdef RPC_HDR 37130803Smarcel 38130803Smarcel%#ifndef FSCALE 39130803Smarcel%/* 40130803Smarcel% * Scale factor for scaled integers used to count load averages. 41130803Smarcel% */ 42130803Smarcel%#define FSHIFT 8 /* bits to right of fixed binary point */ 43130803Smarcel%#define FSCALE (1<<FSHIFT) 44130803Smarcel% 45130803Smarcel%#endif /* ndef FSCALE */ 46130803Smarcel 47130803Smarcel#endif /* def RPC_HDR */ 48130803Smarcel 49130803Smarcelconst RSTAT_CPUSTATES = 4; 50130803Smarcelconst RSTAT_DK_NDRIVE = 4; 51130803Smarcel 52130803Smarcel/* 53130803Smarcel * GMT since 0:00, January 1, 1970 54130803Smarcel */ 55130803Smarcelstruct rstat_timeval { 56130803Smarcel unsigned int tv_sec; /* seconds */ 57130803Smarcel unsigned int tv_usec; /* and microseconds */ 58130803Smarcel}; 59130803Smarcel 60130803Smarcelstruct statstime { /* RSTATVERS_TIME */ 61130803Smarcel int cp_time[RSTAT_CPUSTATES]; 62130803Smarcel int dk_xfer[RSTAT_DK_NDRIVE]; 63130803Smarcel unsigned int v_pgpgin; /* these are cumulative sum */ 64130803Smarcel unsigned int v_pgpgout; 65130803Smarcel unsigned int v_pswpin; 66130803Smarcel unsigned int v_pswpout; 67130803Smarcel unsigned int v_intr; 68130803Smarcel int if_ipackets; 69130803Smarcel int if_ierrors; 70130803Smarcel int if_oerrors; 71130803Smarcel int if_collisions; 72130803Smarcel unsigned int v_swtch; 73130803Smarcel int avenrun[3]; /* scaled by FSCALE */ 74130803Smarcel rstat_timeval boottime; 75130803Smarcel rstat_timeval curtime; 76130803Smarcel int if_opackets; 77130803Smarcel}; 78130803Smarcel 79130803Smarcelstruct statsswtch { /* RSTATVERS_SWTCH */ 80130803Smarcel int cp_time[RSTAT_CPUSTATES]; 81130803Smarcel int dk_xfer[RSTAT_DK_NDRIVE]; 82130803Smarcel unsigned int v_pgpgin; /* these are cumulative sum */ 83130803Smarcel unsigned int v_pgpgout; 84130803Smarcel unsigned int v_pswpin; 85130803Smarcel unsigned int v_pswpout; 86130803Smarcel unsigned int v_intr; 87130803Smarcel int if_ipackets; 88130803Smarcel int if_ierrors; 89130803Smarcel int if_oerrors; 90130803Smarcel int if_collisions; 91130803Smarcel unsigned int v_swtch; 92130803Smarcel unsigned int avenrun[3];/* scaled by FSCALE */ 93130803Smarcel rstat_timeval boottime; 94130803Smarcel int if_opackets; 95130803Smarcel}; 96130803Smarcel 97130803Smarcelstruct stats { /* RSTATVERS_ORIG */ 98130803Smarcel int cp_time[RSTAT_CPUSTATES]; 99130803Smarcel int dk_xfer[RSTAT_DK_NDRIVE]; 100130803Smarcel unsigned int v_pgpgin; /* these are cumulative sum */ 101130803Smarcel unsigned int v_pgpgout; 102130803Smarcel unsigned int v_pswpin; 103130803Smarcel unsigned int v_pswpout; 104130803Smarcel unsigned int v_intr; 105130803Smarcel int if_ipackets; 106130803Smarcel int if_ierrors; 107130803Smarcel int if_oerrors; 108130803Smarcel int if_collisions; 109130803Smarcel int if_opackets; 110130803Smarcel}; 111130803Smarcel 112130803Smarcel 113130803Smarcelprogram RSTATPROG { 114130803Smarcel /* 115130803Smarcel * Newest version includes current time and context switching info 116130803Smarcel */ 117130803Smarcel version RSTATVERS_TIME { 118130803Smarcel statstime 119130803Smarcel RSTATPROC_STATS(void) = 1; 120130803Smarcel 121130803Smarcel unsigned int 122130803Smarcel RSTATPROC_HAVEDISK(void) = 2; 123130803Smarcel } = 3; 124130803Smarcel /* 125130803Smarcel * Does not have current time 126130803Smarcel */ 127130803Smarcel version RSTATVERS_SWTCH { 128130803Smarcel statsswtch 129130803Smarcel RSTATPROC_STATS(void) = 1; 130130803Smarcel 131130803Smarcel unsigned int 132130803Smarcel RSTATPROC_HAVEDISK(void) = 2; 133130803Smarcel } = 2; 134130803Smarcel /* 135130803Smarcel * Old version has no info about current time or context switching 136130803Smarcel */ 137130803Smarcel version RSTATVERS_ORIG { 138130803Smarcel stats 139130803Smarcel RSTATPROC_STATS(void) = 1; 140130803Smarcel 141130803Smarcel unsigned int 142130803Smarcel RSTATPROC_HAVEDISK(void) = 2; 143130803Smarcel } = 1; 144130803Smarcel} = 100001; 145130803Smarcel 146130803Smarcel#ifdef RPC_HDR 147130803Smarcel% 148130803Smarcel%enum clnt_stat rstat(char *, struct statstime *); 149130803Smarcel%int havedisk(char *); 150130803Smarcel% 151130803Smarcel#endif 152130803Smarcel