Get number of jobs for each node

Hi, I’d like to get the number of jobs ((R)unning or otherwise) for each node. It seems there are several ways to achieve this. Here are few ways I’m looking to get the information, but it seems these counts differ a bit from one another. The question is which is most accurate?

  1. qstat -a -n1 (Count the number of lines (status =R) per node)
  2. pbsnodes -aSvj (njobs column provides number of jobs per node)
  3. pbsnodes -v (Count the number of jobs list in the ‘jobs =’ property of the output.

Thanks!

All of the above ideas are good

Also, if you can come up with a json parser, it will be even more better

pbsnodes -av -F json
qstat -fx -F json

Thank you

Can someone explain why job count numbers differ between the output of these two commands ?

qstat -a -n1 | grep ‘node-name-1/’
and
pbsnodes -aSvj | grep ‘node-name-1.’

The first command only displays the list of (R)unning jobs for the grep’ed node, thus the count for that node. The second command displays the output for each node such as ncpus, suspended jobs, etc. as well as jobs running, njobs. However, in the jobs column a JOBID is listed multiple times, and each appears to count as a single job. Why is the job id listed more than once and counted in the number of njobs columns and each accounting for one job?