本文整理汇总了Java中org.hyperic.sigar.NetInterfaceConfig.getFlags方法的典型用法代码示例。如果您正苦于以下问题:Java NetInterfaceConfig.getFlags方法的具体用法?Java NetInterfaceConfig.getFlags怎么用?Java NetInterfaceConfig.getFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hyperic.sigar.NetInterfaceConfig
的用法示例。
在下文中一共展示了NetInterfaceConfig.getFlags方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIfaces
import org.hyperic.sigar.NetInterfaceConfig; //导入方法依赖的package包/类
public static NetInterfaceConfig[] getIfaces() throws SigarException {
_init();
String[] ifaces = sigar.getNetInterfaceList();
List<NetInterfaceConfig> l1 = new ArrayList<NetInterfaceConfig>();
for (int i = 0; i < ifaces.length; i++) {
NetInterfaceConfig cfg = sigar.getNetInterfaceConfig(ifaces[i]);
if (NetFlags.LOOPBACK_ADDRESS.equals(cfg.getAddress()) || (cfg.getFlags() & NetFlags.IFF_LOOPBACK) != 0
|| NetFlags.NULL_HWADDR.equals(cfg.getHwaddr())) {
continue;
}
l1.add(cfg);
}
return l1.toArray(new NetInterfaceConfig[l1.size()]);
}
示例2: getIfstats
import org.hyperic.sigar.NetInterfaceConfig; //导入方法依赖的package包/类
public static List<JSON> getIfstats() throws SigarException {
_init();
String[] ifaces = sigar.getNetInterfaceList();
List<JSON> l1 = new ArrayList<JSON>();
for (int i = 0; i < ifaces.length; i++) {
NetInterfaceConfig cfg = sigar.getNetInterfaceConfig(ifaces[i]);
if ((cfg.getFlags() & 1L) <= 0L || X.isSame(cfg.getAddress(), "0.0.0.0")) {
continue;
}
NetInterfaceStat s = sigar.getNetInterfaceStat(ifaces[i]);
l1.add(JSON.create().append("address", cfg.getAddress()).append("name", cfg.getName())
.append("rxbytes", s.getRxBytes()).append("rxdropped", s.getRxDropped())
.append("rxerrors", s.getRxErrors()).append("rxframe", s.getRxFrame())
.append("rxoverrunns", s.getRxOverruns()).append("rxpackets", s.getRxPackets())
.append("speed", s.getSpeed()).append("txbytes", s.getTxBytes())
.append("txcarrier", s.getTxCarrier()).append("txcollisions", s.getTxCollisions())
.append("txdropped", s.getTxDropped()).append("txerrors", s.getTxErrors())
.append("txoverruns", s.getTxOverruns()).append("txpackets", s.getTxPackets()));
}
return l1;
}
示例3: output
import org.hyperic.sigar.NetInterfaceConfig; //导入方法依赖的package包/类
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());
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) + ")" +
" " +
"TX bytes:" + txBytes +
" (" + Sigar.formatSize(txBytes) + ")");
} catch (SigarException e) {
}
println("");
}