#!/bin/csh -f
#
# diskbusy - plot the number of disks busy over time
#    Note that the plot is shifted by +1 in the y direction, to keep
#  it off the x-axis line.
# This uses the new RTELOG_DISKUSED events
#
# usage: diskbusy logfile.elog...

set P=`procdir`

if ($#argv < 1) then
	echo usage: diskbusy logfile.elog...
	exit 1
endif

set TMP=/tmp/diskbusy
set data=$TMP.data
set plot=$TMP.plot
onintr cleanup

foreach logfile ($*)
    elogdump -stm =20 =21 $logfile:r \
        | Awk -f $P/diskbusy.awk1 \
	   | sort +0n \
	   | Awk -f $P/diskbusy.awk2 \
	   > $data

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

    echo set title \"busy disks+1 $logfile:r\" > $plot
    echo set noclip >> $plot
    echo set samples $samples >> $plot
    echo set yrange "[0:22]" >> $plot
    echo plot \"$data\" w lines >> $plot

    lasergnu -l -f $plot

    rm -f $data $plot
end

cleanup:
rm -f $data $plot
