private long getEgressValue(PortStatistics stats, MetricType metricType) { return metricType == MetricType.BYTES ? stats.bytesSent() : stats.packetsSent(); }
@Override public ObjectNode encode(PortStatistics entry, CodecContext context) { checkNotNull(entry, "Port Statistics cannot be null"); final ObjectNode result = context.mapper().createObjectNode() .put("port", entry.port()) .put("packetsReceived", entry.packetsReceived()) .put("packetsSent", entry.packetsSent()) .put("bytesReceived", entry.bytesReceived()) .put("bytesSent", entry.bytesSent()) .put("packetsRxDropped", entry.packetsRxDropped()) .put("packetsTxDropped", entry.packetsTxDropped()) .put("packetsRxErrors", entry.packetsRxErrors()) .put("packetsTxErrors", entry.packetsTxErrors()) .put("durationSec", entry.durationSec()); return annotate(result, entry, context); }
(((float) stat.durationNano()) / TimeUnit.SECONDS.toNanos(1)); float rateRx = stat.bytesReceived() * 8 / duration; float rateTx = stat.bytesSent() * 8 / duration; print(formatDelta, stat.portNumber(), stat.packetsReceived(), stat.packetsSent(), stat.bytesReceived(), stat.bytesSent(), String.format("%.1f", rateRx), String.format("%.1f", rateTx),
(((float) stat.durationNano()) / TimeUnit.SECONDS.toNanos(1)); float rateRx = duration > 0 ? stat.bytesReceived() * 8 / duration : 0; float rateTx = duration > 0 ? stat.bytesSent() * 8 / duration : 0; print(formatDeltaTable, stat.portNumber(), humanReadable(stat.packetsReceived()), humanReadable(stat.packetsRxDropped()), humanReadable(stat.packetsSent()), humanReadable(stat.bytesSent()), humanReadableBps(rateTx), humanReadable(stat.packetsTxDropped()),
/** * Prints Port Statistics. * * @param deviceId * @param portStats */ private void printPortStats(DeviceId deviceId, Iterable<PortStatistics> portStats) { print("deviceId=%s", deviceId); for (PortStatistics stat : sortByPort(portStats)) { if (isIrrelevant(stat)) { continue; } if (nonzero && stat.isZero()) { continue; } print(FORMAT, stat.portNumber(), stat.packetsReceived(), stat.packetsSent(), stat.bytesReceived(), stat.bytesSent(), stat.packetsRxDropped(), stat.packetsTxDropped(), stat.durationSec(), annotations(stat.annotations())); } }