Add Supervisor::node_status notification event

The Supervisor generates this event every time it receives a status update from
the stem, meaning a node got created or re-created. A corresponding
SupervisorControl::node_status event relays the same information for users
interacting with the Supervisor over Broker.
This commit is contained in:
Christian Kreibich 2022-05-30 12:41:39 -07:00
parent bdfa7e70f5
commit 14188fc7a7
9 changed files with 98 additions and 0 deletions

View file

@ -26,6 +26,8 @@ extern "C"
#include "zeek/DebugLogger.h"
#include "zeek/Dict.h"
#include "zeek/Event.h"
#include "zeek/EventHandler.h"
#include "zeek/ID.h"
#include "zeek/NetVar.h"
#include "zeek/RE.h"
@ -484,6 +486,8 @@ void Supervisor::HandleChildSignal()
void Supervisor::InitPostScript()
{
node_status = event_registry->Register("Supervisor::node_status");
stem_stdout.hook = id::find_func("Supervisor::stdout_hook");
stem_stderr.hook = id::find_func("Supervisor::stderr_hook");
@ -597,6 +601,10 @@ size_t Supervisor::ProcessMessages()
if ( it != nodes.end() )
it->second.pid = std::stoi(msg_tokens[2]);
if ( node_status )
event_mgr.Enqueue(node_status, make_intrusive<StringVal>(name),
val_mgr->Count(std::stoi(msg_tokens[2])));
}
else if ( type == "debug" )
{

View file

@ -332,6 +332,7 @@ private:
detail::Flare signal_flare;
NodeMap nodes;
std::string msg_buffer;
EventHandlerPtr node_status;
};
namespace detail