Can I wake drives using TCP/IP command


Recommended Posts

I am using cinemar's mainlobby program for my dvd browsing.  There seems to be a long wait from the time I select a movie and when the movie actually starts playing.  It seems to have gotten worse over time.

 

Is there a way to spin up the drives up as soon as I start browsing for a movie, so when I select one to play the drives will already be ready.

I was thinking that maybe using a  tcp/ip messages to unraid server would do it.  Can anyone help me out with this?

 

thanks

 

Jim

Link to comment

There's always the SPIN UP command from the web page.

Then there's also Joe L's ping -n- spin tool which pings your client and if it responds sipins up the drives.

 

Recently, I've been contemplating my own control daemon to allow TCP messages to control the raid array

I'm really not a fan of screen scraping and/or using http buttons to initiate functions.

 

I've also been contemplating a new method of using netstat to determine if a station made an active connection (rather then pinging all day long).

This way when unraid sees an active connection from the station, it knows to spin up the drives.

 

All different ideas, but for now you have to use the SPINUP button or the ping-n-spin script.

 

Link to comment

Can you send an arbitrary TCP/IP packet to a specific port when you open up main lobby, or start to browse the available selections?

 

If so, I can show you how to do what you are looking to do.

 

Or, you can do something like I do.  I have my unRAID server ping my media clients every few seconds.  If I find one on-line, I spin up the media drives assuming they will be needed shortly.  Once the drives are spinning, I look every 10 minutes or so to see if the media player has gone off-line while doing an ls -R on my media folders to keep the directories in cache.  This makes file browsing fast.  Eventually, when I find no media players online, I resume my ping every few seconds.

 

You could use netcat to monitor a specific port.  When sent a packet, you could use the same type of script I do to wake up all the media drives.  I generate a random number and then use it to read a random block of data from each disk drive forcing it to spin up.  I need to use a random block each time to ensure the request is not filled by the buffer cache.

 

Joe L.

 

 

Link to comment

Joel I had looked at your script to ping for the media player, but I did not think that will not work in my situation.

 

The way mainlobby works it keeps a catalog of all the movies on my server and when one is selected, it then it starts the player and tells it where the movie is located.

 

I think,  like you said sending an arbitrary tcp/ip packet when I open the browser page will work.  By the time I select the movie the drive should have spun up.

 

Mainlobby does have a plugin for sending commands via TCP/IP over a defined port so it should be easy.  I just don't know what command and what port will it take to spin up the media drives.

 

thanks

 

Jim

 

Link to comment

I have an idea. I wrote a basic shell script and installed it iinto inetd.

 

This is what I have so far.

 

Add line to /etc/services as

spincontrol    8081/tcp        #unraid spincontrol

 

Add line to /etc/inetd.conf as

spincontrol stream  tcp  nowait  root    /usr/sbin/tcpd  /boot/bin/spincontrol -i

 

install my shell script to /boot/bin/spincontrol (Just wrote it today). called spin control

 

Heres the output of a test run.

 

rcotrone@hercules: ~ > telnet unraid 8081
Trying 192.168.1.178...
Connected to unraid.cotrone.com (192.168.1.178).
Escape character is '^]'.
spincontrol: ready on unraid at Sun May  4 13:21:35 GMT+5 2008
check all
spincontrol: ok: Processing. EOF at '.'

/dev/sdf:
drive state is:  active/idle

/dev/sdc:
drive state is:  active/idle

/dev/sdd:
drive state is:  active/idle

/dev/sdb:
drive state is:  active/idle

/dev/sda:
drive state is:  active/idle
.
check /dev/sda
spincontrol: ok: Processing. EOF at '.'

/dev/sda:
drive state is:  active/idle
.
down /dev/sdf   
spincontrol: ok: Processing. EOF at '.'

/dev/sdf:
issuing standby command
.
check /dev/sdf
spincontrol: ok: Processing. EOF at '.'

/dev/sdf:
drive state is:  standby
.
up /dev/sdf
spincontrol: ok: Processing. EOF at '.'

/dev/sdf:
setting standby to 240 (20 minutes)
.
quit
spincontrol: ok: Closing Connection
Connection closed by foreign host.

 

 

Script help screen.

 

 

root@unraid:/boot/bin# /boot/bin/spincontrol 
spincontrol: requires mode -U or -D or -C
  or name as spinup,spindown,spincheck
root@unraid:/boot/bin# /boot/bin/spincontrol -h
spincontrol:  1.0 5/1/08 weebotech
    Usage:  /boot/bin/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

     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

 

Run Screens

root@unraid:/boot/bin# ./spincontrol -C -a 

Spin check on /dev/sdf ata-Hitachi_HTS722020K9SA00_071007DP0400DTG101HA\c

/dev/sdf:
drive state is:  active/idle

Spin check on /dev/sdc ata-MAXTOR_STM3500630AS_5QG00ENH\c

/dev/sdc:
drive state is:  active/idle

Spin check on /dev/sdd ata-MAXTOR_STM3500630AS_5QG04QSP\c

/dev/sdd:
drive state is:  active/idle

Spin check on /dev/sdb ata-WDC_WD10EACS-00ZJB0_WD-WCASJ0353226\c

/dev/sdb:
drive state is:  active/idle

Spin check on /dev/sda ata-WDC_WD10EACS-00ZJB0_WD-WCASJ0437718\c

/dev/sda:
drive state is:  active/idle


root@unraid:/boot/bin# ./spincontrol -D -a 

Spin down on /dev/sdf ata-Hitachi_HTS722020K9SA00_071007DP0400DTG101HA\c

/dev/sdf:
issuing standby command

Spin down on /dev/sdc ata-MAXTOR_STM3500630AS_5QG00ENH\c

/dev/sdc:
issuing standby command

Spin down on /dev/sdd ata-MAXTOR_STM3500630AS_5QG04QSP\c

/dev/sdd:
issuing standby command

Spin down on /dev/sdb ata-WDC_WD10EACS-00ZJB0_WD-WCASJ0353226\c

/dev/sdb:
issuing standby command

Spin down on /dev/sda ata-WDC_WD10EACS-00ZJB0_WD-WCASJ0437718\c

/dev/sda:
issuing standby command

root@unraid:/boot/bin# ./spincontrol -C -a 

Spin check on /dev/sdf ata-Hitachi_HTS722020K9SA00_071007DP0400DTG101HA\c

/dev/sdf:
drive state is:  standby

Spin check on /dev/sdc ata-MAXTOR_STM3500630AS_5QG00ENH\c

/dev/sdc:
drive state is:  standby

Spin check on /dev/sdd ata-MAXTOR_STM3500630AS_5QG04QSP\c

/dev/sdd:
drive state is:  standby

Spin check on /dev/sdb ata-WDC_WD10EACS-00ZJB0_WD-WCASJ0353226\c

/dev/sdb:
drive state is:  standby

Spin check on /dev/sda ata-WDC_WD10EACS-00ZJB0_WD-WCASJ0437718\c

/dev/sda:
drive state is:  standby


root@unraid:/boot/bin# ./spincontrol -U -a 

Spin up on /dev/sdf ata-Hitachi_HTS722020K9SA00_071007DP0400DTG101HA\c

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

Spin up on /dev/sdc ata-MAXTOR_STM3500630AS_5QG00ENH\c

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

Spin up on /dev/sdd ata-MAXTOR_STM3500630AS_5QG04QSP\c

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

Spin up on /dev/sdb ata-WDC_WD10EACS-00ZJB0_WD-WCASJ0353226\c

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

Spin up on /dev/sda ata-WDC_WD10EACS-00ZJB0_WD-WCASJ0437718\c

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

 

Thoughts?

Link to comment

I wanted to get some input first.

Plus I was still working on it. was trying to figure out a way to delete the meta characters to avoid some trouble.

I think it needs a code review by someone seasoned so it does not open up a hole.

I also added some commands for smart access.

 

I've attached what I have so far.

I had to add an install mode.

 

Link to comment

I'll repost an update some time tonight. I found I accidentally commented out the calls to hdparm for debugging.

I'm really paranoid because this runs as root via network connection, so if there are any hooks to run a subordinate shell, then there's a serious hole opened up.

 

Then again, you can always telnet in as root and if there;s no password ...

 

I wrote an install subroutine so you can run the script with spincontrol -i to install it into the services and inetd.conf files.

I have to add, as part of that function,  to install the script itself into a provided path so it's not dependant on a /boot/bin directory.

 

Once I'm happy with this, I'm going to use it as a framework for a powercontrol script.

Hopefully, This will let other UPS control software send a poweroff message to a port and have unRAID shutdown..

 

Finally, I plan to re-engineer these tools into a C program to control/manage unRAID so I have finer control and can add other hooks.

What started out as a 30 line shell turned into 360 2 hours later.  ;D

 

 

 

Link to comment

I have to re-engineer things a lil.

I want to add a simple ability to use a native windows command to send control messages.

 

I.E. using

 

NET SEND unraidservername "command"

 

I figured out a lil about it today using samba's message command directive.

It's only one way, but I think it's all that is needed for some people.

 

I'll have to do s'more programming and while I'm at it I may add poweroff and reboot so it's all in one place.

Link to comment

I want to add a simple ability to use a native windows command to send control messages.

 

I.E. using

 

NET SEND unraidservername "command"

 

I figured out a lil about it today using samba's message command directive.

It's only one way, but I think it's all that is needed for some people.

 

I'll have to do s'more programming and while I'm at it I may add poweroff and reboot so it's all in one place.

That sounds really decent.  You've got my vote.
Link to comment
  • 2 weeks later...

Yes, I was working on it over the past few days.

I was able to get it to interface with the windows "net send" command however I came across a stumbling block.

When the command is run by samba, it is run by user nobody, that user does not have permission to run many of the privileged commands.

I have to re-engineer the interface to use netcat back to the local inetd configuration in order to get it to run privileged.

Not sure how much of an effort that is really worth.

I think I'm doing more to prove something by way of functionality as in.. this is possible.

I did add a hook to my powerdown script and that does work via tcp/ip also.

 

In the meantime I suggest you download netcat for windows. nc11nt.zip

I'll try and release the script in whatever condition I finish over the weekend.

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.