[torqueusers] patch to support "-n1"

Andrew J Caird acaird at umich.edu
Tue Nov 29 20:24:12 MST 2005


On Mon, 28 Nov 2005, Andrew J Caird wrote:
> On Wed, 23 Nov 2005, Garrick Staples wrote:
>
>> On Wed, Nov 23, 2005 at 02:29:27PM -0500, Andrew J Caird alleged:
>>> That last patch wasn't quite right; the attached one is better.
>> 
>> Can you also update the usage and qstat manpage?
>
> Yes, thanks for the reminder.  I'll send a new patch when that is done.

Attached is the last patch for this I'll submit. :)  (Unless I've goofed 
up something else I need to fix.)

This one includes changes to the man page, the usage string, and an 
improved way (strlen) of determining how big to make "maxline" (instead of 
just guessing at 999999, which was lame).

--andy
-------------- next part --------------
diff -c -r torque-2.0.0p1/doc/man1/qstat.1B torque-2.0.0pac/doc/man1/qstat.1B
*** torque-2.0.0p1/doc/man1/qstat.1B	2005-11-03 15:30:46.000000000 -0500
--- torque-2.0.0pac/doc/man1/qstat.1B	2005-11-29 22:12:01.000000000 -0500
***************
*** 83,89 ****
  .Sh SYNOPSIS
  qstat [-f][-W site_specific] [\^job_identifier... | destination...\^]
  .sp
! qstat [-a|-i|-r|-e] [-n] [-s] [-G|-M] [-R] [-u user_list] [\^job_identifier... |\ 
  destination...\^]
  .sp
  qstat -Q [-f][-W site_specific] [\^destination...\^]
--- 83,89 ----
  .Sh SYNOPSIS
  qstat [-f][-W site_specific] [\^job_identifier... | destination...\^]
  .sp
! qstat [-a|-i|-r|-e] [-n [-1]] [-s] [-G|-M] [-R] [-u user_list] [\^job_identifier... |\ 
  destination...\^]
  .sp
  qstat -Q [-f][-W site_specific] [\^destination...\^]
***************
*** 151,156 ****
--- 151,159 ----
  running are displayed,  this includes jobs which are suspended.
  .IP "-n" 10
  In addition to the basic information, nodes allocated to a job are listed.
+ .IP "-1" 10
+ In combination with -n the -1 option puts all of the nodes on the same line as the job ID.  This 
+ is intended to ease the parsing of the qstat output.
  .IP "-s" 10
  In addition to the basic information, any comment provided by the batch
  administrator or scheduler is shown.
diff -c -r torque-2.0.0p1/src/cmds/qstat.c torque-2.0.0pac/src/cmds/qstat.c
*** 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-29 22:09:25.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 = strlen(nodes) + 1;
+ 	}
+ 	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 */
  
***************
*** 2037,2043 ****
      {
      static char usage[]="usage: \n\
  qstat [-f] [-W site_specific] [ job_identifier... | destination... ]\n\
! qstat [-a|-i|-r|-e] [-u user] [-n] [-s] [-G|-M] [-R] [job_id... | destination...]\n\
  qstat -Q [-f] [-W site_specific] [ destination... ]\n\
  qstat -q [-G|-M] [ destination... ]\n\
  qstat -B [-f] [-W site_specific] [ server_name... ]\n";
--- 2059,2065 ----
      {
      static char usage[]="usage: \n\
  qstat [-f] [-W site_specific] [ job_identifier... | destination... ]\n\
! qstat [-a|-i|-r|-e] [-u user] [-n [-1]] [-s] [-G|-M] [-R] [job_id... | destination...]\n\
  qstat -Q [-f] [-W site_specific] [ destination... ]\n\
  qstat -q [-G|-M] [ destination... ]\n\
  qstat -B [-f] [-W site_specific] [ server_name... ]\n";


More information about the torqueusers mailing list