當前位置: 首頁>>代碼示例>>Java>>正文


Java Sigar.close方法代碼示例

本文整理匯總了Java中org.hyperic.sigar.Sigar.close方法的典型用法代碼示例。如果您正苦於以下問題:Java Sigar.close方法的具體用法?Java Sigar.close怎麽用?Java Sigar.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hyperic.sigar.Sigar的用法示例。


在下文中一共展示了Sigar.close方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPlatformName

import org.hyperic.sigar.Sigar; //導入方法依賴的package包/類
/**
 * 3.操作係統信息
 */

// a)取到當前操作係統的名稱:
public String getPlatformName() {
	String hostname = "";
	try {
		hostname = InetAddress.getLocalHost().getHostName();
	} catch (Exception exc) {
		Sigar sigar = new Sigar();
		try {
			hostname = sigar.getNetInfo().getHostName();
		} catch (SigarException e) {
			hostname = "localhost.unknown";
		} finally {
			sigar.close();
		}
	}
	return hostname;
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:22,代碼來源:SysInfo.java

示例2: getStats

import org.hyperic.sigar.Sigar; //導入方法依賴的package包/類
public MachineStats getStats(Sigar sigar) {
    CpuStats cpuStats = CpuStats.builder()
                                .build();
    SwapStats swapStats = SwapStats.builder()
                                   .build();
    MemoryStats memoryStats = MemoryStats.builder()
                                         .build();
    try {
        swapStats = getSwapStats(sigar);
        cpuStats = getCpuStats(sigar);
        getMemoryStats(sigar);

    } catch (SigarException | UnsatisfiedLinkError e) {
        logger.error("Error during sigar stats operation", e);
    } finally {
        sigar.close();
    }

    return getMachineStats(swapStats, cpuStats, memoryStats);

}
 
開發者ID:aol,項目名稱:micro-server,代碼行數:22,代碼來源:MachineStatsChecker.java

示例3: getenv

import org.hyperic.sigar.Sigar; //導入方法依賴的package包/類
private static String getenv(String key) {
    try {
        return System.getenv("ANT_HOME"); //check for junit.jar
    } catch (Error e) {
        /*1.4*/
        Sigar sigar = new Sigar();
        try {
            return sigar.getProcEnv("$$", "ANT_HOME");
        } catch (Exception se) {
            return null;
        }
        finally { sigar.close(); }
    }
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:15,代碼來源:Runner.java

示例4: getCpuCount

import org.hyperic.sigar.Sigar; //導入方法依賴的package包/類
/**
 * 1.CPU資源信息
 */
// a)CPU數量(單位:個)
public static int getCpuCount() throws SigarException {
	Sigar sigar = new Sigar();
	try {
		return sigar.getCpuInfoList().length;
	} finally {
		sigar.close();
	}
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:13,代碼來源:SysInfo.java

示例5: cpuStats

import org.hyperic.sigar.Sigar; //導入方法依賴的package包/類
CpuStats cpuStats(Sigar sigar) {
    try {
        return getCpuStats(sigar);

    } catch (SigarException | UnsatisfiedLinkError e) {
        logger.error("Error during sigar stats operation", e);
    } finally {
        sigar.close();
    }
    return CpuStats.builder()
                   .build();
}
 
開發者ID:aol,項目名稱:micro-server,代碼行數:13,代碼來源:MachineStatsChecker.java

示例6: printNativeInfo

import org.hyperic.sigar.Sigar; //導入方法依賴的package包/類
private static void printNativeInfo(PrintStream os) {
    String version =
        "java=" + Sigar.VERSION_STRING +
        ", native=" + Sigar.NATIVE_VERSION_STRING;
    String build =
        "java=" + Sigar.BUILD_DATE +
        ", native=" + Sigar.NATIVE_BUILD_DATE;
    String scm =
        "java=" + Sigar.SCM_REVISION +
        ", native=" + Sigar.NATIVE_SCM_REVISION;
    String archlib =
        SigarLoader.getNativeLibraryName();

    os.println("Sigar version......." + version);
    os.println("Build date.........." + build);
    os.println("SCM rev............." + scm);
    String host = getHostName();
    String fqdn;
    Sigar sigar = new Sigar(); 
    try {
        File lib = sigar.getNativeLibrary();
        if (lib != null) {
            archlib = lib.getName();
        }
        fqdn = sigar.getFQDN();
    } catch (SigarException e) {
        fqdn = "unknown";
    } finally {
        sigar.close();
    }

    os.println("Archlib............." + archlib);

    os.println("Current fqdn........" + fqdn);
    if (!fqdn.equals(host)) {
        os.println("Hostname............" + host);
    }        

    if (SigarLoader.IS_WIN32) {
        LocaleInfo info = new LocaleInfo();
        os.println("Language............" + info);
        os.println("Perflib lang id....." +
                   info.getPerflibLangId());
    }
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:46,代碼來源:Version.java

示例7: getNativeInfo

import org.hyperic.sigar.Sigar; //導入方法依賴的package包/類
public static void getNativeInfo() {
    Sigar sigar = new Sigar();
    try {
        int uptime = (int) sigar.getUptime().getUptime();

        CpuInfo[] cpuInfoList = sigar.getCpuInfoList();
        int mhz = cpuInfoList[0].getMhz();

        CpuPerc cpuPerc = sigar.getCpuPerc();
        //IO wait
        double wait = cpuPerc.getWait();

        Mem mem = sigar.getMem();
        //included cache
        long actualUsed = mem.getActualUsed();
        long used = mem.getUsed();

        long cache = used - actualUsed;

        //net upload download
        NetInterfaceStat usedNetInterfaceStat = null;
        String[] netInterfaceList = sigar.getNetInterfaceList();
        for (String interfaceName : netInterfaceList) {
            NetInterfaceStat interfaceStat = sigar.getNetInterfaceStat(interfaceName);
            if (interfaceStat.getRxBytes() != 0) {
                usedNetInterfaceStat = interfaceStat;
                break;
            }
        }

        if (usedNetInterfaceStat != null) {
            long speed = usedNetInterfaceStat.getSpeed();

            long receivedBytes = usedNetInterfaceStat.getRxBytes();
            long sentBytes = usedNetInterfaceStat.getTxBytes();
        }

        String rootFileSystem = File.listRoots()[0].getAbsolutePath();
        FileSystemUsage fileSystemUsage = sigar.getFileSystemUsage(rootFileSystem);
        long diskReadBytes = fileSystemUsage.getDiskReadBytes();
        long diskWriteBytes = fileSystemUsage.getDiskWriteBytes();
    } catch (SigarException ex) {
        Logger.getLogger(NativeStats.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        sigar.close();
    }
}
 
開發者ID:games647,項目名稱:Java-Snippets,代碼行數:48,代碼來源:NativeStats.java


注:本文中的org.hyperic.sigar.Sigar.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。