mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Remove deprecated load-balacing policy script
This commit is contained in:
parent
1d0f01d6bc
commit
7a5b29ea81
4 changed files with 2 additions and 120 deletions
|
@ -1,117 +0,0 @@
|
||||||
##! This script implements the "Zeek side" of several load balancing
|
|
||||||
##! approaches for Zeek clusters.
|
|
||||||
|
|
||||||
@deprecated "Remove in v7.1. This script has not seen extensions for the past 10 years and is not at all recommended to use for packet load balancing purposes. On Linux, AF_PACKET is recommended and works out of the box. On FreeBSD, there is Netmap with lb. Otherwise, NIC specific packet sources and approaches exist that handle the load balancing."
|
|
||||||
|
|
||||||
@pragma push ignore-deprecations
|
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
|
||||||
@load base/frameworks/packet-filter
|
|
||||||
|
|
||||||
module LoadBalancing;
|
|
||||||
|
|
||||||
export {
|
|
||||||
|
|
||||||
type Method: enum {
|
|
||||||
## Apply BPF filters to each worker in a way that causes them to
|
|
||||||
## automatically flow balance traffic between them.
|
|
||||||
AUTO_BPF,
|
|
||||||
};
|
|
||||||
|
|
||||||
## Defines the method of load balancing to use.
|
|
||||||
const method = AUTO_BPF &redef;
|
|
||||||
|
|
||||||
redef record Cluster::Node += {
|
|
||||||
## A BPF filter for load balancing traffic sniffed on a single
|
|
||||||
## interface across a number of processes. In normal uses, this
|
|
||||||
## will be assigned dynamically by the manager and installed by
|
|
||||||
## the workers.
|
|
||||||
lb_filter: string &optional;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@if ( Cluster::is_enabled() )
|
|
||||||
|
|
||||||
event zeek_init() &priority=5
|
|
||||||
{
|
|
||||||
if ( method != AUTO_BPF )
|
|
||||||
return;
|
|
||||||
|
|
||||||
local worker_ip_interface: table[addr, string] of count = table();
|
|
||||||
local sorted_node_names: vector of string = vector();
|
|
||||||
local node: Cluster::Node;
|
|
||||||
local name: string;
|
|
||||||
|
|
||||||
# Sort nodes list so that every node iterates over it in same order.
|
|
||||||
for ( name in Cluster::nodes )
|
|
||||||
sorted_node_names += name;
|
|
||||||
|
|
||||||
sort(sorted_node_names, strcmp);
|
|
||||||
|
|
||||||
for ( idx in sorted_node_names )
|
|
||||||
{
|
|
||||||
name = sorted_node_names[idx];
|
|
||||||
node = Cluster::nodes[name];
|
|
||||||
|
|
||||||
if ( node$node_type != Cluster::WORKER )
|
|
||||||
next;
|
|
||||||
|
|
||||||
if ( ! node?$interface )
|
|
||||||
next;
|
|
||||||
|
|
||||||
if ( [node$ip, node$interface] !in worker_ip_interface )
|
|
||||||
worker_ip_interface[node$ip, node$interface] = 0;
|
|
||||||
|
|
||||||
++worker_ip_interface[node$ip, node$interface];
|
|
||||||
}
|
|
||||||
|
|
||||||
# Now that we've counted up how many processes are running per
|
|
||||||
# interface, let's create the filters for each worker.
|
|
||||||
local lb_proc_track: table[addr, string] of count = table();
|
|
||||||
|
|
||||||
for ( idx in sorted_node_names )
|
|
||||||
{
|
|
||||||
name = sorted_node_names[idx];
|
|
||||||
node = Cluster::nodes[name];
|
|
||||||
|
|
||||||
if ( node$node_type != Cluster::WORKER )
|
|
||||||
next;
|
|
||||||
|
|
||||||
if ( ! node?$interface )
|
|
||||||
next;
|
|
||||||
|
|
||||||
if ( [node$ip, node$interface] !in worker_ip_interface )
|
|
||||||
next;
|
|
||||||
|
|
||||||
if ( [node$ip, node$interface] !in lb_proc_track )
|
|
||||||
lb_proc_track[node$ip, node$interface] = 0;
|
|
||||||
|
|
||||||
local this_lb_proc = lb_proc_track[node$ip, node$interface];
|
|
||||||
local total_lb_procs = worker_ip_interface[node$ip, node$interface];
|
|
||||||
++lb_proc_track[node$ip, node$interface];
|
|
||||||
|
|
||||||
if ( total_lb_procs > 1 )
|
|
||||||
node$lb_filter = PacketFilter::sampling_filter(total_lb_procs,
|
|
||||||
this_lb_proc);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Finally, install filter for the current node if it needs one.
|
|
||||||
for ( idx in sorted_node_names )
|
|
||||||
{
|
|
||||||
name = sorted_node_names[idx];
|
|
||||||
node = Cluster::nodes[name];
|
|
||||||
|
|
||||||
if ( name != Cluster::node )
|
|
||||||
next;
|
|
||||||
|
|
||||||
if ( ! node?$lb_filter )
|
|
||||||
next;
|
|
||||||
|
|
||||||
restrict_filters["lb_filter"] = node$lb_filter;
|
|
||||||
PacketFilter::install();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@pragma pop
|
|
|
@ -85,7 +85,6 @@
|
||||||
@load misc/detect-traceroute/__load__.zeek
|
@load misc/detect-traceroute/__load__.zeek
|
||||||
@load misc/detect-traceroute/main.zeek
|
@load misc/detect-traceroute/main.zeek
|
||||||
# @load misc/dump-events.zeek
|
# @load misc/dump-events.zeek
|
||||||
@load misc/load-balancing.zeek
|
|
||||||
@load misc/loaded-scripts.zeek
|
@load misc/loaded-scripts.zeek
|
||||||
@load misc/profiling.zeek
|
@load misc/profiling.zeek
|
||||||
@load misc/stats.zeek
|
@load misc/stats.zeek
|
||||||
|
|
|
@ -9,4 +9,4 @@
|
||||||
#
|
#
|
||||||
# @TEST-EXEC: test -d $DIST/scripts
|
# @TEST-EXEC: test -d $DIST/scripts
|
||||||
# @TEST-EXEC: for script in `find $DIST/scripts/ -name \*\.zeek`; do zeek -b --parse-only $script >>errors 2>&1; done
|
# @TEST-EXEC: for script in `find $DIST/scripts/ -name \*\.zeek`; do zeek -b --parse-only $script >>errors 2>&1; done
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER="grep -v -e 'load-balancing.zeek.*deprecated script loaded' | $SCRIPTS/diff-remove-abspath | $SCRIPTS/diff-sort" btest-diff errors
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER="$SCRIPTS/diff-remove-abspath | $SCRIPTS/diff-sort" btest-diff errors
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
# @TEST-EXEC: CLUSTER_NODE=logger-1 zeek %INPUT
|
# @TEST-EXEC: CLUSTER_NODE=logger-1 zeek %INPUT
|
||||||
# @TEST-EXEC: CLUSTER_NODE=proxy-1 zeek %INPUT
|
# @TEST-EXEC: CLUSTER_NODE=proxy-1 zeek %INPUT
|
||||||
# @TEST-EXEC: CLUSTER_NODE=worker-1 zeek %INPUT
|
# @TEST-EXEC: CLUSTER_NODE=worker-1 zeek %INPUT
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER='grep -v "load-balancing.zeek.*deprecated script" | $SCRIPTS/diff-remove-abspath' btest-diff .stderr
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER='$SCRIPTS/diff-remove-abspath' btest-diff .stderr
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
@load base/frameworks/cluster
|
||||||
@load misc/loaded-scripts
|
@load misc/loaded-scripts
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue