Package org.hyperic.sigar

Examples of org.hyperic.sigar.NetInterfaceStat


  }

  public static void registerMetrics(MetricsRegistry metrics, Class<?> owningClass,
      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();

    metrics.newGauge(owningClass, "network-" + interfaceName + "-receive-bytes", new SigarLongGauge() {
      @Override public long computeValue() throws SigarException {
        return sigar.getNetInterfaceStat(interfaceName).getRxBytes() - initialRxBytes;
      }
View Full Code Here


     
      // 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

   * @throws SigarException
   */
  public static void registerMetrics(MetricsRegistry metrics, Class<?> owningClass,
    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();

    // CHECKSTYLE: stop IndentationCheck
    metrics.newGauge(owningClass, "network-" + interfaceName + "-receive-bytes",
        new SigarLongGauge() {
      @Override public long computeValue() throws SigarException {
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) {
                fail("getNetInterfaceStat(" + name + "): " +
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.