Updating of unRAID variables


bonienl

Recommended Posts

The way unRAID v6 updates its variables in the background is completely different from the old approach done in V5. Let me state first that the approach taken in V6 is a good one because it alleviates the burden on the system itself each time the webGUI is queried by the browser.

 

At the same time the new V6 implementation puts a limitation in place when the need arises to do real-time updates on selective page content. Such selective updates rely on $.ajax requests to pull information from the server without the need to do a complete page refresh. However unRAID's internal variables do not get updated any longer unless a complete page refresh is performed and as side effect real-time updates do not show any changes.

 

It would be a strength for unRAID to have the ability to do automatic real-time updates and not rely on pressing the "refresh" button each time to see the current state. Such a system is required too when a notification system is put in place.

 

Link to comment

We are changing the way unRaid "state" is obtained.

 

Previously this was done via "ini" files located in /var/local/emhttp/.  Each time a webGui page was accessed, emhttp would regenerate those files and then execute /usr/local/emhttp/plugins/webGui/template.php.  template.php would then use parse_ini_file() to read in unraid state.

 

We are moving to a socket-based solution.  When template.php executes, it will do something like this:

 

$s = fsockopen( "unix:///var/run/emhttp.sock");
fwrite($s, "cmdStatus=all\0");
$json = stream_get_contents($s);
extract(json_decode($json, true));

 

This change will appear after -beta10.

 

Eventually will probably implement a full json-rpc api to unraid services... thoughts?

Link to comment

I like the idea to read files on socket based, this would help in making file updates only when requested/needed and thus keeping system load low.

 

Can you include the possibility to query and update selected files too? This would be useful when selective page updates are done (e.g. only the disks table).

 

Haven't made my mind up on json, though ...

 

Link to comment
  • 4 months later...

The way "plugin update" works is that it downloads the PLG file to /tmp directory.  Once download completes it executes 'plugin version' to get the version number and compares against installed version number.  The larger the PLG file, the longer this download can take (though admittedly it's probably negligible).

 

That's not what bonienl is talking about. The unRAID control process (called emhttp) creates a lot of data that are stored under "/var/local/emhttp/" directory and then passed to PHP scripts as variables, like $disks and $vars. In fact, emhttp puts together a lot of data that are difficult to harvest. But this have a caveat in v6: these files are only updated upon a page load/refresh, so scripts that relies on ajax post/get functions can only be reliable if the data they need is static, like the IP address, the temperatue scale etc...

 

Link to comment
  • 3 months later...

How do I access the $disks and $vars data inside my PHPs?

Do I need to load them from the files or are they already loaded in the PHP "cover code"?

This would give you unRAID's ip address from $vars.

$ipaddr = $var['IPADDR'];

Edit: $disks would be $disks['parity']['id'] since its a multidimensional array.

Edit2: This is an example from the webgui ShareEdit.page

  $myDisks = array();
  foreach ($disks as $disk) $myDisks[] = $disk['name'];

And would give you an array $myDisks with the names of all the disks.

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.