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


Java ProcMem类代码示例

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


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

示例1: collectMetrics

import org.hyperic.sigar.ProcMem; //导入依赖的package包/类
private void collectMetrics()
{
	logger.debug("Collecting metrics...");
	try
	{
		//get process CPU usage
		ProcCpu procCpu = sigar.getProcCpu(pid);

		//get process memory usage
		ProcMem procMem = sigar.getProcMem(pid);

		// get network interface stats
		NetInterfaceStat netStat = sigar.getNetInterfaceStat(interfaceName);

		ProcessMetrics measurement = new ProcessMetrics(procCpu.getPercent(),
				procMem.getSize(), procMem.getResident(), procMem.getPageFaults(),
				interfaceName, netStat.getRxBytes(), netStat.getTxBytes());

		metrics.add(measurement);

	} catch(SigarException ex)
	{
		logger.error(ex.getMessage(), ex);
	}
}
 
开发者ID:filipecampos,项目名称:raft_tests,代码行数:26,代码来源:MonitoringThread.java

示例2: main

import org.hyperic.sigar.ProcMem; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    Sigar sigar = new Sigar();

    if (args.length != 1) {
        throw new Exception("Usage: MemWatch pid");
    }

    long pid = Long.parseLong(args[0]);

    long lastTime = System.currentTimeMillis();

    ProcMem last = sigar.getProcMem(pid);

    while (true) {
        ProcMem cur = sigar.getProcMem(pid);
        
        StringBuffer diff = diff(last, cur);

        if (diff.length() == 0) {
            System.out.println("no change " +
                               "(size=" +
                               Sigar.formatSize(cur.getSize()) +
                               ")");
        }
        else {
            long curTime = System.currentTimeMillis();
            long timeDiff = curTime - lastTime;
            lastTime = curTime;
            diff.append(" after " + timeDiff + "ms");
            System.out.println(diff);
        }

        last = cur;
        Thread.sleep(SLEEP_TIME);
    }
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:37,代码来源:MemWatch.java

示例3: output

import org.hyperic.sigar.ProcMem; //导入依赖的package包/类
public void output(String[] args) throws SigarException {
    String query = args[0];
    MultiProcCpu cpu = this.proxy.getMultiProcCpu(query);
    println("Number of processes: " + cpu.getProcesses());
    println("Cpu usage: " + CpuPerc.format(cpu.getPercent()));
    println("Cpu time: "  + Ps.getCpuTime(cpu.getTotal()));

    ProcMem mem = this.proxy.getMultiProcMem(query);
    println("Size: " + Sigar.formatSize(mem.getSize()));
    println("Resident: " + Sigar.formatSize(mem.getResident()));
    println("Share: " + Sigar.formatSize(mem.getShare()));
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:13,代码来源:MultiPs.java

示例4: measureMemory

import org.hyperic.sigar.ProcMem; //导入依赖的package包/类
private void measureMemory(String id, String uid, Collector collector) throws Exception {
    // see https://support.hyperic.com/display/SIGAR/PTQL
    Sigar sigar = new Sigar();
    final ProcessFinder processFinder = new ProcessFinder(sigar);
    long pid = processFinder.findSingleProcess("State.Name.eq=java,Args.1.ct="+uid);

    Jcmd.gc(pid);

    ProcMem procMem = sigar.getProcMem(pid);
    long rss = procMem.getResident();
    collector.onMeasurement(id, Measure.RSS_AFTER_INVOCATION, bytesToMegabytes(rss));

    long javaHeap = Jstat.usedHeap(pid);
    collector.onMeasurement(id, Measure.JAVA_HEAP_AFTER_INVOCATION, bytesToMegabytes(javaHeap));
}
 
开发者ID:wildfly-swarm,项目名称:process-monitor,代码行数:16,代码来源:Monitor.java

示例5: main

import org.hyperic.sigar.ProcMem; //导入依赖的package包/类
public static void main(String[] args) throws SigarException {
	ProcMem mem = sigar.getProcMem(SysJMX.getProcessPID());
	System.out.println(Sigar.formatSize(mem.getSize()));
	System.out.println(Sigar.formatSize(mem.getResident()));
	System.out.println(Sigar.formatSize(mem.getRss()));
	System.out.println(Sigar.formatSize(mem.getShare()));
	System.out.println(Sigar.formatSize(mem.getVsize()));
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:9,代码来源:TopRequest.java

示例6: getVirtualMemSizeMb

import org.hyperic.sigar.ProcMem; //导入依赖的package包/类
@Override
public double getVirtualMemSizeMb() {
  return units.map(memory, ProcMem::getSize, 0L) / ONE_MEGABYTE;
}
 
开发者ID:OctoPerf,项目名称:jmx-agent,代码行数:5,代码来源:SigarProcessMetrics.java

示例7: getResidentMemSizeMb

import org.hyperic.sigar.ProcMem; //导入依赖的package包/类
@Override
public double getResidentMemSizeMb() {
  return units.map(memory, ProcMem::getResident, 0L) / ONE_MEGABYTE;
}
 
开发者ID:OctoPerf,项目名称:jmx-agent,代码行数:5,代码来源:SigarProcessMetrics.java

示例8: getShareMemSizeMb

import org.hyperic.sigar.ProcMem; //导入依赖的package包/类
@Override
public double getShareMemSizeMb() {
  return units.map(memory, ProcMem::getShare, 0L) / ONE_MEGABYTE;
}
 
开发者ID:OctoPerf,项目名称:jmx-agent,代码行数:5,代码来源:SigarProcessMetrics.java

示例9: getValue

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

	int factor = 1;
	double val;
	long cur;
	switch (this.type) {
	case 0:
		val = mem.getSize();
		factor = this.dividingFactor;
		break;
	case 1:
		cur = mem.getShare();
		this.prev = cur;
		val = cur;
		factor = this.dividingFactor;
		break;
	case 2:
		cur = mem.getPageFaults();
		val = this.prev > 0.0D ? cur - this.prev : 0.0D;
		this.prev = cur;
		break;
	case 3:
		cur = mem.getMajorFaults();
		val = this.prev > 0.0D ? cur - this.prev : 0.0D;
		this.prev = cur;
		break;
	case 4:
		cur = mem.getMinorFaults();
		val = this.prev > 0.0D ? cur - this.prev : 0.0D;
		this.prev = cur;
		break;
	case 5:
		cur = mem.getResident();
		this.prev = cur;
		val = cur;
		factor = this.dividingFactor;
		break;
	default:
		throw new SigarException("Unknown proc mem type " + this.type);
	}
	val /= factor;
	res.append(Double.toString(val));
}
 
开发者ID:junehappylove,项目名称:ServerAgent,代码行数:46,代码来源:MemProcMetric.java


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