mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Large update for the SumStats framework.
- On-demand access to sumstats results through "return from" functions named SumStats::request and Sumstats::request_key. Both functions are tested in standalone and clustered modes. - $name field has returned to SumStats which simplifies cluster code and makes the on-demand access stuff possible. - Clustered results can only be collected for 1 minute from their time of creation now instead of time of last read. - Thresholds use doubles instead of counts everywhere now. - Calculation dependency resolution occurs at start up time now instead of doing it at observation time which provide a minor cpu performance improvement. A new plugin registration mechanism was created to support this change. - AppStats now has a minimal doc string and is broken into hook-based plugins. - AppStats and traceroute detection added to local.bro
This commit is contained in:
parent
7d7d30e1f7
commit
bec965b66f
34 changed files with 687 additions and 277 deletions
|
@ -1,4 +1,4 @@
|
|||
@load base/frameworks/sumstats
|
||||
@load ../main
|
||||
|
||||
module SumStats;
|
||||
|
||||
|
@ -14,19 +14,19 @@ export {
|
|||
sum: double &default=0.0;
|
||||
};
|
||||
|
||||
type threshold_function: function(key: SumStats::Key, result: SumStats::Result): count;
|
||||
global sum_threshold: function(data_id: string): threshold_function;
|
||||
#type threshold_function: function(key: SumStats::Key, result: SumStats::Result): count;
|
||||
#global sum_threshold: function(data_id: string): threshold_function;
|
||||
}
|
||||
|
||||
function sum_threshold(data_id: string): threshold_function
|
||||
{
|
||||
return function(key: SumStats::Key, result: SumStats::Result): count
|
||||
{
|
||||
print fmt("data_id: %s", data_id);
|
||||
print result;
|
||||
return double_to_count(result[data_id]$sum);
|
||||
};
|
||||
}
|
||||
#function sum_threshold(data_id: string): threshold_function
|
||||
# {
|
||||
# return function(key: SumStats::Key, result: SumStats::Result): count
|
||||
# {
|
||||
# print fmt("data_id: %s", data_id);
|
||||
# print result;
|
||||
# return double_to_count(result[data_id]$sum);
|
||||
# };
|
||||
# }
|
||||
|
||||
hook init_resultval_hook(r: Reducer, rv: ResultVal)
|
||||
{
|
||||
|
@ -34,10 +34,12 @@ hook init_resultval_hook(r: Reducer, rv: ResultVal)
|
|||
rv$sum = 0;
|
||||
}
|
||||
|
||||
hook observe_hook(r: Reducer, val: double, obs: Observation, rv: ResultVal)
|
||||
hook register_observe_plugins()
|
||||
{
|
||||
if ( SUM in r$apply )
|
||||
register_observe_plugin(SUM, function(r: Reducer, val: double, obs: Observation, rv: ResultVal)
|
||||
{
|
||||
rv$sum += val;
|
||||
});
|
||||
}
|
||||
|
||||
hook compose_resultvals_hook(result: ResultVal, rv1: ResultVal, rv2: ResultVal)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue