if (!(netAddressBlacklist.contains(netconf.getAddress()))) { NetInterfaceStat netstat = null; try { if (stats != null) { final ServiceMetricEvent.Builder builder = builder() .setDimension("netName", netconf.getName()) .setDimension("netAddress", netconf.getAddress()) .setDimension("netHwaddr", netconf.getHwaddr()); MonitorUtils.addDimensionsToBuilder(builder, dimensions); for (Map.Entry<String, Long> entry : stats.entrySet()) { log.debug("Not monitoring net stats for name[%s] with address[%s]", name, netconf.getAddress());
public void output(String name) throws SigarException { NetInterfaceConfig ifconfig = this.sigar.getNetInterfaceConfig(name); long flags = ifconfig.getFlags(); 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); ptp = " P-t-P:" + ifconfig.getDestination(); bcast = " Bcast:" + ifconfig.getBroadcast(); "inet addr:" + ifconfig.getAddress() + " Mask:" + ifconfig.getNetmask()); " MTU:" + ifconfig.getMtu() + " Metric:" + ifconfig.getMetric()); try { NetInterfaceStat ifstat =
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()); }
try { final NetInterfaceConfig netInterfaceConfig = sigar.getNetInterfaceConfig(null); primaryInterface = netInterfaceConfig.getName(); } catch (SigarException e) { primaryInterface = null; netInterfaceConfig.getName(), Collections.singleton(netInterfaceConfig.getAddress()), netInterfaceConfig.getHwaddr(), netInterfaceConfig.getMtu(), interfaceStats); interfaces.put(interfaceName, networkInterface);
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) { } }
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); } }
String interfaceName = netInterfaceList[index]; NetInterfaceConfig config = sigar.getNetInterfaceConfig(interfaceName); String addr = config.getHwaddr(); String name = config.getName(); String description = config.getDescription(); if (description == null) {
private static String nameWithAddress(String name, NetInterfaceConfig config) { return "NIC [" + name + "] with address [" + config.getAddress() + "]"; }
for (String name : ifNames) { NetInterfaceConfig ifconfig = sigar.getNetInterfaceConfig(name); if ((ifconfig.getFlags() & 1L) <= 0L) { logger.info("!IFF_UP...skipping getNetInterfaceStat"); continue;
try { final NetInterfaceConfig netInterfaceConfig = sigar.getNetInterfaceConfig(null); primaryInterface = netInterfaceConfig.getName(); } catch (SigarException e) { primaryInterface = null; netInterfaceConfig.getName(), Collections.singleton(netInterfaceConfig.getAddress()), netInterfaceConfig.getHwaddr(), netInterfaceConfig.getMtu(), interfaceStats); interfaces.put(interfaceName, networkInterface);
public NetworkAdapterInfo(NetInterfaceConfig a, DisplayName displayName) { long flags = a.getFlags(); NetworkAdapterInfo.OperationState state = NetworkAdapterInfo.OperationState.UP; if ((flags & NetFlags.IFF_UP) <= 0) { this.name = a.getName(); switch(displayName) { case FROM_DESCRIPTION: this.displayName = a.getDescription(); break; case FROM_NAME: default: this.displayName = a.getName(); break; 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) { this.multicastAddresses = Collections.singletonList(InetAddress.getByName(a.getBroadcast())); } catch (UnknownHostException 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); } }
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); } }
if (!(netAddressBlacklist.contains(netconf.getAddress()))) { NetInterfaceStat netstat = null; try { if (stats != null) { final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder() .setUser1(netconf.getName()) .setUser2(netconf.getAddress()) .setUser3(netconf.getHwaddr()); for (Map.Entry<String, Long> entry : stats.entrySet()) { emitter.emit(builder.build(entry.getKey(), entry.getValue())); log.debug("Not monitoring net stats for name[%s] with address[%s]", name, netconf.getAddress());
try { final NetInterfaceConfig netInterfaceConfig = sigar.getNetInterfaceConfig(null); primaryInterface = netInterfaceConfig.getName(); } catch (SigarException e) { primaryInterface = null; netInterfaceConfig.getName(), Collections.singleton(netInterfaceConfig.getAddress()), netInterfaceConfig.getHwaddr(), netInterfaceConfig.getMtu(), interfaceStats); interfaces.put(interfaceName, networkInterface);
for (final String netInterface : instance.getNetInterfaceList()) { if ("0.0.0.0".equals(instance.getNetInterfaceConfig(netInterface).getAddress())) continue;
if (!(netAddressBlacklist.contains(netconf.getAddress()))) { NetInterfaceStat netstat = null; try { if (stats != null) { final ServiceMetricEvent.Builder builder = builder() .setDimension("netName", netconf.getName()) .setDimension("netAddress", netconf.getAddress()) .setDimension("netHwaddr", netconf.getHwaddr()); MonitorUtils.addDimensionsToBuilder(builder, dimensions); 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 { if (stats != null) { final ServiceMetricEvent.Builder builder = builder() .setDimension("netName", netconf.getName()) .setDimension("netAddress", netconf.getAddress()) .setDimension("netHwaddr", netconf.getHwaddr()); MonitorUtils.addDimensionsToBuilder(builder, dimensions); for (Map.Entry<String, Long> entry : stats.entrySet()) { log.debug("Not monitoring net stats for name[%s] with address[%s]", name, netconf.getAddress());