mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Management framework: move role variable from logging into framework-wide config
The role isn't just about logging, it can also act as a general indicator to key in on in role-specific code elsewhere, such as @if.
This commit is contained in:
parent
e78fdc39e4
commit
b96a4276eb
5 changed files with 15 additions and 12 deletions
|
@ -40,7 +40,7 @@ redef record Management::Request::Request += {
|
||||||
};
|
};
|
||||||
|
|
||||||
# Tag our logs correctly
|
# Tag our logs correctly
|
||||||
redef Management::Log::role = Management::AGENT;
|
redef Management::role = Management::AGENT;
|
||||||
|
|
||||||
# The global configuration as passed to us by the controller
|
# The global configuration as passed to us by the controller
|
||||||
global g_config: Management::Configuration;
|
global g_config: Management::Configuration;
|
||||||
|
|
|
@ -5,9 +5,16 @@
|
||||||
##! anyway). For role-specific settings, see management/controller/config.zeek
|
##! anyway). For role-specific settings, see management/controller/config.zeek
|
||||||
##! and management/agent/config.zeek.
|
##! and management/agent/config.zeek.
|
||||||
|
|
||||||
|
@load ./types
|
||||||
|
|
||||||
module Management;
|
module Management;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
## The role of this process in cluster management. Use this to
|
||||||
|
## differentiate code based on the type of node in which it ends up
|
||||||
|
## running.
|
||||||
|
const role = Management::NONE &redef;
|
||||||
|
|
||||||
## The fallback listen address if more specific adddresses, such as
|
## The fallback listen address if more specific adddresses, such as
|
||||||
## the controller's :zeek:see:`Management::Controller::listen_address`
|
## the controller's :zeek:see:`Management::Controller::listen_address`
|
||||||
## remains empty. Unless redefined, this uses Broker's own default
|
## remains empty. Unless redefined, this uses Broker's own default
|
||||||
|
|
|
@ -71,7 +71,7 @@ redef record Management::Request::Request += {
|
||||||
};
|
};
|
||||||
|
|
||||||
# Tag our logs correctly
|
# Tag our logs correctly
|
||||||
redef Management::Log::role = Management::CONTROLLER;
|
redef Management::role = Management::CONTROLLER;
|
||||||
|
|
||||||
global check_instances_ready: function();
|
global check_instances_ready: function();
|
||||||
global add_instance: function(inst: Management::Instance);
|
global add_instance: function(inst: Management::Instance);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
##! supervisor. In this setting Zeek's logging framework operates locally, i.e.,
|
##! supervisor. In this setting Zeek's logging framework operates locally, i.e.,
|
||||||
##! this does not involve logger nodes.
|
##! this does not involve logger nodes.
|
||||||
|
|
||||||
@load ./types
|
@load ./config
|
||||||
|
|
||||||
module Management::Log;
|
module Management::Log;
|
||||||
|
|
||||||
|
@ -64,10 +64,6 @@ export {
|
||||||
## message: the message to log.
|
## message: the message to log.
|
||||||
##
|
##
|
||||||
global error: function(message: string);
|
global error: function(message: string);
|
||||||
|
|
||||||
## The role of this process in cluster management. Agent and controller
|
|
||||||
## both redefine this, and we use it during logging.
|
|
||||||
const role = Management::NONE &redef;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Enum translations to strings. This avoids those enums being reported
|
# Enum translations to strings. This avoids those enums being reported
|
||||||
|
@ -93,7 +89,7 @@ function debug(message: string)
|
||||||
|
|
||||||
local node = Supervisor::node();
|
local node = Supervisor::node();
|
||||||
Log::write(LOG, [$ts=network_time(), $node=node$name, $level=l2s[DEBUG],
|
Log::write(LOG, [$ts=network_time(), $node=node$name, $level=l2s[DEBUG],
|
||||||
$role=r2s[role], $message=message]);
|
$role=r2s[Management::role], $message=message]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function info(message: string)
|
function info(message: string)
|
||||||
|
@ -103,7 +99,7 @@ function info(message: string)
|
||||||
|
|
||||||
local node = Supervisor::node();
|
local node = Supervisor::node();
|
||||||
Log::write(LOG, [$ts=network_time(), $node=node$name, $level=l2s[INFO],
|
Log::write(LOG, [$ts=network_time(), $node=node$name, $level=l2s[INFO],
|
||||||
$role=r2s[role], $message=message]);
|
$role=r2s[Management::role], $message=message]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function warning(message: string)
|
function warning(message: string)
|
||||||
|
@ -113,7 +109,7 @@ function warning(message: string)
|
||||||
|
|
||||||
local node = Supervisor::node();
|
local node = Supervisor::node();
|
||||||
Log::write(LOG, [$ts=network_time(), $node=node$name, $level=l2s[WARNING],
|
Log::write(LOG, [$ts=network_time(), $node=node$name, $level=l2s[WARNING],
|
||||||
$role=r2s[role], $message=message]);
|
$role=r2s[Management::role], $message=message]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function error(message: string)
|
function error(message: string)
|
||||||
|
@ -123,7 +119,7 @@ function error(message: string)
|
||||||
|
|
||||||
local node = Supervisor::node();
|
local node = Supervisor::node();
|
||||||
Log::write(LOG, [$ts=network_time(), $node=node$name, $level=l2s[ERROR],
|
Log::write(LOG, [$ts=network_time(), $node=node$name, $level=l2s[ERROR],
|
||||||
$role=r2s[role], $message=message]);
|
$role=r2s[Management::role], $message=message]);
|
||||||
}
|
}
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
module Management::Node;
|
module Management::Node;
|
||||||
|
|
||||||
# Tag our logs correctly
|
# Tag our logs correctly
|
||||||
redef Management::Log::role = Management::NODE;
|
redef Management::role = Management::NODE;
|
||||||
|
|
||||||
## The type of dispatch callbacks. These implement a particular dispatch action,
|
## The type of dispatch callbacks. These implement a particular dispatch action,
|
||||||
## using the provided string vector as arguments, filling results into the
|
## using the provided string vector as arguments, filling results into the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue