Package org.hyperic.sigar

Examples of org.hyperic.sigar.NetInterfaceConfig


        //NetInterface beans
        try {
            String[] ifnames = this.sigar.getNetInterfaceList();
            for (int i=0; i<ifnames.length; i++) {
                String name = ifnames[i];
                NetInterfaceConfig ifconfig =
                    this.sigar.getNetInterfaceConfig(name);
                try {
                    this.sigar.getNetInterfaceStat(name);
                } catch (SigarException e) {
                    continue;
View Full Code Here


    public String getUsageShort() {
        return "Display network info";
    }

    public void output(String[] args) throws SigarException {
        NetInterfaceConfig config = this.sigar.getNetInterfaceConfig(null);
        println("primary interface....." +
                config.getName());

        println("primary ip address...." +
                config.getAddress());

        println("primary mac address..." +
                config.getHwaddr());

        println("primary netmask......." +
                config.getNetmask());

        org.hyperic.sigar.NetInfo info =
            this.sigar.getNetInfo();

        println("host name............." +
View Full Code Here

            }
        }
    }

    public void output(String name) throws SigarException {
        NetInterfaceConfig ifconfig =
            this.sigar.getNetInterfaceConfig(name);
        long flags = ifconfig.getFlags();

        String hwaddr = "";
        if (!NetFlags.NULL_HWADDR.equals(ifconfig.getHwaddr())) {
            hwaddr = " HWaddr " + ifconfig.getHwaddr();
        }

        if (!ifconfig.getName().equals(ifconfig.getDescription())) {
            println(ifconfig.getDescription());
        }

        println(ifconfig.getName() + "\t" +
                "Link encap:" + ifconfig.getType() +
                hwaddr);

        String ptp = "";
        if ((flags & NetFlags.IFF_POINTOPOINT) > 0) {
            ptp = "  P-t-P:" + ifconfig.getDestination();
        }

        String bcast = "";
        if ((flags & NetFlags.IFF_BROADCAST) > 0) {
            bcast = "  Bcast:" + ifconfig.getBroadcast();
        }

        println("\t" +
                "inet addr:" + ifconfig.getAddress() +
                ptp + //unlikely
                bcast +
                "  Mask:" + ifconfig.getNetmask());

        if (ifconfig.getPrefix6Length() != 0) {
            println("\t" +
                    "inet6 addr: " + ifconfig.getAddress6() + "/" +
                    ifconfig.getPrefix6Length() +
                    " Scope:" + NetFlags.getScopeString(ifconfig.getScope6()));
        }

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

            println("\t" +
View Full Code Here

    private void getNetIflist(Sigar sigar, boolean getStats) throws Exception {
        String[] ifNames = sigar.getNetInterfaceList();

        for (int i=0; i<ifNames.length; i++) {
            String name = ifNames[i];
            NetInterfaceConfig ifconfig =
                sigar.getNetInterfaceConfig(name);

            traceln("name=" + name);

            assertTrueTrace("Address", ifconfig.getAddress());
            assertTrueTrace("Netmask", ifconfig.getNetmask());

            if (!getStats) {
                continue;
            }

            if ((ifconfig.getFlags() & NetFlags.IFF_UP) <= 0) {
                traceln("!IFF_UP...skipping getNetInterfaceStat");
                continue;
            }

            try {
View Full Code Here

        super(name);
    }

    public void testNetInfo() throws SigarException {
        NetInfo info = getSigar().getNetInfo();
        NetInterfaceConfig config = getSigar().getNetInterfaceConfig(null);
        traceln("");
        traceln(info.toString());
        traceln(config.toString());

        int flags = NetFlags.CONN_SERVER | NetFlags.CONN_TCP;

        NetConnection[] connections;
View Full Code Here

    }

    public void testCreate() throws Exception {
        Sigar sigar = getSigar();

        NetInterfaceConfig ifconfig =
            sigar.getNetInterfaceConfig(null);

        ArrayList addrs = new ArrayList();
        addrs.add(ifconfig.getAddress());
        addrs.add(NetFlags.LOOPBACK_ADDRESS);
        if (JDK_14_COMPAT) {
            addrs.add(NetFlags.LOOPBACK_ADDRESS_V6);
        }
View Full Code Here

    try {
      String ifNames[] = m_sigar.getNetInterfaceList();

      for (int i = 0; i < ifNames.length; i++) {
        String name = ifNames[i];
        NetInterfaceConfig ifconfig = m_sigar.getNetInterfaceConfig(name);
        String currentIp = ifconfig.getAddress();

        if (currentIp.equals(m_ipAddr)) {
          return false;
        }
      }
View Full Code Here

      SystemType stTemp = stList.get(stList.size() - 1);
      for (int i = 0; i < netNames.length; i++) {
        // 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);
View Full Code Here

      Map<String, Double> netTxSpeed = new HashMap<String, Double>();
      for (int i = 0; i < netNames.length; i++) {
        // 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);
View Full Code Here

    public String getUsageShort() {
        return "Display network info";
    }

    public void output(String[] args) throws SigarException {
        NetInterfaceConfig config = this.sigar.getNetInterfaceConfig(null);
        println("primary interface....." +
                config.getName());

        println("primary ip address...." +
                config.getAddress());

        println("primary mac address..." +
                config.getHwaddr());

        println("primary netmask......." +
                config.getNetmask());

        org.hyperic.sigar.NetInfo info =
            this.sigar.getNetInfo();

        println("host name............." +
View Full Code Here

TOP

Related Classes of org.hyperic.sigar.NetInterfaceConfig

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.