@Override public Long getValue() { return getSnapshot().getTxBytes(); } });
long txBytes = net.getTxBytes();
.put("sys/net/read/overruns", netstat.getRxOverruns()) .put("sys/net/read/frame", netstat.getRxFrame()) .put("sys/net/write/size", netstat.getTxBytes()) .put("sys/net/write/packets", netstat.getTxPackets()) .put("sys/net/write/errors", netstat.getTxErrors())
netInterfaceStat.getTxCollisions(), netInterfaceStat.getRxBytes(), netInterfaceStat.getTxBytes()); final NetInterfaceConfig netInterfaceConfig = sigar.getNetInterfaceConfig(interfaceName);
long txBytes = ifstat.getTxBytes();
long rxCurrenttmp = netStat.getRxBytes(); saveChange(rxCurrentMap, rxChangeMap, hwaddr, rxCurrenttmp, ni); long txCurrenttmp = netStat.getTxBytes(); saveChange(txCurrentMap, txChangeMap, hwaddr, txCurrenttmp, ni);
/** * Get the current network usage. * * @return BandWith * @throws SigarException thrown when the underlying lib is not linked */ public BandWidth getNetworkUsage() throws SigarException { BandWidth bandWidth = new BandWidth(System.currentTimeMillis()); for (String each : netInterfaces) { try { NetInterfaceStat netInterfaceStat = sigar.getNetInterfaceStat(each); bandWidth.setReceived(bandWidth.getReceived() + netInterfaceStat.getRxBytes()); bandWidth.setSent(bandWidth.getSent() + netInterfaceStat.getTxBytes()); } catch (Exception e) { NoOp.noOp(); } } return bandWidth; }
@Override public double extract(NetInterfaceStat prev, NetInterfaceStat last) { return last.getTxBytes() - prev.getTxBytes(); } },
@Override public Long getValue() { return getSnapshot().getTxBytes(); } });
@Override public Long getValue() throws Exception { return sigar.getNetInterfaceStat(interfaceName).getTxBytes(); } };
@Override public long computeValue() throws SigarException { return sigar.getNetInterfaceStat(interfaceName).getTxBytes() - initialTxBytes; } });
@Override public Double getValue() { try { if (Config.getConfig().metrics_console_rate == 0) return -1.; NetInterfaceStat interfaceStat = sigar.getNetInterfaceStat( Config.getConfig() .network_interface_monitor); long now = System.currentTimeMillis(); long currentTCPOutboundTotal = interfaceStat.getTxBytes(); double ret = 0; if (lastTCPOutboundTimestamp != 0 && now - lastTCPOutboundTimestamp != 0) { ret = ((double) (currentTCPOutboundTotal - lastTCPOutboundTotal)) / TimeUnit.SECONDS .convert(now - lastTCPOutboundTimestamp, TimeUnit.MILLISECONDS); } lastTCPOutboundTotal = currentTCPOutboundTotal; lastTCPOutboundTimestamp = now; return ret; } catch (SigarException e) { logger.error("TCP Outbound Metrics error: ", e); } return 0.; } });
@Override public float poll() throws SigarException { NetInterfaceStat ifstat = this.sigarWrapper.getSigarInstance() .getNetInterfaceStat( ifName ); long txBytes = fixLongValue( fixOverflow( getName(), ifstat.getTxBytes() ) ); double result; if( txBytes >= 0 ) { result = ( txBytes - this.lastLongValue ) * normalizationFactor; this.lastLongValue = txBytes; } else { return -1.0F; } // calculate TX bytes per second result = result / ( ( double ) getElapsedTime() / 1000 ); return new BigDecimal( result ).setScale( 2, BigDecimal.ROUND_DOWN ).floatValue(); } } );
outgoingNetworkTraffic = ifstat.getTxBytes(); incomingNetworkTrafficMap.put(name, incomingNetworkTraffic); outgoingNetworkTrafficMap.put(name, outgoingNetworkTraffic);
@Override public TcpData getTcpData() { TcpData data = new TcpData(); try { NetStat stat = sigar.getNetStat(); data.setTcpBound(stat.getTcpBound()); data.setTcpEstablished(stat.getTcpEstablished()); data.setTcpIdle(stat.getTcpIdle()); data.setTcpListen(stat.getTcpListen()); data.setTcpSynchronizedReceived(stat.getTcpSynRecv()); long inboundBytes = 0; long outboundBytes = 0; for(String netInterface : sigar.getNetInterfaceList()) { for(String mask : interfaceNames) { if(netInterface.matches(mask)) { inboundBytes += sigar.getNetInterfaceStat(netInterface).getRxBytes(); outboundBytes += sigar.getNetInterfaceStat(netInterface).getTxBytes(); } } } data.setTcpInboundTotal(inboundBytes); data.setTcpOutboundTotal(outboundBytes); logger.debug("getTcpData: {}", data); } catch (SigarException e) { logger.warn("Exception during getTcpData", e); } return data; }
public NetworkAdapterStats(NetInterfaceStat nis) { this.rxBytes = nis.getRxBytes(); this.rxPackets = nis.getRxPackets(); this.rxErrors = nis.getRxErrors(); this.rxDropped = nis.getRxDropped(); this.rxOverruns = nis.getRxOverruns(); this.rxFrame = nis.getRxFrame(); this.txBytes = nis.getTxBytes(); this.txPackets = nis.getTxPackets(); this.txErrors = nis.getTxErrors(); this.txDropped = nis.getTxDropped(); this.txOverruns = nis.getTxOverruns(); this.txCollisions = nis.getTxCollisions(); this.txCarrier = nis.getTxCarrier(); }
public NetworkAdapterStats(NetInterfaceStat nis) { this.rxBytes = nis.getRxBytes(); this.rxPackets = nis.getRxPackets(); this.rxErrors = nis.getRxErrors(); this.rxDropped = nis.getRxDropped(); this.rxOverruns = nis.getRxOverruns(); this.rxFrame = nis.getRxFrame(); this.txBytes = nis.getTxBytes(); this.txPackets = nis.getTxPackets(); this.txErrors = nis.getTxErrors(); this.txDropped = nis.getTxDropped(); this.txOverruns = nis.getTxOverruns(); this.txCollisions = nis.getTxCollisions(); this.txCarrier = nis.getTxCarrier(); }
private NetworkStatistic getCurrentNetworkStatistic(final ITimeSource timesource, final String interfaceName) throws SigarException { final long currentTimestamp = timesource.getTime(); final NetInterfaceStat interfaceStat = this.sigar.getNetInterfaceStat(interfaceName); final long speed = interfaceStat.getSpeed(); final long txBytes = interfaceStat.getTxBytes(); final long txCarrier = interfaceStat.getTxCarrier(); final long txCollisions = interfaceStat.getTxCollisions(); final long txDropped = interfaceStat.getTxDropped(); final long txErrors = interfaceStat.getTxErrors(); final long txOverruns = interfaceStat.getTxOverruns(); final long txPackets = interfaceStat.getTxPackets(); final long rxBytes = interfaceStat.getRxBytes(); final long rxDropped = interfaceStat.getRxDropped(); final long rxErrors = interfaceStat.getRxErrors(); final long rxFrame = interfaceStat.getRxFrame(); final long rxOverruns = interfaceStat.getRxOverruns(); final long rxPackets = interfaceStat.getRxPackets(); return new NetworkStatistic(currentTimestamp, speed, txBytes, txCarrier, txCollisions, txDropped, txErrors, txOverruns, txPackets, rxBytes, rxDropped, rxErrors, rxFrame, rxOverruns, rxPackets); }
private NetworkStatistic getCurrentNetworkStatistic(final ITimeSource timesource, final String interfaceName) throws SigarException { final long currentTimestamp = timesource.getTime(); final NetInterfaceStat interfaceStat = this.sigar.getNetInterfaceStat(interfaceName); final long speed = interfaceStat.getSpeed(); final long txBytes = interfaceStat.getTxBytes(); final long txCarrier = interfaceStat.getTxCarrier(); final long txCollisions = interfaceStat.getTxCollisions(); final long txDropped = interfaceStat.getTxDropped(); final long txErrors = interfaceStat.getTxErrors(); final long txOverruns = interfaceStat.getTxOverruns(); final long txPackets = interfaceStat.getTxPackets(); final long rxBytes = interfaceStat.getRxBytes(); final long rxDropped = interfaceStat.getRxDropped(); final long rxErrors = interfaceStat.getRxErrors(); final long rxFrame = interfaceStat.getRxFrame(); final long rxOverruns = interfaceStat.getRxOverruns(); final long rxPackets = interfaceStat.getRxPackets(); return new NetworkStatistic(currentTimestamp, speed, txBytes, txCarrier, txCollisions, txDropped, txErrors, txOverruns, txPackets, rxBytes, rxDropped, rxErrors, rxFrame, rxOverruns, rxPackets); }
network.setTxBytes(stats.getTxBytes()); network.setTxCarrier(stats.getTxCarrier()); network.setTxCollisions(stats.getTxCollisions());