[ADDED] Possibility to disable navbar live updates

* Added new admin options: disable_navbar and disable_navbar_api
* Removes LIVE STATS from navigation list
* Removes live updates on Pool General Statistics page
* Added system load checks to getnavbardata API call

This will help to decrease load on high-volume servers at the cost of
losing live status.

Fixes #1014 once merged.
This commit is contained in:
Sebastian Grewe 2013-12-23 21:38:21 +01:00
parent ba625e100e
commit 9485b3f9d6
6 changed files with 68 additions and 49 deletions

View File

@ -287,6 +287,20 @@ $aSettings['system'][] = array(
'name' => 'disable_dashboard_api', 'value' => $setting->getValue('disable_dashboard_api'),
'tooltip' => 'Disable dashboard API entirely to reduce server load.'
);
$aSettings['system'][] = array(
'display' => 'Disable Live Navbar', 'type' => 'select',
'options' => array( 0 => 'No', 1 => 'Yes'),
'default' => 0,
'name' => 'disable_navbar', 'value' => $setting->getValue('disable_navbar'),
'tooltip' => 'Disable live updates on the navbar to reduce server load.'
);
$aSettings['system'][] = array(
'display' => 'Disable Navbar API', 'type' => 'select',
'options' => array( 0 => 'No', 1 => 'Yes'),
'default' => 0,
'name' => 'disable_navbar_api', 'value' => $setting->getValue('disable_navbar_api'),
'tooltip' => 'Disable navbar API entirely to reduce server load. Used in pool stats and navbar mini stats.'
);
$aSettings['system'][] = array(
'display' => 'Disable TX Summaries', 'type' => 'select',
'options' => array( 0 => 'No', 1 => 'Yes'),

View File

@ -3,8 +3,19 @@
// Make sure we are called from index.php
if (!defined('SECURITY')) die('Hacking attempt');
// Check if the API is activated
$api->isActive();
// Check if the system is enabled
if ($setting->getValue('disable_navbar_api')) {
echo $api->get_json(array('error' => 'disabled'));
die();
}
// System load check
if ($load = @sys_getloadavg()) {
if (isset($config['system']['load']['max']) && $load[0] > $config['system']['load']['max']) {
header('HTTP/1.1 503 Too busy, try again later');
die('Server too busy. Please try again later.');
}
}
// Fetch RPC information
if ($bitcoin->can_connect() === true) {

View File

@ -65,6 +65,8 @@ $aGlobal = array(
'price' => $setting->getValue('price'),
'disable_payouts' => $setting->getValue('disable_payouts'),
'config' => array(
'disable_navbar' => $setting->getValue('disable_navbar'),
'disable_navbar_api' => $setting->getValue('disable_navbar_api'),
'algorithm' => $config['algorithm'],
'target_bits' => $config['target_bits'],
'accounts' => $config['accounts'],

View File

@ -88,6 +88,7 @@
{if $smarty.session.AUTHENTICATED|default:"0" == 1}
<br />
{else}
{if !$GLOBAL.website.api.disabled && !$GLOBAL.config.disable_navbar && !$GLOBAL.config.disable_navbar_api}
<ul>
<center>
<div style="display: inline-block;">
@ -100,3 +101,4 @@
<hr/>
{include file="global/navjs.tpl"}
{/if}
{/if}

View File

@ -10,46 +10,43 @@ $(document).ready(function(){
var storedHashrate=[];
var storedWorkers=[];
// Helper to initilize gauges
function initGauges(data) {
g1 = new JustGage({
id: "mr",
value: parseFloat({/literal}{$GLOBAL.workers}{literal}).toFixed(0),
min: 0,
max: Math.round({/literal}{$GLOBAL.workers}{literal} * 2),
title: "Miners",
gaugeColor: '#6f7a8a',
labelFontColor: '#555',
titleFontColor: '#555',
valueFontColor: '#555',
label: "Active Miners",
relativeGaugeSize: true,
showMinMax: true,
shadowOpacity : 0.8,
shadowSize : 0,
shadowVerticalOffset : 10
});
g1 = new JustGage({
id: "mr",
value: parseFloat(data.getnavbardata.data.pool.workers).toFixed(0),
min: 0,
max: Math.round(data.getnavbardata.data.pool.workers * 4),
title: "Miners",
gaugeColor: '#6f7a8a',
labelFontColor: '#555',
titleFontColor: '#555',
valueFontColor: '#555',
label: "Active Miners",
relativeGaugeSize: true,
showMinMax: true,
shadowOpacity : 0.8,
shadowSize : 0,
shadowVerticalOffset : 10
});
g2 = new JustGage({
id: "hr",
value: parseFloat(data.getnavbardata.data.pool.hashrate).toFixed(2),
min: 0,
max: Math.round(data.getnavbardata.data.pool.hashrate * 4),
title: "Pool Hashrate",
gaugeColor: '#6f7a8a',
labelFontColor: '#555',
titleFontColor: '#555',
valueFontColor: '#555',
label: "{/literal}{$GLOBAL.hashunits.pool}{literal}",
relativeGaugeSize: true,
showMinMax: true,
shadowOpacity : 0.8,
shadowSize : 0,
shadowVerticalOffset : 10
});
}
g2 = new JustGage({
id: "hr",
value: parseFloat({/literal}{$GLOBAL.hashrate}{literal}).toFixed(2),
min: 0,
max: Math.round({/literal}{$GLOBAL.hashrate}{literal} * 2),
title: "Pool Hashrate",
gaugeColor: '#6f7a8a',
labelFontColor: '#555',
titleFontColor: '#555',
valueFontColor: '#555',
label: "{/literal}{$GLOBAL.hashunits.pool}{literal}",
relativeGaugeSize: true,
showMinMax: true,
shadowOpacity : 0.8,
shadowSize : 0,
shadowVerticalOffset : 10
});
{/literal}{if $GLOBAL.config.disable_navbar|default:"0" != 1 && $GLOBAL.config.disable_navbar_api|default:"0" != 1}{literal}
// Helper to refresh graphs
function refreshInformation(data) {
g1.refresh(parseFloat(data.getnavbardata.data.pool.workers).toFixed(0));
@ -61,14 +58,6 @@ $(document).ready(function(){
storedHashrate[storedHashrate.length] = [timeNow, data.getnavbardata.data.raw.pool.hashrate];
}
// Fetch initial data via Ajax, starts proper gauges to display
$.ajax({
url: url,
async: false, // Run all others requests after this only if it's done
dataType: 'json',
success: function (data) { initGauges(data); }
});
// Our worker process to keep gauges and graph updated
(function worker() {
$.ajax({
@ -81,6 +70,7 @@ $(document).ready(function(){
setTimeout(worker, {/literal}{($GLOBAL.config.statistics_ajax_refresh_interval * 1000)|default:"1000"}{literal})
}
});
{/literal}{/if}{literal}
})();
});
{/literal}

View File

@ -6,6 +6,6 @@
{include file="statistics/blocks/small_table.tpl" ALIGN="right" SHORT=true}
{if !$GLOBAL.website.api.disabled}
{if !$GLOBAL.website.api.disabled && !$GLOBAL.config.disable_navbar && !$GLOBAL.config.disable_navbar_api}
{include file="statistics/js.tpl"}
{/if}