From 0c20f16055000c7e37bd68dbf4f46dda4fb6c934 Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Mon, 13 Jun 2022 21:12:42 -0700 Subject: [PATCH] Management framework: control output-to-console in Supervisor It helps during testing to be able to control whether the Supervisor process also routs node output to the console, in addition to writing to output files. Since the Supervisor runs as the main process in Docker containers, its output becomes visible in "docker logs" that way, simplifying diagnostics. --- .../frameworks/management/supervisor/config.zeek | 12 ++++++++++++ .../frameworks/management/supervisor/main.zeek | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/scripts/policy/frameworks/management/supervisor/config.zeek b/scripts/policy/frameworks/management/supervisor/config.zeek index f910ee8a7d..1f69f1b569 100644 --- a/scripts/policy/frameworks/management/supervisor/config.zeek +++ b/scripts/policy/frameworks/management/supervisor/config.zeek @@ -7,6 +7,18 @@ export { ## Supervisor. The agent subscribes to this. const topic_prefix = "zeek/management/supervisor" &redef; + ## Whether to print the stdout sent up to the Supervisor by created + ## nodes to the terminal. By default, this is disabled since this output + ## already ends up in a node-specific stdout file, per + ## :zeek:see:`Management::Node::stdout_file`. + const print_stdout = F &redef; + + ## Whether to print the stderr sent up to the Supervisor by created + ## nodes to the terminal. By default, this is disabled since this output + ## already ends up in a node-specific stderr file, per + ## :zeek:see:`Management::Node::stderr_file`. + const print_stderr = F &redef; + ## The maximum number of stdout/stderr output lines to convey in ## :zeek:see:`Management::Supervisor::API::notify_node_exit` events. const output_max_lines: count = 100 &redef; diff --git a/scripts/policy/frameworks/management/supervisor/main.zeek b/scripts/policy/frameworks/management/supervisor/main.zeek index f68413a5d3..8683a895f7 100644 --- a/scripts/policy/frameworks/management/supervisor/main.zeek +++ b/scripts/policy/frameworks/management/supervisor/main.zeek @@ -70,8 +70,8 @@ hook Supervisor::stdout_hook(node: string, msg: string) # Update the sliding window of recent output lines. Queue::put(g_outputs[node]$stdout, msg); - # Don't print this message in the Supervisor's own stdout - break; + if ( ! print_stdout ) + break; } hook Supervisor::stderr_hook(node: string, msg: string) @@ -87,8 +87,8 @@ hook Supervisor::stderr_hook(node: string, msg: string) Queue::put(g_outputs[node]$stderr, msg); - # Don't print this message in the Supervisor's own stdout - break; + if ( ! print_stderr ) + break; } event Supervisor::node_status(node: string, pid: count)