SPINCONTROL: Local and Remote Management of Drive Standby State.


Recommended Posts

Can I wake drives using TCP/IP command?

http://lime-technology.com/forum/index.php?topic=1933.0

 

Cont'd from Prior query.

 

---

 

Here is what I have so far.

I have not made this an installable package. it can be done, but it needs some testing first.

 

First time install

 

mkdir -p /boot/custom/bin

unzip the attached archive into that directory above.

 

To install upon each boot add the following lines to your /boot/config/go script

 

fromdos < /boot/custom/bin/spincontrol > /usr/sbin/spincontrol
chmod u+x /usr/sbin/spincontrol 
/usr/sbin/spincontrol -I

 

Here's what the output of install looks like.

 

spincontrol: installing spincontrol service to /etc/services
spincontrol: installing spincontrol service to /etc/inetd.conf
spincontrol: installing spincontrol service to /etc/samba/smb.names

 

you can change the path of -I if you like, however, the -I MUST USE THE FULL PATH.

It is used to determine it's own run location which is then installed into the /etc/inetd.conf file.

 

root@Atlas:~# grep spincontrol /etc/inetd.conf
spincontrol stream tcp nowait root /usr/sbin/tcpd /usr/sbin/spincontrol -i

 

 

This tool works in three ways.

 

1. Command line

root@Atlas:/boot/custom/bin# /usr/sbin/spincontrol -h
spincontrol:  1.0 5/1/08 weebotech
    Usage:  /usr/sbin/spincontrol [ -U | -D | -C ]  [ -a || -d ] ...

    Where:  -U - spin up drives
            -D - spin down drives
            -C - check power state on drives

            -a - do all drives
            -d - do a specified drive (to mimic smart ctl or hdparm)
            ... - provide a list of drives as /dev/sda /dev/sdb /dev/sdc

            -i - Special mode to run via inetd with custom protocol
            -I - Installs defintions into /etc/services, /etc/inetd.conf

     Mode (up,down,check) can also be controlled by naming program
          with appropriate suffix as spindown,spinup,spincheck
          However this requires maintaining links or multiple programs

 

2. Network access mode (which does a lil more but allows finer control)

 

root@Atlas:/boot/custom/bin# telnet localhost spincontrol 
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
spincontrol: ready on Atlas at Sat May 17 15:40:04 GMT+4 2008
help
spincontrol: quit exit
spincontrol: list dir up down check benchmark
spincontrol: info smart smartlog errorlog testlog
spincontrol: test longtest
quit
spincontrol: ok: Closing Connection
Connection closed by foreign host.

 

3. Samba Message mode from windows NET SEND command

 

I've been able to make this work through windoiws net send command along with Samba by using netcat on unRAID to loop back around to the localhost and pass the commands.

 

If you install netcat then on windows you can use

 

net send (your unraid host) command

 

whereby commands are the same commands as in the telnet commands.

 

It will send back up to 1600 bytes of output.

 

Please note, this requires enabling a service in your windows machine and could open up some issues for you.

Start -> Control Panel -> Adminstrative Tools -> Services.

Scroll down to MESSENGER service.

Mine was disabled, enable it according to your preferences.

I set mine to manual, then issued a start.

Upon reboot, the service will not be started. (but I'm only testing).

If you want to use this, then you will probably want it to be in automatic mode.

 

Windows NETCAT will also work without the enabling of this service.

 

 

Although I've added powercontrol in this script, you will need my powerdown script for it to work.

I added this hook for those with remote UPS's to send a shutdown command remotely.

Again, you will need to use netcat or enable the windows messenger service.

 

 

 

NOTES

I should add, I spin UP the drives by issuing the hdparm auto spinddown command.

I have this set for 240 in the script you can alter this to whatever you like.

The line to change is

export HDPARM_SPINDOWN_VALUE="240"

I copied a section of the manpage for you to alter as you would like.

This will probably be different then what is set from emhttp. I have not worked on using that value yet.

It's feasible, but this is where I'm at now.

 

edit: New command installed

 

fup (same as up but command is forked into background with 1 second delay added per drive).

I.E. for each drive that is started a counter is increneted so the last drive is fired up n(drives) seconds.

So the 15th drive will be trigged for spinup 15 seconds after the first drive.

Link to comment

Windows Version of NETCAT.

 

Another thing to consider,  Some virus scanners consider netcat to be a hacking tool and it may send out alerts.

 

It's a very comprehensive network swiss army tool

 

http://m.nu/program/util/netcat/netcat.html

 

Using netcat in windows to send remote commands.

Here is how I did it.

 

C:\bin>copy con unraid.cmds
up all
quit
^Z
        1 file(s) copied.

C:\bin>nc atlas 8081 < unraid.cmds
spincontrol: ready on Atlas at Sat May 17 15:58:03 GMT+4
spincontrol: ok: Processing. EOF at '.'

/dev/sdd:
setting standby to 240 (20 minutes)

/dev/sde:
setting standby to 240 (20 minutes)

/dev/sdc:
setting standby to 240 (20 minutes)

/dev/sda:
setting standby to 240 (20 minutes)
.
spincontrol: ok: Closing Connection

C:\bin>

 

C:\bin>copy con unraid.cmds
smartlog /dev/sdd
Overwrite unraid.cmds? (Yes/No/All): yes
quit
^Z
        1 file(s) copied.

C:\bin>nc atlas 8081 < unraid.cmds
spincontrol: ready on Atlas at Sat May 17 16:00:49 GMT+4 2008
spincontrol: ok: Processing. EOF at '.'
/dev/sdd: ata-WDC_WD10EACS-00ZJB0_WD-WCASJ1352706

=== START OF INFORMATION SECTION ===
Device Model:     WDC WD10EACS-00ZJB0
Serial Number:    WD-WCASJ1352706
Firmware Version: 01.01B01
User Capacity:    1,000,204,886,016 bytes
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   8
ATA Standard is:  Exact ATA specification draft version not indicated
Local Time is:    Sat May 17 16:00:49 2008 GMT+4
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x84) Offline data collection activity
                                        was suspended by an interrupting command
from host.
                                        Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0) The previous self-test routine completed

                                        without error or no self-test has ever
                                        been run.
Total time to complete Offline
data collection:                 (26400) seconds.
Offline data collection
capabilities:                    (0x7b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off supp
ort.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        Conveyance Self-test supported.
                                        Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine
recommended polling time:        (   2) minutes.
Extended self-test routine
recommended polling time:        ( 255) minutes.
Conveyance self-test routine
recommended polling time:        (   5) minutes.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_
FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   200   200   051    Pre-fail  Always       -
       0
  3 Spin_Up_Time            0x0003   176   175   021    Pre-fail  Always       -
       8183
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -
       83
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -
       0
  7 Seek_Error_Rate         0x000e   200   200   051    Old_age   Always       -
       0
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -
       574
10 Spin_Retry_Count        0x0012   100   253   051    Old_age   Always       -
       0
11 Calibration_Retry_Count 0x0012   100   253   051    Old_age   Always       -
       0
12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -
       64
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -
       119
193 Load_Cycle_Count        0x0032   200   200   000    Old_age   Always       -
       737
194 Temperature_Celsius     0x0022   116   106   000    Old_age   Always       -
       36
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -
       0
197 Current_Pending_Sector  0x0012   200   200   000    Old_age   Always       -
       0
198 Offline_Uncorrectable   0x0010   200   200   000    Old_age   Offline      -
       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -
       0
200 Multi_Zone_Error_Rate   0x0008   200   200   051    Old_age   Offline      -
       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA
_of_first_error
# 1  Short offline       Completed without error       00%       406         -

SMART Selective self-test log data structure revision number 1
SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

.
spincontrol: ok: Closing Connection

 

Notes

The last command send should be quit.

Otherwise the netcat will hang.

I put a timeout parameter in the read command of the tool, it is set for 55 seconds.

If you want a faster finish, put in the quit command.

 

C:\bin>copy con unraid.cmds
help
Overwrite unraid.cmds? (Yes/No/All): y
^Z
        1 file(s) copied.

C:\bin>nc atlas 8081 < unraid.cmds
spincontrol: ready on Atlas at Sat May 17 16:08:44 GMT+4 2008
spincontrol: quit exit
spincontrol: list dir up down check benchmark
spincontrol: info smart smartlog errorlog testlog
spincontrol: test longtest

(WITHOUT QUIT, THERE WILL BE A DELAY FOR 55 SECONDS)
C:\bin>

Link to comment

thanks again for your time on this.

 

I have set it up so far where it loads the script on startup.  I then can use the command in telnet to spin up or spindown the drives.

 

A couple of questions:

 

  How would I spin up all the drives at once, instead of in a sequence?

 

How would the tcp/ip command look to spin up the drives?

what the plugin that I am trying to use asks for is:

ip address: ok

port:  what port would the server use?

command: ?

Link to comment

you can do

up /dev/sda /dev/sdb /dev/sdc

or

up all

 

 

ip address: address of your server

 

root@unraid:~# grep spincontrol /etc/services

spincontrol    8081/tcp

 

port:  8081

command: up all

 

root@unraid:~# telnet atlas 8081
Trying 192.168.1.179...
Connected to atlas.
Escape character is '^]'.
spincontrol: ready on Atlas at Mon May 19 21:46:26 GMT+4 2008
help
spincontrol: quit exit
spincontrol: list dir up down check benchmark
spincontrol: info smart smartlog errorlog testlog
spincontrol: test longtest
quit
spincontrol: ok: Closing Connection
Connection closed by foreign host.

Link to comment

 

I tried the following,  but it does not seem to spin the drives up, here is the log

 

Got [sEND~server~/usr/sbin/spincontrol -U -a]

Opening connection to 192.168.1.142 on port 8081

Server Connecting...

Server Connected...

TCP Sending [/usr/sbin/spincontrol -U -a]

Rcvd: [spincontrol: ready on Tower at Mon May 19 22:03:54 GMT-5 2008\x0A]

 

 

and is there an "up all" command or did you mean to simply specify all drives

/usr/sbin/spincontrol -U /dev/sde /dev/hdq ..............

Link to comment

The program has two interfaces.

On the command line you use /usr/sbin/spincontrol -U -a

if you connect with tcp/ip and telnet you use

 

up all

 

For the record, do a test

type telnet yourunraidhostname 8081

 

Then type  help

those are the commands available.

type  up all

then  quit

 

So the command you send to the server is

up all

 

not the full path.

 

See the prior post where I did a screen capture of a dialog.

I.E. the telnet atlas 8081...

That's the telnet interface.

 

So in response

 

ip address: ok

port:  8081

command: up all

 

Link to comment

thanks for clarifying that for me.

 

I tried the telnet tower 8081 and that worked.

 

I dint get a spinup using tcp/ip here is the log

 

Got [send~server~up all]

Opening connection to 192.168.1.142 on port 8081

server Connecting...

server Connected...

TCP Sending [up all]

Rcvd: [spincontrol: ready on Tower at Mon May 19 23:42:34 GMT-5 2008\x0A]

 

Link to comment

Here is what it should look like.

 

rcotrone@gatekeeper ~> telnet atlas 8081

Trying 192.168.1.179...

Connected to atlas.

Escape character is '^]'.

spincontrol: ready on Atlas at Tue May 20 11:31:09 GMT+4 2008

up all

spincontrol: ok: Processing. EOF at '.'

 

/dev/sdd:

setting standby to 240 (20 minutes)

 

/dev/sde:

setting standby to 240 (20 minutes)

 

/dev/sdc:

setting standby to 240 (20 minutes)

 

/dev/sda:

setting standby to 240 (20 minutes)

.

quit

spincontrol: ok: Closing Connection

Connection closed by foreign host.

 

 

it seems like the command is sent, but the client program is not waiting to end.

Is there anything after the Rcvd line?

Do you send a quit message.

What could be happening is the message is being sent and the client is disconnecting before all the drives have spun up.

 

What I would need is some documentation on how the TCP/IP Send command works.

I looked at the wiki for a few moments and realized I could be there all day.

If you could point me to somewhere in a manual that defines how it works, I'll adjust the program.

I don't have the time to search the manuals as there are so many areas.

 

What I found were some "plugins" but no real docs.

 

MLTCPSend This driver will allow you to send commands to another device via a TCP/IP connection.\

 

This one is cool.. I have X10 in my apt so I was planning to port X10D to unRAID.

MLFirecracker  Driver to allow MainLobby clients to communicate with a Firecracker/CM17a X-10 transmitter on the server computer.

Send X10 only (not 2 way).

 

 

 

 

Link to comment

I have to say this, the design of the script is to send a command to "SET" the spin down time.

If the drive is already spun down, it will issue the command, which ends up spinning up the drive, (which takes mechanical time), then waits for acknowledgment.

 

I could change it, so it does this in the background (while not returning an actual status to the foreground).

The side effect is all these commands will run in parallel, thereby causing all the drives to spin up very close to one another.

The net effect is a higher drain on the power supply. Sure you want this?

 

It will only become marginally faster. I.E. The command will not return until the last drive has powered up.

So if you had 10 drives, instead of it taking 10 x 10 seconds each, it may take 15-20 seconds for the whole lot to finish.

 

I could make a new command call "fup".

This will stand for forked'up which means all the hdparm commands are run in the background at the same time.

 

The return value of this would only be acknowledgment.

I.E. I cannot capture all of the outputs in a reliable manner. (at least in this scripted version).

 

 

Link to comment

I could make a new command call "fup".

This will stand for forked'up which means all the hdparm commands are run in the background at the same time.

 

The return value of this would only be acknowledgment.

I.E. I cannot capture all of the outputs in a reliable manner. (at least in this scripted version).

Sure you can...

Have each hdparm command write to its own output file when run in the background and use the "wait" command to pause until all have completed.

Then concatenate their outputs to return to the user.

 

Pseudo code follows:

for i in /dev/md*

do

    n=`basename $i`

    echo "spinning up $i >/tmp/spinup${n}.out

    hdparm -S242 $i >>/tmp/spinup${n}.out &

    #sleep 1

done

wait

cat /tmp/spinup*.out >/tmp/spincontrol.out

#... send /tmp/spincontrol.out contents back to the user here ...

 

All the drives will spin up in turn.  If you want a slight delay between each drive to minimize the power needed from the power supply, add uncomment the "sleep 1" before the "done"

When the last of the hdparm commands being run in the background completes, the "wait" will allow the continuation of the script to return the final results.

 

Joe L.

Link to comment

I had thought of what you have there.

However, I got the notion the tool/plugin being used terminates the session early, which means I cannot return the real data. Therefore they have to be nohuped.

Right now the output of the commands are returned in succession, by looking at the transaction log the only thing returned is the banner.

I may just capture the output's to syslog just so this will work for the plugin. 

I have to think about this more.

I'll see if there is a better way to trigger a spin up.

What I want to do is grab the actual spin up value from the config on /boot/config.

I just did not want to delay the release of this tool.

Link to comment

New version posted in the first message in this thread. fup has been enabled.

This forks an hdparm -S242 into the background sending all output to syslog.

Each successive drive that is started up has a 1 second delay incremented.

I.E. for N drives an N second delay is issued before using the hdparm command.

So the 15th drive would be initiated 15 seconds after the first drive.

A sequential delayed spin up.

It will take more then one second to spin up a drive (I think it;s on the order of 10).

But this will help alleviate a huge spike in the power supply (or so I believe).

The normal up command INSURES that each drive is started upon succession.

fup accelerates this.

 

Also the delay of spindown is set to 1 hour.

In the future, I'll have this delay be what ever the web interface sets.

Link to comment
  • 1 year later...

Long time since this thread has been active, but I'm looking for this sort of functionality and just gave it a try.  Everything seems to install and run properly, but the drives don't seem to spin up.

 

root@WatchTower:~# spincontrol -U -a

Spin up on /dev/sdk ata-SAMSUNG_HD103UJ_S13PJ1NPA00122\c

/dev/sdk:
setting standby to 242 (1 hours)

Spin up on /dev/sdm ata-SAMSUNG_HD154UI_S1XWJ1KS807855\c

/dev/sdm:
setting standby to 242 (1 hours)

Spin up on /dev/sdn ata-SAMSUNG_HD154UI_S1XWJ1KS807856\c

/dev/sdn:
setting standby to 242 (1 hours)

Spin up on /dev/sde ata-SAMSUNG_HD501LJ_S0MUJ13P325950\c

/dev/sde:
setting standby to 242 (1 hours)

 

That's some of the output (it continues for the rest of my drives).  I can hear the array in my closet making clicking noises like it is accessing drives, but when I check the unRaid webpage, it shows the drives as spun down (except the cache drive for some reason).

 

Is it possible something has changed in the new versions of unRaid (I'm on 4.5) that spins the drives back down immediately after receiving these commands or something?

 

I've also tried the telnet version include fup (is fup available on the command line), with the same results.

Link to comment

Is it possible something has changed in the new versions of unRaid (I'm on 4.5) that spins the drives back down immediately after receiving these commands or something?

 

I've also tried the telnet version include fup (is fup available on the command line), with the same results.

 

Come to think of it I think there is a new interface for spinning the drives down (happened during the spin groups update).

I think this script needs to be refined. I know the web page will be out of sync with the actual status because it caches the last known state.

 

I'll have to take a peek at the script and update it.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.