mirror of
https://github.com/friendica/friendica
synced 2024-11-17 23:03:41 +00:00
Merge pull request #14485 from nupplaphil/feat/admin_stats
Add admin info to stats Endpoint
This commit is contained in:
commit
4b662f919f
4 changed files with 80 additions and 14 deletions
|
@ -24,6 +24,44 @@ class Update
|
||||||
|
|
||||||
const NEW_TABLE_STRUCTURE_VERSION = 1288;
|
const NEW_TABLE_STRUCTURE_VERSION = 1288;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the status of the current update
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getStatus(): int
|
||||||
|
{
|
||||||
|
return (int)DI::config()->get('system', 'update') ?? static::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the latest Version of the Friendica git repository and null, if this node doesn't check updates automatically
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getAvailableVersion(): ?string
|
||||||
|
{
|
||||||
|
return DI::keyValue()->get('git_friendica_version') ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true, if there's a new update and null if this node doesn't check updates automatically
|
||||||
|
*
|
||||||
|
* @return bool|null
|
||||||
|
*/
|
||||||
|
public static function isAvailable(): ?bool
|
||||||
|
{
|
||||||
|
if (DI::config()->get('system', 'check_new_version_url', 'none') != 'none') {
|
||||||
|
if (version_compare(App::VERSION, static::getAvailableVersion()) < 0) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to check if the Database structure needs an update.
|
* Function to check if the Database structure needs an update.
|
||||||
*
|
*
|
||||||
|
|
|
@ -188,6 +188,16 @@ class DBStructure
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current status of the Update
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getUpdateStatus(): int
|
||||||
|
{
|
||||||
|
return (int)DI::config()->get('system', 'dbupdate') ?? static::UPDATE_NOT_CHECKED;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates DB structure from the installation and returns eventual errors messages
|
* Updates DB structure from the installation and returns eventual errors messages
|
||||||
*
|
*
|
||||||
|
|
|
@ -64,23 +64,19 @@ class Summary extends BaseAdmin
|
||||||
|
|
||||||
// Check if github.com/friendica/stable/VERSION is higher then
|
// Check if github.com/friendica/stable/VERSION is higher then
|
||||||
// the local version of Friendica. Check is opt-in, source may be stable or develop branch
|
// the local version of Friendica. Check is opt-in, source may be stable or develop branch
|
||||||
if (DI::config()->get('system', 'check_new_version_url', 'none') != 'none') {
|
if (Update::isAvailable()) {
|
||||||
$gitversion = DI::keyValue()->get('git_friendica_version') ?? '';
|
$warningtext[] = DI::l10n()->t('There is a new version of Friendica available for download. Your current version is %1$s, upstream version is %2$s', App::VERSION, Update::getAvailableVersion());
|
||||||
|
|
||||||
if (version_compare(App::VERSION, $gitversion) < 0) {
|
|
||||||
$warningtext[] = DI::l10n()->t('There is a new version of Friendica available for download. Your current version is %1$s, upstream version is %2$s', App::VERSION, $gitversion);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DI::config()->get('system', 'dbupdate', DBStructure::UPDATE_NOT_CHECKED) == DBStructure::UPDATE_NOT_CHECKED) {
|
if (DBStructure::getUpdateStatus() == DBStructure::UPDATE_NOT_CHECKED) {
|
||||||
DBStructure::performUpdate();
|
DBStructure::performUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DI::config()->get('system', 'dbupdate') == DBStructure::UPDATE_FAILED) {
|
if (DBStructure::getUpdateStatus() == DBStructure::UPDATE_FAILED) {
|
||||||
$warningtext[] = DI::l10n()->t('The database update failed. Please run "php bin/console.php dbstructure update" from the command line and have a look at the errors that might appear.');
|
$warningtext[] = DI::l10n()->t('The database update failed. Please run "php bin/console.php dbstructure update" from the command line and have a look at the errors that might appear.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DI::config()->get('system', 'update') == Update::FAILED) {
|
if (Update::getStatus() == Update::FAILED) {
|
||||||
$warningtext[] = DI::l10n()->t('The last update failed. Please run "php bin/console.php dbstructure update" from the command line and have a look at the errors that might appear. (Some of the errors are possibly inside the logfile.)');
|
$warningtext[] = DI::l10n()->t('The last update failed. Please run "php bin/console.php dbstructure update" from the command line and have a look at the errors that might appear. (Some of the errors are possibly inside the logfile.)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,9 +156,6 @@ class Summary extends BaseAdmin
|
||||||
// We can do better, but this is a quick queue status
|
// We can do better, but this is a quick queue status
|
||||||
$queues = ['label' => DI::l10n()->t('Message queues'), 'deferred' => $deferred, 'workerq' => $workerqueue];
|
$queues = ['label' => DI::l10n()->t('Message queues'), 'deferred' => $deferred, 'workerq' => $workerqueue];
|
||||||
|
|
||||||
$variables = DBA::toArray(DBA::p('SHOW variables LIKE "max_allowed_packet"'));
|
|
||||||
$max_allowed_packet = $variables ? $variables[0]['Value'] : 0;
|
|
||||||
|
|
||||||
$server_settings = [
|
$server_settings = [
|
||||||
'label' => DI::l10n()->t('Server Settings'),
|
'label' => DI::l10n()->t('Server Settings'),
|
||||||
'php' => [
|
'php' => [
|
||||||
|
@ -173,7 +166,7 @@ class Summary extends BaseAdmin
|
||||||
'memory_limit' => ini_get('memory_limit')
|
'memory_limit' => ini_get('memory_limit')
|
||||||
],
|
],
|
||||||
'mysql' => [
|
'mysql' => [
|
||||||
'max_allowed_packet' => $max_allowed_packet
|
'max_allowed_packet' => DBA::getVariable('max_allowed_packet'),
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,11 @@ use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
|
use Friendica\Core\Update;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\Database\DBStructure;
|
||||||
use Friendica\Model\Register;
|
use Friendica\Model\Register;
|
||||||
use Friendica\Moderation\Entity\Report;
|
use Friendica\Moderation\Entity\Report;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
@ -23,6 +26,10 @@ use Friendica\Util\Profiler;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns statistics of the current node for administration use
|
||||||
|
* Like for monitoring
|
||||||
|
*/
|
||||||
class Stats extends BaseModule
|
class Stats extends BaseModule
|
||||||
{
|
{
|
||||||
/** @var IManageConfigValues */
|
/** @var IManageConfigValues */
|
||||||
|
@ -129,7 +136,25 @@ class Stats extends BaseModule
|
||||||
],
|
],
|
||||||
'open' => $this->dba->count('report', ['status' => Report::STATUS_OPEN]),
|
'open' => $this->dba->count('report', ['status' => Report::STATUS_OPEN]),
|
||||||
'closed' => $this->dba->count('report', ['status' => Report::STATUS_CLOSED]),
|
'closed' => $this->dba->count('report', ['status' => Report::STATUS_CLOSED]),
|
||||||
]
|
],
|
||||||
|
'update' => [
|
||||||
|
'available' => Update::isAvailable(),
|
||||||
|
'available_version' => Update::getAvailableVersion(),
|
||||||
|
'status' => Update::getStatus(),
|
||||||
|
'db_status' => DBStructure::getUpdateStatus(),
|
||||||
|
],
|
||||||
|
'server' => [
|
||||||
|
'version' => App::VERSION,
|
||||||
|
'php' => [
|
||||||
|
'version' => phpversion(),
|
||||||
|
'upload_max_filesize' => ini_get('upload_max_filesize'),
|
||||||
|
'post_max_size' => ini_get('post_max_size'),
|
||||||
|
'memory_limit' => ini_get('memory_limit'),
|
||||||
|
],
|
||||||
|
'database' => [
|
||||||
|
'max_allowed_packet' => DBA::getVariable('max_allowed_packet'),
|
||||||
|
],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (Addon::isEnabled('bluesky')) {
|
if (Addon::isEnabled('bluesky')) {
|
||||||
|
|
Loading…
Reference in a new issue