[torqueusers] patch to support "-n1"
Andrew J Caird
acaird at umich.edu
Tue Nov 22 11:56:06 MST 2005
We were using another version of PBS and had scripts that relied on being
able to have the "-n" output from qstat on the same lines as the job ID
(handy for grep'ing and otherwise parsing); the option to do this was -1,
but it required a -n. The existing way looks like:
[acaird at morpheus-login ~]$ qstat -an
cluster1:
Req'd Req'd Elap
Job ID Username Queue Jobname SessID NDS TSK Memory Time S Time
------------------ -------- -------- ---------- ------ --- --- ------ ----- - -----
494.cluster1 user1 cac Sgmntd_CsI 7249 1 -- 250mb 02:00 R 00:29
mor061/0
495.cluster1 user1 cac Sgmntd_CsI 7276 1 -- 250mb 02:00 R 00:29
mor061/1
But we wanted:
$ qstat -an1
cluster1
Req'd Req'd Elap
Job ID Username Queue Jobname SessID NDS TSK Memory Time S Time
------------------ -------- -------- ---------- ------ --- --- ------ ----- - -----
494.cluster1 user1 cac Sgmntd_CsI 7249 1 -- 250mb 02:00 R 00:30 mor061/0
495.cluster1 user1 cac Sgmntd_CsI 7276 1 -- 250mb 02:00 R 00:30 mor061/1
It might not be clear from the line wrapping, but in the second example,
the node names are on the same line as the job ID.
The patch to make this happen is attached. It might not be perfect, but I
tried to make it as much like the surrounding code as I could.
--andy
-------------- next part --------------
*** torque-2.0.0p1/src/cmds/qstat.c 2005-11-08 21:28:03.000000000 -0500
--- torque-2.0.0pac/src/cmds/qstat.c 2005-11-18 19:27:46.000000000 -0500
***************
*** 122,127 ****
--- 122,128 ----
#define ALT_DISPLAY_Mb 0x100 /* show sizes in MB */
#define ALT_DISPLAY_Mw 0x200 /* -M option - show sizes in MW */
#define ALT_DISPLAY_G 0x400 /* -G option - show sizes in GB */
+ #define ALT_DISPLAY_o 0x800 /* -1 option - add node list on same line */
#endif /* not PBS_NO_POSIX_VIOLATION */
***************
*** 412,430 ****
char *nodes)
{
! int i;
char linebuf[78];
char *stp;
if ((nodes == (char *)0) || (*nodes == '\0'))
return;
i = 0;
stp = nodes;
while (*nodes != '\0') {
if ((*stp == '.') || (*stp == '+') || (*stp == '\0')) {
/* does node fit into line? */
! if (i + stp - nodes < 77) {
while (nodes < stp)
linebuf[i++] = *nodes++;
} else {
--- 413,437 ----
char *nodes)
{
! int i,maxline;
char linebuf[78];
char *stp;
if ((nodes == (char *)0) || (*nodes == '\0'))
return;
+ maxline = 77;
+
+ if (ALT_DISPLAY_o) {
+ maxline = 99999;
+ }
+
i = 0;
stp = nodes;
while (*nodes != '\0') {
if ((*stp == '.') || (*stp == '+') || (*stp == '\0')) {
/* does node fit into line? */
! if (i + stp - nodes < maxline) {
while (nodes < stp)
linebuf[i++] = *nodes++;
} else {
***************
*** 676,682 ****
if (alt_opt & ALT_DISPLAY_R)
{
! printf("%5.5s %3.3s %6.6s %5.5s %1.1s %5.5s %5.5s %5.5s %5.5s\n",
nodect,
tasks,
rqmem,
--- 683,689 ----
if (alt_opt & ALT_DISPLAY_R)
{
! printf("%5.5s %3.3s %6.6s %5.5s %1.1s %5.5s %5.5s %5.5s %5.5s",
nodect,
tasks,
rqmem,
***************
*** 689,695 ****
}
else
{
! printf("%-10.10s %6.6s %5.5s %3.3s %6.6s %5.5s %1.1s %5.5s\n",
jobn,
sess,
nodect,
--- 696,702 ----
}
else
{
! printf("%-10.10s %6.6s %5.5s %3.3s %6.6s %5.5s %1.1s %5.5s",
jobn,
sess,
nodect,
***************
*** 698,703 ****
--- 705,713 ----
usecput ? rqtimecpu : rqtimewal,
jstate,
usecput ? eltimecpu : eltimewal);
+ if (! (alt_opt & ALT_DISPLAY_o)) {
+ printf ("\n");
+ } /*else {printf ("[ADo on(%x)]",ALT_DISPLAY_o); } */
}
if (alt_opt & ALT_DISPLAY_n)
***************
*** 1748,1754 ****
#endif /* !FALSE */
#if !defined(PBS_NO_POSIX_VIOLATION)
! #define GETOPT_ARGS "aefinqrsu:xGMQRBW:-:"
#else
#define GETOPT_ARGS "fQBW:"
#endif /* PBS_NO_POSIX_VIOLATION */
--- 1758,1764 ----
#endif /* !FALSE */
#if !defined(PBS_NO_POSIX_VIOLATION)
! #define GETOPT_ARGS "aefin1qrsu:xGMQRBW:-:"
#else
#define GETOPT_ARGS "fQBW:"
#endif /* PBS_NO_POSIX_VIOLATION */
***************
*** 1805,1810 ****
--- 1815,1826 ----
break;
+ case '1':
+
+ alt_opt |= ALT_DISPLAY_o;
+
+ break;
+
case 'q':
alt_opt |= ALT_DISPLAY_q;
***************
*** 2030,2035 ****
--- 2046,2057 ----
errflg++;
}
+ if (( alt_opt & ALT_DISPLAY_o) && ! (alt_opt & ALT_DISPLAY_n))
+ {
+ fprintf(stderr, conflict);
+
+ errflg++;
+ }
#endif /* PBS_NO_POSIX_VIOLATION */
More information about the torqueusers
mailing list