mirror of
https://github.com/Cacti/cacti.git
synced 2026-11-30 12:16:40 +09:00
fix: Improve Script Server performance by guarding debug log strings (#8586)
Building the per-request INC and RESPONSE debug log strings (basename(), implode() and string concatenation) on every poll is wasteful when debug logging is disabled, which is the normal production configuration. Introduce testable helpers in lib/functions.php: - cacti_effective_log_level() resolves the effective verbosity the same way cacti_log() does (selective per-file/per-plugin override, else log_verbosity). - script_server_log_request() / script_server_log_response() only assemble and emit their debug strings when that level is POLLER_VERBOSITY_DEBUG. script_server.php now calls these helpers instead of building the strings inline, so the hot path stays cheap while selective script-server debugging keeps working. Unit coverage is added for the new helpers. This is the develop counterpart of the 1.2.x change in #8585. Co-authored-by: TheWitness <copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
4 files changed
+148
-4
No files matched your search
+2
-4
@@ -279,9 +279,7 @@ while (1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
cacti_log("DEBUG: PID[$pid] CTR[$ctr] INC: '" . basename($include_file) .
|
||||
"' FUNC: '$function' PARMS: '" . implode('\', \'',$parameter_array) .
|
||||
"'", false, 'PHPSVR', POLLER_VERBOSITY_DEBUG);
|
||||
script_server_log_request((int) $pid, $ctr, $include_file, $function, $parameter_array);
|
||||
|
||||
// validate the existence of the function, and include if applicable
|
||||
if (!function_exists($function)) {
|
||||
@@ -323,7 +321,7 @@ while (1) {
|
||||
fputs(STDOUT, trim($result) . "\n");
|
||||
fflush(STDOUT);
|
||||
|
||||
cacti_log("DEBUG: PID[$pid] CTR[$ctr] RESPONSE:'$result'", false, 'PHPSVR', POLLER_VERBOSITY_DEBUG);
|
||||
script_server_log_response((int) $pid, $ctr, $result);
|
||||
|
||||
$ctr++;
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user