Poller: Use the processlist when the number of maximum database connections was provided manually

This commit is contained in:
Michael Vogel 2016-02-11 11:33:45 +01:00
parent a4804a25ee
commit 4af77b60ce

View File

@ -131,13 +131,13 @@ function poller_max_connections_reached() {
return false; return false;
// Fetch the max value from the config. This is needed when the system cannot detect the correct value by itself. // Fetch the max value from the config. This is needed when the system cannot detect the correct value by itself.
// In that case we use the processlist to determine the current number of connections
$max = get_config("system", "max_connections"); $max = get_config("system", "max_connections");
if ($max == 0) { if ($max == 0) {
$max = intval($r[0]["Value"]); $max = intval($r[0]["Value"]);
if ($max == 0) if ($max == 0)
return false; return false;
}
$r = q("SHOW STATUS WHERE `variable_name` = 'Threads_connected'"); $r = q("SHOW STATUS WHERE `variable_name` = 'Threads_connected'");
if (!$r) if (!$r)
@ -146,6 +146,13 @@ function poller_max_connections_reached() {
$connected = intval($r[0]["Value"]); $connected = intval($r[0]["Value"]);
if ($connected == 0) if ($connected == 0)
return false; return false;
} else {
$r = q("SHOW PROCESSLIST");
if (!$r)
return false;
$connected = count($r);
}
$level = $connected / $max; $level = $connected / $max;