Skip to content

Commit

Permalink
Added pretty-fied memory for -u JohnDoe --details. Adjusted man page.
Browse files Browse the repository at this point in the history
The memory printed from the --details flag for a user's jobs will now show easily read memory units. The units shown are; KB, MB, and GB. TB is not reflected as very few machines have mroe than 1 TB of memory anyways. Perhaps in 5 years that will change. The manual page was updated to reflect the change in --details for a user's jobs showing the processes now instead of only the jobs through UGE.
  • Loading branch information
CodyKank committed Sep 8, 2017
1 parent a7da43d commit 7c1f1c6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
21 changes: 14 additions & 7 deletions node_search.1
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ Examples below.
." Next Option . . .
.TP
\fB--details
\fRShow a more detailed output of whatever was passed in to \fRnode_search\fR. The result of
\fB--details\fR depends on what it is modifying. If it is modifying the debug or long queues or a
\fRShow a more detailed output of whatever was passed into \fRnode_search\fR. The result of
\fB--details\fR depends on what it is modifying. If it is modifying the debug queue, long queue, or a
specifed host-group, then the output will show all of the machines/nodes that belong to that queue
or host-group. Each one of those nodes will also show its core usage (used vs total). If \fB--details
\fRis modifying a user, then all of the nodes that the user has jobs running on will be displayed,
along with every other job running on that specific node. If the user has any pending jobs then those
will be shown as well. If \fB--details \fRis modifying the \fB-uf \fRoption, then it will display
all of the nodes which belong to the host-groups the specified user has access to.
or host-group. Each one of those nodes will also show its core usage (used vs total). This will be
the same behavior that occurs if \fB--details\fR is used to modify \fB-a \fR or\fB --all\fR. If \fB--details
\fRis modifying a user, then all of the nodes the specified user is running will be displayed along with all
of the processes that user owns and the respective memory usage, CPU%, and time. This is useful for when a job submitted
through UGE spawns or starts multiple processes which are not necessarily tracked by UGE. If the user has any
pending jobs then those will be shown as well. If \fB--details \fRis modifying the \fB-uf \fRoption, then it will
display all of the nodes which belong to the host-groups the specified user has access to.

." END OPTIONS !!

Expand All @@ -131,6 +133,11 @@ needed for the host-group.
and every node that also belongs to those host-groups. It may be wise to pipe this output through
something along the lines of less/more. e.g. node_search.py -uf JohnDoe33 --details | less

.TP
\fBnode_search.py -u JohnDoe
\fRDisplay the user JohnDoe and their jobs along with core usage and the nodes the jobs are running
on.


.SH BUGS
\fRnode_search.py -uf fake_user \- will act as if it is a real user.
Expand Down
21 changes: 19 additions & 2 deletions node_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,14 +786,14 @@ def print_detailed_user(node_list, pending_list, user_name):
tmp_user_list = {}
lineSplit = line.split()
tmp_user_list["PID"] = lineSplit[0]
tmp_user_list["RESMEM"] = lineSplit[5]
tmp_user_list["RESMEM"] = cleanMem(lineSplit[5])
tmp_user_list["CPU%"] = lineSplit[8]
tmp_user_list["TIME"] = lineSplit[10]
tmp_user_list["PNAME"] = lineSplit[11]
user_proc_list.append(tmp_user_list)

# Printing processes information that pertains to the current user only.
print(node.name + (str(node.used_cores) + "/" + str(node.total_cores)).rjust(int(TERMWIDTH/2)))
print(node.name + ("Cores: " + str(node.used_cores) + "/" + str(node.total_cores)).rjust(int(TERMWIDTH/2)))
print('-'.center(TERMWIDTH,"-"))
print('PID'.center(10, ' ') + 'ProcName'.center(20, ' ') + 'Memory Used'.center(20) + 'CPU%'.center(10) + 'TIME'.center(16))
for proc in user_proc_list:
Expand All @@ -810,6 +810,23 @@ def print_detailed_user(node_list, pending_list, user_name):
sys.exit()
#^----------------------------------------------------------------------------- print_detailed_user(. . .)

def cleanMem(badMem):
"""Function which accepts a string which is the memory of a process from top. These are in KB or in t for terabyte.
These will be transformed into human readable memory untis like MB and GB to easily understand them. Returns:
a string which holds the human readable memory amount."""

if len(badMem) > 3 and len(badMem) <= 6 and ('t' not in badMem):
return (str( float(badMem) / 1000.0) + ' MB') # Moving decimal point over 3 times and adding MB
elif len(badMem) > 6 and ('t' not in badMem ):
return (str( float(badMem) /100000.0) + ' GB')
elif 't' in badMem:
badMem = badMem.replace('t','') # removing the t from terabyte
return (str(float(badMem)*1000) + ' GB')
else:
# The true usagem must be in KB, so add that
return badMem + ' KB'


def print_short_user(node_list, pending_list, user_name):
"""Prints a short version of the user details: the node the user is running on with their jobs, and the
user's pending jobs (if any)."""
Expand Down

0 comments on commit 7c1f1c6

Please sign in to comment.