Determining whether or not a SCSI disk is in use
Bigby Findrake
bigby at ephemeron.org
Fri Apr 14 20:21:13 UTC 2006
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.
>> -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
>
/-------------------------------------------------------------------------/
Workaholics procrastinate too... I'll sleep tommorow.
finger://bigby@ephemeron.org
http://www.ephemeron.org/~bigby/
irc://irc.ephemeron.org/#the_pub
news://news.ephemeron.org/alt.lemurs
/-------------------------------------------------------------------------/
More information about the freebsd-questions
mailing list