Version 1 (modified by bas, 18 years ago) (diff) |
---|
Show free resources
This program wil show for each node how many cpu there are free:
!/usr/bin/env python from PBSQuery import PBSQuery from PBSQuery import PBSError import string p = PBSQuery() attr = [ 'state', 'jobs', 'np' ] nodes = p.getnodes(attr) total_nodes = len(nodes) stats = {} for nodename, node in nodes.items(): np = int(node['np']) try: stats[np] except KeyError: stats[np] = {} if node.has_job(): dummy = string.splitfields(node['jobs'], ',') diff = np - len(dummy) #print nodename, np, diff try: stats[np][diff] += 1 except KeyError: stats[np][diff] = 1 else: try: stats[np][np] += 1 except KeyError: stats[np][np] = 1 print 'Total number of nodes %d' %(total_nodes) for np, free_cpus in stats.items(): print '\tNodes with %s processors' %(np) for free_cpu in free_cpus: print '\t\t%d nodes has %d free' %(free_cpus[free_cpu], free_cpu)
Attachments (1)
-
show_pbs_res.py
(821 bytes) -
added by bas 18 years ago.
Show free resources
Download all attachments as: .zip