Port-sparc64 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Power management



On Mon, 2 Feb 2009 19:43:30 +0000
raymond.meyer%rambler.ru@localhost wrote:

> Does NetBSD support power management on sparc64 hardware? For
> example, I'd like the SCSI disks to spin down after a period of
> inactivity. Is there an automatic way of doing this, rather then
> typing 'scsictl /dev/sd0 stop'

Since nobody replied to me I assume there is no power management on
sparc64. After thinking about the problem I came up with a shell script
to spin down hard disks. It seems to work pretty well.
#!/bin/sh

# This script should be run periodically. It uses iostat command to obtain the
# running total data transfers. It saves the transfer values and compares the
# previous and current values, if the values are equal (i.e. there were no data
# transfers during a given time, the script runs 'scsictl device stop' to spin
# down the hard disks.
#
# We don't need to keep the state of the disks, i.e. if they are spinning, or
# stopped. Running 'scsictl device stop' on a stopped disk will simply return
# and the disk will be left in the stopped state without restarting it.
#
# 1. Add the following entry to crontab to run this script every 15 min.
# 0,15,30,45 * * * *    /bin/sh /root/bin/scsi_stop.sh
#
# 2. Make sure /tmp is mounted on tmpfs filesystem to avoid accessing disk
#    every time this script is run
#
# 3. It helps to relocate /var to solid state media, like a USB flash drive,
#    since syslog periodically writes log files under /var/log
#
# 4. Edit /etc/daily.conf and disable most daily services which access local
#    disks. See daily.conf(5)

DISKS="sd0 sd1"

for disk in $DISKS
do
        # If there is no I/O snapshot file (since this is the first time we run
        # the script), create one and wait for next time this script is called
        if ! test -f /tmp/scsi_iosnapshot.$disk
        then
                iostat -Ix $disk | grep "^$disk" | awk '{print $3 "+" $7}'\
                  > /tmp/scsi_iosnapshot.$disk
        else
                prev_io=`cat /tmp/scsi_iosnapshot.$disk`
                curr_io=`iostat -Ix $disk | grep "^$disk" | awk '{print $3 "+" 
$7}'`

                # Update I/O to current values
                echo "$curr_io" > /tmp/scsi_iosnapshot.$disk

                # Make sure I/O values are not empty strings
                test x"$prev_io" = x -o x"$curr_io" = x && exit 1
                if test "$prev_io" = "$curr_io"
                then
                        #echo "$disk: prev = curr -> $curr_io"
                        #echo "should run:scsictl $disk stop"
                        /sbin/scsictl $disk stop &
                fi
        fi
done


Home | Main Index | Thread Index | Old Index