mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Extend Supervisor Node config with list of custom scripts
This commit is contained in:
parent
297317b232
commit
00cd04b0ae
4 changed files with 25 additions and 0 deletions
|
@ -23,6 +23,7 @@ export {
|
||||||
name: string;
|
name: string;
|
||||||
interface: string &optional;
|
interface: string &optional;
|
||||||
directory: string &optional;
|
directory: string &optional;
|
||||||
|
scripts: vector of string &default = vector();
|
||||||
cluster: table[string] of ClusterEndpoint &default=table();
|
cluster: table[string] of ClusterEndpoint &default=table();
|
||||||
|
|
||||||
# TODO: separate node config fields from status fields ?
|
# TODO: separate node config fields from status fields ?
|
||||||
|
|
|
@ -732,6 +732,14 @@ Supervisor::Node Supervisor::Node::FromRecord(const RecordVal* node)
|
||||||
if ( directory_val )
|
if ( directory_val )
|
||||||
rval.directory = directory_val->AsString()->CheckString();
|
rval.directory = directory_val->AsString()->CheckString();
|
||||||
|
|
||||||
|
auto scripts_val = node->Lookup("scripts")->AsVectorVal();
|
||||||
|
|
||||||
|
for ( auto i = 0; i < scripts_val->Size(); ++i )
|
||||||
|
{
|
||||||
|
auto script = scripts_val->Lookup(i)->AsStringVal()->ToStdString();
|
||||||
|
rval.scripts.emplace_back(std::move(script));
|
||||||
|
}
|
||||||
|
|
||||||
auto cluster_table_val = node->Lookup("cluster")->AsTableVal();
|
auto cluster_table_val = node->Lookup("cluster")->AsTableVal();
|
||||||
auto cluster_table = cluster_table_val->AsTable();
|
auto cluster_table = cluster_table_val->AsTable();
|
||||||
auto c = cluster_table->InitForIteration();
|
auto c = cluster_table->InitForIteration();
|
||||||
|
@ -773,6 +781,11 @@ Supervisor::Node Supervisor::Node::FromJSON(std::string_view json)
|
||||||
if ( auto it = j.find("directory"); it != j.end() )
|
if ( auto it = j.find("directory"); it != j.end() )
|
||||||
rval.directory= *it;
|
rval.directory= *it;
|
||||||
|
|
||||||
|
auto scripts = j["scripts"];
|
||||||
|
|
||||||
|
for ( auto& s : scripts )
|
||||||
|
rval.scripts.emplace_back(std::move(s));
|
||||||
|
|
||||||
auto cluster = j["cluster"];
|
auto cluster = j["cluster"];
|
||||||
|
|
||||||
for ( const auto& e : cluster.items() )
|
for ( const auto& e : cluster.items() )
|
||||||
|
@ -820,6 +833,13 @@ IntrusivePtr<RecordVal> Supervisor::Node::ToRecord() const
|
||||||
if ( directory )
|
if ( directory )
|
||||||
rval->Assign(rt->FieldOffset("directory"), new StringVal(*directory));
|
rval->Assign(rt->FieldOffset("directory"), new StringVal(*directory));
|
||||||
|
|
||||||
|
auto st = BifType::Record::Supervisor::Node->FieldType("scripts");
|
||||||
|
auto scripts_val = new VectorVal(st->AsVectorType());
|
||||||
|
rval->Assign(rt->FieldOffset("scripts"), scripts_val);
|
||||||
|
|
||||||
|
for ( const auto& s : scripts )
|
||||||
|
scripts_val->Assign(scripts_val->Size(), new StringVal(s));
|
||||||
|
|
||||||
auto tt = BifType::Record::Supervisor::Node->FieldType("cluster");
|
auto tt = BifType::Record::Supervisor::Node->FieldType("cluster");
|
||||||
auto cluster_val = new TableVal(tt->AsTableType());
|
auto cluster_val = new TableVal(tt->AsTableType());
|
||||||
rval->Assign(rt->FieldOffset("cluster"), cluster_val);
|
rval->Assign(rt->FieldOffset("cluster"), cluster_val);
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
std::string name;
|
std::string name;
|
||||||
std::optional<std::string> interface;
|
std::optional<std::string> interface;
|
||||||
std::optional<std::string> directory;
|
std::optional<std::string> directory;
|
||||||
|
std::vector<std::string> scripts;
|
||||||
std::map<std::string, ClusterEndpoint> cluster;
|
std::map<std::string, ClusterEndpoint> cluster;
|
||||||
|
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
|
|
|
@ -961,6 +961,9 @@ int main(int argc, char** argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ( const auto& s : zeek::supervised_node->scripts )
|
||||||
|
options.scripts_to_load.emplace_back(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
double time_start = current_time(true);
|
double time_start = current_time(true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue