It’s pretty simple, but I can’t seem to find a way to output a list of nodes to std out based off of the queue.
Thanks! Sorry if this is obvious, I couldn’t figure it out with qstat, qmgr or pbsnodes.
It’s pretty simple, but I can’t seem to find a way to output a list of nodes to std out based off of the queue.
Thanks! Sorry if this is obvious, I couldn’t figure it out with qstat, qmgr or pbsnodes.
Good question @dward4 indeed
There is no command to get this output. You would need to write a script ( bash, python , perl or others ) to get this .
Might help:
import os
import sys
queue_cmd="source /etc/pbs.conf; $PBS_EXEC/bin/qmgr -c 'l q @default' | grep ^[a-zA-Z] | awk '{print $2}'"
for queuename in os.popen(queue_cmd).readlines():
queuename=queuename.strip()
qstat_rn1_cmd = "source /etc/pbs.conf ; $PBS_EXEC/bin/qstat -rn1 | tail -n +6 | grep " + queuename + " | awk \'{print $12}\' > "+ queuename +".txt"
os.system(qstat_rn1_cmd)
def nodes_return(queuename):
nodelist=[]
filename="./"+queuename+".txt"
nodes=open(filename,'r').readlines()
for line in nodes:
line=line.strip()
line=line.split('+')
for node in line:
node=node.split('/')[0]
nodelist.append(node)
nodelist=list(set(nodelist))
return nodelist
for i in os.popen(queue_cmd).readlines():
i = i.strip()
j=nodes_return(i)
print i,"(",len(j),")"
print ','.join(j)
Thanks @adarsh!
This worked for me (similar to what you have in queue_cmd, line 3:
qmgr -c ‘p n @default’ | grep “queue = <queue_name>” | awk ‘{print $3}’