mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00

This is a preliminary implementation of a subset of the functionality set out in our cluster controller architecture. The controller is the central management node, existing once in any Zeek cluster. The agent is a node that runs once per instance, where an instance will commonly be a physical machine. The agent in turn manages the "data cluster", i.e. the traditional notion of a Zeek cluster with manager, worker nodes, etc. Agent and controller live in the policy folder, and are activated when loading policy/frameworks/cluster/agent and policy/frameworks/cluster/controller, respectively. Both run in nodes forked by the supervisor. When Zeek doesn't use the supervisor, they do nothing. Otherwise, boot.zeek instructs the supervisor to create the respective node, running main.zeek. Both controller and agent have their own config.zeek with relevant knobs. For both, controller/types.zeek provides common data types, and controller/log.zeek provides basic logging (without logger communication -- no such node might exist). A primitive request-tracking abstraction can be found in controller/request.zeek to track outstanding request events and their subsequent responses.
85 lines
3 KiB
Text
85 lines
3 KiB
Text
@load policy/frameworks/cluster/controller/types
|
|
|
|
module ClusterAgent;
|
|
|
|
export {
|
|
# The name this agent uses to represent the cluster instance
|
|
# it manages. When the environment variable isn't set and there's,
|
|
# no redef, this falls back to "agent-<hostname>".
|
|
const name = getenv("ZEEK_AGENT_NAME") &redef;
|
|
|
|
# Agent stdout/stderr log files to produce in Zeek's working
|
|
# directory. If empty, no such logs will result. The actual
|
|
# log files have the agent's name (as per above) dot-prefixed.
|
|
const stdout_file_suffix = "agent.stdout" &redef;
|
|
const stderr_file_suffix = "agent.stderr" &redef;
|
|
|
|
# The address and port the agent listens on. When
|
|
# undefined, falls back to configurable default values.
|
|
const listen_address = getenv("ZEEK_AGENT_ADDR") &redef;
|
|
const default_address = Broker::default_listen_address &redef;
|
|
|
|
const listen_port = getenv("ZEEK_AGENT_PORT") &redef;
|
|
const default_port = 2151/tcp &redef;
|
|
|
|
# The agent communicates under to following topic prefix,
|
|
# suffixed with "/<name>" (see above):
|
|
const topic_prefix = "zeek/cluster-control/agent" &redef;
|
|
|
|
# The coordinates of the controller. When defined, it means
|
|
# agents peer with (connect to) the controller; otherwise the
|
|
# controller knows all agents and peers with them.
|
|
const controller: Broker::NetworkInfo = [
|
|
$address="0.0.0.0", $bound_port=0/unknown] &redef;
|
|
|
|
# Agent and controller currently log only, not via the data cluster's
|
|
# logger. (This might get added later.) For now, this means that
|
|
# if both write to the same log file, it gets garbled. The following
|
|
# lets you specify the working directory specifically for the agent.
|
|
const directory = "" &redef;
|
|
|
|
# Working directory for data cluster nodes. When relative, note
|
|
# that this will apply from the working directory of the agent,
|
|
# since it creates data cluster nodes.
|
|
const cluster_directory = "" &redef;
|
|
|
|
# The following functions return the effective network endpoint
|
|
# information for this agent, in two related forms.
|
|
global instance: function(): ClusterController::Types::Instance;
|
|
global endpoint_info: function(): Broker::EndpointInfo;
|
|
}
|
|
|
|
function instance(): ClusterController::Types::Instance
|
|
{
|
|
local epi = endpoint_info();
|
|
return ClusterController::Types::Instance($name=epi$id,
|
|
$host=to_addr(epi$network$address),
|
|
$listen_port=epi$network$bound_port);
|
|
}
|
|
|
|
function endpoint_info(): Broker::EndpointInfo
|
|
{
|
|
local epi: Broker::EndpointInfo;
|
|
local network: Broker::NetworkInfo;
|
|
|
|
if ( ClusterAgent::name != "" )
|
|
epi$id = ClusterAgent::name;
|
|
else
|
|
epi$id = fmt("agent-%s", gethostname());
|
|
|
|
if ( ClusterAgent::listen_address != "" )
|
|
network$address = ClusterAgent::listen_address;
|
|
else if ( ClusterAgent::default_address != "" )
|
|
network$address = ClusterAgent::default_address;
|
|
else
|
|
network$address = "127.0.0.1";
|
|
|
|
if ( ClusterAgent::listen_port != "" )
|
|
network$bound_port = to_port(ClusterAgent::listen_port);
|
|
else
|
|
network$bound_port = ClusterAgent::default_port;
|
|
|
|
epi$network = network;
|
|
|
|
return epi;
|
|
}
|