sign: stats infra extended for sign stats

This commit is contained in:
Srivats P 2016-08-22 23:26:33 +05:30
parent fdceca71e8
commit 10559c2a56
6 changed files with 78 additions and 0 deletions

View File

@ -170,6 +170,13 @@ QVariant PortStatsModel::data(const QModelIndex &index, int role) const
case e_STAT_BYTES_SENT_NIC:
return stats.tx_bytes_nic();
#endif
// Sign Stats
case e_STAT_SIGN_FRAMES_RCVD:
return quint64(stats.sign().rx_pkts());
case e_STAT_SIGN_FRAMES_SENT:
return quint64(stats.sign().tx_pkts());
// TODO: Other sign stats
case e_STAT_RX_DROPS : return quint64(stats.rx_drops());
case e_STAT_RX_ERRORS: return quint64(stats.rx_errors());
case e_STAT_RX_FIFO_ERRORS: return quint64(stats.rx_fifo_errors());

View File

@ -60,12 +60,18 @@ typedef enum {
e_STAT_BYTES_SENT_NIC,
#endif
// Sign Stats
e_STAT_SIGN_FRAMES_RCVD,
e_STAT_SIGN_FRAMES_SENT,
// TODO: Other sign stats
// Rx Errors
e_STAT_RX_DROPS,
e_STAT_RX_ERRORS,
e_STAT_RX_FIFO_ERRORS,
e_STAT_RX_FRAME_ERRORS,
e_STATISTICS_END = e_STAT_RX_FRAME_ERRORS,
e_STAT_MAX
@ -92,6 +98,10 @@ static QStringList PortStatName = (QStringList()
<< "Bytes Received (NIC)"
<< "Bytes Sent (NIC)"
#endif
<< "(Sign) Frames Received"
<< "(Sign) Frames Sent"
<< "Receive Drops"
<< "Receive Errors"
<< "Receive Fifo Errors"

View File

@ -235,6 +235,19 @@ message PortState {
optional bool is_capture_on = 3 [default = false];
}
message Stats {
// FIXME: change tag numbers?
optional uint64 rx_pkts = 11;
optional uint64 rx_bytes = 12;
optional uint64 rx_pps = 15;
optional uint64 rx_bps = 16;
optional uint64 tx_pkts = 21;
optional uint64 tx_bytes = 22;
optional uint64 tx_pps = 25;
optional uint64 tx_bps = 26;
}
message PortStats {
required PortId port_id = 1;
@ -259,6 +272,8 @@ message PortStats {
optional uint64 rx_errors = 101;
optional uint64 rx_fifo_errors = 102;
optional uint64 rx_frame_errors = 103;
optional Stats sign = 1000;
}
message PortStatsList {

View File

@ -615,6 +615,25 @@ void AbstractPort::stats(PortStats *stats)
stats->rxFrameErrors = (stats_.rxFrameErrors >= epochStats_.rxFrameErrors) ?
stats_.rxFrameErrors - epochStats_.rxFrameErrors :
stats_.rxFrameErrors + (maxStatsValue_ - epochStats_.rxFrameErrors);
// Sign stats
stats->sign.rxPkts = (stats_.sign.rxPkts >= epochStats_.sign.rxPkts) ?
stats_.sign.rxPkts - epochStats_.sign.rxPkts :
stats_.sign.rxPkts + (maxStatsValue_ - epochStats_.sign.rxPkts);
stats->sign.rxBytes = (stats_.sign.rxBytes >= epochStats_.sign.rxBytes) ?
stats_.sign.rxBytes - epochStats_.sign.rxBytes :
stats_.sign.rxBytes + (maxStatsValue_ - epochStats_.sign.rxBytes);
stats->sign.rxPps = stats_.sign.rxPps;
stats->sign.rxBps = stats_.sign.rxBps;
stats->sign.txPkts = (stats_.sign.txPkts >= epochStats_.sign.txPkts) ?
stats_.sign.txPkts - epochStats_.sign.txPkts :
stats_.sign.txPkts + (maxStatsValue_ - epochStats_.sign.txPkts);
stats->sign.txBytes = (stats_.sign.txBytes >= epochStats_.sign.txBytes) ?
stats_.sign.txBytes - epochStats_.sign.txBytes :
stats_.sign.txBytes + (maxStatsValue_ - epochStats_.sign.txBytes);
stats->sign.txPps = stats_.sign.txPps;
stats->sign.txBps = stats_.sign.txBps;
}
void AbstractPort::clearDeviceNeighbors()

View File

@ -36,6 +36,19 @@ class QIODevice;
class AbstractPort
{
public:
struct Stats
{
quint64 rxPkts;
quint64 rxBytes;
quint64 rxPps;
quint64 rxBps;
quint64 txPkts;
quint64 txBytes;
quint64 txPps;
quint64 txBps;
};
struct PortStats
{
quint64 rxPkts;
@ -52,6 +65,8 @@ public:
quint64 txBytes;
quint64 txPps;
quint64 txBps;
Stats sign;
};
enum Accuracy

View File

@ -492,6 +492,7 @@ void MyService::getStats(::google::protobuf::RpcController* /*controller*/,
AbstractPort::PortStats stats;
OstProto::PortStats *s;
OstProto::PortState *st;
OstProto::Stats *sign;
portId = request->port_id(i).id();
if ((portId < 0) || (portId >= portInfo.size()))
@ -528,6 +529,17 @@ void MyService::getStats(::google::protobuf::RpcController* /*controller*/,
s->set_rx_errors(stats.rxErrors);
s->set_rx_fifo_errors(stats.rxFifoErrors);
s->set_rx_frame_errors(stats.rxFrameErrors);
sign = s->mutable_sign();
sign->set_rx_pkts(stats.sign.rxPkts);
sign->set_rx_bytes(stats.sign.rxBytes);
sign->set_rx_pps(stats.sign.rxPps);
sign->set_rx_bps(stats.sign.rxBps);
sign->set_tx_pkts(stats.sign.txPkts);
sign->set_tx_bytes(stats.sign.txBytes);
sign->set_tx_pps(stats.sign.txPps);
sign->set_tx_bps(stats.sign.txBps);
}
done->Run();