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


Java Mem.getFree方法代码示例

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


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

示例1: output

import org.hyperic.sigar.Mem; //导入方法依赖的package包/类
public void output(String[] args) throws SigarException {
    Mem mem   = this.sigar.getMem();
    Swap swap = this.sigar.getSwap();

    Object[] header = new Object[] { "total", "used", "free" };

    Object[] memRow = new Object[] {
        format(mem.getTotal()),
        format(mem.getUsed()),
        format(mem.getFree())
    };

    Object[] actualRow = new Object[] {
        format(mem.getActualUsed()),
        format(mem.getActualFree())
    };

    Object[] swapRow = new Object[] {
        format(swap.getTotal()),
        format(swap.getUsed()),
        format(swap.getFree())
    };

    printf("%18s %10s %10s", header);

    printf("Mem:    %10ld %10ld %10ld", memRow);

    //e.g. linux
    if ((mem.getUsed() != mem.getActualUsed()) ||
        (mem.getFree() != mem.getActualFree()))
    {
        printf("-/+ buffers/cache: " + "%10ld %10d", actualRow);
    }

    printf("Swap:   %10ld %10ld %10ld", swapRow);

    printf("RAM:    %10ls", new Object[] { mem.getRam() + "MB" });
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:39,代码来源:Free.java

示例2: getFreeRam

import org.hyperic.sigar.Mem; //导入方法依赖的package包/类
/**
 * Gets the free RAM memory available on the device.
 *
 * @return the free RAM memory in MBs.
 */
public static long getFreeRam() {
    try {
        Mem memory = sigar.getMem();
        long freeMemory = memory.getFree();

        // Convert the free memory from bytes to MBs.
        freeMemory /= 1024 * 1024;
        return freeMemory;
    } catch (SigarException e) {
        LOGGER.warn("Could not get the free RAM memory.", e);
    }

    return FALLBACK_FREE_RAM;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:20,代码来源:SystemInformation.java

示例3: osMemStats

import org.hyperic.sigar.Mem; //导入方法依赖的package包/类
/**
 * Generate memory statistics
 * http://casidiablo.net/capturar-informacion-sistema-operativo-java/
 */
public JFreeChart osMemStats() throws IOException, ServletException {
	DefaultPieDataset dataset = new DefaultPieDataset();
	Sigar sigar = new Sigar();
	String title = null;

	try {
		Mem mem = sigar.getMem();
		long max = mem.getRam();
		long available = mem.getFree();
		long total = mem.getTotal();
		long used = mem.getUsed();
		long free = mem.getFree();
		title = "OS memory: " + FormatUtil.formatSize(total);

		log.debug("OS maximun memory: {}", FormatUtil.formatSize(max));
		log.debug("OS available memory: {}", FormatUtil.formatSize(available));
		log.debug("OS free memory: {}", FormatUtil.formatSize(free));
		log.debug("OS used memory: {}", FormatUtil.formatSize(used));
		log.debug("OS total memory: {}", FormatUtil.formatSize(total));

		dataset.setValue("Available (" + FormatUtil.formatSize(free) + ")", free * 100 / total);
		dataset.setValue("Used (" + FormatUtil.formatSize(used) + ")", used * 100 / total);
	} catch (SigarException se) {
		title = "OS memory: " + se.getMessage();
	} catch (UnsatisfiedLinkError ule) {
		title = "OS memory: (missing native libraries)";
	}

	return ChartFactory.createPieChart(title, dataset, true, false, false);
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:35,代码来源:StatsGraphServlet.java

示例4: getFreeMemory

import org.hyperic.sigar.Mem; //导入方法依赖的package包/类
public long getFreeMemory() {
    if (osBean instanceof com.sun.management.OperatingSystemMXBean) {
        com.sun.management.OperatingSystemMXBean nativeOsBean = (com.sun.management.OperatingSystemMXBean) osBean;
        return nativeOsBean.getFreePhysicalMemorySize();
    } else if (sigar != null) {
        try {
            Mem mem = sigar.getMem();
            return mem.getFree();
        } catch (SigarException ex) {
            logger.log(Level.SEVERE, null, ex);
        }
    }

    return -1;
}
 
开发者ID:games647,项目名称:LagMonitor,代码行数:16,代码来源:NativeData.java

示例5: freeMem

import org.hyperic.sigar.Mem; //导入方法依赖的package包/类
/**
 * 获取剩余内存
 */
public static long freeMem() throws SigarException{
	Mem mem = sigar.getMem();
	long used = (long)(mem.getFree()/1048576);
	return used;
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:9,代码来源:MonitorUtil.java

示例6: getValue

import org.hyperic.sigar.Mem; //导入方法依赖的package包/类
@Override
public void getValue(StringBuffer res) throws SigarException {
	Mem mem = this.sigarProxy.getMem();

	int factor = 1;
	double val;
	switch (this.type) {
	case 0:
		val = mem.getActualFree();
		factor = this.dividingFactor;
		break;
	case 1:
		val = mem.getActualUsed();
		factor = this.dividingFactor;
		break;
	case 2:
		val = mem.getFree();
		factor = this.dividingFactor;
		break;
	case 3:
		val = mem.getFreePercent();
		break;
	case 4:
		val = mem.getRam();
		break;
	case 5:
		val = mem.getTotal();
		factor = this.dividingFactor;
		break;
	case 6:
		val = mem.getUsed();
		factor = this.dividingFactor;
		break;
	case 7:
		val = mem.getUsedPercent();
		break;
	default:
		throw new SigarException("Unknown total mem type " + this.type);
	}
	val /= factor;
	res.append(Double.toString(val));
}
 
开发者ID:junehappylove,项目名称:ServerAgent,代码行数:43,代码来源:MemTotalMetric.java


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