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.
Add a comment  | 

1 Answer 1

Reset to default 1

I 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