mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-12-27 09:36:09 +08:00
Show loadavg in Admin -> About for #971
This commit is contained in:
parent
5b536f81e3
commit
1506a158f4
4 changed files with 79 additions and 53 deletions
|
@ -16,6 +16,9 @@ export class AdminSettingsAbout /*extends AbstractViewSettings*/ {
|
|||
coreWarning: false,
|
||||
coreVersion: '',
|
||||
coreVersionCompare: -2,
|
||||
load1: 0,
|
||||
load5: 0,
|
||||
load15: 0,
|
||||
errorDesc: ''
|
||||
});
|
||||
this.coreChecking = ko.observable(false).extend({ throttle: 100 });
|
||||
|
@ -51,18 +54,21 @@ export class AdminSettingsAbout /*extends AbstractViewSettings*/ {
|
|||
}
|
||||
|
||||
onBuild() {
|
||||
Remote.request('AdminPHPExtensions', (iError, data) => iError || this.phpextensions(data.Result));
|
||||
|
||||
// beforeShow() {
|
||||
this.coreChecking(true);
|
||||
Remote.request('AdminUpdateInfo', (iError, data) => {
|
||||
Remote.request('AdminInfo', (iError, data) => {
|
||||
this.coreChecking(false);
|
||||
if (!iError && data?.Result) {
|
||||
data = data?.Result;
|
||||
if (!iError && data) {
|
||||
this.load1(data.system.load?.[0]);
|
||||
this.load5(data.system.load?.[1]);
|
||||
this.load15(data.system.load?.[2]);
|
||||
this.phpextensions(data.php);
|
||||
this.coreReal(true);
|
||||
this.coreUpdatable(!!data.Result.updatable);
|
||||
this.coreWarning(!!data.Result.warning);
|
||||
this.coreVersion(data.Result.version || '');
|
||||
this.coreVersionCompare(data.Result.versionCompare);
|
||||
this.coreUpdatable(!!data.core.updatable);
|
||||
this.coreWarning(!!data.core.warning);
|
||||
this.coreVersion(data.core.version || '');
|
||||
this.coreVersionCompare(data.core.versionCompare);
|
||||
} else {
|
||||
this.coreReal(false);
|
||||
this.coreWarning(false);
|
||||
|
|
|
@ -205,40 +205,6 @@ class ActionsAdmin extends Actions
|
|||
: false);
|
||||
}
|
||||
|
||||
public function DoAdminPHPExtensions() : array
|
||||
{
|
||||
$aResult = [
|
||||
[
|
||||
'name' => 'PHP ' . PHP_VERSION,
|
||||
'loaded' => true,
|
||||
'version' => PHP_VERSION
|
||||
],
|
||||
[
|
||||
'name' => 'PHP 64bit',
|
||||
'loaded' => PHP_INT_SIZE == 8,
|
||||
'version' => PHP_INT_SIZE
|
||||
]
|
||||
];
|
||||
foreach (['APCu', 'cURL','GnuPG','GD','Gmagick','Imagick','iconv','intl','LDAP','OpenSSL','pdo_mysql','pdo_pgsql','pdo_sqlite','redis','Sodium','Tidy','uuid','XXTEA','Zip'] as $name) {
|
||||
$aResult[] = [
|
||||
'name' => ('OpenSSL' === $name && \defined('OPENSSL_VERSION_TEXT')) ? OPENSSL_VERSION_TEXT : $name,
|
||||
'loaded' => \extension_loaded(\strtolower($name)),
|
||||
'version' => \phpversion($name)
|
||||
];
|
||||
}
|
||||
$aResult[] = [
|
||||
'name' => 'Fileinfo',
|
||||
'loaded' => \class_exists('finfo'),
|
||||
'version' => \phpversion('fileinfo')
|
||||
];
|
||||
$aResult[] = [
|
||||
'name' => 'Phar',
|
||||
'loaded' => \class_exists('PharData'),
|
||||
'version' => \phpversion('phar')
|
||||
];
|
||||
return $this->DefaultResponse($aResult);
|
||||
}
|
||||
|
||||
// /?admin/Backup
|
||||
public function DoAdminBackup() : void
|
||||
{
|
||||
|
@ -261,7 +227,7 @@ class ActionsAdmin extends Actions
|
|||
exit;
|
||||
}
|
||||
|
||||
public function DoAdminUpdateInfo() : array
|
||||
public function DoAdminInfo() : array
|
||||
{
|
||||
$this->IsAdminLoggined();
|
||||
|
||||
|
@ -294,13 +260,50 @@ class ActionsAdmin extends Actions
|
|||
$aWarnings[] = 'Can not edit: ' . APP_INDEX_ROOT_PATH . 'index.php';
|
||||
}
|
||||
|
||||
return $this->DefaultResponse(array(
|
||||
'updatable' => \SnappyMail\Repository::canUpdateCore(),
|
||||
'warning' => $bShowWarning,
|
||||
'version' => $sVersion,
|
||||
'versionCompare' => \version_compare(APP_VERSION, $sVersion),
|
||||
'warnings' => $aWarnings
|
||||
));
|
||||
$aResult = [
|
||||
'system' => [
|
||||
'load' => \is_callable('sys_getloadavg') ? \sys_getloadavg() : null
|
||||
],
|
||||
'core' => [
|
||||
'updatable' => \SnappyMail\Repository::canUpdateCore(),
|
||||
'warning' => $bShowWarning,
|
||||
'version' => $sVersion,
|
||||
'versionCompare' => \version_compare(APP_VERSION, $sVersion),
|
||||
'warnings' => $aWarnings
|
||||
],
|
||||
'php' => [
|
||||
[
|
||||
'name' => 'PHP ' . PHP_VERSION,
|
||||
'loaded' => true,
|
||||
'version' => PHP_VERSION
|
||||
],
|
||||
[
|
||||
'name' => 'PHP 64bit',
|
||||
'loaded' => PHP_INT_SIZE == 8,
|
||||
'version' => PHP_INT_SIZE
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
foreach (['APCu', 'cURL','GnuPG','GD','Gmagick','Imagick','iconv','intl','LDAP','OpenSSL','pdo_mysql','pdo_pgsql','pdo_sqlite','redis','Sodium','Tidy','uuid','XXTEA','Zip'] as $name) {
|
||||
$aResult['php'][] = [
|
||||
'name' => ('OpenSSL' === $name && \defined('OPENSSL_VERSION_TEXT')) ? OPENSSL_VERSION_TEXT : $name,
|
||||
'loaded' => \extension_loaded(\strtolower($name)),
|
||||
'version' => \phpversion($name)
|
||||
];
|
||||
}
|
||||
$aResult['php'][] = [
|
||||
'name' => 'Fileinfo',
|
||||
'loaded' => \class_exists('finfo'),
|
||||
'version' => \phpversion('fileinfo')
|
||||
];
|
||||
$aResult['php'][] = [
|
||||
'name' => 'Phar',
|
||||
'loaded' => \class_exists('PharData'),
|
||||
'version' => \phpversion('phar')
|
||||
];
|
||||
|
||||
return $this->DefaultResponse($aResult);
|
||||
}
|
||||
|
||||
public function DoAdminUpgradeCore() : array
|
||||
|
|
|
@ -19,12 +19,12 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
$bResult = parent::Load();
|
||||
|
||||
$max = \floatval($this->Get('security', 'max_sys_getloadavg', 0));
|
||||
if ($max && \function_exists('sys_getloadavg')) {
|
||||
if ($max && \is_callable('sys_getloadavg')) {
|
||||
$load = \sys_getloadavg();
|
||||
if ($load && $load[0] > $max) {
|
||||
\header('HTTP/1.1 503 Service Unavailable');
|
||||
\header('HTTP/1.1 503 Service Unavailable', true, 503);
|
||||
\header('Retry-After: 120');
|
||||
exit('Mailserver too busy. Please try again later.');
|
||||
exit("Mailserver too busy ({$load[0]}). Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,23 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<h3>System</h3>
|
||||
<table class="table table-hover table-bordered"><tbody>
|
||||
<tr>
|
||||
<td>Average load past minute</td>
|
||||
<td data-bind="text: load1"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Average load past 5 minutes</td>
|
||||
<td data-bind="text: load5"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Average load past 15 minutes</td>
|
||||
<td data-bind="text: load15"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3>PHP optional extensions</h3>
|
||||
<table class="table table-hover table-bordered"><thead><tr>
|
||||
<th>Extension</th>
|
||||
|
|
Loading…
Reference in a new issue