mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 23:28:20 +00:00
Changed netstats (packet loss) handling to script-land.
- Removed the net_stats_update event. - Created a net_stats function for building and retrieving the current network statistics. - Removed the internal timer for firing the net_stats_update event along with the global heartbeat_interval variable. - Updated the netstats script to use the new BiF. - Updated the stats script to use the new BiF.
This commit is contained in:
parent
871eff9f90
commit
c60015af22
10 changed files with 75 additions and 174 deletions
|
@ -44,27 +44,6 @@ enum NetBIOS_Service {
|
|||
|
||||
NetSessions* sessions;
|
||||
|
||||
|
||||
class NetworkTimer : public Timer {
|
||||
public:
|
||||
NetworkTimer(NetSessions* arg_sess, double arg_t)
|
||||
: Timer(arg_t, TIMER_NETWORK)
|
||||
{ sess = arg_sess; }
|
||||
|
||||
void Dispatch(double t, int is_expire);
|
||||
|
||||
protected:
|
||||
NetSessions* sess;
|
||||
};
|
||||
|
||||
void NetworkTimer::Dispatch(double t, int is_expire)
|
||||
{
|
||||
if ( is_expire )
|
||||
return;
|
||||
|
||||
sess->HeartBeat(t);
|
||||
}
|
||||
|
||||
void TimerMgrExpireTimer::Dispatch(double t, int is_expire)
|
||||
{
|
||||
if ( mgr->LastAdvance() + timer_mgr_inactivity_timeout < timer_mgr->Time() )
|
||||
|
@ -106,9 +85,6 @@ NetSessions::NetSessions()
|
|||
udp_conns.SetDeleteFunc(bro_obj_delete_func);
|
||||
fragments.SetDeleteFunc(bro_obj_delete_func);
|
||||
|
||||
if ( (reading_live || pseudo_realtime) && net_stats_update )
|
||||
timer_mgr->Add(new NetworkTimer(this, 1.0));
|
||||
|
||||
if ( stp_correlate_pair )
|
||||
stp_manager = new SteppingStoneManager();
|
||||
else
|
||||
|
@ -1085,39 +1061,6 @@ void NetSessions::Drain()
|
|||
ExpireTimerMgrs();
|
||||
}
|
||||
|
||||
void NetSessions::HeartBeat(double t)
|
||||
{
|
||||
unsigned int recv = 0;
|
||||
unsigned int drop = 0;
|
||||
unsigned int link = 0;
|
||||
|
||||
loop_over_list(pkt_srcs, i)
|
||||
{
|
||||
PktSrc* ps = pkt_srcs[i];
|
||||
|
||||
struct PktSrc::Stats stat;
|
||||
ps->Statistics(&stat);
|
||||
recv += stat.received;
|
||||
drop += stat.dropped;
|
||||
link += stat.link;
|
||||
}
|
||||
|
||||
val_list* vl = new val_list;
|
||||
|
||||
vl->append(new Val(t, TYPE_TIME));
|
||||
|
||||
RecordVal* ns = new RecordVal(net_stats);
|
||||
ns->Assign(0, new Val(recv, TYPE_COUNT));
|
||||
ns->Assign(1, new Val(drop, TYPE_COUNT));
|
||||
ns->Assign(2, new Val(link, TYPE_COUNT));
|
||||
|
||||
vl->append(ns);
|
||||
|
||||
mgr.QueueEvent(net_stats_update, vl);
|
||||
|
||||
timer_mgr->Add(new NetworkTimer(this, t + heartbeat_interval));
|
||||
}
|
||||
|
||||
void NetSessions::GetStats(SessionStats& s) const
|
||||
{
|
||||
s.num_TCP_conns = tcp_conns.Length();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue