Merge branch '6.4-wip' into 6.4-wip

This commit is contained in:
bergware
2017-07-08 23:11:04 +02:00
committed by GitHub
19 changed files with 68 additions and 60 deletions

View File

@@ -66,6 +66,7 @@ foreach ($custom as $network) {
<form markdown="1" id="settingsForm" method="POST" action="/update.php" target="progressFrame">
<input type="hidden" name="#file" value="<?=$docker_cfgfile;?>">
<input type="hidden" name="#command" value="/plugins/dynamix/scripts/emhttpd_update" />
Enable Docker:
: <select id="DOCKER_ENABLED" name="DOCKER_ENABLED" class="narrow">
<?= mk_option($dockercfg['DOCKER_ENABLED'], 'no', 'No'); ?>

View File

@@ -104,6 +104,7 @@ foreach ($arrSyslinuxCfg as &$strSyslinuxCfg) {
<?endif;?>
<form id="settingsForm" method="POST" action="/update.php" target="progressFrame">
<input type="hidden" name="#file" value="<?=htmlspecialchars($domain_cfgfile)?>" />
<input type="hidden" name="#command" value="/plugins/dynamix/scripts/emhttpd_update" />
<dl>
<dt>Enable VMs:</dt>

View File

@@ -12,11 +12,9 @@
?>
<?
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/publish.php";
// Load emhttp variables if needed.
if (!isset($var)){
refresh_emhttp_state();
$var = @parse_ini_file("$docroot/state/var.ini");
$disks = @parse_ini_file("$docroot/state/disks.ini", true);
extract(parse_plugin_cfg("dynamix",true));

View File

@@ -114,6 +114,7 @@ $slots = count($disks) + count($devs);
?>
<?if ($slots<30):?>
<style>
table.share_status.fixed{width:<?=min(round(($slots+1)*10/3+13),100)?>%}
table.share_status.fixed td:nth-child(<?=$slots+1?>)~td{display:none}
</style>
<?endif;?>
@@ -542,6 +543,35 @@ function toggle_net(init) {
$('.net_closed').show();
}
}
function parseINI(data){
var regex = {
section: /^\s*\[\s*\"*([^\]]*)\s*\"*\]\s*$/,
param: /^\s*([^=]+?)\s*=\s*\"*(.*?)\s*\"*$/,
comment: /^\s*;.*$/
};
var value = {};
var lines = data.split(/[\r\n]+/);
var section = null;
lines.forEach(function(line){
if(regex.comment.test(line)){
return;
}else if(regex.param.test(line)){
var match = line.match(regex.param);
if(section){
value[section][match[1]] = match[2];
}else{
value[match[1]] = match[2];
}
}else if(regex.section.test(line)){
var match = line.match(regex.section);
value[match[1]] = {};
section = match[1];
}else if(line.length == 0 && section){
section = null;
};
});
return value;
}
$(function() {
dropdown('enter_share');
dropdown('enter_view');
@@ -557,9 +587,14 @@ $(function() {
cpuload_sub.on("message", function(message, message_metadata) {
// message should be something like: {"cpuload": {"cpu":[0,0],"cpu0":[0,0],"cpu1":[0,0],"cpu2":[0,0],"cpu3":[0,0]}}
// The array values are [<load-percentage>,<guest-percentage>]. guest-percentage is that part of load-percentage that is being consumed by VM guests
var json = $.parseJSON(message);
$.each(json["cpuload"],function(k,v) {
$('#'+k).animate({width:v[0]+'%'},{step:function(){$('#'+k).css('overflow','visible');}}).text(v[0]+'%');
// var json = $.parseJSON(message);
// $.each(json["cpuload"],function(k,v) {
// $('#'+k).animate({width:v[0]+'%'},{step:function(){$('#'+k).css('overflow','visible');}}).text(v[0]+'%');
// });
// message is the cpuload.ini file contents
var ini = parseINI(message);
$.each(ini,function(k,v) {
$('#'+k).animate({width:v['host']+'%'},{step:function(){$('#'+k).css('overflow','visible');}}).text(v['host']+'%');
});
});
cpuload_sub.start();

View File

@@ -1,3 +1,3 @@
Menu="Tasks:1"
Type="xmenu"
Tabs="false"
Tabs="false"

View File

@@ -18,7 +18,7 @@ Icon="date-time.png"
<form markdown="1" name="datetime_settings" method="POST" action="/update.htm" target="progressFrame">
Current date and time:
: <?=my_time($var['currTime'])?>
: <?=my_time(time())?>
Time zone:
: <select name="timeZone" size="1"><?
@@ -55,7 +55,7 @@ NTP server 3:
> This is the alternate NTP Server to use if NTP Servers 1 and 2 are both down.
New date and time:
: <input type="text" name="newDateTime" maxlength="40" value="<?=my_time($var['currTime'], "%F %T")?>">
: <input type="text" name="newDateTime" maxlength="40" value="<?=my_time(time(), "%F %T")?>">
> Enter the current time-of-day. Use format YYYY-MM-DD HH:MM:SS. Greyed out when using NTP.

View File

@@ -1,2 +1,2 @@
Menu="Tasks:1"
Type="xmenu"
Type="xmenu"

View File

@@ -1,10 +0,0 @@
#!/usr/bin/php
<?PHP
// The cpuload.ini file is generated by emhttpd just before the 'heartbeat' event callout.
// todo: having emhttpd directly publish json would be more efficient
require_once "/usr/local/emhttp/webGui/include/publish.php";
$data = @parse_ini_file("/var/local/emhttp/cpuload.ini", true);
if ($data !== FALSE) {
publish("cpuload", json_encode($data, JSON_NUMERIC_CHECK));
}
?>

View File

@@ -1,26 +0,0 @@
#!/usr/bin/php
<?PHP
// todo: this should generate/publish json-encoded string and let subscriber handle html
require_once "/usr/local/emhttp/webGui/include/publish.php";
$var = @parse_ini_file("/var/local/emhttp/var.ini");
$fsState=$var['fsState'];
if ($fsState == "Stopped")
$state = "<span class='red strong'>Array Stopped</span>";
elseif ($fsState == "Starting")
$state = "<span class='orange strong'>Array Starting</span>";
else {
$state = "<span class='green strong'>Array Started</span>";
$mdResync = $var['mdResync'];
if ($mdResync > 0) {
$mdResyncAction = $var['mdResyncAction'];
if (strstr($mdResyncAction, "recon")) $action="Parity-Sync / Data-Rebuild";
elseif (strstr($mdResyncAction, "clear")) $action="Clearing";
elseif ($mdResyncAction == "check") $action="Read-Check";
elseif (strstr($mdResyncAction, "check")) $action="Parity-Check";
$mdResyncPos = $var['mdResyncPos'];
$progress = number_format($mdResyncPos/($mdResync/100+1),1);
$state .= "&bullet;<span class='orange strong'>$action $progress %</span>";
}
}
publish("watchdog", $state);
?>

View File

@@ -208,7 +208,7 @@ case 'parity':
$mode = 'Parity-Check';
}
echo "<span class='orange p0'><strong>".$mode." in progress... Completed: ".number_format(($var['mdResyncPos']/($var['mdResync']/100+1)),0)." %.</strong></span>";
echo "<br><em>Elapsed time: ".my_clock(floor(($var['currTime']-$var['sbUpdated'])/60)).". Estimated finish: ".my_clock(round(((($var['mdResyncDt']*(($var['mdResync']-$var['mdResyncPos'])/($var['mdResyncDb']/100+1)))/100)/60),0))."</em>";
echo "<br><em>Elapsed time: ".my_clock(floor((time()-$var['sbUpdated'])/60)).". Estimated finish: ".my_clock(round(((($var['mdResyncDt']*(($var['mdResync']-$var['mdResyncPos'])/($var['mdResyncDb']/100+1)))/100)/60),0))."</em>";
break;
case 'shares':
$names = explode(',',$_POST['names']);

View File

@@ -338,7 +338,7 @@ case 'parity':
$data = [];
if ($var['mdResync']>0) {
$data[] = my_scale($var['mdResync']*1024,$unit)." $unit";
$data[] = my_clock(floor(($var['currTime']-$var['sbUpdated'])/60));
$data[] = my_clock(floor((time()-$var['sbUpdated'])/60));
$data[] = my_scale($var['mdResyncPos']*1024,$unit)." $unit (".number_format(($var['mdResyncPos']/($var['mdResync']/100+1)),1,substr($display['number'],0,1),'')." %)";
$data[] = my_scale($var['mdResyncDb']*1024/$var['mdResyncDt'],$unit, 1)." $unit/sec";
$data[] = my_clock(round(((($var['mdResyncDt']*(($var['mdResync']-$var['mdResyncPos'])/($var['mdResyncDb']/100+1)))/100)/60),0));

View File

@@ -205,7 +205,8 @@
############
TITLE=$(echo -e "$TITLE")
MESSAGE=$(echo -e "$MESSAGE")
curl -X POST -d "payload={\"username\": \"$APP_NAME\", \"text\": \"*$TITLE* \n $MESSAGE\"}" $WEBH_URL 2>&1
curl -X POST --header 'Content-Type: application/json' \
-d "{\"username\": \"$APP_NAME\", \"text\": \"*$TITLE* \n $MESSAGE\"}" $WEBH_URL 2>&1
]]>
</Script>
</Agent>

View File

@@ -22,10 +22,6 @@ function curl_socket($socket, $url, $postdata = NULL)
curl_exec($ch);
curl_close($ch);
}
function refresh_emhttp_state()
{
curl_socket("/var/run/emhttpd.socket", "http://localhost/status.htm");
}
function publish($endpoint, $message)
{
curl_socket("/var/run/nginx.socket", "http://localhost/pub/$endpoint?buffer_length=1", $message);

View File

@@ -1,5 +1,4 @@
#!/bin/bash
# todo: this should generate/publish json-encoded string
ini=/var/local/emhttp/diskload.ini
declare -a sector reads writes

View File

@@ -0,0 +1,18 @@
#!/usr/bin/php -q
<?PHP
/* Copyright 2005-2017, Lime Technology
* Copyright 2012-2017, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/publish.php";
curl_socket("/var/run/emhttpd.socket", "http://localhost/status.htm");
?>

View File

@@ -12,8 +12,6 @@
*/
?>
<?
require_once "/usr/local/emhttp/webGui/include/publish.php";
refresh_emhttp_state();
$var = parse_ini_file("/var/local/emhttp/var.ini");
$devs = parse_ini_file("/var/local/emhttp/devs.ini",true);
$disks = parse_ini_file("/var/local/emhttp/disks.ini",true);

View File

@@ -12,8 +12,6 @@
*/
?>
<?
require_once "/usr/local/emhttp/webGui/include/publish.php";
refresh_emhttp_state();
$var = parse_ini_file("/var/local/emhttp/var.ini");
$disks = parse_ini_file("/var/local/emhttp/disks.ini",true);

View File

@@ -16,13 +16,11 @@ $docroot = $_SERVER['DOCUMENT_ROOT'];
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/PageBuilder.php";
require_once "$docroot/webGui/include/publish.php";
// Get the webGui configuration preferences
extract(parse_plugin_cfg('dynamix',true));
// Read emhttp status
refresh_emhttp_state();
$var = parse_ini_file('state/var.ini');
$sec = parse_ini_file('state/sec.ini',true);
$devs = parse_ini_file('state/devs.ini',true);
@@ -60,7 +58,7 @@ $myPage = $site[basename($path)];
$pageroot = $docroot.'/'.dirname($myPage['file']);
$update = true; // set for legacy
// Maybe delete stale share size files
// hack: maybe delete stale share size files
if ($myPage['name'] != 'Shares')
foreach(glob('/var/local/emhttp/*.ssz*', GLOB_NOSORT) as $sszfile) @unlink($sszfile);

View File

@@ -38,6 +38,7 @@ function write_log($string) {
}
// unRAID update control
readfile('update.htm');
flush();
$docroot = $_SERVER['DOCUMENT_ROOT'];
if (isset($_POST['#file'])) {