Added support for rx error stats on Linux.
Updates issue 28
This commit is contained in:
parent
8ef427b0fd
commit
88cb294567
@ -166,6 +166,11 @@ QVariant PortStatsModel::data(const QModelIndex &index, int role) const
|
||||
case e_STAT_BYTES_SENT_NIC:
|
||||
return stats.tx_bytes_nic();
|
||||
#endif
|
||||
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());
|
||||
case e_STAT_RX_FRAME_ERRORS: return quint64(stats.rx_frame_errors());
|
||||
|
||||
default:
|
||||
qWarning("%s: Unhandled stats id %d\n", __FUNCTION__,
|
||||
index.row());
|
||||
|
@ -53,7 +53,13 @@ typedef enum {
|
||||
e_STAT_BYTES_SENT_NIC,
|
||||
#endif
|
||||
|
||||
e_STATISTICS_END = e_STAT_BYTE_RECV_RATE,
|
||||
// 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
|
||||
} PortStat;
|
||||
@ -77,6 +83,10 @@ static QStringList PortStatName = (QStringList()
|
||||
<< "Bytes Received (NIC)"
|
||||
<< "Bytes Sent (NIC)"
|
||||
#endif
|
||||
<< "Receive Drops"
|
||||
<< "Receive Errors"
|
||||
<< "Receive Fifo Errors"
|
||||
<< "Receive Frame Errors"
|
||||
);
|
||||
|
||||
static QStringList LinkStateName = (QStringList()
|
||||
|
@ -214,6 +214,11 @@ message PortStats {
|
||||
optional uint64 tx_bytes_nic = 24;
|
||||
optional uint64 tx_pps = 25;
|
||||
optional uint64 tx_bps = 26;
|
||||
|
||||
optional uint64 rx_drops = 100;
|
||||
optional uint64 rx_errors = 101;
|
||||
optional uint64 rx_fifo_errors = 102;
|
||||
optional uint64 rx_frame_errors = 103;
|
||||
}
|
||||
|
||||
message PortStatsList {
|
||||
|
@ -551,4 +551,9 @@ void AbstractPort::stats(PortStats *stats)
|
||||
stats->txBytes = stats_.txBytes - epochStats_.txBytes;
|
||||
stats->txPps = stats_.txPps;
|
||||
stats->txBps = stats_.txBps;
|
||||
|
||||
stats->rxDrops = stats_.rxDrops - epochStats_.rxDrops;
|
||||
stats->rxErrors = stats_.rxErrors - epochStats_.rxErrors;
|
||||
stats->rxFifoErrors = stats_.rxFifoErrors - epochStats_.rxFifoErrors;
|
||||
stats->rxFrameErrors = stats_.rxFrameErrors - epochStats_.rxFrameErrors;
|
||||
}
|
||||
|
@ -38,6 +38,11 @@ public:
|
||||
quint64 rxPps;
|
||||
quint64 rxBps;
|
||||
|
||||
quint64 rxDrops;
|
||||
quint64 rxErrors;
|
||||
quint64 rxFifoErrors;
|
||||
quint64 rxFrameErrors;
|
||||
|
||||
quint64 txPkts;
|
||||
quint64 txBytes;
|
||||
quint64 txPps;
|
||||
|
@ -132,8 +132,8 @@ void LinuxPort::StatsMonitor::run()
|
||||
char *p, *end;
|
||||
int count, index;
|
||||
const char* fmtopt[] = {
|
||||
"%llu%llu%u%u%u%u%u%u%llu%llu%u%u%u%u%u%u\n",
|
||||
"%llu%llu%u%u%u%u%n%n%llu%llu%u%u%u%u%u%n\n",
|
||||
"%llu%llu%llu%llu%llu%llu%u%u%llu%llu%u%u%u%u%u%u\n",
|
||||
"%llu%llu%llu%llu%llu%llu%n%n%llu%llu%u%u%u%u%u%n\n",
|
||||
};
|
||||
const char *fmt;
|
||||
struct ifreq ifr;
|
||||
@ -299,6 +299,7 @@ void LinuxPort::StatsMonitor::run()
|
||||
{
|
||||
uint dummy;
|
||||
quint64 rxBytes, rxPkts;
|
||||
quint64 rxErrors, rxDrops, rxFifo, rxFrame;
|
||||
quint64 txBytes, txPkts;
|
||||
|
||||
// Skip interface name - we assume the number and order of ports
|
||||
@ -315,8 +316,10 @@ void LinuxPort::StatsMonitor::run()
|
||||
p++;
|
||||
|
||||
sscanf(p, fmt,
|
||||
&rxBytes, &rxPkts, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy,
|
||||
&txBytes, &txPkts, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy);
|
||||
&rxBytes, &rxPkts, &rxErrors, &rxDrops, &rxFifo, &rxFrame,
|
||||
&dummy, &dummy,
|
||||
&txBytes, &txPkts, &dummy, &dummy, &dummy, &dummy, &dummy,
|
||||
&dummy);
|
||||
|
||||
if (index < count)
|
||||
{
|
||||
@ -331,6 +334,11 @@ void LinuxPort::StatsMonitor::run()
|
||||
stats->txBps = (txBytes - stats->txBytes)/kRefreshFreq_;
|
||||
stats->txPkts = txPkts;
|
||||
stats->txBytes = txBytes;
|
||||
|
||||
stats->rxDrops = rxDrops;
|
||||
stats->rxErrors = rxErrors;
|
||||
stats->rxFifoErrors = rxFifo;
|
||||
stats->rxFrameErrors = rxFrame;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -441,6 +441,11 @@ void MyService::getStats(::google::protobuf::RpcController* /*controller*/,
|
||||
s->set_tx_bytes(stats.txBytes);
|
||||
s->set_tx_pps(stats.txPps);
|
||||
s->set_tx_bps(stats.txBps);
|
||||
|
||||
s->set_rx_drops(stats.rxDrops);
|
||||
s->set_rx_errors(stats.rxErrors);
|
||||
s->set_rx_fifo_errors(stats.rxFifoErrors);
|
||||
s->set_rx_frame_errors(stats.rxFrameErrors);
|
||||
}
|
||||
|
||||
done->Run();
|
||||
|
Loading…
Reference in New Issue
Block a user