Now the standalone sumstats works even if Bro is shutting down by blocking.

This commit is contained in:
Seth Hall 2014-03-17 16:45:36 -04:00
parent af36915186
commit a07a40dc86
2 changed files with 15 additions and 4 deletions

View file

@ -37,7 +37,19 @@ event SumStats::finish_epoch(ss: SumStat)
if ( ss?$epoch_result )
{
local data = result_store[ss$name];
event SumStats::process_epoch_result(ss, network_time(), data);
local now = network_time();
if ( bro_is_terminating() )
{
for ( key in data )
ss$epoch_result(now, key, data[key]);
if ( ss?$epoch_finished )
ss$epoch_finished(now);
}
else
{
event SumStats::process_epoch_result(ss, now, data);
}
}
# We can reset here because we know that the reference

View file

@ -23,8 +23,7 @@ event bro_init() &priority=5
local r = result["test.metric"];
print fmt("Host: %s - num:%d - sum:%.1f - var:%.1f - avg:%.1f - max:%.1f - min:%.1f - std_dev:%.1f - unique:%d - hllunique:%d", key$host, r$num, r$sum, r$variance, r$average, r$max, r$min, r$std_dev, r$unique, r$hll_unique);
terminate();
}
])
}]);
SumStats::observe("test.metric", [$host=1.2.3.4], [$num=5]);
SumStats::observe("test.metric", [$host=1.2.3.4], [$num=22]);