Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2018-11-26 23:14:58 +0300
committerGitHub <noreply@github.com>2018-11-26 23:14:58 +0300
commitad992c423b477581372ce4ce49853d198c153cc2 (patch)
tree75c85fcea0f66889f90b9a722a41c5a3c1570e36 /plugins/Diagnostics
parent235c1cd64b0fc9ba13b9802c9aeaa31bd92e0271 (diff)
Add max_allowed_packet diagnostic check (#13497)
* Add max_allowed_packet diagnostic check * Update DbMaxPacket.php
Diffstat (limited to 'plugins/Diagnostics')
-rw-r--r--plugins/Diagnostics/Diagnostic/DbMaxPacket.php50
-rw-r--r--plugins/Diagnostics/config/config.php1
-rw-r--r--plugins/Diagnostics/lang/en.json2
3 files changed, 53 insertions, 0 deletions
diff --git a/plugins/Diagnostics/Diagnostic/DbMaxPacket.php b/plugins/Diagnostics/Diagnostic/DbMaxPacket.php
new file mode 100644
index 0000000000..91745db88d
--- /dev/null
+++ b/plugins/Diagnostics/Diagnostic/DbMaxPacket.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace Piwik\Plugins\Diagnostics\Diagnostic;
+
+use Piwik\Db;
+use Piwik\MetricsFormatter;
+use Piwik\Piwik;
+use Piwik\SettingsPiwik;
+use Piwik\Translation\Translator;
+
+/**
+ * Check if Piwik is connected with database through ssl.
+ */
+class DbMaxPacket implements Diagnostic
+{
+ /**
+ * @var Translator
+ */
+ private $translator;
+
+ const MIN_VALUE_MAX_PACKET_MB = 64;
+
+ public function __construct(Translator $translator)
+ {
+ $this->translator = $translator;
+ }
+
+ public function execute()
+ {
+ if (!SettingsPiwik::isPiwikInstalled()) {
+ return array(); // only possible to perform check once we have DB connection
+ }
+
+ $maxPacketBytes = Db::fetchRow("SHOW VARIABLES LIKE 'max_allowed_packet'");
+
+ $status = DiagnosticResult::STATUS_OK;
+ $label = $this->translator->translate('Diagnostics_MysqlMaxPacketSize');
+ $comment = '';
+
+ $minSize = self::MIN_VALUE_MAX_PACKET_MB * 1000 * 1000; // not using 1024 just in case... this amount be good enough
+ if (!empty($maxPacketBytes['Value']) && $maxPacketBytes['Value'] < $minSize) {
+ $status = DiagnosticResult::STATUS_WARNING;
+ $pretty = MetricsFormatter::getPrettySizeFromBytes($maxPacketBytes['Value'], 'M');
+ $configured = str_replace(array(' M', '&nbsp;M'), 'MB', $pretty);
+ $comment = Piwik::translate('Diagnostics_MysqlMaxPacketSizeWarning', array('64MB', $configured));
+ }
+
+ return array(DiagnosticResult::singleResult($label, $status, $comment));
+ }
+}
diff --git a/plugins/Diagnostics/config/config.php b/plugins/Diagnostics/config/config.php
index 13bf140925..0a7c51bf72 100644
--- a/plugins/Diagnostics/config/config.php
+++ b/plugins/Diagnostics/config/config.php
@@ -25,6 +25,7 @@ return array(
DI\get('Piwik\Plugins\Diagnostics\Diagnostic\CronArchivingCheck'),
DI\get('Piwik\Plugins\Diagnostics\Diagnostic\LoadDataInfileCheck'),
Di\get('Piwik\Plugins\Diagnostics\Diagnostic\DbOverSSLCheck'),
+ Di\get('Piwik\Plugins\Diagnostics\Diagnostic\DbMaxPacket'),
Di\get('Piwik\Plugins\Diagnostics\Diagnostic\ForceSSLCheck'),
),
// Allows other plugins to disable diagnostics that were previously registered
diff --git a/plugins/Diagnostics/lang/en.json b/plugins/Diagnostics/lang/en.json
index 2fed3e81a1..38c1990891 100644
--- a/plugins/Diagnostics/lang/en.json
+++ b/plugins/Diagnostics/lang/en.json
@@ -1,6 +1,8 @@
{
"Diagnostics": {
"ConfigFileTitle": "Config file",
+ "MysqlMaxPacketSize": "Max Packet Size",
+ "MysqlMaxPacketSizeWarning": "It is recommended to configure a 'max_allowed_packet' size in your MySQL database of at least %s. Configured is currently %s.",
"ConfigFileIntroduction": "Here you can view the Matomo configuration. If you are running Matomo in a load balanced environment the page might be different depending from which server this page is loaded. Rows with a different background color are changed config values that are specified for example in the %1$s file.",
"HideUnchanged": "If you want to see only changed values you can %1$shide all unchanged values%2$s.",
"Sections": "Sections"