admin管理员组文章数量:1221303
I am trying to fetch cpu % using jt400, however I am getting cpu % as zero for all the jobs? Can someone pls help here? Below is the code for reference.
JobList list = new JobList(as400);
list.clearJobSelectionCriteria();
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_LARGE);
list.addJobAttributeToRetrieve(Job.JOB_NAME);
list.addJobAttributeToRetrieve(Job.USER_NAME);
while (jobs.hasMoreElements()) {
Job job = (Job) jobs.nextElement();
job.loadStatistics();
String user = job.getUser();
int cpuPercent = (Integer) job.getValue(Job.ELAPSED_CPU_PERCENT_USED);
System.out.println("Percent CPU: " + cpuPercent);
}
I am trying to fetch cpu % using jt400, however I am getting cpu % as zero for all the jobs? Can someone pls help here? Below is the code for reference.
JobList list = new JobList(as400);
list.clearJobSelectionCriteria();
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_LARGE);
list.addJobAttributeToRetrieve(Job.JOB_NAME);
list.addJobAttributeToRetrieve(Job.USER_NAME);
while (jobs.hasMoreElements()) {
Job job = (Job) jobs.nextElement();
job.loadStatistics();
String user = job.getUser();
int cpuPercent = (Integer) job.getValue(Job.ELAPSED_CPU_PERCENT_USED);
System.out.println("Percent CPU: " + cpuPercent);
}
Share
Improve this question
asked Feb 6 at 20:28
Poojan ShahPoojan Shah
111 silver badge
New contributor
Poojan Shah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1 Answer
Reset to default 1I believe you need to call loadStatistics() before trying to get elapsed statistics.
Also there's resetStatistics().
Lastly, you may want to look at getCPUUssed instead, I believe that is the cumulative value for the jobs lifetime.
本文标签: javaGetting As400 Job Percent CPU Utilization using jt400Stack Overflow
版权声明:本文标题:java - Getting As400 Job Percent CPU Utilization using jt400 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739362125a2159869.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论