mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00

- 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
38 lines
723 B
Text
38 lines
723 B
Text
@load ../main
|
|
|
|
module SumStats;
|
|
|
|
export {
|
|
redef enum Calculation += {
|
|
## Find the maximum value.
|
|
MAX
|
|
};
|
|
|
|
redef record ResultVal += {
|
|
## For numeric data, this tracks the maximum value given.
|
|
max: double &optional;
|
|
};
|
|
}
|
|
|
|
hook register_observe_plugins()
|
|
{
|
|
register_observe_plugin(MAX, function(r: Reducer, val: double, obs: Observation, rv: ResultVal)
|
|
{
|
|
if ( ! rv?$max )
|
|
rv$max = val;
|
|
else if ( val > rv$max )
|
|
rv$max = val;
|
|
});
|
|
}
|
|
|
|
hook compose_resultvals_hook(result: ResultVal, rv1: ResultVal, rv2: ResultVal)
|
|
{
|
|
if ( rv1?$max && rv2?$max )
|
|
result$max = (rv1$max > rv2$max) ? rv1$max : rv2$max;
|
|
else if ( rv1?$max )
|
|
result$max = rv1$max;
|
|
else if ( rv2?$max )
|
|
result$max = rv2$max;
|
|
}
|
|
|
|
|