本文整理汇总了Java中jnr.posix.POSIXFactory类的典型用法代码示例。如果您正苦于以下问题:Java POSIXFactory类的具体用法?Java POSIXFactory怎么用?Java POSIXFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
POSIXFactory类属于jnr.posix包,在下文中一共展示了POSIXFactory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: monitorParent
import jnr.posix.POSIXFactory; //导入依赖的package包/类
private static void monitorParent(final int pid) {
Subprocesses.startDaemon(() -> {
while (true) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
continue;
}
int ppid = POSIXFactory.getPOSIX().getppid();
if (ppid != pid) {
// If we've been reparented, then the spawning parent is dead.
System.exit(Subprocesses.OK_EXIT_CODE);
}
}
});
}
示例2: main
import jnr.posix.POSIXFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
LinuxCpuService linuxCpuService = new LinuxCpuService(POSIXFactory.getPOSIX());
List<CpuDetails> allCpuDetails = linuxCpuService.getAllCpuDetails();
for (CpuDetails cpuDetails : allCpuDetails) {
System.out.println("cpuDetails = " + cpuDetails);
}
List<CpuUsage> allCpuUsage1 = linuxCpuService.getAllCpuUsage();
for (CpuUsage cpuUsage : allCpuUsage1) {
System.out.println("cpuUsage = " + cpuUsage);
}
Thread.sleep(1 * 1000l);
List<CpuUsage> allCpuUsage2 = linuxCpuService.getAllCpuUsage();
for (int i = 0; i < allCpuUsage2.size(); i++) {
CpuUsageRatio cpuUsageRatio = new CpuUsageRatio(allCpuUsage1.get(i), allCpuUsage2.get(i));
System.out.println("cpuUsageRatio = " + cpuUsageRatio);
}
}
示例3: getPOSIX
import jnr.posix.POSIXFactory; //导入依赖的package包/类
public static synchronized POSIX getPOSIX()
{
if (posix == null) {
posix = POSIXFactory.getPOSIX(DEFAULT_HANDLER, true);
}
return posix;
}
示例4: sendSignalToProcess
import jnr.posix.POSIXFactory; //导入依赖的package包/类
private static void sendSignalToProcess(Process process, Signal signal) {
int processPid = getProcessPid(process);
if (processPid != -1) {
LOGGER.info("Sending signal {} to process {}", signal.intValue(), processPid);
POSIXFactory.getNativePOSIX().kill(processPid, signal.intValue());
}
}
示例5: main
import jnr.posix.POSIXFactory; //导入依赖的package包/类
public static void main(String[] args) {
POSIX posix = POSIXFactory.getPOSIX();
LinuxProcessService service = new LinuxProcessService(posix);
int[] allPids = service.getAllPids();
System.out.println("allPids.length = " + allPids.length);
int pid = posix.getpid();
System.out.println(service.getProcessDetails(pid));
System.out.println(service.getProcessMemoryUsage(pid));
System.out.println(service.getProcessExecutionContext(pid));
System.out.println(service.getProcessCpuUsage(pid));
}
示例6: sendSignalToProcess
import jnr.posix.POSIXFactory; //导入依赖的package包/类
private void sendSignalToProcess(Process process, Signal signal) {
int processPid = getProcessPid(process);
if (processPid != -1) {
LOGGER.info("Sending signal {} to process {}", signal.intValue(), processPid);
POSIXFactory.getNativePOSIX().kill(processPid, signal.intValue());
}
}
示例7: pid
import jnr.posix.POSIXFactory; //导入依赖的package包/类
static int pid() {
return POSIXFactory.getPOSIX().getpid();
}
示例8: createCpuService
import jnr.posix.POSIXFactory; //导入依赖的package包/类
public static CpuService createCpuService() {
return createCpuService(POSIXFactory.getPOSIX());
}
示例9: createProcessService
import jnr.posix.POSIXFactory; //导入依赖的package包/类
public static ProcessService createProcessService() {
return createProcessService(POSIXFactory.getPOSIX());
}
示例10: main
import jnr.posix.POSIXFactory; //导入依赖的package包/类
public static void main(String[] args) {
LinuxSystemService service = new LinuxSystemService(POSIXFactory.getPOSIX());
System.out.println(service.getSystemLoad());
System.out.println(service.getSystemMemoryUsage().toStringRatio());
}
示例11: createSystemService
import jnr.posix.POSIXFactory; //导入依赖的package包/类
public static SystemService createSystemService() {
return createSystemService(POSIXFactory.getPOSIX());
}
示例12: kill
import jnr.posix.POSIXFactory; //导入依赖的package包/类
public static int kill(Process process, Signal signal) throws Exception {
int pid = getPid(process);
return POSIXFactory.getPOSIX().kill(pid, signal.intValue());
}