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


Java FileSystem.TYPE_LOCAL_DISK属性代码示例

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


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

示例1: output

public void output(String[] args) throws SigarException {
    if (args.length == 1) {
        String arg = args[0];
        if ((arg.indexOf('/') != -1) || (arg.indexOf('\\') != -1)) {
            outputFileSystem(arg);
        }
        else {
            outputDisk(arg);
        }
    }
    else {
        FileSystem[] fslist = this.proxy.getFileSystemList();
        printHeader();
        for (int i=0; i<fslist.length; i++) {
            if (fslist[i].getType() == FileSystem.TYPE_LOCAL_DISK) {
                output(fslist[i]);
            }
        }
    }
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:20,代码来源:Iostat.java

示例2: initializePlugin

@Override
public void initializePlugin(StagemonitorPlugin.InitArguments initArguments) throws Exception {
	final CorePlugin corePlugin = initArguments.getPlugin(CorePlugin.class);

	corePlugin.getGrafanaClient().sendGrafanaDashboardAsync("grafana/ElasticsearchHostDashboard.json");
	if (sigar == null) {
		if (!SigarNativeBindingLoader.loadNativeSigarBindings()) {
			// redeploys are a problem, because the native libs can only be loaded by one class loader
			// this would lead to a UnsatisfiedLinkError: Native Library sigar already loaded in another class loader
			throw new RuntimeException("The OsPlugin only works with one application per JVM " +
					"and does not work after a redeploy");
		}
		sigar = newSigar();
	}
	initArguments.getMetricRegistry().registerAll(init(new CpuMetricSet(sigar, sigar.getCpuInfoList()[0])));
	initArguments.getMetricRegistry().registerAll(init(new MemoryMetricSet(sigar)));
	initArguments.getMetricRegistry().registerAll(init(new SwapMetricSet(sigar)));

	Set<String> routedNetworkInterfaces = new HashSet<String>();
	for (NetRoute netRoute : sigar.getNetRouteList()) {
		routedNetworkInterfaces.add(netRoute.getIfname());
	}
	for (String ifname : routedNetworkInterfaces) {
		initArguments.getMetricRegistry().registerAll(init(new NetworkMetricSet(ifname, sigar)));
	}
	@SuppressWarnings("unchecked")
	final Set<Map.Entry<String, FileSystem>> entries = (Set<Map.Entry<String, FileSystem>>) sigar.getFileSystemMap().entrySet();
	for (Map.Entry<String, FileSystem> e : entries) {
		final FileSystem fs = e.getValue();
		if (fs.getType() == FileSystem.TYPE_LOCAL_DISK || fs.getType() == FileSystem.TYPE_NETWORK) {
			initArguments.getMetricRegistry().registerAll(init(new FileSystemMetricSet(e.getKey(), sigar)));
		}
	}
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:34,代码来源:OsPlugin.java

示例3: getFirstMountPoint

private String getFirstMountPoint() throws SigarException {
	@SuppressWarnings("unchecked")
	final Set<Map.Entry<String, FileSystem>> entries = (Set<Map.Entry<String, FileSystem>>) sigar.getFileSystemMap().entrySet();
	for (Map.Entry<String, FileSystem> e : entries) {
		if (e.getValue().getType() == FileSystem.TYPE_LOCAL_DISK) {
			return e.getKey();
		}
	}
	throw new IllegalStateException("No mount point found");
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:10,代码来源:OsPluginTest.java

示例4: getInfoFromSigar

private StringBuilder getInfoFromSigar() throws Exception {

        StringBuilder sb = new StringBuilder();
        Sigar sigar = new Sigar();

        sb.append("Fully Qualified Domain Name:\n\t" + sigar.getFQDN().toString());
        sb.append("\nSystem uptime:\n\t" + new Double(sigar.getUptime().getUptime()).intValue()
                  + " seconds");
        sb.append("\nDate:\n\t" + new Date());
        sb.append("\nNetwork settings:" + format(sigar.getNetInfo().toString(), 1));

        sb.append("\nCPU info:");
        CpuInfo[] cpuInfoList = sigar.getCpuInfoList();
        for (int i = 0; i < cpuInfoList.length; i++) {
            CpuInfo cpuInfo = cpuInfoList[i];
            sb.append("\n\tCPU " + i + ": ");
            sb.append(format(cpuInfo.toString(), 2));
        }

        double totalMemory = (new Long(sigar.getMem().getTotal()).doubleValue() / 1024 / 1024 / 1024);
        sb.append("\nTotal memory:\n\t"
                  + new BigDecimal(totalMemory).setScale(2, BigDecimal.ROUND_DOWN).floatValue() + " GB");

        String[] nicList = sigar.getNetInterfaceList();
        sb.append("\nNIC info: ");
        for (int i = 0; i < nicList.length; i++) {
            NetInterfaceConfig nic = sigar.getNetInterfaceConfig(nicList[i]);
            sb.append("\n\tNIC " + i + ": ");
            sb.append(format(nic.toString(), 2));
        }

        FileSystem[] fileSystemList = sigar.getFileSystemList();
        sb.append("\nFile system info: ");
        for (int i = 0; i < fileSystemList.length; i++) {
            FileSystem fileSystem = fileSystemList[i];

            sb.append("\n\t" + fileSystem.getDevName() + " is a");
            if (fileSystem.getType() == FileSystem.TYPE_LOCAL_DISK) {
                sb.append(" local");
            } else if (fileSystem.getType() == FileSystem.TYPE_NETWORK) {
                sb.append(" network");
            } else if (fileSystem.getType() == FileSystem.TYPE_RAM_DISK) {
                sb.append(" ram disk");
            } else if (fileSystem.getType() == FileSystem.TYPE_SWAP) {
                sb.append(" swap");
            }

            sb.append(" " + fileSystem.getSysTypeName() + ", dir name '" + fileSystem.getDirName()
                      + "', options '" + fileSystem.getOptions() + "'");
        }

        sb.append("\nResource limits:" + format(sigar.getResourceLimit().toString(), "max", 1));
        return sb;
    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:54,代码来源:MachineDescriptionOperations.java

示例5: getDevicesForIoMonitoring

/**
 * Get device names for monitoring - disk(AIX) or logical volume names
 * <p><em>Note</em>: For AIX for example a disk names should be returned.
 * As later Sigar invokes getDiskUsage(name). Check on Linux
 * </p>
 * @param sigarWrapper
 * @param readBytes
 * @return
 * @throws SigarException
 */
private static List<String> getDevicesForIoMonitoring(
                                                       SigarWrapper sigarWrapper,
                                                       boolean readBytes ) throws SigarException {

    List<String> devices = new LinkedList<String>();
    StringBuilder problematicMounts = new StringBuilder();

    if (IS_AIX_OS) {
        String[] cmdCommand = new String[]{ "/bin/sh", "-c", "lspv 2>&1" };
        String result = null;
        try {
            Process p = Runtime.getRuntime().exec(cmdCommand);
            result = IoUtils.streamToString(p.getInputStream()).trim();
        } catch (Exception e) {
            throw new RuntimeException("Error getting devices to monitor for IO (Read/Write) transfer. lspv command invoke error",
                                       e);
        }
        String[] lines = result.split("[\r\n]+");
        int lineNum = 0;
        for (String line : lines) {
            lineNum++;
            LOG.trace("Get AIX device[" + lineNum + "]: " + line);
            String[] words = line.split("[\\s]+");
            if (words.length > 0) {
                LOG.trace(" Found disk: " + words[0]);
                if (getReadWriteBytes(sigarWrapper, words[0], readBytes) == -1) {
                    problematicMounts.append("'" + words[0] + "', ");
                } else {
                    devices.add(words[0]);
                }
            }
        }
    } else {
        FileSystem[] fslist = sigarWrapper.getSigarInstance().getFileSystemList();
        for (int i = 0; i < fslist.length; i++) {
            if (fslist[i].getType() == FileSystem.TYPE_LOCAL_DISK) {
                if (getReadWriteBytes(sigarWrapper, fslist[i].getDevName(), readBytes) == -1) {
                    problematicMounts.append("'" + fslist[i].getDevName() + "', ");
                } else {
                    devices.add(fslist[i].getDevName());
                }
            }
        }
    }

    if (problematicMounts.length() > 0) {

        LOG.warn("Unable to get " + (readBytes
                                               ? "Read"
                                               : "Write")
                 + "Bytes on devices: "
                 + problematicMounts.substring(0, problematicMounts.length() - 2));
    }
    return devices;
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:65,代码来源:IOReadingInstancesFactory.java


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