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


Java ProcessFinder类代码示例

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


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

示例1: findPid

import org.hyperic.sigar.ptql.ProcessFinder; //导入依赖的package包/类
@Override
public long findPid(BeyondJProcessQuery query, List<String> optionalArgs) throws IOException {

    try {
        long[] pids = ProcessFinder.find(sigar, query.getQuery());

        if (pids.length > 0) {
            return pids[0];
        } else {
            return new PureJavaProcessManager().findPid(optionalArgs);
        }
    } catch (Exception s1) {
        try {
            return new PureJavaProcessManager().findPid(optionalArgs);
        } catch (Exception e) {
            throw new IOException("findPid failed", s1);
        }
    } finally {
        sigar.close();
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:22,代码来源:SigarProcessManager.java

示例2: getPids

import org.hyperic.sigar.ptql.ProcessFinder; //导入依赖的package包/类
public static long[] getPids(SigarProxy sigar, String[] args)
    throws SigarException {

    long[] pids;

    switch (args.length) {
      case 0:
        pids = new long[] { sigar.getPid() };
        break;
      case 1:
        if (args[0].indexOf("=") > 0) {
            pids = ProcessFinder.find(sigar, args[0]);
        }
        else if (args[0].equals("$$")) {
            pids = new long[] { sigar.getPid() };
        }
        else {
            pids = new long[] {
                Long.parseLong(args[0])
            };
        }
        break;
      default:
        pids = new long[args.length];
        for (int i=0; i<args.length; i++) {
            pids[i] = Long.parseLong(args[i]);
        }
        break;
    }

    return pids;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:33,代码来源:Shell.java

示例3: getPIDByPTQL

import org.hyperic.sigar.ptql.ProcessFinder; //导入依赖的package包/类
private long getPIDByPTQL(String token) {
	String query = token.substring(token.indexOf("=") + 1);
	try {
		@SuppressWarnings("deprecation")
		long[] pids = new ProcessFinder(this.sigar).find(query);
		if (pids.length < 1) {
			log.warn("Unable to find process from query: " + query);
			return -1L;
		}
		return pids[0];
	} catch (SigarException ex) {
		log.warn("Error querying PTQL: " + query, ex);
	}
	return -1L;
}
 
开发者ID:junehappylove,项目名称:ServerAgent,代码行数:16,代码来源:MetricParamsSigar.java

示例4: measureMemory

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

import org.hyperic.sigar.ptql.ProcessFinder; //导入依赖的package包/类
private Set<Integer> getAliveWithSigar(boolean printProcesses) {
    Sigar sigar = new Sigar();
    try {
        long[] pids = new ProcessFinder(sigar).find("State.Name.eq=java,Args.*.re=" + pattern);
        Set<Integer> setOfPids = new HashSet<>();
        for (long pid : pids) {
            setOfPids.add((int) pid);
            if (printProcesses)
                System.out.println("Running java processes matching regex:" + pid);
        }
        return setOfPids;
    } catch (SigarException e) {
        return Collections.emptySet();
    }
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:16,代码来源:ProcessCleaner.java

示例6: getPid

import org.hyperic.sigar.ptql.ProcessFinder; //导入依赖的package包/类
private long getPid(String processName) throws SigarException {
	long pid;

	ProcessFinder processFinder = new ProcessFinder(sigarImpl);
	String query;

	if (processName.equals("$$")) {
		pid = sigar.getPid();
		logger.debug("Return own pid {}", pid);
		return pid;
	} else if (processName.startsWith("*")) {
		query = "State.Name.sw=" + processName.replace("*", "");
	} else if (processName.endsWith("*")) {
		query = "State.Name.ew=" + processName.replace("*", "");
	} else if (processName.startsWith("=")) {
		query = "State.Name.eq=" + processName.replace("=", "");
	} else if (processName.startsWith("#")) {
		query = processName.replace("#", "");
	} else {
		query = "State.Name.ct=" + processName;
	}

	logger.debug("Query pid by '{}'", query);
	pid = processFinder.findSingleProcess(query);

	logger.debug("Return pid {}", pid);
	return pid;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:29,代码来源:SysteminfoBinding.java

示例7: getPid

import org.hyperic.sigar.ptql.ProcessFinder; //导入依赖的package包/类
private long getPid(String processName) throws SigarException {
    long pid;

    ProcessFinder processFinder = new ProcessFinder(sigarImpl);
    String query;

    if (processName.equals("$$")) {
        pid = sigar.getPid();
        logger.debug("Return own pid {}", pid);
        return pid;
    } else if (processName.startsWith("*")) {
        query = "State.Name.sw=" + processName.replace("*", "");
    } else if (processName.endsWith("*")) {
        query = "State.Name.ew=" + processName.replace("*", "");
    } else if (processName.startsWith("=")) {
        query = "State.Name.eq=" + processName.replace("=", "");
    } else if (processName.startsWith("#")) {
        query = processName.replace("#", "");
    } else {
        query = "State.Name.ct=" + processName;
    }

    logger.debug("Query pid by '{}'", query);
    pid = processFinder.findSingleProcess(query);

    logger.debug("Return pid {}", pid);
    return pid;
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:29,代码来源:SysteminfoBinding.java


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