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