mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
When auto-generating metrics ports for worker nodes, get them more uniform across instances.
This commit is contained in:
parent
7172b682f2
commit
b120f39bd7
1 changed files with 12 additions and 11 deletions
|
@ -414,15 +414,17 @@ function config_assign_metrics_ports(config: Management::Configuration)
|
||||||
[Supervisor::WORKER] = 3,
|
[Supervisor::WORKER] = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
local p = port_to_count(Management::Controller::auto_assign_metrics_start_port);
|
local instance_metrics_start_port: table[string] of count;
|
||||||
local ports_set: set[count];
|
local instance_ports_set: table[string] of set[count];
|
||||||
local node: Management::Node;
|
local node: Management::Node;
|
||||||
|
|
||||||
# Pre-populate agents ports, if we have them:
|
# Pre-populate agents ports, if we have them:
|
||||||
for ( inst in config$instances )
|
for ( inst in config$instances )
|
||||||
{
|
{
|
||||||
|
instance_metrics_start_port[inst$name] = port_to_count(Management::Controller::auto_assign_metrics_start_port);
|
||||||
|
instance_ports_set[inst$name] = {};
|
||||||
if ( inst?$listen_port )
|
if ( inst?$listen_port )
|
||||||
add ports_set[port_to_count(inst$listen_port)];
|
add instance_ports_set[inst$name][port_to_count(inst$listen_port)];
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pre-populate nodes with pre-defined metrics ports, as well
|
# Pre-populate nodes with pre-defined metrics ports, as well
|
||||||
|
@ -430,11 +432,10 @@ function config_assign_metrics_ports(config: Management::Configuration)
|
||||||
for ( node in config$nodes )
|
for ( node in config$nodes )
|
||||||
{
|
{
|
||||||
if ( node?$p )
|
if ( node?$p )
|
||||||
add ports_set[port_to_count(node$p)];
|
add instance_ports_set[node$instance][port_to_count(node$p)];
|
||||||
|
|
||||||
if ( node?$metrics_port )
|
if ( node?$metrics_port )
|
||||||
{
|
{
|
||||||
add ports_set[port_to_count(node$metrics_port)];
|
add instance_ports_set[node$instance][port_to_count(node$metrics_port)];
|
||||||
add new_nodes[node];
|
add new_nodes[node];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -468,15 +469,15 @@ function config_assign_metrics_ports(config: Management::Configuration)
|
||||||
node = nodes[i];
|
node = nodes[i];
|
||||||
|
|
||||||
# Find next available port ...
|
# Find next available port ...
|
||||||
while ( p in ports_set )
|
while ( instance_metrics_start_port[node$instance] in instance_ports_set[node$instance] )
|
||||||
++p;
|
++instance_metrics_start_port[node$instance];
|
||||||
|
|
||||||
node$metrics_port = count_to_port(p, tcp);
|
node$metrics_port = count_to_port(instance_metrics_start_port[node$instance], tcp);
|
||||||
add new_nodes[node];
|
add new_nodes[node];
|
||||||
add ports_set[p];
|
add instance_ports_set[node$instance][instance_metrics_start_port[node$instance]];
|
||||||
|
|
||||||
# ... and consume it.
|
# ... and consume it.
|
||||||
++p;
|
++instance_metrics_start_port[node$instance];
|
||||||
}
|
}
|
||||||
|
|
||||||
config$nodes = new_nodes;
|
config$nodes = new_nodes;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue