if (!(netAddressBlacklist.contains(netconf.getAddress()))) { NetInterfaceStat netstat = null; try { final ServiceMetricEvent.Builder builder = builder() .setDimension("netName", netconf.getName()) .setDimension("netAddress", netconf.getAddress()) .setDimension("netHwaddr", netconf.getHwaddr()); MonitorUtils.addDimensionsToBuilder(builder, dimensions); log.debug("Not monitoring net stats for name[%s] with address[%s]", name, netconf.getAddress());
Collections.singleton(netInterfaceConfig.getAddress()), netInterfaceConfig.getHwaddr(), netInterfaceConfig.getMtu(),
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............." + info.getHostName()); println("domain name..........." + info.getDomainName()); println("default gateway......." + info.getDefaultGateway()); println("primary dns..........." + info.getPrimaryDns()); println("secondary dns........." + info.getSecondaryDns()); }
"inet addr:" + ifconfig.getAddress() +
private static String nameWithAddress(String name, NetInterfaceConfig config) { return "NIC [" + name + "] with address [" + config.getAddress() + "]"; }
public Collection<String> getNetInterfacesNames() { try { HashSet<String> result = new HashSet<String>(); String[] names = sigar.getNetInterfaceList(); if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "The following network interface cards were detected by Sigar: " + Arrays.toString(names)); for (String name : names) { NetInterfaceConfig config = sigar.getNetInterfaceConfig(name); if (config.getAddress().equals(NetFlags.ANY_ADDR)) { if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "Skipping " + nameWithAddress(name, config) + " - invalid address"); } else { boolean added = result.add(name); if (added) { if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, nameWithAddress(name, config) + " will be registered for metrics"); } else { if (logger.isLoggable(Level.WARNING)) logger.log(Level.WARNING, "Skipping " + nameWithAddress(name, config) + " - a NIC by the same name has already been registered for metrics"); } } } return result; } catch (SigarException e) { throw new RuntimeException("Failed to get network interfaces names", e); } }
public NetworkAdapterInfo(NetInterfaceConfig a) { long flags = a.getFlags(); NetworkAdapterInfo.OperationState state = NetworkAdapterInfo.OperationState.UP; if ((flags & NetFlags.IFF_UP) <= 0) { state = NetworkAdapterInfo.OperationState.DOWN; } this.name = a.getName(); this.displayName = a.getName(); this.description = a.getDescription(); this.macAddress = a.getHwaddr(); this.type = a.getType(); this.operationalStatus = state; this.dhcpEnabled = Boolean.FALSE; this.dnsServers = null; // TODO: DNS server addresses? this.flags = a.getFlags(); try { this.unicastAddresses = Collections.singletonList(InetAddress.getByName(a.getAddress())); // TODO: can't sigar give us more than one? } catch (UnknownHostException e) { } try { this.multicastAddresses = Collections.singletonList(InetAddress.getByName(a.getBroadcast())); } catch (UnknownHostException e) { } }
if (!(netAddressBlacklist.contains(netconf.getAddress()))) { NetInterfaceStat netstat = null; try { final ServiceMetricEvent.Builder builder = builder() .setDimension("netName", netconf.getName()) .setDimension("netAddress", netconf.getAddress()) .setDimension("netHwaddr", netconf.getHwaddr()); MonitorUtils.addDimensionsToBuilder(builder, dimensions); log.debug("Not monitoring net stats for name[%s] with address[%s]", name, netconf.getAddress());
this.flags = a.getFlags(); try { this.unicastAddresses = Collections.singletonList(InetAddress.getByName(a.getAddress())); // TODO: can't sigar give us more than one? } catch (UnknownHostException e) {
if (!(netAddressBlacklist.contains(netconf.getAddress()))) { NetInterfaceStat netstat = null; try { final ServiceMetricEvent.Builder builder = builder() .setDimension("netName", netconf.getName()) .setDimension("netAddress", netconf.getAddress()) .setDimension("netHwaddr", netconf.getHwaddr()); MonitorUtils.addDimensionsToBuilder(builder, dimensions); log.debug("Not monitoring net stats for name[%s] with address[%s]", name, netconf.getAddress());
if (!(netAddressBlacklist.contains(netconf.getAddress()))) { NetInterfaceStat netstat = null; try { final ServiceMetricEvent.Builder builder = builder() .setDimension("netName", netconf.getName()) .setDimension("netAddress", netconf.getAddress()) .setDimension("netHwaddr", netconf.getHwaddr()); MonitorUtils.addDimensionsToBuilder(builder, dimensions); log.debug("Not monitoring net stats for name[%s] with address[%s]", name, netconf.getAddress());
if (!(netAddressBlacklist.contains(netconf.getAddress()))) { NetInterfaceStat netstat = null; try { final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder() .setUser1(netconf.getName()) .setUser2(netconf.getAddress()) .setUser3(netconf.getHwaddr()); for (Map.Entry<String, Long> entry : stats.entrySet()) { log.debug("Not monitoring net stats for name[%s] with address[%s]", name, netconf.getAddress());
if (!(netAddressBlacklist.contains(netconf.getAddress()))) { NetInterfaceStat netstat = null; try { final ServiceMetricEvent.Builder builder = builder() .setDimension("netName", netconf.getName()) .setDimension("netAddress", netconf.getAddress()) .setDimension("netHwaddr", netconf.getHwaddr()); MonitorUtils.addDimensionsToBuilder(builder, dimensions); log.debug("Not monitoring net stats for name[%s] with address[%s]", name, netconf.getAddress());
if (!(netAddressBlacklist.contains(netconf.getAddress()))) { NetInterfaceStat netstat = null; try { final ServiceMetricEvent.Builder builder = builder() .setDimension("netName", netconf.getName()) .setDimension("netAddress", netconf.getAddress()) .setDimension("netHwaddr", netconf.getHwaddr()); MonitorUtils.addDimensionsToBuilder(builder, dimensions); log.debug("Not monitoring net stats for name[%s] with address[%s]", name, netconf.getAddress());
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;
Collections.singleton(netInterfaceConfig.getAddress()), netInterfaceConfig.getHwaddr(), netInterfaceConfig.getMtu(),
Collections.singleton(netInterfaceConfig.getAddress()), netInterfaceConfig.getHwaddr(), netInterfaceConfig.getMtu(),