• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java OSProcess类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getProcessRecentCpuUsage

import oshi.software.os.OSProcess; //导入依赖的package包/类
private double getProcessRecentCpuUsage() {
    double output = 0d;
    HardwareAbstractionLayer hal = si.getHardware();
    OperatingSystem os = si.getOperatingSystem();
    OSProcess p = os.getProcess(os.getProcessId());

    if (cpuTime != 0) {
        double uptimeDiff = p.getUpTime() - uptime;
        double cpuDiff = (p.getKernelTime() + p.getUserTime()) - cpuTime;
        output = cpuDiff / uptimeDiff;
    } else {
        output = ((double) (p.getKernelTime() + p.getUserTime())) / (double) p.getUserTime();
    }

    // Record for next invocation
    uptime = p.getUpTime();
    cpuTime = p.getKernelTime() + p.getUserTime();
    return output / hal.getProcessor().getLogicalProcessorCount();
}
 
开发者ID:Frederikam,项目名称:Lavalink,代码行数:20,代码来源:StatsTask.java


示例2: create

import oshi.software.os.OSProcess; //导入依赖的package包/类
public static Process create(OSProcess process, GlobalMemory memory) {
    return new Process(process.getName(),
            process.getPath(),
            process.getCommandLine(),
            process.getUser(),
            process.getUserID(),
            process.getGroup(),
            process.getGroupID(),
            process.getState(),
            process.getProcessID(),
            process.getParentProcessID(),
            process.getThreadCount(),
            process.getPriority(),
            process.getVirtualSize(),
            process.getResidentSetSize(),
            100d * process.getResidentSetSize() / memory.getTotal(),
            process.getKernelTime(), process.getUserTime(),
            process.getUpTime(),
            100d * (process.getKernelTime() + process.getUserTime()) / process.getUpTime(),
            process.getStartTime(),
            process.getBytesRead(),
            process.getBytesWritten());
}
 
开发者ID:Krillsson,项目名称:sys-api,代码行数:24,代码来源:Process.java


示例3: printProcesses

import oshi.software.os.OSProcess; //导入依赖的package包/类
/**
 * Prints the processes.
 *
 * @param os the os
 * @param memory the memory
 */
private static void printProcesses(OperatingSystem os, GlobalMemory memory) {
  oshi.add("Processes: " + os.getProcessCount() + ", Threads: " + os.getThreadCount());
  // Sort by highest CPU
  List<OSProcess> procs = Arrays.asList(os.getProcesses(5, ProcessSort.CPU));

  oshi.add("   PID  %CPU %MEM       VSZ       RSS Name");
  for (int i = 0; i < procs.size() && i < 5; i++) {
    OSProcess p = procs.get(i);
    oshi.add(String.format(" %5d %5.1f %4.1f %9s %9s %s%n", p.getProcessID(),
        100d * (p.getKernelTime() + p.getUserTime()) / p.getUpTime(),
        100d * p.getResidentSetSize() / memory.getTotal(),
        FormatUtil.formatBytes(p.getVirtualSize()),
        FormatUtil.formatBytes(p.getResidentSetSize()), p.getName()));
  }
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:22,代码来源:OshiController.java


示例4: update

import oshi.software.os.OSProcess; //导入依赖的package包/类
private void update() {
    List<OSProcess> procs = Arrays.asList(os.getProcesses(10, OperatingSystem.ProcessSort.CPU));
    for (OSProcess process : procs) {
        ProcessBean bean = null;
        if(processList.getItems().size() <= procs.indexOf(process)) {
            bean = beanManager.create(ProcessBean.class);
            processList.getItems().add(bean);
        } else {
            bean = processList.getItems().get(procs.indexOf(process));
        }
        bean.setProcessID(new Integer(process.getProcessID()).toString());
        bean.setCpuPercentage(format.format(100d * (process.getKernelTime() + process.getUserTime()) / process.getUpTime()));
        bean.setMemoryPercentage(format.format(100d * process.getResidentSetSize() / memory.getTotal()));
        bean.setName(process.getName());
    }
    asyncServerRunner.execute(new Runnable() {
        @Override
        public void run() {
            sessionExecutor.runLaterInClientSession(() -> update());
        }
    });
}
 
开发者ID:canoo,项目名称:dolphin-platform,代码行数:23,代码来源:ProcessMonitorController.java


示例5: getProcessResourceConsumptionInternal

import oshi.software.os.OSProcess; //导入依赖的package包/类
@Nullable
static ProcessResourceConsumption getProcessResourceConsumptionInternal(
    @Nullable OSProcess process) {
  if (process == null) {
    return null;
  }
  return ProcessResourceConsumption.builder()
      .setMemResident(process.getResidentSetSize())
      .setMemSize(process.getVirtualSize())
      .setCpuReal(process.getUpTime())
      .setCpuUser(process.getUserTime())
      .setCpuSys(process.getKernelTime())
      .setCpuTotal(process.getUserTime() + process.getKernelTime())
      .setIoBytesRead(process.getBytesRead())
      .setIoBytesWritten(process.getBytesWritten())
      .setIoTotal(process.getBytesRead() + process.getBytesWritten())
      .build();
}
 
开发者ID:facebook,项目名称:buck,代码行数:19,代码来源:ProcessHelper.java


示例6: setupDataUnix

import oshi.software.os.OSProcess; //导入依赖的package包/类
private void setupDataUnix(OperatingSystem.ProcessSort sort) {
    OSProcess[] processes = services.processorService.getProcessesList(sort);
    data = new String[processes.length][5];

    for(int i = 0; i < processes.length; i++) {
        // path, uptime, pid, name
        data[i][0] = processes[i].getName();
        data[i][1] = Integer.toString(processes[i].getProcessID());
        data[i][2] = Long.toString(processes[i].getResidentSetSize() / (1024 * 1024)) + " MB";
    }
}
 
开发者ID:ozankaraali,项目名称:SystemMonitor,代码行数:12,代码来源:ProcessesPanel.java


示例7: setUp

import oshi.software.os.OSProcess; //导入依赖的package包/类
@Before
public void setUp() {

    process = new Process(
            "name",
            "path",
            "commandLine",
            "user",
            "123",
            "group",
            "1233",
            OSProcess.State.RUNNING,
            100,
            99,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0);
}
 
开发者ID:Krillsson,项目名称:sys-api,代码行数:28,代码来源:ProcessesResourceTest.java


示例8: getProcess

import oshi.software.os.OSProcess; //导入依赖的package包/类
private OSProcess getProcess(int pid) throws DeviceNotFoundException {
    OSProcess process = operatingSystem.getProcess(pid);
    if (process == null) {
        throw new DeviceNotFoundException("Error while getting information for process with PID " + pid);
    }
    return process;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:8,代码来源:OshiSysteminfo.java


示例9: getProcessName

import oshi.software.os.OSProcess; //导入依赖的package包/类
@Override
public StringType getProcessName(int pid) throws DeviceNotFoundException {
    if (pid > 0) {
        OSProcess process = getProcess(pid);
        String name = process.getName();
        return new StringType(name);
    } else {
        return null;
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:11,代码来源:OshiSysteminfo.java


示例10: getProcessCpuUsage

import oshi.software.os.OSProcess; //导入依赖的package包/类
@Override
public DecimalType getProcessCpuUsage(int pid) throws DeviceNotFoundException {
    if (pid > 0) {
        OSProcess process = getProcess(pid);
        double cpuUsageRaw = (process.getKernelTime() + process.getUserTime()) / process.getUpTime();
        BigDecimal cpuUsage = getPercentsValue(cpuUsageRaw);
        return new DecimalType(cpuUsage);
    } else {
        return null;
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:12,代码来源:OshiSysteminfo.java


示例11: getProcessMemoryUsage

import oshi.software.os.OSProcess; //导入依赖的package包/类
@Override
public DecimalType getProcessMemoryUsage(int pid) throws DeviceNotFoundException {
    if (pid > 0) {
        OSProcess process = getProcess(pid);
        long memortInBytes = process.getResidentSetSize();
        long memoryInMB = getSizeInMB(memortInBytes);
        return new DecimalType(memoryInMB);
    } else {
        return null;
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:12,代码来源:OshiSysteminfo.java


示例12: getProcessPath

import oshi.software.os.OSProcess; //导入依赖的package包/类
@Override
public StringType getProcessPath(int pid) throws DeviceNotFoundException {
    if (pid > 0) {
        OSProcess process = getProcess(pid);
        String path = process.getPath();
        return new StringType(path);
    } else {
        return null;
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:11,代码来源:OshiSysteminfo.java


示例13: getProcessThreads

import oshi.software.os.OSProcess; //导入依赖的package包/类
@Override
public DecimalType getProcessThreads(int pid) throws DeviceNotFoundException {
    if (pid > 0) {
        OSProcess process = getProcess(pid);
        int threadCount = process.getThreadCount();
        return new DecimalType(threadCount);
    } else {
        return null;
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:11,代码来源:OshiSysteminfo.java


示例14: getProcessResourceConsumption

import oshi.software.os.OSProcess; //导入依赖的package包/类
/** Gets resource consumption of the process with the given pid. */
@Nullable
public ProcessResourceConsumption getProcessResourceConsumption(long pid) {
  try {
    OperatingSystem os = OSHI.getOperatingSystem();
    OSProcess process = os.getProcess((int) pid);
    return getProcessResourceConsumptionInternal(process);
  } catch (Exception ex) {
    // do nothing
    return null;
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:13,代码来源:ProcessHelper.java


示例15: add

import oshi.software.os.OSProcess; //导入依赖的package包/类
public Node add(OSProcess info) {
  Node node = getOrCreate(info.getProcessID());
  if (node.info == null) {
    node.info = info;
  }
  Node parent = getOrCreate(info.getParentProcessID());
  parent.addChild(node);
  return node;
}
 
开发者ID:facebook,项目名称:buck,代码行数:10,代码来源:ProcessHelper.java


示例16: getProcessByPid

import oshi.software.os.OSProcess; //导入依赖的package包/类
@Override
public Optional<Process> getProcessByPid(int pid) {
    return Optional
            .of(operatingSystem.getProcess(pid))
            .map((OSProcess p) -> Process.create(p, hal.getMemory()));
}
 
开发者ID:Krillsson,项目名称:sys-api,代码行数:7,代码来源:DefaultInfoProvider.java


示例17: Process

import oshi.software.os.OSProcess; //导入依赖的package包/类
public Process(String name,
               String path,
               String commandLine,
               String user,
               String userID,
               String group,
               String groupID,
               OSProcess.State state,
               int processID,
               int parentProcessID,
               int threadCount,
               int priority,
               long virtualSize,
               long residentSetSize,
               double memoryPercent,
               long kernelTime,
               long userTime,
               long upTime,
               double cpuPercent,
               long startTime,
               long bytesRead,
               long bytesWritten) {
    this.name = name;
    this.path = path;
    this.commandLine = commandLine;
    this.user = user;
    this.userID = userID;
    this.group = group;
    this.groupID = groupID;
    this.state = state;
    this.processID = processID;
    this.parentProcessID = parentProcessID;
    this.threadCount = threadCount;
    this.priority = priority;
    this.virtualSize = virtualSize;
    this.residentSetSize = residentSetSize;
    this.memoryPercent = memoryPercent;
    this.kernelTime = kernelTime;
    this.userTime = userTime;
    this.upTime = upTime;
    this.cpuPercent = cpuPercent;
    this.startTime = startTime;
    this.bytesRead = bytesRead;
    this.bytesWritten = bytesWritten;
}
 
开发者ID:Krillsson,项目名称:sys-api,代码行数:46,代码来源:Process.java


示例18: getState

import oshi.software.os.OSProcess; //导入依赖的package包/类
public OSProcess.State getState() {
    return state;
}
 
开发者ID:Krillsson,项目名称:sys-api,代码行数:4,代码来源:Process.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AudienceRestrictionCondition类代码示例发布时间:2022-05-22
下一篇:
Java JRCsvExporterParameter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap