Package org.hyperic.sigar

Examples of org.hyperic.sigar.NetInterfaceStat


     
      // Network Utilization
      netIf = sigar.getNetInterfaceList();
      JSONArray netInterfaces = new JSONArray();
      for (int i = 0; i < netIf.length; i++) {
        NetInterfaceStat net = new NetInterfaceStat();
        net = sigar.getNetInterfaceStat(netIf[i]);
        JSONObject netMap = new JSONObject();
        netMap.putAll(net.toMap());
        if(previousNetworkStats.containsKey(netIf[i])) {
          JSONObject deltaMap = previousNetworkStats.get(netIf[i]);
          deltaMap.put("RxBytes", Long.parseLong(netMap.get("RxBytes").toString()) - Long.parseLong(deltaMap.get("RxBytes").toString()));
          deltaMap.put("RxDropped", Long.parseLong(netMap.get("RxDropped").toString()) - Long.parseLong(deltaMap.get("RxDropped").toString()));
          deltaMap.put("RxErrors", Long.parseLong(netMap.get("RxErrors").toString()) - Long.parseLong(deltaMap.get("RxErrors").toString()));
View Full Code Here


        return adapters;
    }

    public NetworkAdapterStats getNetworkAdapterStats(String interfaceName) {
        try {
            NetInterfaceStat interfaceStat = sigar.getNetInterfaceStat(interfaceName);
            return new NetworkAdapterStats(interfaceStat);
        } catch (SigarException e) {
            throw new SystemInfoException(e);
        }
    }
View Full Code Here

        println("\t" +
                NetFlags.getIfFlagsString(flags) +
                " MTU:" + ifconfig.getMtu() +
                "  Metric:" + ifconfig.getMetric());
        try {
            NetInterfaceStat ifstat =
                this.sigar.getNetInterfaceStat(name);

            println("\t" +
                    "RX packets:" + ifstat.getRxPackets() +
                    " errors:" + ifstat.getRxErrors() +
                    " dropped:" + ifstat.getRxDropped() +
                    " overruns:" + ifstat.getRxOverruns() +
                    " frame:" + ifstat.getRxFrame());

            println("\t" +
                    "TX packets:" + ifstat.getTxPackets() +
                    " errors:" + ifstat.getTxErrors() +
                    " dropped:" + ifstat.getTxDropped() +
                    " overruns:" + ifstat.getTxOverruns() +
                    " carrier:" + ifstat.getTxCarrier());
            println("\t" + "collisions:" +
                    ifstat.getTxCollisions());

            long rxBytes = ifstat.getRxBytes();
            long txBytes = ifstat.getTxBytes();

            println("\t" +
                    "RX bytes:" + rxBytes +
                    " (" + Sigar.formatSize(rxBytes) + ")" +
                    "  " +
View Full Code Here

                traceln("!IFF_UP...skipping getNetInterfaceStat");
                continue;
            }

            try {
                NetInterfaceStat ifstat = sigar.getNetInterfaceStat(name);
                assertGtEqZeroTrace("RxPackets", ifstat.getRxPackets());
                assertGtEqZeroTrace("TxPackets", ifstat.getTxPackets());
                traceMethods(ifstat);
            } catch (SigarNotImplementedException e) {
                //ok
            } catch (SigarException e) {
                if (name.indexOf(':') == -1) {
View Full Code Here

  private List<DataEntity> buildNetworkInfo() {
    List<DataEntity> entities = new ArrayList<DataEntity>();

    for (String netInterface : m_envConfig.getTrafficInterfaceList()) {
      try {
        NetInterfaceStat curIfStat = m_sigar.getNetInterfaceStat(netInterface);
        NetInterfaceStat preIfStat = m_preIfStatMap.get(netInterface);

        if (preIfStat != null) {
          Map<String, Double> values = new HashMap<String, Double>();
          double totalRxBytes = curIfStat.getRxBytes() - preIfStat.getRxBytes();
          double totalTxBytes = curIfStat.getTxBytes() - preIfStat.getTxBytes();

          values.put(buildSystemId(netInterface + "-inFlow"), totalRxBytes);
          values.put(buildSystemId(netInterface + "-outFlow"), totalTxBytes);

          if (m_envConfig.getPackageInterface().equals(netInterface)) {
            double txDropped = curIfStat.getTxDropped() - preIfStat.getTxDropped();
            double txErrors = curIfStat.getTxErrors() - preIfStat.getTxErrors();
            double txCollisions = curIfStat.getTxCollisions() - preIfStat.getTxCollisions();

            values.put(buildSystemId(netInterface + "-dropped"), txDropped);
            values.put(buildSystemId(netInterface + "-errors"), txErrors);
            values.put(buildSystemId(netInterface + "-collisions"), txCollisions);
          }
View Full Code Here

        // if (netNames[i].toLowerCase().equals("lo")) {
        // continue;
        // }
        NetInterfaceConfig netConfig = sigar
            .getNetInterfaceConfig(netNames[i]);
        NetInterfaceStat netStat = sigar
            .getNetInterfaceStat(netNames[i]);
        netConfigs.put(netNames[i], netConfig);
        netStats.put(netNames[i], netStat);
        double doubRx = 0.0;
        double doubTx = 0.0;
        if (stTemp != null && stTemp.getNetStats() != null) {
          NetInterfaceStat netStatTemp = stTemp.getNetStats().get(
              netNames[i]);
          if (netStatTemp != null && netStatTemp.getRxBytes() > 0
              && netStatTemp.getTxBytes() > 0) {
            doubRx = (netStat.getRxBytes() - netStatTemp
                .getRxBytes()) / 5;
            doubTx = (netStat.getTxBytes() - netStatTemp
                .getTxBytes()) / 5;
          }
        }
        netRxSpeed.put(netNames[i], doubRx);
        netTxSpeed.put(netNames[i], doubTx);
View Full Code Here

        // if (netNames[i].toLowerCase().equals("lo")) {
        // continue;
        // }
        NetInterfaceConfig netConfig = sigar
            .getNetInterfaceConfig(netNames[i]);
        NetInterfaceStat netStat = sigar
            .getNetInterfaceStat(netNames[i]);
        netConfigs.put(netNames[i], netConfig);
        netStats.put(netNames[i], netStat);
        double doubRx = 0.0;
        double doubTx = 0.0;
View Full Code Here

        println("\t" +
                NetFlags.getIfFlagsString(flags) +
                " MTU:" + ifconfig.getMtu() +
                "  Metric:" + ifconfig.getMetric());
        try {
            NetInterfaceStat ifstat =
                this.sigar.getNetInterfaceStat(name);

            println("\t" +
                    "RX packets:" + ifstat.getRxPackets() +
                    " errors:" + ifstat.getRxErrors() +
                    " dropped:" + ifstat.getRxDropped() +
                    " overruns:" + ifstat.getRxOverruns() +
                    " frame:" + ifstat.getRxFrame());

            println("\t" +
                    "TX packets:" + ifstat.getTxPackets() +
                    " errors:" + ifstat.getTxErrors() +
                    " dropped:" + ifstat.getTxDropped() +
                    " overruns:" + ifstat.getTxOverruns() +
                    " carrier:" + ifstat.getTxCarrier());
            println("\t" + "collisions:" +
                    ifstat.getTxCollisions());

            long rxBytes = ifstat.getRxBytes();
            long txBytes = ifstat.getTxBytes();

            println("\t" +
                    "RX bytes:" + rxBytes +
                    " (" + Sigar.formatSize(rxBytes) + ")" +
                    "  " +
View Full Code Here

                traceln("!IFF_UP...skipping getNetInterfaceStat");
                continue;
            }

            try {
                NetInterfaceStat ifstat = sigar.getNetInterfaceStat(name);
                assertGtEqZeroTrace("RxPackets", ifstat.getRxPackets());
                assertGtEqZeroTrace("TxPackets", ifstat.getTxPackets());
                traceMethods(ifstat);
            } catch (SigarNotImplementedException e) {
                //ok
            } catch (SigarException e) {
                if (name.indexOf(':') == -1) {
View Full Code Here

                traceln("!IFF_UP...skipping getNetInterfaceStat");
                continue;
            }

            try {
                NetInterfaceStat ifstat = sigar.getNetInterfaceStat(name);
                assertGtEqZeroTrace("RxPackets", ifstat.getRxPackets());
                assertGtEqZeroTrace("TxPackets", ifstat.getTxPackets());
                traceMethods(ifstat);
            } catch (SigarNotImplementedException e) {
                //ok
            } catch (SigarException e) {
                if (name.indexOf(':') == -1) {
View Full Code Here

TOP

Related Classes of org.hyperic.sigar.NetInterfaceStat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.