From owner-freebsd-questions@FreeBSD.ORG Fri Apr 14 20:21:13 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4D9BF16A401 for ; Fri, 14 Apr 2006 20:21:13 +0000 (UTC) (envelope-from bigby@ephemeron.org) Received: from dsl.ephemeron.org (dsl092-035-072.lax1.dsl.speakeasy.net [66.92.35.72]) by mx1.FreeBSD.org (Postfix) with ESMTP id C984543D45 for ; Fri, 14 Apr 2006 20:21:12 +0000 (GMT) (envelope-from bigby@ephemeron.org) Received: from home.ephemeron.org (root@home.fake.net [10.0.2.3]) by dsl.ephemeron.org (8.12.11/8.12.11) with ESMTP id k3EKLCMV015999; Fri, 14 Apr 2006 13:21:12 -0700 (PDT) (envelope-from bigby@ephemeron.org) Received: from home.ephemeron.org (bigby@localhost [127.0.0.1]) by home.ephemeron.org (8.13.4/8.13.4) with ESMTP id k3EKLCPk085455; Fri, 14 Apr 2006 13:21:12 -0700 (PDT) (envelope-from bigby@ephemeron.org) Received: from localhost (bigby@localhost) by home.ephemeron.org (8.13.4/8.13.4/Submit) with ESMTP id k3EKLC8N085452; Fri, 14 Apr 2006 13:21:12 -0700 (PDT) (envelope-from bigby@ephemeron.org) X-Authentication-Warning: home.ephemeron.org: bigby owned process doing -bs Date: Fri, 14 Apr 2006 13:21:12 -0700 (PDT) From: Bigby Findrake To: Garrett Cooper In-Reply-To: <20060414130832.Y81702@home.ephemeron.org> Message-ID: <20060414131931.Q81702@home.ephemeron.org> References: <443F5CE6.4080107@u.washington.edu> <20060414091338.GY44921@wantadilla.lemis.com> <443FF97B.6000303@u.washington.edu> <20060414130832.Y81702@home.ephemeron.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-questions@freebsd.org Subject: Re: Determining whether or not a SCSI disk is in use X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Apr 2006 20:21:13 -0000 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 /-------------------------------------------------------------------------/