zeek/policy/frameworks/cluster/base/external-events.bro
Seth Hall be65acec4e Initial commit of the new cluster framework.
- It's ok to always load the framework.  If you don't
  specifiy the CLUSTER_NODE environment variable it doesn't
  ultimately do anything.
- The $CLUSTER_NODE variable causes the framework to try and
  load a script named cluster-layout.bro which must be located
  somewhere in your $BROPATH.  The value of the $CLUSTER_NODE
  variable is a count that indicates a node in the Cluster::nodes
  variable that is set in the cluster-layout.bro script.
- The Cluster::nodes variable is a flat configuration because
  it's assumed that it would be automatically generated by a
  utility such as BroControl.  This will facilitate the tiered or
  "deep" clustering that is coming.
2011-07-07 13:21:19 -04:00

74 lines
2.2 KiB
Text

##! Events which can be sent dynamically to Bro instances to retrieve
##! information about the running process.
module Cluster;
export {
## Event for requesting the value of an ID (a variable).
global id_request: event(id: string);
## Event for returning the value of an ID after an :bro:id:`id_request` event.
global id_response: event(id: string, val: string);
## Requests the current communication status.
global peer_status_request: event();
## Returns the current communication status.
global peer_status_response: event(s: string);
global net_stats_request: event();
global net_stats_response: event(s: string);
}
event id_request(id: string)
{
local msg = fmt("%.6f got event id_request(%s)", network_time(), id);
Log::write(CLUSTER, [$ts=network_time(), $msg=msg]);
local val = lookup_ID(id);
event id_response(id, fmt("%s", val));
}
event id_response(id: string, val: string)
{
local msg = fmt("%.6f raised event id_response(%s, %s)", network_time(), id, val);
Log::write(CLUSTER, [$ts=network_time(), $peer=peer_description, $msg=msg]);
}
event peer_status_request()
{
local msg = fmt("%.6f got event peer_status_request()", network_time());
Log::write(CLUSTER, [$ts=network_time(), $peer=peer_description, $msg=msg]);
local status = "";
for ( p in Communication::nodes )
{
local peer = Communication::nodes[p];
if ( ! peer$connected )
next;
status += fmt("peer=%s host=%s events_in=? events_out=? ops_in=? ops_out=? bytes_in=? bytes_out=?\n",
peer$peer$descr, peer$host);
}
event peer_status_response(status);
}
event peer_status_response(s: string)
{
local msg = fmt("%.6f raised event peer_status_response(%s)", network_time(), s);
Log::write(CLUSTER, [$ts=network_time(), $peer=peer_description, $msg=msg]);
}
event net_stats_request()
{
local ns = net_stats();
local reply = fmt("%.6f recvd=%d dropped=%d link=%d\n", network_time(),
ns$pkts_recvd, ns$pkts_dropped, ns$pkts_link);
event net_stats_response(reply);
}
event net_stats_response(s: string)
{
local msg = fmt("%.6f raised event net_stats_response(%s)", network_time(), s);
Log::write(CLUSTER, [$ts=network_time(), $peer=peer_description, $msg=msg]);
}