1
1
Fork 0

Quit when processlist is too long

This commit is contained in:
Michael Vogel 2016-06-03 23:10:23 +02:00
parent 4914e8826b
commit df337e57d1
3 changed files with 21 additions and 7 deletions

View file

@ -15,12 +15,14 @@ class dbm {
// updating // updating
$statelist = ""; $statelist = "";
$processes = 0;
foreach ($states AS $state => $usage) { foreach ($states AS $state => $usage) {
if ($statelist != "") if ($statelist != "")
$statelist .= ", "; $statelist .= ", ";
$statelist .= $state.": ".$usage; $statelist .= $state.": ".$usage;
++$processes;
} }
return($statelist); return(array("list" => $statelist, "amount" => $processes));
} }
} }
?> ?>

View file

@ -28,8 +28,11 @@ function poller_run(&$argv, &$argc){
}; };
$processlist = dbm::processlist(); $processlist = dbm::processlist();
if ($processlist != "") if ($processlist["list"] != "") {
logger("Processlist: ".$processlist, LOGGER_DEBUG); logger("Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
if ($processlist["amount"] > 5)
return;
}
if (poller_max_connections_reached()) if (poller_max_connections_reached())
return; return;
@ -66,8 +69,11 @@ function poller_run(&$argv, &$argc){
// Log the type of database processes // Log the type of database processes
$processlist = dbm::processlist(); $processlist = dbm::processlist();
if ($processlist != "") if ($processlist["amount"] != "") {
logger("Processlist: ".$processlist, LOGGER_DEBUG); logger("Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
if ($processlist["amount"] > 5)
return;
}
// Constantly check the number of available database connections to let the frontend be accessible at any time // Constantly check the number of available database connections to let the frontend be accessible at any time
if (poller_max_connections_reached()) if (poller_max_connections_reached())

View file

@ -55,8 +55,14 @@ if(!$install) {
load_config('system'); load_config('system');
$processlist = dbm::processlist(); $processlist = dbm::processlist();
if ($processlist != "") if ($processlist["list"] != "") {
logger("Processlist: ".$processlist, LOGGER_DEBUG); logger("Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
// More than 20 running database processes?
// The system is too busy, so quit.
if ($processlist["amount"] > 20)
system_unavailable();
}
$maxsysload_frontend = intval(get_config('system','maxloadavg_frontend')); $maxsysload_frontend = intval(get_config('system','maxloadavg_frontend'));
if($maxsysload_frontend < 1) if($maxsysload_frontend < 1)