1 /*- 2 * Copyright (c) 2010, Oracle America, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following 12 * disclaimer in the documentation and/or other materials 13 * provided with the distribution. 14 * * Neither the name of the "Oracle America, Inc." nor the names of its 15 * contributors may be used to endorse or promote products derived 16 * from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 25 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 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 #endif /* def RPC_HDR */ 48 49 const RSTAT_CPUSTATES = 4; 50 const RSTAT_DK_NDRIVE = 4; 51 52 /* 53 * GMT since 0:00, January 1, 1970 54 */ 55 struct rstat_timeval { 56 unsigned int tv_sec; /* seconds */ 57 unsigned int tv_usec; /* and microseconds */ 58 }; 59 60 struct statstime { /* RSTATVERS_TIME */ 61 int cp_time[RSTAT_CPUSTATES]; 62 int dk_xfer[RSTAT_DK_NDRIVE]; 63 unsigned int v_pgpgin; /* these are cumulative sum */ 64 unsigned int v_pgpgout; 65 unsigned int v_pswpin; 66 unsigned int v_pswpout; 67 unsigned int v_intr; 68 int if_ipackets; 69 int if_ierrors; 70 int if_oerrors; 71 int if_collisions; 72 unsigned int v_swtch; 73 int avenrun[3]; /* scaled by FSCALE */ 74 rstat_timeval boottime; 75 rstat_timeval curtime; 76 int if_opackets; 77 }; 78 79 struct statsswtch { /* RSTATVERS_SWTCH */ 80 int cp_time[RSTAT_CPUSTATES]; 81 int dk_xfer[RSTAT_DK_NDRIVE]; 82 unsigned int v_pgpgin; /* these are cumulative sum */ 83 unsigned int v_pgpgout; 84 unsigned int v_pswpin; 85 unsigned int v_pswpout; 86 unsigned int v_intr; 87 int if_ipackets; 88 int if_ierrors; 89 int if_oerrors; 90 int if_collisions; 91 unsigned int v_swtch; 92 unsigned int avenrun[3];/* scaled by FSCALE */ 93 rstat_timeval boottime; 94 int if_opackets; 95 }; 96 97 struct stats { /* RSTATVERS_ORIG */ 98 int cp_time[RSTAT_CPUSTATES]; 99 int dk_xfer[RSTAT_DK_NDRIVE]; 100 unsigned int v_pgpgin; /* these are cumulative sum */ 101 unsigned int v_pgpgout; 102 unsigned int v_pswpin; 103 unsigned int v_pswpout; 104 unsigned int v_intr; 105 int if_ipackets; 106 int if_ierrors; 107 int if_oerrors; 108 int if_collisions; 109 int if_opackets; 110 }; 111 112 113 program RSTATPROG { 114 /* 115 * Newest version includes current time and context switching info 116 */ 117 version RSTATVERS_TIME { 118 statstime 119 RSTATPROC_STATS(void) = 1; 120 121 unsigned int 122 RSTATPROC_HAVEDISK(void) = 2; 123 } = 3; 124 /* 125 * Does not have current time 126 */ 127 version RSTATVERS_SWTCH { 128 statsswtch 129 RSTATPROC_STATS(void) = 1; 130 131 unsigned int 132 RSTATPROC_HAVEDISK(void) = 2; 133 } = 2; 134 /* 135 * Old version has no info about current time or context switching 136 */ 137 version RSTATVERS_ORIG { 138 stats 139 RSTATPROC_STATS(void) = 1; 140 141 unsigned int 142 RSTATPROC_HAVEDISK(void) = 2; 143 } = 1; 144 } = 100001; 145 146 #ifdef RPC_HDR 147 % 148 %enum clnt_stat rstat(char *, struct statstime *); 149 %int havedisk(char *); 150 % 151 #endif 152