9#include "daq/rfarm/manager/RFFlowStat.h"
15RFFlowStat::RFFlowStat(
const char* shmname,
int id,
RingBuffer* rbuf)
18 m_cell = &(m_rfshm->GetCell(
id));
23 gettimeofday(&m_t0, 0);
26RFFlowStat::RFFlowStat(
const char* shmname)
31RFFlowStat::~RFFlowStat()
36void RFFlowStat::log(
int size)
42 m_cell->nqueue = m_rbuf->
numq();
45 m_flowsize += (float)size;
47 if (m_cell->nevent % m_interval == 0) {
48 gettimeofday(&tnow, 0);
49 float delta = (float)((tnow.tv_sec - m_t0.tv_sec) * 1000000 +
50 (tnow.tv_usec - m_t0.tv_usec));
51 m_cell->flowrate = m_flowsize / delta;
53 m_cell->avesize = m_flowsize / (float)m_nevtint / 1000.0;
54 m_cell->evtrate = (float)m_nevtint / delta * 1000000.0;
55 m_cell->elapsed = time(NULL);
61void RFFlowStat::clear(
int cellid)
75 return m_rfshm->GetCell(
id);
78void RFFlowStat::fillNodeInfo(
int id,
RfNodeInfo* info,
bool outflag)
83 info->nevent_in = cell.nevent;
84 info->nqueue_in = cell.nqueue;
85 info->flowrate_in = cell.flowrate;
86 info->avesize_in = cell.avesize;
87 info->evtrate_in = cell.evtrate;
89 info->nevent_out = cell.nevent;
90 info->nqueue_out = cell.nqueue;
91 info->flowrate_out = cell.flowrate;
92 info->avesize_out = cell.avesize;
93 info->evtrate_out = cell.evtrate;
96 if (getloadavg(loads, 3) > 0)
97 info->loadave = (float)loads[0];
109void RFFlowStat::fillProcessStatus(
RfNodeInfo* info,
int input,
int output,
int basf2,
int hserver,
int hrelay)
111 info->pid_input = input;
112 info->pid_output = output;
113 info->pid_basf2 = basf2;
114 info->pid_hserver = hserver;
115 info->pid_hrelay = hrelay;
Class to manage a Ring Buffer placed in an IPC shared memory.
int numq() const
Returns number of entries/buffers in the RingBuffer.
Abstract base class for different kinds of events.