Skip to content

Commit fa9019a

Browse files
author
Till Brehm
committed
Merge branch 'avoid-mysql-aborted-connections' into 'develop'
Avoid syslog errors about MySQL/MariaDB "Aborted connections" due to cron script. Closes #6380 See merge request ispconfig/ispconfig3!1628
2 parents 49658d6 + a4108e8 commit fa9019a

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

server/lib/classes/monitor_tools.inc.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -470,16 +470,21 @@ public function monitorServices() {
470470
}
471471
}
472472

473-
/* Monitor MySQL Server */
474-
$data['mysqlserver'] = -1; // unknown - not needed
475-
if ($services['db_server'] == 1) {
476-
if ($this->_checkTcp($conf['db_host'], $conf['db_port'])) {
477-
$data['mysqlserver'] = 1;
478-
} else {
479-
$data['mysqlserver'] = 0;
480-
$state = 'error'; // because service is down
481-
}
482-
}
473+
/* Monitor MySQL Server */
474+
$data['mysqlserver'] = -1; // unknown - not needed
475+
if ($services['db_server'] == 1) {
476+
// hail MySQL server:
477+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
478+
$ispcDB = mysqli_connect($conf['db_host'], $conf['db_user'], $conf['db_password'], $conf['db_database'], $conf['db_port']);
479+
if ($ispcDB !== false) {
480+
$data['mysqlserver'] = 1;
481+
} else {
482+
$data['mysqlserver'] = 0;
483+
$state = 'error'; // because service is down
484+
}
485+
mysqli_close($ispcDB); // we can ignore the result (gwyneth 20220605)
486+
}
487+
483488
/*
484489
$data['mongodbserver'] = -1;
485490
if ($this->_checkTcp('localhost', 27017)) {

0 commit comments

Comments
 (0)