On Apr 14, 2006, at 1:21 PM, Bigby Findrake wrote:

On Fri, 14 Apr 2006, Bigby Findrake wrote:

I'm sorry, I'm an idiot - the script, in its current incarnation, needs to be modified. It's doing exactly what you don't want it to do - it will shut down the disk if there was activity. The if statement should read:

if [ $STATUS -ne 0 ]

On Fri, 14 Apr 2006, Garrett Cooper wrote:

Yes. Recently accessed or is being accessed.

Well, for a shell-script-hack, which (i) requires no new kernel and (ii) could be fairly portable but (iii) could conceivably miss some activity, you could do something like the following:


SHUTDOWN_COMMAND="camcontrol stop 0,1,0"

# check for activity
# watch iostat for $SECONDS seconds for anything

iostat -d $DISKDEV 1 5 | awk ' NR>2 && $2>0 { print "x" } ' |\
grep x > /dev/null


if [ $STATUS -eq 0 ]

        # there was activity,

        Brilliant! That's exactly what I was looking for!
The only thing I've noticed is that there is a small amount of data being transferred while the disk is idle, so perhaps the sampling needs to watch for the amount of data as well as the overall transactions being done to properly fix up a script to do this?
        Anyhow, I'll end up doing that, but thanks for the command :).
freebsd-questions@freebsd.org mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to