[torqueusers] patch to support "-n1"
Andrew J Caird
acaird at umich.edu
Wed Nov 23 12:29:27 MST 2005
That last patch wasn't quite right; the attached one is better.
--andy
On Tue, 22 Nov 2005, Andrew J Caird wrote:
> 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-23 14:17:38.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 */
***************
*** 408,430 ****
*/
static void prt_nodes(
!
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 {
--- 409,437 ----
*/
static void prt_nodes(
! int alt_opt,
char *nodes)
{
! int i,maxline;
char *stp;
if ((nodes == (char *)0) || (*nodes == '\0'))
return;
+ maxline = 77;
+
+ if (alt_opt & ALT_DISPLAY_o) {
+ maxline = 99999;
+ }
+ char linebuf[maxline];
+
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,710 ****
usecput ? rqtimecpu : rqtimewal,
jstate,
usecput ? eltimecpu : eltimewal);
}
if (alt_opt & ALT_DISPLAY_n)
{
/* print assigned nodes */
! prt_nodes(exechost);
}
if (alt_opt & ALT_DISPLAY_s)
--- 705,720 ----
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)
{
/* print assigned nodes */
! prt_nodes(alt_opt,exechost);
}
if (alt_opt & ALT_DISPLAY_s)
***************
*** 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