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


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


desc
@@


1.1
log
@Initial revision
@
text
@#!/bin/csh -f
#
# extract-one - get a list of stats from one sim file (*.sim)
#
set usage='usage: extract-one 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 = (Pattern CPFS IOPFS DISK_SORT RECORD_SIZE DISK_LAYOUT \
    	FILE_BLOCKS BLOCK_SIZE Nio Ncomp NO_OF_DISKS total tthruput)

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 -s -m -f $file > $parmfile

# run through $parmfile to get all the values for each stat in V
echo > $someparmfile
foreach stat ($V)
	grep "\[$stat\]" $parmfile >> $someparmfile
end
awk '{printf "%s ", $NF}   END {print '$trial'}' $someparmfile > $data

# did anything go wrong?
set tthruput=`colex 13 < $data`
if ($tthruput == 0) rm $data	# yes, delete the data file

cleanup:
rm -f $parmfile $someparmfile
@
