public static NetInterfaceData gather(SigarProxy sigar, String name) throws SigarException { NetInterfaceData data = new NetInterfaceData(); data._config = sigar.getNetInterfaceConfig(name); try { data._stat = sigar.getNetInterfaceStat(name); } catch (SigarException e) { // _stat is null } return data; }
public List<NetworkAdapterInfo> getAllNetworkAdapters() throws SystemInfoException { List<NetworkAdapterInfo> adapters = new ArrayList<NetworkAdapterInfo>(); try { String[] interfaceNames = sigar.getNetInterfaceList(); if (interfaceNames != null) { for (String interfaceName : interfaceNames) { if (interfaceName.indexOf(':') != -1) { continue; //filter out virtual IPs } adapters.add(new NetworkAdapterInfo(sigar.getNetInterfaceConfig(interfaceName))); } } } catch (Exception e) { throw new SystemInfoException(e); } return adapters; }
public List<NetworkAdapterInfo> getAllNetworkAdapters() throws SystemInfoException { List<NetworkAdapterInfo> adapters = new ArrayList<NetworkAdapterInfo>(); try { String[] interfaceNames = sigar.getNetInterfaceList(); if (interfaceNames != null) { NetworkAdapterInfo.DisplayName displayName = NetworkAdapterInfo.DisplayName.FROM_NAME; // If Sigar can't get the adapter name it just starts naming the network adapters as eth0, eth1, etc. // This can be confusing on Windows, so we switch to their description // All references should be the same, as we are are only changing the displayName if (this.getOperatingSystemType() == OperatingSystemType.WINDOWS) { displayName = NetworkAdapterInfo.DisplayName.FROM_DESCRIPTION; } for (String interfaceName : interfaceNames) { if (interfaceName.indexOf(':') != -1) { continue; //filter out virtual IPs } adapters.add(new NetworkAdapterInfo(sigar.getNetInterfaceConfig(interfaceName), displayName)); } } } catch (Exception e) { throw new SystemInfoException(e); } return adapters; }
static void logAvailableInterfaces(SigarProxy sigar) { log.info("*** Logging available network interfaces ***"); try { String[] list = sigar.getNetInterfaceList(); for (int n = 0; n < list.length; n++) { NetInterfaceConfig ifc = sigar.getNetInterfaceConfig(list[n]); log.info("Network interface: iface=" + ifc.getName() + " addr=" + ifc.getAddress() + " type=" + ifc.getType()); } } catch (SigarException e) { log.debug("Can't get network info", e); } }
static void logAvailableInterfaces(SigarProxy sigar) { log.info("*** Logging available network interfaces ***"); try { String[] list = sigar.getNetInterfaceList(); for (int n = 0; n < list.length; n++) { NetInterfaceConfig ifc = sigar.getNetInterfaceConfig(list[n]); log.info("Network interface: iface=" + ifc.getName() + " addr=" + ifc.getAddress() + " type=" + ifc.getType()); } } catch (SigarException e) { log.debug("Can't get network info", e); } }
for (final String netInterface : instance.getNetInterfaceList()) { if ("0.0.0.0".equals(instance.getNetInterfaceConfig(netInterface).getAddress())) continue;