本文整理汇总了Java中org.hyperic.sigar.Swap.getFree方法的典型用法代码示例。如果您正苦于以下问题:Java Swap.getFree方法的具体用法?Java Swap.getFree怎么用?Java Swap.getFree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hyperic.sigar.Swap
的用法示例。
在下文中一共展示了Swap.getFree方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
示例2: 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;
}
示例3: freeSwap
import org.hyperic.sigar.Swap; //导入方法依赖的package包/类
/**
* 获取交换区剩余
*/
public static long freeSwap() throws SigarException{
Swap swap = sigar.getSwap();
return (long)(swap.getFree()/1048576);
}
示例4: 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);
}
}