mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Measurement framework is ready for testing.
- New, expanded API. - Calculations moved into plugins. - Scripts using measurement framework ported. - Updated the script-land queue implementation to make it more generic. -
This commit is contained in:
parent
93eca70e6b
commit
b477d2b02d
11 changed files with 183 additions and 186 deletions
|
@ -255,6 +255,11 @@ function reset(m: Measurement)
|
|||
|
||||
function create(m: Measurement)
|
||||
{
|
||||
if ( (m?$threshold || m?$threshold_series) && ! m?$threshold_val )
|
||||
{
|
||||
Reporter::error("Measurement given a threshold with no $threshold_val function");
|
||||
}
|
||||
|
||||
if ( ! m?$id )
|
||||
m$id=unique_id("");
|
||||
local tmp: table[Key] of Thresholding = table();
|
||||
|
@ -365,9 +370,6 @@ function threshold_crossed(m: Measurement, key: Key, result: Result)
|
|||
if ( ! m?$threshold_crossed )
|
||||
return;
|
||||
|
||||
#if ( val?$sample_queue )
|
||||
# val$samples = Queue::get_str_vector(val$sample_queue);
|
||||
|
||||
# Add in the extra ResultVals to make threshold_crossed callbacks easier to write.
|
||||
if ( |m$reducers| != |result| )
|
||||
{
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
@load base/utils/queue
|
||||
|
||||
module Measurement;
|
||||
|
||||
|
@ -29,7 +30,10 @@ hook add_to_reducer_hook(r: Reducer, val: double, data: DataPoint, rv: ResultVal
|
|||
{
|
||||
if ( ! rv?$sample_queue )
|
||||
rv$sample_queue = Queue::init([$max_len=r$samples]);
|
||||
Queue::push(rv$sample_queue, data$str);
|
||||
if ( ! rv?$samples )
|
||||
rv$samples = vector();
|
||||
Queue::put(rv$sample_queue, data);
|
||||
Queue::get_vector(rv$sample_queue, rv$samples);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,12 @@ function sum_threshold(data_id: string): threshold_function
|
|||
};
|
||||
}
|
||||
|
||||
hook init_resultval_hook(r: Reducer, rv: ResultVal)
|
||||
{
|
||||
if ( SUM in r$apply && ! rv?$sum )
|
||||
rv$sum = 0;
|
||||
}
|
||||
|
||||
hook add_to_reducer_hook(r: Reducer, val: double, data: DataPoint, rv: ResultVal)
|
||||
{
|
||||
if ( SUM in r$apply )
|
||||
|
|
|
@ -10,7 +10,7 @@ export {
|
|||
redef record ResultVal += {
|
||||
## If cardinality is being tracked, the number of unique
|
||||
## items is tracked here.
|
||||
unique: count &optional;
|
||||
unique: count &default=0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue