Index: /trunk/pbs_swig/distro/examples/pbsmon.py
===================================================================
--- /trunk/pbs_swig/distro/examples/pbsmon.py	(revision 62)
+++ /trunk/pbs_swig/distro/examples/pbsmon.py	(revision 63)
@@ -16,4 +16,6 @@
 import pbs
 
+pbs_ND_free_and_job = 'not_all_procs_used'
+
 translate_state = {
     pbs.ND_free             : '_',
@@ -26,5 +28,6 @@
     pbs.ND_state_unknown    : '?',   
     pbs.ND_timeshared       : 'T',
-    pbs.ND_cluster          : 'C'
+    pbs.ND_cluster          : 'C',
+    pbs_ND_free_and_job     : 'j'
 }
 
@@ -37,6 +40,8 @@
   #
   if len(nl) == 1: 
+    print nl[0]
     width = len( nl[0] )
   else:
+    print nl[0]
     width = len( nl[1] )
 
@@ -81,5 +86,5 @@
   for key in translate_state.keys():
     value = translate_state[key]
-    print "%2s %-15s : %d\t |" %( value, key, sl.count(value) ),
+    print "%3s %-21s : %d\t |" %( value, key, sl.count(value) ),
     if n%2:
       print ''
@@ -104,8 +109,9 @@
    sys.exit(1)
 
-  # We are only interested in the state of a node
+  # We are only interested in the state and jobs of a node
   #
-  attrl = pbs.new_attrl(1);
+  attrl = pbs.new_attrl(2);
   attrl[0].name='state'
+  attrl[1].name = 'jobs'
 
 
@@ -123,6 +129,18 @@
     #
     temp = string.splitfields(node_attr[0].value, ',')
-    state_list.append(translate_state[ temp[0] ])
+    state = temp[0]
+    state_list.append(translate_state[state])
 
+    # look if on a free node a job is scheduled
+    #
+    if state == pbs.ND_free:
+       if len(node_attr) > 1:
+          state_list.append(translate_state[pbs_ND_free_and_job])
+       else:
+          state_list.append(translate_state[state])
+    else:
+          state_list.append(translate_state[state])
+		
+		
     re_host = re.compile(r"""
 
@@ -132,5 +150,7 @@
 
     result = re_host.search(node.name)
+    result = None
     if result:
+      print 'bas'
       node_list.append( result.group('name') )
     else:
Index: /trunk/pbs_swig/distro/examples/rack_pbsmon.py
===================================================================
--- /trunk/pbs_swig/distro/examples/rack_pbsmon.py	(revision 63)
+++ /trunk/pbs_swig/distro/examples/rack_pbsmon.py	(revision 63)
@@ -0,0 +1,135 @@
+#! /usr/bin/env python
+#
+#	pbsmon	WJ104
+#
+#	Hint: set ts=4
+#
+# SVN INFO:
+#	$Id$
+
+import os
+import sys
+import string
+
+import pbs
+
+
+NODES_PER_RACK = 19
+N_RACKS = 15
+
+PBS_STATES = {
+	pbs.ND_free				: '_',
+	pbs.ND_down				: 'X',
+	pbs.ND_offline			: '.',
+	pbs.ND_reserve			: 'R',
+	pbs.ND_job_exclusive	: 'J',
+	pbs.ND_job_sharing		: 'S',
+	pbs.ND_busy				: '*',
+	pbs.ND_state_unknown	: '?',
+	pbs.ND_timeshared		: 'T',
+	pbs.ND_cluster			: 'C'
+}
+
+PBS_STATE_JOB_BUT_FREE = 'j'
+
+
+def pbsmon():
+	global NODES_PER_RACK, N_RACKS, PBS_STATES, PBS_STATE_JOB_BUT_FREE
+
+	if len(sys.argv) > 1:
+		pbs_server = sys.argv[1]
+	else:
+		pbs_server = pbs.pbs_default()
+		if not pbs_server:
+			print 'No default pbs server, usage: %s [server]' % os.path.basename(sys.argv[0])
+			sys.exit(1)
+
+	con = pbs.pbs_connect(pbs_server)
+	if con < 0:
+		print pbs.pbs_geterrmsg(con)
+		sys.exit(1)
+
+# get the state of the nodes
+	attrl = pbs.new_attrl(2)
+	attrl[0].name = 'state'
+	attrl[1].name = 'jobs'
+	nodes = pbs.pbs_statnode(con, '', attrl, 'NULL')
+
+	node_dict = {}
+
+	count_states = {}
+	for key in PBS_STATES.keys():
+		count_states[key] = 0
+
+	for node in nodes:
+		node_attr = node.attribs
+		temp = string.split(node_attr[0].value, ',')
+		state = temp[0]
+		state_char = PBS_STATES[state]
+		count_states[state] = count_states[state] + 1
+
+		if state == pbs.ND_free:
+			if len(node_attr) > 1:
+#				print 'TD: %s' % node.name, node_attr[1]
+				state_char = PBS_STATE_JOB_BUT_FREE
+				count_states[pbs.ND_free] = count_states[pbs.ND_free] - 1
+				count_states[pbs.ND_job_exclusive] = count_states[pbs.ND_job_exclusive] + 1
+
+#		print 'TD: %s %s' % (node.name, state_char)
+		node_dict[node.name] = state_char
+
+	legend = PBS_STATES.keys()
+	legend.sort()
+
+# print nodes with gb-r%dn%d naming scheme
+	print '  ',
+	for rack in xrange(1, N_RACKS+1):
+		print '%2d' % rack,
+	print
+
+	for node_nr in xrange(1, NODES_PER_RACK+1):
+		print '%2d' % node_nr,
+
+		for rack in xrange(1, N_RACKS+1):
+			node_name = 'gb-r%dn%d' % (rack, node_nr)
+
+			if node_dict.has_key(node_name):
+				print ' %s' % node_dict[node_name],
+
+				del node_dict[node_name]
+			else:
+				print '  ',
+
+		if node_nr-1 < len(legend):
+			state = legend[node_nr-1]
+			print '  %s  %-13s : %d' % (PBS_STATES[state], state, count_states[state])
+		else:
+			print
+
+	print
+
+# any other nodes?
+	arr = node_dict.keys()
+	if arr:
+		arr.sort()
+
+		for node in arr:
+			print '%s %s' % (node, node_dict[node])
+
+		print
+
+#	n = 0
+#	for state in legend:
+#		print '%s  %-13s : %-3d     ' % (PBS_STATES[state], state, count_states[state]),
+#		n = n + 1
+#		if n > 1:
+#			n = 0
+#			print
+
+
+if __name__ == '__main__':
+	pbsmon()
+
+
+# EOB
+
