diff --git a/node_search.1 b/node_search.1 index 075fcbb..74598c0 100644 --- a/node_search.1 +++ b/node_search.1 @@ -1,6 +1,6 @@ .\" Manpage for node_search.py. .\" Contact ckankel@nd.edu to correct typos or errors. -.TH man 1 "8 SEPT 2017" "1.0.4" "node_search man page" +.TH man 1 "15 SEPT 2017" "1.1.0" "node_search man page" .SH NAME node_search \- get node, user, or host-group information from Univa Grid Engine .SH SYNOPSIS @@ -104,10 +104,10 @@ specifed host-group, then the output will show all of the machines/nodes that be 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. +of the processes that user owns and the respective memory usage, CPU%, and run time of each process. 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 !! @@ -136,11 +136,11 @@ something along the lines of less/more. e.g. node_search.py -uf JohnDoe33 --deta .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. +on. Will display total memory usage per node as used by user JohnDoe. .SH BUGS -\fRnode_search.py -uf fake_user \- will act as if it is a real user. +\fRNo known bugs at the current moment in time. Report any new findings to ckankel@nd.edu. .SH AUTHOR \fRCody Kankel (ckankel@nd.edu) diff --git a/node_search.py b/node_search.py index 7c3f3d4..f8381f2 100755 --- a/node_search.py +++ b/node_search.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +from pwd import getpwnam import sys, subprocess, urllib.request """Script to get and report information on nodes withtin the Sun Grid Engine for the CRC. It uses @@ -377,6 +378,12 @@ def find_host_groups(user_name, detail_switch): and method will send needed info to the respective printing functions depending if it is a detailed print or not. Program exits after executing this method.""" + try: + user_pwd = getpwnam(user_name) + except KeyError: + print("Error: User {0} is not recognized.".format(user_name)) + sys.exit(25) + all_user_lists = subprocess.getoutput("qconf -sul").split('\n') user_list = [] @@ -664,9 +671,10 @@ def process_user(user_name): """Function to process the username given after -u option. Will find information pertaining to the specified user and send them to the printing function.""" - user_list = subprocess.getoutput("qconf -suserl") - if str(user_name) not in user_list: - print('Error: User, ' + user_name + ' is currently not logged on or does not exist.') + try: + user_pwd = getpwnam(user_name) + except KeyError: + print('Error: User {0} is not recognized.'.format(user_name)) sys.exit(25) qstat = subprocess.getoutput("qstat -f").split('-'.center(81, '-')) #81 -'s diff --git a/node_search.sh b/node_search.sh index 454bdf0..ede52a6 100755 --- a/node_search.sh +++ b/node_search.sh @@ -4,6 +4,8 @@ # without having to 'module load python/3.x.x' Then, it is running the node_search.py script. # Please read that script or view the man page for more information on what that script does. +#ckankel --> This is who to bug about this + # NOTE: These requirements will change when there is a new version of Python3 installed. To update # simply look at what is loaded in your env when you have the latest python3 module loaded for the # following variables: