After being hard at work on this issue most of the day, I've managed to create a working script based on the one I linked in the OP.
Here's how it looks so far: #!/bin/bash a=0 #check for 45 minutes with 30s gaps, and go on adding. for i in `seq 0 89` do b=`iostat -MCxn 30 2 |grep -w "c8" |sed '1d' |cut -c 60-61` a=`expr $a + $b` done echo $a if [ $a == 0 ] then echo "No Activity" sg_start -S /dev/rdsk/c8t0d0 sg_start -S /dev/rdsk/c8t1d0 sg_start -S /dev/rdsk/c8t2d0 sg_start -S /dev/rdsk/c8t3d0 sg_start -S /dev/rdsk/c8t4d0 sg_start -S /dev/rdsk/c8t5d0 sg_start -S /dev/rdsk/c8t6d0 sg_start -S /dev/rdsk/c8t8d0 else echo "Disk Active" fi exit 0 What it does is running a loop 90 times that lasts for 30 secs each, and sums the %b number from iostat (percent of time the disk is busy) If the sum of %b during those 45 minutes is zero, then it spins down the disks. I'll try and explain what the different commands used in the script does. In -MCxn for iostat the "M" is to keep the output of iostat properly formated as the kr/s and kw/s column's will screw up the output when reading or writing to the array. Using the "M" switch will present the data as MB/s and not KB/s, keeping the column's in place. The "C" is to get the controllers listed in the output as to not rely on the %b stat from a single disk. "x" is for getting extended disk statistics, must be used for the "C" switch to work and to get the %b statistic shown. "n" is for disk names to display in the cXtYdZ format. "30 2" makes iostat report I/O statistics twice with a 30 sec interval between the 1st and 2nd run. The output of iostat is then piped to grep. "-w" makes grep look specifically for the controller name "c8". The output of grep is then piped to sed. " '1d' " is used to delete the line from the first run of iostat, leaving the output of the 2nd run untouched. (The first run of iostat shows accumulated statistics. It is useless info for use in this script, and is why iostat is asked to run twice, showing accumulated statistics for the last 30 secs only.) The output of sed is then piped to cut to remove everything else but the %b column data with the "-c 60-61" switch. It tells cut to remove all characters before and after character 60. Now b is defined and can be added to a using expr. The loop is done and runs again until it has done so 90 times. It is then determined if the disks on the c8 controller was active during the last 45 minutes or not. If not then sg_start command, from the sg3_utils tools (SUNWsg3utils), is used to spin down the disks on controller c8 using the "-S" switch. The plan is to run the script via cron, but it would be much better if it could be made to run permantly at bootup and be using a rolling 45 minutes, as to always spin down the disks when they've been idle for exact 45 minutes or whatever interval you'd like. Ideas are most certainly welcome :-) -- This message posted from opensolaris.org _______________________________________________ distribution-discuss mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/distribution-discuss
