From 10559c2a56672731fc6fceabcc4fec80c1fd3929 Mon Sep 17 00:00:00 2001 From: Srivats P Date: Mon, 22 Aug 2016 23:26:33 +0530 Subject: [PATCH] sign: stats infra extended for sign stats --- client/portstatsmodel.cpp | 7 +++++++ client/portstatsmodel.h | 10 ++++++++++ common/protocol.proto | 15 +++++++++++++++ server/abstractport.cpp | 19 +++++++++++++++++++ server/abstractport.h | 15 +++++++++++++++ server/myservice.cpp | 12 ++++++++++++ 6 files changed, 78 insertions(+) diff --git a/client/portstatsmodel.cpp b/client/portstatsmodel.cpp index 94a88c2..3acd61d 100644 --- a/client/portstatsmodel.cpp +++ b/client/portstatsmodel.cpp @@ -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()); diff --git a/client/portstatsmodel.h b/client/portstatsmodel.h index b3e4ed2..bcd86b1 100644 --- a/client/portstatsmodel.h +++ b/client/portstatsmodel.h @@ -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" diff --git a/common/protocol.proto b/common/protocol.proto index 439d28f..6e25f5a 100644 --- a/common/protocol.proto +++ b/common/protocol.proto @@ -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 { diff --git a/server/abstractport.cpp b/server/abstractport.cpp index 0a97ff9..899f530 100644 --- a/server/abstractport.cpp +++ b/server/abstractport.cpp @@ -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() diff --git a/server/abstractport.h b/server/abstractport.h index 939e701..0ecea70 100644 --- a/server/abstractport.h +++ b/server/abstractport.h @@ -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 diff --git a/server/myservice.cpp b/server/myservice.cpp index 6ba4f15..a2b9eda 100644 --- a/server/myservice.cpp +++ b/server/myservice.cpp @@ -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();