head	1.1;
access;
symbols;
locks
	dfk:1.1; strict;
comment	@# @;


1.1
date	96.07.04.03.03.24;	author dfk;	state Exp;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@#!/bin/csh -f
#
# extract-one-lu - get a list of stats from one sim file (*.sim)
#
set usage='usage: extract-one-lu foo.sim[.gz] [foo.data]'
#
# Part of
#              The STARFISH Parallel file-system simulator
#        (Simulation Tool for Advanced Research in File Systems)
# 
#                               David Kotz
#                           Dartmouth College
#                              Version 2.0
#                              January 1995
#                          dfk@@cs.dartmouth.edu

if ($#argv != 1 && $#argv != 2) then
	echo "$usage"
	exit 1
endif

set parmfile=/tmp/extract$$a
set someparmfile=/tmp/extract$$b
onintr cleanup

set V = (LU_MATRIX_SIZE LU_SLAB_SIZE BLOCK_SIZE CPFS IOPFS \
	DISK_SORT DISK_LAYOUT IOPread_bytes IOPwrite_bytes total tthruput)
# plus some array metrics, see below

set file=$1
if ($#argv > 1) then
	set data=$2
else
	# set "data" to be data file name
	if ($file:e == gz || $file:e == Z || $file:e == z) then
		set temp = $file:r
		set data = $temp:r.data
	else
		set data = $file:r.data
	endif
endif

set temp = $data:r
set trial = $temp:e   # get trial number from file name

statgraph -t 1000 -s -m -f $file > $parmfile
if ($status != 0) then
    rm -f $parmfile
    exit $status
endif

# run through $parmfile to get all the values for each stat in V
echo > $someparmfile
foreach stat ($V)
	grep "\[$stat\]" $parmfile >> $someparmfile
end
sum-metric "[diskread] Disk reads, per disk"    $file >> $someparmfile
sum-metric "[diskwrite] Disk writes, per disk"  $file >> $someparmfile
awk '{printf "%s ", $NF}   END {print '$trial'}' $someparmfile > $data

# did anything go wrong?
set wc=`wc -w $data`
set cols=$wc[1]
if ($cols < 14) rm $data	# yes, delete the data file

cleanup:
rm -f $parmfile $someparmfile
@
