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


Java Swap类代码示例

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


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

示例1: getNodeSwapInfo

import org.hyperic.sigar.Swap; //导入依赖的package包/类
/**
 * Method getNodeSwapInfo.
 * 
 * @return Map<Object,Object>
 */
public Map<Object, Object> getNodeSwapInfo() {

	Swap swap = null;
	Map<Object, Object> nodeSwapInfo = new HashMap<Object, Object>();

	try {
		swap = sigar.getSwap();
	} catch (Exception e) {
		LOGGER.error(e.getMessage(), e);
	}

	nodeSwapInfo.put("freeSystemSwap", swap.getFree());
	nodeSwapInfo.put("pageIn", swap.getPageIn());
	nodeSwapInfo.put("pageOut", swap.getPageOut());
	nodeSwapInfo.put("totalSystemSwap", swap.getTotal());
	nodeSwapInfo.put("usedSystemSwap", swap.getUsed());

	return nodeSwapInfo;
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:25,代码来源:SigarNodeInfoProvider.java

示例2: executeCommand

import org.hyperic.sigar.Swap; //导入依赖的package包/类
@Override
public String executeCommand(final SigarProxy sigar) throws SigarException {
	StrBuilder sb = new StrBuilder(200);

	Swap swap = sigar.getSwap();

	sb.append(TYPE_SWAP);
	sb.append(separator);
	sb.append(swap.getTotal() / 1024L);
	sb.append(separator);
	sb.append(swap.getUsed() / 1024L);
	sb.append(separator);
	sb.append(swap.getFree() / 1024L);

	return sb.toString();
}
 
开发者ID:mgm-tp,项目名称:perfload-perfmon,代码行数:17,代码来源:PerfMonSwap.java

示例3: output

import org.hyperic.sigar.Swap; //导入依赖的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

示例4: getPhysicalMemory

import org.hyperic.sigar.Swap; //导入依赖的package包/类
/**
 * 2.内存资源信息
 */

public void getPhysicalMemory() {
	// a)物理内存信息
	DecimalFormat df = new DecimalFormat("#0.00");
	Sigar sigar = new Sigar();
	Mem mem;
	try {
		mem = sigar.getMem();
		// 内存总量
		System.out.println("内存总量:" + df.format((float) mem.getTotal() / 1024 / 1024 / 1024) + "G");
		// 当前内存使用量
		System.out.println("当前内存使用量:" + df.format((float) mem.getUsed() / 1024 / 1024 / 1024) + "G");
		// 当前内存剩余量
		System.out.println("当前内存剩余量:" + df.format((float) mem.getFree() / 1024 / 1024 / 1024) + "G");
		// b)系统页面文件交换区信息
		Swap swap = sigar.getSwap();
		// 交换区总量
		System.out.println("交换区总量:" + df.format((float) swap.getTotal() / 1024 / 1024 / 1024) + "G");
		// 当前交换区使用量
		System.out.println("当前交换区使用量:" + df.format((float) swap.getUsed() / 1024 / 1024 / 1024) + "G");
		// 当前交换区剩余量
		System.out.println("当前交换区剩余量:" + df.format((float) swap.getFree() / 1024 / 1024 / 1024) + "G");
	} catch (SigarException e) {
		e.printStackTrace();
	}
}
 
开发者ID:funtl,项目名称:framework,代码行数:30,代码来源:SysInfo.java

示例5: totalSwap

import org.hyperic.sigar.Swap; //导入依赖的package包/类
/**
 * 获取交换区总大小
 */
public static long totalSwap() throws SigarException{
	if(staticResource.totalSwap == null){
		Swap swap = sigar.getSwap();
		staticResource.totalSwap = (long)(swap.getTotal()/1048576);
	}
	return staticResource.totalSwap;
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:11,代码来源:MonitorUtil.java

示例6: getValue

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

	int factor = 1;
	double cur;
	double val;
	switch (this.type) {
	case 0:
		cur = mem.getPageIn();
		val = this.prev != -1.0D ? cur - this.prev : 0.0D;
		this.prev = cur;
		break;
	case 1:
		cur = mem.getPageOut();
		val = this.prev != -1.0D ? cur - this.prev : 0.0D;
		this.prev = cur;
		break;
	case 2:
		val = mem.getFree();
		factor = this.dividingFactor;
		break;
	case 3:
		val = mem.getTotal();
		factor = this.dividingFactor;
		break;
	case 4:
		val = mem.getUsed();
		factor = this.dividingFactor;
		break;
	default:
		throw new SigarException("Unknown swap type " + this.type);
	}
	val /= factor;
	res.append(Double.toString(val));
}
 
开发者ID:junehappylove,项目名称:ServerAgent,代码行数:37,代码来源:SwapMetric.java

示例7: getFreeSwap

import org.hyperic.sigar.Swap; //导入依赖的package包/类
public long getFreeSwap() {
    if (osBean instanceof com.sun.management.OperatingSystemMXBean) {
        com.sun.management.OperatingSystemMXBean nativeOsBean = (com.sun.management.OperatingSystemMXBean) osBean;
        return nativeOsBean.getFreeSwapSpaceSize();
    } else if (sigar != null) {
        try {
            Swap swap = sigar.getSwap();
            return swap.getFree();
        } catch (SigarException ex) {
            logger.log(Level.SEVERE, null, ex);
        }
    }

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

示例8: getTotalSwap

import org.hyperic.sigar.Swap; //导入依赖的package包/类
public long getTotalSwap() {
    if (osBean instanceof com.sun.management.OperatingSystemMXBean) {
        com.sun.management.OperatingSystemMXBean nativeOsBean = (com.sun.management.OperatingSystemMXBean) osBean;
        return nativeOsBean.getTotalSwapSpaceSize();
    } else if (sigar != null) {
        try {
            Swap swap = sigar.getSwap();
            return swap.getTotal();
        } catch (SigarException ex) {
            logger.log(Level.SEVERE, null, ex);
        }
    }

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

示例9: setUp

import org.hyperic.sigar.Swap; //导入依赖的package包/类
@Before
public void setUp() {
	sigar = mock(Sigar.class);
	swap = mock(Swap.class);
	cpuPerc = mock(CpuPerc.class);
	cpuInfo = mock(CpuInfo.class);
	mem = mock(Mem.class);
	
	machineStatsChecker = new MachineStatsChecker();		
}
 
开发者ID:aol,项目名称:micro-server,代码行数:11,代码来源:MachineStatsCheckerTest.java

示例10: freeSwap

import org.hyperic.sigar.Swap; //导入依赖的package包/类
/**
 * 获取交换区剩余
 */
public static long freeSwap() throws SigarException{
	Swap swap = sigar.getSwap();
	return (long)(swap.getFree()/1048576);
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:8,代码来源:MonitorUtil.java

示例11: getSwap

import org.hyperic.sigar.Swap; //导入依赖的package包/类
public static Swap getSwap() throws SigarException {
	_init();
	return sigar.getSwap();
}
 
开发者ID:giiwa,项目名称:giiwa,代码行数:5,代码来源:Host.java

示例12: getMemInfo

import org.hyperic.sigar.Swap; //导入依赖的package包/类
public static MemInfo getMemInfo() {

		LOGGER.debug("Getting memory info...");

		try {

			Mem mem = sigar.getMem();
			Swap swap = sigar.getSwap();

			MemInfo memInfo = new MemInfo(mem.getTotal(), mem.getActualUsed(), mem.getActualFree(), swap.getTotal() - mem.getTotal(), swap.getUsed()
					- mem.getActualUsed(), swap.getFree());

			LOGGER.debug("Memory info: {}", memInfo);

			return memInfo;

		} catch (SigarException e) {
			throw new AgentException("Error reading memory info", e);
		}

	}
 
开发者ID:monocycle,项目名称:monocycle-agent,代码行数:22,代码来源:SystemInformationHelper.java

示例13: sendRAMEvent

import org.hyperic.sigar.Swap; //导入依赖的package包/类
private void sendRAMEvent() throws JMSException, SigarException {

			log.finer("Starting to collect RAM event");

			final RAMEvent event = new RAMEvent();
			initializeBaseEventProperties(event);
			event.setHostId(hostId);

			if (sunOsMX == null) {
				final Runtime runtime = Runtime.getRuntime();
				event.setMaxMemory(runtime.maxMemory());
				event.setFreeMemory(runtime.freeMemory());
				event.setUsedMemory(event.getMaxMemory() - event.getFreeMemory());
			} else {
				event.setFreeMemory(sunOsMX.getFreePhysicalMemorySize());
				event.setMaxMemory(sunOsMX.getTotalPhysicalMemorySize());
				event.setUsedMemory(event.getMaxMemory() - event.getFreeMemory());
				event.setCommitedMemory(sunOsMX.getCommittedVirtualMemorySize());
				event.setFreeSwapMemory(sunOsMX.getFreeSwapSpaceSize());
				event.setMaxSwapMemory(sunOsMX.getTotalSwapSpaceSize());
				event.setUsedSwapMemory(event.getMaxSwapMemory() - event.getFreeSwapMemory());
			}

			// Sigar
			if (sigar != null) {
				final Mem memory = sigar.getMem();
				final Swap swap = sigar.getSwap();

				// getActual* doesn't take buffers/caches into account, but
				// doesn' match the behavior of runtime/sunOsMX
				// event.setFreeMemory(memory.getActualFree());
				// event.setUsedMemory(memory.getActualUsed());
				event.setFreeMemory(memory.getFree());
				event.setMaxMemory(memory.getTotal());
				event.setUsedMemory(memory.getUsed());

				event.setFreeSwapMemory(swap.getFree());
				event.setMaxSwapMemory(swap.getTotal());
				event.setUsedSwapMemory(swap.getUsed());
			}

			log.finer("Current RAM usage is " + event.getUsedMemory());
			getMqHelper().sendEvent(event);
			log.finer("Successfully sent RAM event");

		}
 
开发者ID:xLeitix,项目名称:jcloudscale,代码行数:47,代码来源:StateEventAspect.java

示例14: loadSnapshot

import org.hyperic.sigar.Swap; //导入依赖的package包/类
@Override
Swap loadSnapshot(Sigar sigar) throws SigarException {
	return sigar.getSwap();
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:5,代码来源:SwapMetricSet.java


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