Skip to content
Snippets Groups Projects
Commit 31d0897d authored by Moe Jette's avatar Moe Jette
Browse files

Add support for squeue environment variables SLURM_FORMAT, SLURM_PARTITION,

SLURM_SORT, SLURM_STATES, and SLURM_USERS.
parent 5ebb62f2
No related branches found
No related tags found
No related merge requests found
...@@ -78,7 +78,8 @@ The days and hours are printed only as needed. ...@@ -78,7 +78,8 @@ The days and hours are printed only as needed.
.br .br
\fB%O\fR Are contiguous nodes requested by the job \fB%O\fR Are contiguous nodes requested by the job
.br .br
\fB%p\fR Priority of the job (converted to a floating point number between 0.0 and 1.0 \fB%p\fR Priority of the job (converted to a floating point number
between 0.0 and 1.0
.br .br
\fB%P\fR Partition of the job or job step \fB%P\fR Partition of the job or job step
.br .br
...@@ -130,6 +131,26 @@ reported. ...@@ -130,6 +131,26 @@ reported.
\fB\-v\fR, \fB\-\-verbose\fR \fB\-v\fR, \fB\-\-verbose\fR
Report details of squeues actions. Report details of squeues actions.
.SH "ENVIRONMENT VARIABLES"
.PP
Some \fBsqueue\fR options may be set via environment variables. These
environment variables, along with their corresponding options, are listed
below. (Note: commandline options will always override these settings)
.TP 20
SQUEUE_FORMAT
\fB\-o, \-\-format\fR
.TP
SQUEUE_PARTITION
\fB\-p, \-\-partition\fR
.TP
SQUEUE_SORT
\fB\-S, \-\-sort\fR
.TP
SQUEUE_STATES
\fB\-t, \-\-states\fR
.TP
SQUEUE_USERS
\fB\-u, \-\-users\fR
.SH "EXAMPLES" .SH "EXAMPLES"
.eo .eo
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include <popt.h> #include <popt.h>
#include <pwd.h> #include <pwd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include "src/common/xstring.h" #include "src/common/xstring.h"
...@@ -45,8 +47,8 @@ ...@@ -45,8 +47,8 @@
#define OPT_VERBOSE 0x09 #define OPT_VERBOSE 0x09
#define OPT_ITERATE 0x0a #define OPT_ITERATE 0x0a
#define OPT_USERS 0x0b #define OPT_USERS 0x0b
#define OPT_LONG 0x0c #define OPT_LONG 0x0c
#define OPT_SORT 0x0d #define OPT_SORT 0x0d
#define OPT_NO_HEAD 0x0e #define OPT_NO_HEAD 0x0e
/* FUNCTIONS */ /* FUNCTIONS */
...@@ -71,7 +73,8 @@ parse_command_line( int argc, char* argv[] ) ...@@ -71,7 +73,8 @@ parse_command_line( int argc, char* argv[] )
{ {
poptContext context; poptContext context;
char next_opt, curr_opt; char next_opt, curr_opt;
int rc = 0; char *env_val = NULL;
int i = 0, rc = 0;
/* Declare the Options */ /* Declare the Options */
static const struct poptOption options[] = static const struct poptOption options[] =
...@@ -138,20 +141,17 @@ parse_command_line( int argc, char* argv[] ) ...@@ -138,20 +141,17 @@ parse_command_line( int argc, char* argv[] )
case OPT_STEPS_NONE: case OPT_STEPS_NONE:
if ( (opt_arg = poptGetArg( context )) != NULL ) if ( (opt_arg = poptGetArg( context )) != NULL )
params.steps = (char*)opt_arg; params.steps = (char*)opt_arg;
params.step_list = params.step_list = _build_step_list( params.steps );
_build_step_list( params.steps );
break; break;
case OPT_STATES: case OPT_STATES:
params.state_list = params.state_list = _build_state_list( params.states );
_build_state_list( params.states );
break; break;
case OPT_PARTITIONS: case OPT_PARTITIONS:
params.part_list = params.part_list =
_build_part_list( params.partitions ); _build_part_list( params.partitions );
break; break;
case OPT_USERS: case OPT_USERS:
params.user_list = params.user_list = _build_user_list( params.users );
_build_user_list( params.users );
break; break;
case OPT_VERBOSE: case OPT_VERBOSE:
params.verbose = true; params.verbose = true;
...@@ -184,6 +184,49 @@ parse_command_line( int argc, char* argv[] ) ...@@ -184,6 +184,49 @@ parse_command_line( int argc, char* argv[] )
exit( 1 ); exit( 1 );
} }
if ( ( params.format == NULL ) &&
( env_val = getenv("SQUEUE_FORMAT") ) ) {
i = strlen(env_val);
params.format = xmalloc(i);
strcpy(params.format, env_val);
env_val = NULL;
}
if ( ( params.partitions == NULL ) &&
( env_val = getenv("SQUEUE_PARTITION") ) ) {
i = strlen(env_val);
params.partitions = xmalloc(i);
strcpy(params.partitions, env_val);
params.part_list = _build_part_list( params.partitions );
env_val = NULL;
}
if ( ( params.sort == NULL ) &&
( env_val = getenv("SQUEUE_SORT") ) ) {
i = strlen(env_val);
params.sort = xmalloc(i);
strcpy(params.sort, env_val);
env_val = NULL;
}
if ( ( params.states == NULL ) &&
( env_val = getenv("SQUEUE_STATES") ) ) {
i = strlen(env_val);
params.states = xmalloc(i);
strcpy(params.states, env_val);
params.state_list = _build_state_list( params.states );
env_val = NULL;
}
if ( ( params.users == NULL ) &&
( env_val = getenv("SQUEUE_USERS") ) ) {
i = strlen(env_val);
params.users = xmalloc(i);
strcpy(params.users, env_val);
params.user_list = _build_user_list( params.users );
env_val = NULL;
}
if ( params.format ) if ( params.format )
_parse_format( params.format ); _parse_format( params.format );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment