Copyright (c) 2001 James Newsome <jnewsome@engin.umich.edu>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


Three files should be included:

rpcstat.diff	kernel patch
rpcstat.c	program to read stats
smooth.pl	smooth out data points

***** rpcstat.diff *****

The kernel patch adds two files to the
proc filesystem:

rpcstat		statistics sorted by procedure number
rpcmisc		miscellaneous statistics

rpcstat has the following format:
<procedure #>	<new rqsts>	<completed rqsts>	<sent rqsts>	<ackd rqsts>

A write call to either file will reset the counts. 

***** rpcstat.c *****

rpcstat.c can be compiled by
gcc -o rpcstat rpcstat.c 

rpcstat executes a command, and gathers data about rpc activity
while the command is executing. The data gathered is in a format
ideal for use with gnuplot.

There are four types of files that have procedure specific information:
<proc>.new	Rate that new rpc's were issued via rpc_execute
<proc>.fin	Rate that rpc's completed execution
<proc>.sent	Rate that rpc's were transmitted
<proc>.ackd	Rate that rpc's were acknowledged

All of the files have the format
<time>	<rate>

All rates are in RPCs / 10 ms. Using the default 10 ms polling interval, this
is the same as the count (read from the proc interface) since the last
poll. The counts are converted to rates to normalize for different polling
intervals.

There are also a few special files:
cwnd	Congestion window
cong	Congestion
backlog	Number of RPC's currently backlogged
pending	Number of RPC's currently pending (waiting for a reply from the server)
timeo	Number of timeouts since last poll

cwnd is derived from the current congestion window in the RPC. The number
given in the current maximum number of RPC's to be processed at once.

cong is derived from the current congestion. It is the current number
of RPC's being processed.

backlog is the number of RPCs on the backlog queue, waiting for congestion
to clear.

pending is the number of RPC's on the pending queue, waiting for a reply
from the server.

timeo is the number of timeouts since the last polling interval.

The rpcstat program is called as:
rpcstat <command> <command arguments>

The command must be the full path of the command to execute.

rpcstat executes the command, and as long as the command is running,
it will get the rpc statistics from the proc files at regular intervals.
Statistics are gathered as quickly as possible. If NICE is defined, 
sched_yield will be called between each sampling; This helps rpcstat
to be less intrusive.

If COMPRESS is defines, most of the '0' datapoints will not be recorded.
Only the first and last 0 in a stretch of 0's is recorded- for example

10	5
10.1	0
10.2	0
10.3	0
10.4	0
10.5	0
10.6	3

becomes

10	5
10.1	0
10.5	0
10.6	3

***** smooth.pl *****

Output from rpcstat tends to have a lot of spikes 
smooth.pl averages out data points,
helping to make trends easier to see.

It is called by
smooth.pl <input file> <factor>

It reads data points from input file, averaging out <factor> consecutive
data points to produce one data point. For example, if the input file has
1000 data points, and factor is 10, then the output will contain
100 data points.
