Changeset 357
- Timestamp:
- 04/11/18 15:02:50 (6 years ago)
- Location:
- trunk/examples
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/pbs_joblogin
r356 r357 24 24 # (os.getenv('USER')) 25 25 # 26 from __future__ import print_function 26 27 from PBSQuery import PBSQuery 27 28 import sys,os -
trunk/examples/pbs_jobmonitor
r356 r357 24 24 # (os.getenv('USER')) 25 25 # 26 from __future__ import print_function 26 27 from PBSQuery import PBSQuery 27 28 import sys,os -
trunk/examples/pbsmon.py
r356 r357 10 10 # $Id$ 11 11 # 12 from __future__ import print_function 12 13 import sys 13 14 import string -
trunk/examples/rack_pbsmon.py
r356 r357 1 1 #! /usr/bin/env python 2 2 # 3 # pbsmonWJ1043 # pbsmon WJ104 4 4 # 5 # 5 # Hint: set ts=4 6 6 # 7 7 from __future__ import print_function 8 8 import os 9 9 import sys … … 20 20 21 21 PBS_STATES = { 22 pbs.ND_free: '_',23 pbs.ND_down: 'X',24 pbs.ND_offline: '.',25 pbs.ND_reserve: 'R',26 pbs.ND_job_exclusive: 'J',27 pbs.ND_job_sharing: 'S',28 pbs.ND_busy: '*',29 pbs.ND_state_unknown: '?',30 pbs.ND_timeshared: 'T',31 pbs.ND_cluster: 'C',32 pbs_ND_single: 'j'22 pbs.ND_free : '_', 23 pbs.ND_down : 'X', 24 pbs.ND_offline : '.', 25 pbs.ND_reserve : 'R', 26 pbs.ND_job_exclusive : 'J', 27 pbs.ND_job_sharing : 'S', 28 pbs.ND_busy : '*', 29 pbs.ND_state_unknown : '?', 30 pbs.ND_timeshared : 'T', 31 pbs.ND_cluster : 'C', 32 pbs_ND_single : 'j' 33 33 } 34 34 … … 36 36 37 37 def pbsmon(): 38 38 global NODES_PER_RACK, N_RACKS, PBS_STATES 39 39 40 41 42 43 40 if len(sys.argv) > 1: 41 pbs_server = sys.argv[1] 42 else: 43 pbs_server = pbs.pbs_default() 44 44 45 46 47 45 if not pbs_server: 46 print('No default pbs server, usage: %s [server]' % os.path.basename(sys.argv[0])) 47 sys.exit(1) 48 48 49 50 51 52 53 49 con = pbs.pbs_connect(pbs_server) 50 if con < 0: 51 errno, text = pbs.error() 52 print(errno, text) 53 sys.exit(1) 54 54 55 55 # get the state of the nodes 56 57 58 59 56 attrl = pbs.new_attrl(2) 57 attrl[0].name = 'state' 58 attrl[1].name = 'jobs' 59 nodes = pbs.pbs_statnode(con, '', attrl, 'NULL') 60 60 61 61 node_dict = {} 62 62 63 64 65 63 count_states = {} 64 for key in PBS_STATES.keys(): 65 count_states[key] = 0 66 66 67 68 69 70 71 72 67 for node in nodes: 68 node_attr = node.attribs 69 temp = string.split(node_attr[0].value, ',') 70 state = temp[0] 71 state_char = PBS_STATES[state] 72 count_states[state] = count_states[state] + 1 73 73 74 75 76 # 77 78 79 74 if state == pbs.ND_free: 75 if len(node_attr) > 1: 76 # print 'TD: %s' % node.name, node_attr[1] 77 state_char = PBS_STATES[pbs_ND_single] 78 count_states[pbs.ND_free] = count_states[pbs.ND_free] - 1 79 count_states[pbs_ND_single] = count_states[pbs_ND_single] + 1 80 80 81 # 82 81 # print 'TD: %s %s' % (node.name, state_char) 82 node_dict[node.name] = state_char 83 83 84 85 84 legend = PBS_STATES.keys() 85 legend.sort() 86 86 87 87 # print nodes with gb-r%dn%d naming scheme 88 89 90 91 88 print(' ', end=' ') 89 for rack in xrange(1, N_RACKS+1): 90 print('%2d' % rack, end=' ') 91 print() 92 92 93 94 93 for node_nr in xrange(1, NODES_PER_RACK+1): 94 print('%2d' % node_nr, end=' ') 95 95 96 97 96 for rack in xrange(1, N_RACKS+1): 97 node_name = 'gb-r%dn%d' % (rack, node_nr) 98 98 99 100 99 if node_dict.has_key(node_name): 100 print(' %s' % node_dict[node_name], end=' ') 101 101 102 103 104 102 del node_dict[node_name] 103 else: 104 print(' ', end=' ') 105 105 106 107 108 109 110 106 if node_nr-1 < len(legend): 107 state = legend[node_nr-1] 108 print(' %s %-13s : %d' % (PBS_STATES[state], state, count_states[state])) 109 else: 110 print() 111 111 112 112 print() 113 113 114 114 # any other nodes? 115 116 117 115 arr = node_dict.keys() 116 if arr: 117 arr.sort() 118 118 119 120 119 for node in arr: 120 print('%s %s' % (node, node_dict[node])) 121 121 122 122 print() 123 123 124 # 125 # 126 # 127 # 128 # 129 # 130 # 124 # n = 0 125 # for state in legend: 126 # print '%s %-13s : %-3d ' % (PBS_STATES[state], state, count_states[state]), 127 # n = n + 1 128 # if n > 1: 129 # n = 0 130 # print 131 131 132 132 133 133 if __name__ == '__main__': 134 134 pbsmon() 135 135 136 136
Note: See TracChangeset
for help on using the changeset viewer.