当前位置: 首页>>代码示例>>Java>>正文


Java NetFlags.IFF_BROADCAST属性代码示例

本文整理汇总了Java中org.hyperic.sigar.NetFlags.IFF_BROADCAST属性的典型用法代码示例。如果您正苦于以下问题:Java NetFlags.IFF_BROADCAST属性的具体用法?Java NetFlags.IFF_BROADCAST怎么用?Java NetFlags.IFF_BROADCAST使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.hyperic.sigar.NetFlags的用法示例。


在下文中一共展示了NetFlags.IFF_BROADCAST属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: output

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("");
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:72,代码来源:Ifconfig.java


注:本文中的org.hyperic.sigar.NetFlags.IFF_BROADCAST属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。