1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\Diagnostics\Commands;
use Piwik\Config;
use Piwik\Config\DatabaseConfig;
use Piwik\Config\GeneralConfig;
use Piwik\Plugin\ConsoleCommand;
/**
* Diagnostic command that returns current configuration settings for archiving
*/
class ArchivingConfig extends ConsoleCommand
{
protected function configure()
{
$this->setName('diagnostics:archiving-config');
$this->addNoValueOption(
'json',
null,
"If supplied, the command will return data in json format"
);
$this->setDescription('Show configuration settings that can affect archiving performance');
}
protected function doExecute(): int
{
$input = $this->getInput();
$output = $this->getOutput();
$metrics = $this->getArchivingConfig();
if ($input->getOption('json')) {
$output->write(json_encode($metrics));
} else {
$headers = ['Section', 'Setting', 'Value'];
$this->renderTable($headers, $metrics);
}
return self::SUCCESS;
}
/**
* Retrieve various data statistics useful for diagnosing archiving performance
*
* @return array
*/
public function getArchivingConfig(): array
{
$configs = [
'database' => [
'enable_segment_first_table_join_prefix',
'enable_first_table_join_prefix',
],
'general' => [
'browser_archiving_disabled_enforce',
'enable_processing_unique_visitors_day',
'enable_processing_unique_visitors_week',
'enable_processing_unique_visitors_month',
'enable_processing_unique_visitors_year',
'enable_processing_unique_visitors_range',
'enable_processing_unique_visitors_multiple_sites',
'process_new_segments_from',
'time_before_today_archive_considered_outdated',
'time_before_week_archive_considered_outdated',
'time_before_month_archive_considered_outdated',
'time_before_year_archive_considered_outdated',
'time_before_range_archive_considered_outdated',
'enable_browser_archiving_triggering',
'archiving_range_force_on_browser_request',
'archiving_custom_ranges[]',
'archiving_query_max_execution_time',
'archiving_ranking_query_row_limit',
'disable_archiving_segment_for_plugins',
'disable_archive_actions_goals',
'datatable_archiving_maximum_rows_referrers',
'datatable_archiving_maximum_rows_subtable_referrers',
'datatable_archiving_maximum_rows_userid_users',
'datatable_archiving_maximum_rows_custom_dimensions',
'datatable_archiving_maximum_rows_subtable_custom_dimensions',
'datatable_archiving_maximum_rows_actions',
'datatable_archiving_maximum_rows_subtable_actions',
'datatable_archiving_maximum_rows_site_search',
'datatable_archiving_maximum_rows_events',
'datatable_archiving_maximum_rows_subtable_events',
'datatable_archiving_maximum_rows_products',
'datatable_archiving_maximum_rows_standard',
],
];
$data = [];
foreach ($configs as $section => $sectionConfigs) {
foreach ($sectionConfigs as $setting) {
switch ($section) {
case 'general':
$value = GeneralConfig::getConfigValue($setting);
break;
case 'database':
$value = DatabaseConfig::getConfigValue($setting);
break;
default:
$value = Config::getInstance()->{$section}[$setting] ?? '';
}
$data[] = ['Section' => $section, 'Setting' => $setting, 'Value' => $value];
}
}
return $data;
}
}
|