~ubuntu-branches/ubuntu/precise/torque/precise-updates

« back to all changes in this revision

Viewing changes to src/cmds/qstat.c

  • Committer: Bazaar Package Importer
  • Author(s): Dominique Belhachemi
  • Date: 2010-05-17 20:56:46 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100517205646-yjsoqs5r1s9xpnu9
Tags: upstream-2.4.8+dfsg
ImportĀ upstreamĀ versionĀ 2.4.8+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
* are permitted provided that all of the following conditions are met.
21
21
* After December 31, 2001, only conditions 3-6 must be met:
22
22
*
23
 
* 1. Commercial and/or non-commercial use of the Software is permitted
24
 
*    provided a current software registration is on file at www.OpenPBS.org.
25
 
*    If use of this software contributes to a publication, product, or
26
 
*    service, proper attribution must be given; see www.OpenPBS.org/credit.html
27
 
*
28
 
* 2. Redistribution in any form is only permitted for non-commercial,
29
 
*    non-profit purposes.  There can be no charge for the Software or any
30
 
*    software incorporating the Software.  Further, there can be no
31
 
*    expectation of revenue generated as a consequence of redistributing
32
 
*    the Software.
33
 
*
34
23
* 3. Any Redistribution of source code must retain the above copyright notice
35
24
*    and the acknowledgment contained in paragraph 6, this list of conditions
36
25
*    and the disclaimer contained in paragraph 7.
106
95
 
107
96
#include "cmds.h"
108
97
#include "mcom.h"
 
98
#include "utils.h"
109
99
 
110
100
static void states();
111
101
 
147
137
#endif
148
138
 
149
139
int   tasksize = DEFTASKSIZE;
 
140
int   alias_opt = FALSE;
150
141
 
151
142
 
152
143
 
173
164
 
174
165
 
175
166
 
 
167
 
176
168
int istrue(
177
169
 
178
170
  char *string)  /* I */
352
344
 
353
345
 
354
346
 
 
347
 
355
348
/*
356
349
 * locate a attribute (attrl) by name (and resource) and return value
357
350
 * returns null if not found
596
589
  char *jobn = NULL;
597
590
  char *sess;
598
591
  char *tasks;
 
592
  char  calcTasks[64];
599
593
  char *nodect;
600
594
  char *rqtimecpu;
601
595
  char *rqtimewal;
602
596
  char *jstate;
603
597
  char *eltimecpu;
604
598
  char *eltimewal;
605
 
 
606
599
  char tmpLine[MAX_LINE_LEN];
607
600
 
608
601
  int   usecput;
704
697
          {
705
698
          nodect = pat->value;
706
699
          }
 
700
        else if (!strcmp(pat->resource, "nodes"))
 
701
          {
 
702
          char *tmp = pat->value;
 
703
          char *eq = strchr(tmp,'=');
 
704
          
 
705
          if (eq != NULL)
 
706
            {
 
707
            int nodes = atoi(pat->value);
 
708
            int procs = atoi(eq+1);
 
709
 
 
710
            sprintf(calcTasks,"%d",nodes*procs);
 
711
            tasks = calcTasks;
 
712
            }
 
713
          else
 
714
            {
 
715
            tasks = pat->value;
 
716
            }
 
717
 
 
718
          }
707
719
        else if (!strcmp(pat->resource, "ncpus"))
708
720
          {
709
 
          if (strcmp(pat->value, "0"))
 
721
          if ((!strcmp(tasks,blank)) && (strcmp(pat->value, "0")))
710
722
            tasks = pat->value;
711
723
          }
712
724
        else if (!strcmp(pat->resource, "mppe"))
794
806
      }
795
807
    else
796
808
      {
797
 
 
798
809
      snprintf(tmpLine, sizeof(tmpLine), "%%-%d.%ds %%6.6s %%5.5s %%*.*s %%6.6s %%5.5s %%1.1s %%5.5s",
799
810
               PBS_NAMELEN, PBS_NAMELEN);
800
811
 
1046
1057
 
1047
1058
 
1048
1059
 
1049
 
/* dispay when a normal "qstat" is executed */
 
1060
/* display when a normal "qstat" is executed */
1050
1061
 
1051
1062
void display_statjob(
1052
1063
 
1075
1086
  mxml_t *JE;
1076
1087
  mxml_t *AE;
1077
1088
  mxml_t *RE1;
 
1089
  mxml_t *JI;
1078
1090
 
1079
1091
  /* XML only support for full output */
1080
1092
 
1126
1138
 
1127
1139
        MXMLCreateE(&JE, "Job");
1128
1140
 
1129
 
        MXMLSetVal(JE, p->name, mdfString);
1130
 
 
1131
1141
        MXMLAddE(DE, JE);
 
1142
 
 
1143
        JI = NULL;
 
1144
 
 
1145
        MXMLCreateE(&JI, "Job_Id");
 
1146
 
 
1147
        MXMLSetVal(JI, p->name,mdfString);
 
1148
 
 
1149
        MXMLAddE(JE, JI);
1132
1150
        }
1133
1151
      else
1134
1152
        {
1178
1196
                !strcmp(a->name, ATTR_mtime) ||
1179
1197
                !strcmp(a->name, ATTR_qtime) ||
1180
1198
                !strcmp(a->name, ATTR_start_time) ||
 
1199
                !strcmp(a->name, ATTR_comp_time) ||
 
1200
                !strcmp(a->name, ATTR_checkpoint_time) ||
1181
1201
                !strcmp(a->name, ATTR_a))
1182
1202
              {
1183
1203
              epoch = (time_t)atoi(a->value);
1207
1227
        while ((*c != '.') && (*c != '\0'))
1208
1228
          c++;
1209
1229
 
 
1230
        if (alias_opt == TRUE)
 
1231
          {
 
1232
          /* show the alias as well as the first part of the server name */
 
1233
          if (*c == '.')
 
1234
            {
 
1235
            c++;
 
1236
 
 
1237
            while((*c != '.') && (*c != '\0'))
 
1238
              c++;
 
1239
            }
 
1240
          }
 
1241
 
1210
1242
        c++;    /* List the first part of the server name, too. */
1211
1243
 
1212
1244
        while ((*c != '.') && (*c != '\0'))
1968
2000
 
1969
2001
 
1970
2002
 
 
2003
 
 
2004
 
 
2005
 
1971
2006
/* connects to server side routine pbs_statjob() in lib/Libifl/pbs_statjob.c */
1972
2007
/*  routes to req_stat_job() in server/req_stat.c (PBS_BATCH_StatusJob) */
1973
2008
 
2031
2066
#endif /* !FALSE */
2032
2067
 
2033
2068
#if !defined(PBS_NO_POSIX_VIOLATION)
2034
 
#define GETOPT_ARGS "aeE:fin1qrsu:xGMQRBW:-:"
 
2069
#define GETOPT_ARGS "aeE:filn1qrsu:xGMQRBW:-:"
2035
2070
#else
2036
 
#define GETOPT_ARGS "fQBW:"
 
2071
#define GETOPT_ARGS "flQBW:"
2037
2072
#endif /* PBS_NO_POSIX_VIOLATION */
2038
2073
 
2039
2074
  mode = JOBS; /* default */
2185
2220
 
2186
2221
        break;
2187
2222
 
 
2223
      case 'l':
 
2224
 
 
2225
        alias_opt = TRUE;
 
2226
 
 
2227
        break;
 
2228
 
2188
2229
      case 'Q':
2189
2230
 
2190
2231
        Q_opt = 1;
2372
2413
  if (errflg)
2373
2414
    {
2374
2415
    static char usage[] = "usage: \n\
2375
 
                          qstat [-f] [-1] [-W site_specific] [ job_identifier... | destination... ]\n\
 
2416
                          qstat [-f [-1]] [-W site_specific] [-x] [ job_identifier... | destination... ]\n\
2376
2417
                          qstat [-a|-i|-r|-e] [-u user] [-n [-1]] [-s] [-G|-M] [-R] [job_id... | destination...]\n\
2377
2418
                          qstat -Q [-f [-1]] [-W site_specific] [ destination... ]\n\
2378
2419
                          qstat -q [-G|-M] [ destination... ]\n\
2496
2537
                &queue_name_out,
2497
2538
                &server_name_out))
2498
2539
            {
2499
 
            fprintf(stderr, "qstat: illegally formed destination: %s\n", destination);
 
2540
            fprintf(stderr, "qstat: illegally formed destination: %s\n",
 
2541
                    destination);
2500
2542
 
2501
2543
            ret = tcl_stat(error, NULL, f_opt);
 
2544
 
2502
2545
            any_failed = 1;
 
2546
 
2503
2547
            break;
2504
2548
            }
 
2549
 
 
2550
          if (notNULL(server_name_out))
 
2551
            {
 
2552
            strcpy(server_out, server_name_out);
 
2553
            }
2505
2554
          else
2506
2555
            {
2507
 
            if (notNULL(server_name_out))
2508
 
              {
2509
 
              strcpy(server_out, server_name_out);
2510
 
              }
2511
 
            else
2512
 
              {
2513
 
              server_out[0] = '\0';
2514
 
              }
2515
 
 
2516
 
            (void)strcpy(job_id_out, queue_name_out);
2517
 
 
2518
 
            if (*queue_name_out != '\0')
2519
 
              {
2520
 
              add_atropl(&p_atropl, ATTR_q, NULL, queue_name_out, EQ);
2521
 
              }
2522
 
            }
2523
 
          }
 
2556
            server_out[0] = '\0';
 
2557
            }
 
2558
 
 
2559
          strcpy(job_id_out, queue_name_out);
 
2560
 
 
2561
          if (*queue_name_out != '\0')
 
2562
            {
 
2563
            add_atropl(&p_atropl, ATTR_q, NULL, queue_name_out, EQ);
 
2564
            }
 
2565
          }    /* END else */
2524
2566
 
2525
2567
job_no_args:
2526
2568
 
2575
2617
            if (locate_job(job_id_out, server_out, rmt_server))
2576
2618
              {
2577
2619
              pbs_disconnect(connect);
 
2620
 
2578
2621
              strcpy(server_out, rmt_server);
 
2622
 
2579
2623
              goto job_no_args;
2580
2624
              }
2581
2625
 
2582
2626
            ret = tcl_stat("job", NULL, f_opt);
2583
2627
 
2584
2628
            prt_job_err("qstat", connect, job_id_out);
 
2629
 
2585
2630
            any_failed = pbs_errno;
2586
2631
            }
2587
2632
          else
2591
2636
            if (pbs_errno != PBSE_NONE)
2592
2637
              {
2593
2638
              prt_job_err("qstat", connect, job_id_out);
 
2639
 
2594
2640
              any_failed = pbs_errno;
2595
2641
              }
2596
2642
            }
2601
2647
            {
2602
2648
            altdsp_statjob(p_status, p_server, alt_opt);
2603
2649
            }
2604
 
          else if (f_opt == 0 || tcl_stat("job", p_status, f_opt))
 
2650
          else if ((f_opt == 0) || tcl_stat("job", p_status, f_opt))
 
2651
            {
2605
2652
            display_statjob(p_status, p_header, f_opt);
 
2653
            }
2606
2654
 
2607
2655
          p_header = FALSE;
2608
2656
 
2614
2662
        break;
2615
2663
 
2616
2664
      case QUEUES:        /* get status of batch queues */
 
2665
 
2617
2666
        strcpy(destination, operand);
2618
2667
 
2619
2668
        if (parse_destination_id(destination,