Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Apr 2006 13:18:06 -0700 (PDT)
From:      Bigby Findrake <bigby@ephemeron.org>
To:        Garrett Cooper <youshi10@u.washington.edu>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Determining whether or not a SCSI disk is in use
Message-ID:  <20060414130832.Y81702@home.ephemeron.org>
In-Reply-To: <443FF97B.6000303@u.washington.edu>
References:  <443F5CE6.4080107@u.washington.edu> <20060414091338.GY44921@wantadilla.lemis.com> <443FF97B.6000303@u.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 14 Apr 2006, Garrett Cooper wrote:

> Yes. Recently accessed or is being accessed.
> -Garrett

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:

#!/bin/sh

DISKDEV=da0
SHUTDOWN_COMMAND="camcontrol stop 0,1,0"
SECONDS=60

# 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

STATUS=$?

if [ $STATUS -eq 0 ]
then

 	# there was activity,
 	$SHUTDOWN_COMMAND
fi


/-------------------------------------------------------------------------/
You always miss 100% of the chances you never take.

                    finger://bigby@ephemeron.org
                   http://www.ephemeron.org/~bigby/
                   irc://irc.ephemeron.org/#the_pub
                 news://news.ephemeron.org/alt.lemurs
/-------------------------------------------------------------------------/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060414130832.Y81702>