-
Notifications
You must be signed in to change notification settings - Fork 3
/
cluster_status.bash
executable file
·136 lines (100 loc) · 3.2 KB
/
cluster_status.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
#
# cluster_status.bash
#
# Copyright 2010 Dan Ginsburg
# Children's Hospital Boston
#
# GPL v2
#
# "include" the set of common script functions
source common.bash
G_LOGFILE=${G_SELF}.log
G_CLUSTERTYPE="-x"
G_CMD="-x"
G_JOBID="-x"
G_REMOTESERVERNAME="-x"
G_SYNOPSIS="
NAME
cluster_status.bash
SYNOPSIS
cluster_status.bash -C <clusterType> \\
-c <cmd> \\
[-J <jobID>] \\
[-r <remoteServerName>]
DESCRIPTION
'cluster_status.bash' is a script for determing the status of the job
on a cluster. Its purpose it to be an abstraction on the underlying
clustering software. It will invoke <cluster_type>_status.bash to get
the status on the cluster. If you need to create a new cluster type, simply
add new bash scripts with the appropriate name.
ARGUMENTS
-C <clusterType>
This is the name of the cluster for example 'mosix' or 'pbs'. The
script will attempt to execute '<clusterType>_status.bash', for example
'mosix_status.bash'. If you have your own clustering system, you can
create new scripts with a new name and pass the <clusterType> argument
specifying that name.
-c <cmd>
Command that was executed. On local runs, this will be used rather than
the Job ID to identify the process.
-J <jobId> (Optional)
Specify a job ID to get the status of. If not specified, returns the status
of all jobs in the queue.
-r <remoteServerName> (Optional)
The remote name of the server to run the status command on (for example, the
head node of the cluster).
PRECONDITIONS
o The appropriate clustering status script (e.g., mosix_status.bash) must exist.
POSTCONDITIONS
o The status of the job will be returned.
HISTORY
5 May 20010
o Initial design and coding
"
###\\\
# Global variables --->
###///
# Actions
A_noClusterTypeArg="checking on the -C <clusterType> argument"
# Error messages
EM_noClusterTypeArg="it seems as though you didn't specify a -C <clusterType>."
# Error codes
EC_noClusterTypeArg=10
EC_noJobIdArg=11
###\\\
# function definitions --->
###///
###\\\
# Process command options --->
###///
while getopts r:C:J:c: option ; do
case "$option"
in
C) G_CLUSTERTYPE=$OPTARG;;
c) G_CMD=$OPTARG;;
J) G_JOBID=$OPTARG;;
r) G_REMOTESERVERNAME=$OPTARG;;
\?) synopsis_show;;
esac
done
###\\\
# Some error checking --->
###///
if [[ "$G_CLUSTERTYPE" == "-x" ]] ; then fatal noClusterTypeArg ; fi
###\\\
# Main --->
###///
ARGS=""
if [[ "$G_JOBID" != "-x" ]] ; then
ARGS="-J $G_JOBID"
fi
if [[ "$G_CMD" != "-x" ]] ; then
ARGS="$ARGS -c $G_CMD"
fi
if [[ "$G_REMOTESERVERNAME" != "-x" ]] ; then
ARGS="$ARGS -r $G_REMOTESERVERNAME"
fi
# Execute the cluster script
STATUSCMD="${G_CLUSTERTYPE}_status.bash $ARGS"
eval $STATUSCMD