Refine search
ifaces = sigar.getNetInterfaceList(); NetInterfaceConfig netconf = null; try { netconf = sigar.getNetInterfaceConfig(name); NetInterfaceStat netstat = null; try { netstat = sigar.getNetInterfaceStat(name); name, ImmutableMap.<String, Long>builder() .put("sys/net/read/size", netstat.getRxBytes()) .put("sys/net/read/packets", netstat.getRxPackets()) .put("sys/net/read/errors", netstat.getRxErrors()) .put("sys/net/read/dropped", netstat.getRxDropped()) .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()) .put("sys/net/write/dropped", netstat.getTxDropped()) .put("sys/net/write/collisions", netstat.getTxCollisions()) .put("sys/net/write/overruns", netstat.getTxOverruns()) .build() );
long rxBytes = net.getRxBytes(); long txBytes = net.getTxBytes();
public synchronized OSStatistics probeStatistics() throws Exception { String[] ifs = sigar.getNetInterfaceList(); List<OSStatistics.OSNetInterfaceStats> netStats = new ArrayList<OSStatistics.OSNetInterfaceStats>(); for (String anIf : ifs) { if (failureCount == null || failureCount < 3) { try { NetInterfaceStat stat = sigar.getNetInterfaceStat(anIf); netStats.add(new OSStatistics.OSNetInterfaceStats(anIf, stat.getRxBytes(), stat.getTxBytes(), stat.getRxPackets(), stat.getTxPackets(), stat.getRxErrors(), stat.getTxErrors(), stat.getRxDropped(), stat.getTxDropped())); } catch (SigarException e) { if (failureCount == null) { Swap swap = sigar.getSwap(); Mem mem = sigar.getMem(); CpuPerc cpuPerc = sigar.getCpuPerc();
new NetworkData(new Sigar()); NetworkData.startMetricTest(); String info = sigar.getNetInfo().toString(); info += "\n"+ sigar.getNetInterfaceConfig().toString(); return info; long rxCurrenttmp = netStat.getRxBytes(); saveChange(rxCurrentMap, rxChangeMap, hwaddr, rxCurrenttmp, ni); long txCurrenttmp = netStat.getTxBytes(); saveChange(txCurrentMap, txChangeMap, hwaddr, txCurrenttmp, ni);
@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; }
CpuPerc cpuList[] = sigar.getCpuPercList(); double userSum = 0; double sysSum = 0; Map<String, Long> incomingNetworkTrafficMap = new HashMap<>(); Map<String, Long> outgoingNetworkTrafficMap = new HashMap<>(); String ifNames[] = sigar.getNetInterfaceList(); for (String name : ifNames) { NetInterfaceConfig ifconfig = sigar.getNetInterfaceConfig(name); if ((ifconfig.getFlags() & 1L) <= 0L) { logger.info("!IFF_UP...skipping getNetInterfaceStat"); NetInterfaceStat ifstat = sigar.getNetInterfaceStat(name); incomingNetworkTraffic = ifstat.getRxBytes(); outgoingNetworkTraffic = ifstat.getTxBytes(); incomingNetworkTrafficMap.put(name, incomingNetworkTraffic); outgoingNetworkTrafficMap.put(name, outgoingNetworkTraffic);
final String interfaceName, final Sigar sigar) throws SigarException NetInterfaceStat netInterfaceStat = sigar.getNetInterfaceStat(interfaceName); final long initialRxBytes = netInterfaceStat.getRxBytes(); final long initialRxPackets = netInterfaceStat.getRxPackets(); final long initialTxBytes = netInterfaceStat.getTxBytes(); final long initialTxPackets = netInterfaceStat.getTxPackets();
@Override public long computeValue() throws SigarException { return sigar.getNetInterfaceStat(interfaceName).getRxBytes() - initialRxBytes; } });
@Override public Long getValue() throws Exception { return sigar.getNetInterfaceStat(interfaceName).getTxBytes(); } };
if (getSnapshot().getRxOverruns() >= 0) { metrics.put(name("network_io").tag("ifname", ifname).type("read").unit("overruns").build(), new Gauge<Long>() { @Override if (getSnapshot().getRxFrame() >= 0) { metrics.put(name("network_io").tag("ifname", ifname).type("read").unit("frame").build(), new Gauge<Long>() { @Override if (getSnapshot().getTxOverruns() >= 0) { metrics.put(name("network_io").tag("ifname", ifname).type("write").unit("overruns").build(), new Gauge<Long>() { @Override if (getSnapshot().getTxCarrier() >= 0) { metrics.put(name("network_io").tag("ifname", ifname).type("write").unit("carrier").build(), new Gauge<Long>() { @Override
/** * 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 long computeValue() throws SigarException { return sigar.getNetInterfaceStat(interfaceName).getRxPackets() - initialRxPackets; } });
@Override public Long getValue() throws Exception { return sigar.getNetInterfaceStat(interfaceName).getTxPackets(); } };
@Override public Long getValue() { return getSnapshot().getRxBytes(); } });
@Override public Long getValue() { return getSnapshot().getTxBytes(); } });
@Override public Long getValue() throws Exception { return sigar.getNetInterfaceStat(interfaceName).getTxDropped(); } };
@Override public Long getValue() throws Exception { return sigar.getNetInterfaceStat(interfaceName).getRxErrors(); } };
@Override public Long getValue() throws Exception { return sigar.getNetInterfaceStat(interfaceName).getTxErrors(); } };
@Override public Long getValue() throws Exception { return sigar.getNetInterfaceStat(interfaceName).getRxDropped(); } };
@Override public Long getValue() { return getSnapshot().getTxPackets(); } });