From owner-freebsd-questions@FreeBSD.ORG Fri Apr 14 21:48:30 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 D660D16A403 for ; Fri, 14 Apr 2006 21:48:30 +0000 (UTC) (envelope-from daeg@houston.rr.com) Received: from ms-smtp-01.texas.rr.com (ms-smtp-01.texas.rr.com [24.93.47.40]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6FFA543D45 for ; Fri, 14 Apr 2006 21:48:30 +0000 (GMT) (envelope-from daeg@houston.rr.com) Received: from cpe-24-167-65-111.houston.res.rr.com (cpe-24-167-65-111.houston.res.rr.com [24.167.65.111]) by ms-smtp-01.texas.rr.com (8.13.4/8.13.4) with ESMTP id k3ELmRv9027577; Fri, 14 Apr 2006 16:48:28 -0500 (CDT) From: David J Brooks Organization: KC5WNK To: freebsd-questions@freebsd.org Date: Fri, 14 Apr 2006 16:48:27 -0500 User-Agent: KMail/1.9.1 References: <443F5CE6.4080107@u.washington.edu> <20060414131931.Q81702@home.ephemeron.org> <308097D9-B881-4A41-89F2-B3D963C17EA4@u.washington.edu> In-Reply-To: <308097D9-B881-4A41-89F2-B3D963C17EA4@u.washington.edu> X-Face: "\j?x](l|]4p?-1Bf@!wN<&p=$.}^k-HgL}cJKbQZ3r#Ar]\%U(#6}'?<3s7%(%(=?utf-8?q?gxJxxc=0A=09R=09nSNPNr*/=5E=7EStawWU9KDJ-CT0k=24f=23?=@t2^K&BS_f|?ZV/.7Q MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200604141648.27728.daeg@houston.rr.com> X-Virus-Scanned: Symantec AntiVirus Scan Engine Cc: Garrett Cooper 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 21:48:31 -0000 On Friday 14 April 2006 16:43, Garrett Cooper wrote: > 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. > >>> -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 > > 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 :). Perhaps a softupdate hasn't completed yet? David -- Sure God created the world in only six days, but He didn't have an established user-base.