#!/bin/csh -f
#
# diskwait - plot the disk wait time, over time for all disks
#
# This uses the new RTELOG_DISKWAIT events
#
# usage: diskwait logfile.elog...

set P=`procdir`

if ($#argv == 0) then
	echo usage: diskwait logfile.elog...
	exit 1
endif

set TMP=/tmp/diskwait$$
set plot=$TMP/plot
onintr cleanup
mkdir $TMP

foreach logfile ($*)
    elogdump -msu =21 $logfile:r \
        | (cd $TMP; Awk -f $P/diskwait.awk)

    # find out how many points there are 
    set samples=`wc -l $TMP/wait`
    set samples=$samples[1]

    echo set title \"$logfile:r\" > $plot
    echo set noclip >> $plot
    echo set samples $samples >> $plot
    echo plot \"wait\" w lines >> $plot

    (cd $TMP; lasergnu -l -f plot)

    rm -f $TMP/*
end

cleanup:
rm -rf $TMP
