Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

spinning disks up/down using TCP over network

Featured Replies

I have an extensive home theater and all media (movies, TV shows) is on my unraid tower. The theater app runs on a small PC and has a movie browser that id very much like Kelaidescape. Most of the time I am just watching TV and not using the unraid repository.  When I go to watch a movie, there is a significant delay since I normally keep all disks spun down. I would like to be able to send a command over the network (HTTP GET) to spin up all the disks not waiting for the disks to spin up.

 

In general the ability to send commands that are simple buttons on the WEB GUI page would be greatly appreciated.  I used to be able to do this  with a command such as:

     GET /update.htm?cmdSpinupAll=Spin%20Up HTTP/1.1 plus the necessary http clauses

Why not send a read request to a file on the disks in question at the same point in the script that you are trying to use the http spinup?

  • Author

Two reasons. 

1)  A read request does not return until the data has been read

2) I don't know until the user selects what movie to watch which disk needs to spin up. At that point I can just start reading the movie file

  • 2 weeks later...
  • Author

Bump+

I wrote a REST Api for Unraid that I have been experimenting with. It has the functionality you are looking for. I haven't released it yet, but you are more than welcome to give it a try.

 

It runs as a docker container and exposes APIs for managing the server. These endpoints are also secured with your local credentials as well. For example
{{host}}:{{port}}/api/disks/up

{{host}}:{{port}}/api/disks/down

  • Author

Hitch,

welcome to the unraid community.

I would be very interested in trying this. I am not at all familiar with Docker containers.  Is there somewhere I can retrieve it from.?

Not being familiar with docker containers I don't want to hold you up from the completion of the project.  When do you expect to have it completed as an installable container perhaps as a Community applications.?  I would like to see the source code so I know what is going on. If a donation would enable you to complete this more rapidly, let me know. 

Hey Barry, I have a stable docker image uploaded you could use. I can guide you through the required configuration under the docker tab, should only take a few minutes to get it up and running. As far as getting it approved under the Community Applications, i know they have some sort of review process and I haven't taken a dive into that process yet, but plan to! PM me your github account and I will add you to the repository for your review.

 

I appreciate your support but that will not be necessary 🙂 . Writing an application that helps people is rewarding enough for me. Any feedback you have will help me make a better application!

Edited by hitch

On 12/1/2020 at 9:33 AM, barrygordon said:

I have an extensive home theater and all media (movies, TV shows) is on my unraid tower. The theater app runs on a small PC and has a movie browser that id very much like Kelaidescape. Most of the time I am just watching TV and not using the unraid repository.  When I go to watch a movie, there is a significant delay since I normally keep all disks spun down. I would like to be able to send a command over the network (HTTP GET) to spin up all the disks not waiting for the disks to spin up.

 

In general the ability to send commands that are simple buttons on the WEB GUI page would be greatly appreciated.  I used to be able to do this  with a command such as:

     GET /update.htm?cmdSpinupAll=Spin%20Up HTTP/1.1 plus the necessary http clauses

Look at the '/usr/local/emhttp/emcmd' script.  You could use like this:

 

emcmd "cmdSpinupAll=apply"  # spin up all hdd's

emcmd "cmdSpindownAll=apply"  # spin 'em down

emcmd "cmdSpinup=disk1"  # spin up disk1.  If disk1 was a member of a spinup group all disks of the group would spin up.

On 12/1/2020 at 9:33 AM, barrygordon said:

In general the ability to send commands that are simple buttons on the WEB GUI page would be greatly appreciated.  I used to be able to do this  with a command such as:

     GET /update.htm?cmdSpinupAll=Spin%20Up HTTP/1.1 plus the necessary http clauses

That still works but you are missing the csrf token, look at that emcmd script.

  • Author

Limetech,

 

Thanks for the reply. I have been a lime tech user for a very long time. I get uptimes measured in years, only going down for updates.

I found emcmd script at /usr/local/emhttp/plugins/dynamix/scripts/.  The script looks like:

 

#!/usr/bin/php
<?PHP
require_once "/usr/local/emhttp/webGui/include/publish.php";
function emhttp_command($cmd)
{
    $var = parse_ini_file("/var/local/emhttp/var.ini");
    $cmd .= "&csrf_token={$var['csrf_token']}";
    return curl_socket("/var/run/emhttpd.socket", "http://localhost/update", $cmd);
}
$result = emhttp_command($argv[1]);
if ($result === "") exit(0);
echo "$result".PHP_EOL;
exit(1);
?>
 

I am not at all conversant with PHP so I would not know where to start.

A sample of the httpget command to properly (with the necessary csrf, and how to get the current csrf) access the spin states and/or spin up/down the drives would help me a great deal. I can see the csrf token in /var/local/emhttp/var .ini.

 

TIA,

Barry

2 hours ago, barrygordon said:

A sample of the httpget command to properly (with the necessary csrf, and how to get the current csrf) access the spin states and/or spin up/down the drives would help me a great deal. I can see the csrf token in /var/local/emhttp/var .ini.

Ok location of 'emcmd' moved in 6.9, probably you're on 6.8 right?

 

I guess I'm confused about what you're doing.  If you have created your own little app to spin up the drives, I assumed you know enough to figure out how to add the csrf token.  How were you doing this before and I guess now it's broken?  Why not just fire up webGUI and click 'Spin up' button?

 

  • Author

Limetech,

 

Correct  I am on 6.8.3

  • 3 weeks later...
  • Author

I had done this a long long time ago (IIRC unraid 4).  I never wrote anything on the unRaid system.  I always did what I wanted using TCP/IP and GET . . .   I have no idea how to include a csrf token, nor what one looks like.   All I need is an example of using GET over TCP/IP.

 

I am working with member hitch who is developing a container app to handle TCP/IP commands. That app works quite however here is a problem with the app that has been documented as a 6.8.x problem and is fixed in 6.9.  The problem seems to be an inordinate number of accesses to the disk containing the container.  As soon as 6.9 becomes a stable release I will move to it.

 

I don't want to use the web and push the 'Spin up' button.  My theater is controlled by an app I wrote. It controls devices such as the nVidia Shield, the Fire TV cube, a Dune HD Player and TiVo boxes. It has its own extensive movie/video librarian with all the content stored on the unRaid server. When I select the librarian to browse the library (prior to selecting the movie/video I want to watch)  I would like to spin up all the disks on the unRaid server. This way the delay when selecting the movie to play and initiating the read from unRaid is significantly shortened (almost 0 ms)  and makes for an improved experience. The disk spin up would be overlapped with the browsing of the library.

 

I will try what you have suggested (emcmd) using Telnet, but I am much more comfortable using TCP/IP. 

 

 

14 minutes ago, barrygordon said:

I will try what you have suggested (emcmd) using Telnet, but I am much more comfortable using TCP/IP. 

 

You *might* want to also consider looking at something akin to https://forums.unraid.net/topic/91450-alexa-unraid-voice-control-how-to/

(Although its geared towards Alexa, but the concept is the same.  Drop a file into dropbox and have the server act upon it).  No CSRF's involved assuming you can upload a file from your app to drop box, and you'd be able to start / do anything you want at all.

FYI the current CSRF token is located at /var/local/emhttp/var.ini at the bottom.

  • Author

I have written a small standalone exe that will spin up all the unraid disks using emcmd via Telnet.  It will be launched when I want to watch a movie and have started the movie librarian.  The spin up will be overlapped by the the action of the user selecting the movie to watch.  I have set a spin down of any disk after an hour of no activity

Edited by barrygordon
update

  • 2 months later...
  • Author

I am still interested in asynchronously spinning the disks up/down using TCP/IP .  Here is a sample of the prototype command I would send in unRaid version 4. 

"GET /update.htm?cmdSpindownAll=Spin%20Down HTTP/1.1" + vbCrLf + All.

 

If someone could show me how to change the command to include the CSRF token that would be greatly appreciated

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.