使用 JT400 获取所有作业的 CPU 利用率



我需要使用 JT400 获取所有作业的 CPU 利用率百分比。但是我无法一次获得作业列表,因为 loadStatistics(( 仅在作业级别不可用,不在列表中(更省时(。

截取以下代码后,我可以逐个获取每个作业的 CPU%,但需要很长时间:

AS400 as400 = new AS400("hostname", "username", "password");
//Reading SystemStatus like CPU usage and hdd usage
SystemStatus systemStatus = new SystemStatus(as400);
JobList list = new JobList(as400);
list.addJobSelectionCriteria(JobList.SELECTION_PRIMARY_JOB_STATUS_ACTIVE, Boolean.TRUE);
list.addJobSelectionCriteria(JobList.SELECTION_PRIMARY_JOB_STATUS_JOBQ, Boolean.FALSE);
list.addJobSelectionCriteria(JobList.SELECTION_PRIMARY_JOB_STATUS_OUTQ, Boolean.FALSE);
list.addJobAttributeToRetrieve(Job.CPU_TIME_USED);
list.addJobAttributeToRetrieve(Job.SUBSYSTEM);
list.addJobAttributeToRetrieve(Job.JOB_NAME);
list.addJobAttributeToRetrieve(Job.JOB_NUMBER);
list.addJobAttributeToRetrieve(Job.USER_NAME);
//list.addJobAttributeToRetrieve(Job.ELAPSED_CPU_PERCENT_USED);

Enumeration jobs = list.getJobs();
while (jobs.hasMoreElements())  {
Job  j= (Job) jobs.nextElement();
j.loadStatistics();
//TimeUnit.SECONDS.sleep(10);
System.out.println("Name " + j.getName() + " | Job NO : " + j.getNumber() + " | User : " + j.getUser() + " | CPU USED : " + j.getCPUUsed()+ " |  CPU% : " + j.getValue(Job.ELAPSED_CPU_PERCENT_USED));
j.resetStatistics();
}

有没有办法一次获得所有作业的 CPU% (Job.ELAPSED_CPU_PERCENT_USED(?

看一些工作管理 DB2 for i 系统服务。

您应该能够从这些函数中提取要查找的信息。

我当时使用 com.ibm.jtopenlite.components 解决了这个问题

JobInfo [] jobs = lstJobs.getJobs(connection, false);
List<Point> pointList = new ArrayList<Point>();

for (JobInfo job : jobs) {
log.debug("getCPUPercent: " + job.getCPUPercent());
log.debug("getCurrentUser: " + job.getCurrentUser());
log.debug("getJobName: " + job.getJobName());
log.debug("getJobType: " + job.getJobType());
log.debug("getSubsystem: " + job.getSubsystem());
log.debug("getTotalCPUUsed: " + job.getTotalCPUUsed());
log.debug("getUserName: " + job.getUserName());
log.debug("getCPUPercentInTenths: " + job.getCPUPercentInTenths());

}

相关内容

  • 没有找到相关文章

最新更新