本文整理匯總了Java中org.hyperic.sigar.Sigar.getPid方法的典型用法代碼示例。如果您正苦於以下問題:Java Sigar.getPid方法的具體用法?Java Sigar.getPid怎麽用?Java Sigar.getPid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.hyperic.sigar.Sigar
的用法示例。
在下文中一共展示了Sigar.getPid方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: shutdown
import org.hyperic.sigar.Sigar; //導入方法依賴的package包/類
static void shutdown(final Sigar sigar) {
LOG.info("Shutting down perfMon...");
String[] type = new String[] { "State.Name.sw=java,Args.*.re=perf(m|M)on" };
try {
long ownPid = sigar.getPid();
long[] pids = Shell.getPids(sigar, type);
for (long pid : pids) {
if (pid != ownPid) {
LOG.info("Sending SIGTERM signal to perfMon process with PID {}", pid);
sigar.kill(pid, "TERM");
}
}
} catch (SigarException ex) {
LOG.error(ex.getMessage(), ex);
}
}
示例2: NativeData
import org.hyperic.sigar.Sigar; //導入方法依賴的package包/類
public NativeData(Logger logger, Sigar sigar) {
this.logger = logger;
this.sigar = sigar;
if (sigar == null) {
pid = -1;
} else {
pid = sigar.getPid();
}
if (sigar == null && !(osBean instanceof com.sun.management.OperatingSystemMXBean)) {
logger.severe("You're not using Oracle Java nor using the native library. "
+ "You wan't be able to read native data");
}
}
示例3: updateProcessCpuUsage
import org.hyperic.sigar.Sigar; //導入方法依賴的package包/類
private void updateProcessCpuUsage(Sigar sigar, MachineInfo info)
{
try {
long pid = sigar.getPid();
ProcCpu cpu = sigar.getProcCpu(pid);
info.setProcessCpuUsage((float) cpu.getPercent());
} catch (SigarException e) {
log.error(e.getMessage(), e);
}
}