~ubuntu-branches/ubuntu/vivid/slurm-llnl/vivid

« back to all changes in this revision

Viewing changes to src/sacctmgr/sacctmgr.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2009-09-24 23:28:15 UTC
  • mfrom: (1.1.11 upstream) (3.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090924232815-enh65jn32q1ebg07
Tags: 2.0.5-1
* New upstream release 
* Changed dependecy from lib-mysqlclient15 to lib-mysqlclient 
* Added Default-Start for runlevel 2 and 4 and $remote_fs requirement in
  init.d scripts (Closes: #541252)
* Postinst checks for wrong runlevels 2 and 4 links
* Upgraded to standard version 3.8.3
* Add lintian overrides for missing slurm-llnl-configurator.html in doc
  base registration
* modified postrm scripts to ignore pkill return value in order to avoid
  postrm failure when no slurm process is running
* Checking for slurmctld.pid before cancelling running and pending
  jobs during package removal 

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *               provides interface to read, write, update, and configure
4
4
 *               accounting.
5
5
 *****************************************************************************
6
 
 *  Copyright (C) 2008 Lawrence Livermore National Security.
 
6
 *  Copyright (C) 2008-2009 Lawrence Livermore National Security.
7
7
 *  Copyright (C) 2002-2007 The Regents of the University of California.
8
8
 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
9
9
 *  Written by Danny Auble <da@llnl.gov>
10
 
 *  LLNL-CODE-402394.
 
10
 *  CODE-OCEC-09-009. All rights reserved.
11
11
 *  
12
12
 *  This file is part of SLURM, a resource management program.
13
 
 *  For details, see <http://www.llnl.gov/linux/slurm/>.
 
13
 *  For details, see <https://computing.llnl.gov/linux/slurm/>.
 
14
 *  Please also read the included file: DISCLAIMER.
14
15
 *  
15
16
 *  SLURM is free software; you can redistribute it and/or modify it under
16
17
 *  the terms of the GNU General Public License as published by the Free
77
78
        int option_index;
78
79
        static struct option long_options[] = {
79
80
                {"help",     0, 0, 'h'},
 
81
                {"usage",    0, 0, 'h'},
80
82
                {"immediate",0, 0, 'i'},
 
83
                {"noheader",0, 0, 'n'},
81
84
                {"oneliner", 0, 0, 'o'},
82
 
                {"no_header", 0, 0, 'n'},
83
85
                {"parsable", 0, 0, 'p'},
84
86
                {"parsable2", 0, 0, 'P'},
85
87
                {"quiet",    0, 0, 'q'},
86
88
                {"readonly", 0, 0, 'r'},
87
89
                {"associations", 0, 0, 's'},
88
 
                {"usage",    0, 0, 'h'},
89
90
                {"verbose",  0, 0, 'v'},
90
91
                {"version",  0, 0, 'V'},
91
92
                {NULL,       0, 0, 0}
185
186
                exit(1);
186
187
        }
187
188
        xfree(temp);
 
189
 
188
190
        /* always do a rollback.  If you don't then if there is an
189
191
         * error you can not rollback ;)
190
192
         */
191
193
        errno = 0;
192
194
        db_conn = acct_storage_g_get_connection(false, 0, 1);
193
195
        if(errno != SLURM_SUCCESS) {
194
 
                error("sacctmgr: %m");
 
196
                int tmp_errno = errno;
 
197
                if((input_field_count == 2) &&
 
198
                   (!strncasecmp(argv[2], "Configuration", strlen(argv[1]))) &&
 
199
                   ((!strncasecmp(argv[1], "list", strlen(argv[0]))) || 
 
200
                    (!strncasecmp(argv[1], "show", strlen(argv[0])))))
 
201
                        sacctmgr_list_config(false);
 
202
                errno = tmp_errno;
 
203
                fprintf(stderr, "Problem talking to the database: %m\n");
195
204
                exit(1);
196
205
        }
197
206
        my_uid = getuid();
234
243
        int len;
235
244
        printf("%s", prompt);
236
245
 
237
 
        fgets(buf, 4096, stdin);
 
246
        /* we only set this here to avoid a warning.  We throw it away
 
247
           later. */
 
248
        line = fgets(buf, 4096, stdin);
238
249
        len = strlen(buf);
239
250
        if ((len > 0) && (buf[len-1] == '\n'))
240
251
                buf[len-1] = '\0';
405
416
        } else if ((strncasecmp (argv[0], "show", MAX(command_len, 3)) == 0) ||
406
417
                   (strncasecmp (argv[0], "list", MAX(command_len, 3)) == 0)) {
407
418
                _show_it((argc - 1), &argv[1]);
408
 
        } else if (strncasecmp (argv[0], "modify", MAX(command_len, 1)) == 0) {
 
419
        } else if (!strncasecmp (argv[0], "modify", MAX(command_len, 1))
 
420
                   || !strncasecmp (argv[0], "update", MAX(command_len, 1))) {
409
421
                _modify_it((argc - 1), &argv[1]);
410
422
        } else if ((strncasecmp (argv[0], "delete",
411
423
                                 MAX(command_len, 3)) == 0) ||
430
442
                }               
431
443
                readonly_flag = 1;
432
444
        } else if (strncasecmp (argv[0], "rollup", MAX(command_len, 2)) == 0) {
433
 
                time_t my_time = 0;
434
 
                if (argc > 2) {
 
445
                time_t my_start = 0;
 
446
                time_t my_end = 0;
 
447
                uint16_t archive_data = 0;
 
448
                if (argc > 4) {
435
449
                        exit_code = 1;
436
450
                        fprintf (stderr,
437
451
                                 "too many arguments for %s keyword\n",
439
453
                }
440
454
 
441
455
                if(argc > 1)
442
 
                        my_time = parse_time(argv[1], 1);
443
 
                if(acct_storage_g_roll_usage(db_conn, my_time)
 
456
                        my_start = parse_time(argv[1], 1);
 
457
                if(argc > 2)
 
458
                        my_end = parse_time(argv[2], 1);
 
459
                if(argc > 3)
 
460
                        archive_data = atoi(argv[3]);
 
461
                if(acct_storage_g_roll_usage(db_conn, my_start, 
 
462
                                             my_end, archive_data)
444
463
                   == SLURM_SUCCESS) {
445
464
                        if(commit_check("Would you like to commit rollup?")) {
446
465
                                acct_storage_g_commit(db_conn, 1);
586
605
        } else if (strncasecmp (argv[0], "Clusters", 
587
606
                                MAX(command_len, 1)) == 0) {
588
607
                error_code = sacctmgr_list_cluster((argc - 1), &argv[1]);
 
608
        } else if (strncasecmp (argv[0], "Configuration", 
 
609
                                MAX(command_len, 1)) == 0) {
 
610
                error_code = sacctmgr_list_config(true);
589
611
        } else if (strncasecmp (argv[0], "QOS", MAX(command_len, 1)) == 0) {
590
612
                error_code = sacctmgr_list_qos((argc - 1), &argv[1]);
591
613
        } else if (strncasecmp (argv[0], "Transactions", 
714
736
    Valid <OPTION> values are:                                             \n\
715
737
     -h or --help: equivalent to \"help\" command                          \n\
716
738
     -i or --immediate: commit changes immediately                         \n\
717
 
     -n or --no_header: no header will be added to the beginning of output \n\
 
739
     -n or --noheader: no header will be added to the beginning of output  \n\
718
740
     -o or --oneliner: equivalent to \"oneliner\" command                  \n\
719
741
     -p or --parsable: output will be '|' delimited with a '|' at the end  \n\
720
742
     -P or --parsable2: output will be '|' delimited without a '|' at the end\n\
758
780
     oneliner                 report output one record per line.           \n\
759
781
     parsable                 output will be | delimited with an ending '|'\n\
760
782
     parsable2                output will be | delimited without an ending '|'\n\
761
 
     readonly                 makes it so no modification can happen.      \n\
762
783
     quiet                    print no messages other than error messages. \n\
763
784
     quit                     terminate this command.                      \n\
 
785
     readonly                 makes it so no modification can happen.      \n\
764
786
     show                     same as list                                 \n\
765
787
     verbose                  enable detailed logging.                     \n\
766
788
     version                  display tool version number.                 \n\
767
789
     !!                       Repeat the last command entered.             \n\
768
790
                                                                           \n\
769
791
  <ENTITY> may be \"account\", \"association\", \"cluster\",               \n\
770
 
                  \"coordinator\", \"qos\", \"transaction\", \"user\",     \n\
771
 
                  or \"wckey\"                                             \n\
 
792
                  \"configuration\", \"coordinator\", \"qos\",             \n\
 
793
                  \"transaction\", \"user\",or \"wckey\"                   \n\
772
794
                                                                           \n\
773
795
  <SPECS> are different for each command entity pair.                      \n\
774
796
       list account       - Clusters=, Descriptions=, Format=, Names=,     \n\
789
811
       delete account     - Clusters=, Descriptions=, Names=,              \n\
790
812
                            Organizations=, and Parents=                   \n\
791
813
                                                                           \n\
792
 
       list associations  - Accounts=, Clusters=, Format=, IDs=,            \n\
 
814
       list associations  - Accounts=, Clusters=, Format=, IDs=,           \n\
793
815
                            Partitions=, Parent=, Tree, Users=,            \n\
794
816
                            WithSubAccounts, WithDeleted, WOPInfo,         \n\
795
817
                            and WOPLimits                                  \n\
796
818
                                                                           \n\
797
819
       list cluster       - Format=, Names=                                \n\
798
 
       add cluster        - Fairshare=, GrpCPUMins=, GrpCPUs=, GrpJobs=,   \n\
799
 
                            GrpNodes=, GrpSubmitJob=, GrpWall=, MaxCPUMins=\n\
800
 
                            MaxJobs=, MaxNodes=, MaxWall=, and Name=       \n\
801
 
       modify cluster     - (set options) Fairshare=, GrpCPUMins=,         \n\
 
820
       add cluster        - Fairshare=, GrpCPUs=, GrpJobs=,                \n\
 
821
                            GrpNodes=, GrpSubmitJob=, MaxCPUMins=          \n\
 
822
                            MaxJobs=, MaxNodes=, MaxWall=, Name=,          \n\
 
823
                            and QosLevel=                                  \n\
 
824
       modify cluster     - (set options) Fairshare=,                      \n\
802
825
                            GrpCPUs=, GrpJobs=, GrpNodes=, GrpSubmitJob=,  \n\
803
 
                            GrpWall=, MaxCPUMins=, MaxJobs=, MaxNodes=,    \n\
804
 
                            and MaxWall=                                   \n\
 
826
                            MaxCPUMins=, MaxJobs=, MaxNodes=, MaxWall=,    \n\
 
827
                            and QosLevel=                                  \n\
805
828
                            (where options) Names=                         \n\
806
829
       delete cluster     - Names=                                         \n\
807
830
                                                                           \n\
841
864
       list wckey         - Clusters=, End=, Format=, IDs=, Names=,        \n\
842
865
                            Start=, User=, and WCKeys=                     \n\
843
866
                                                                           \n\
844
 
       archive dump       - Directory=, Jobs, PurgeJobsBefore=,            \n\
845
 
                            PurgeStepsBefore=, Script=, and Steps          \n\
 
867
       archive dump       - Directory=, Events, Jobs, PurgeEventMonths=,   \n\
 
868
                            PurgeJobMonths=, PurgeStepMonths=,             \n\
 
869
                            PurgeSuspendMonths=, Script=, Steps and Suspend\n\
846
870
                                                                           \n\
847
871
       archive load       - File=, or Insert=                              \n\
848
872
                                                                           \n\
849
873
  Format options are different for listing each entity pair.               \n\
850
874
                                                                           \n\
 
875
  One can get an number of characters by following the field option with   \n\
 
876
  a %%NUMBER option.  i.e. format=name%%30 will print 30 chars of field name.\n\
 
877
                                                                           \n\
851
878
       Account            - Account, CoordinatorList, Description,         \n\
852
879
                            Organization                                   \n\
853
880
                                                                           \n\
858
885
                            ParentID, ParentName, Partition, RawQOS, RGT,  \n\
859
886
                            User                                           \n\
860
887
                                                                           \n\
861
 
       Cluster            - Cluster, ControlHost, ControlPort, Fairshare   \n\
862
 
                            GrpCPUMins, GrpCPUs, GrpJobs, GrpNodes,        \n\
863
 
                            GrpSubmitJob, GrpWall, MaxCPUs, MaxCPUMins,    \n\
864
 
                            MaxJobs, MaxNodes, MaxSubmitJobs, MaxWall      \n\
 
888
       Cluster            - Cluster, ControlHost, ControlPort, CpuCount,   \n\
 
889
                            Fairshare, GrpCPUs, GrpJobs,                   \n\
 
890
                            GrpNodes, GrpSubmitJob, MaxCPUs,               \n\
 
891
                            MaxCPUMins, MaxJobs, MaxNodes, MaxSubmitJobs,  \n\
 
892
                            MaxWall, NodeCount, NodeNames                  \n\
865
893
                                                                           \n\
866
894
       QOS                - Description, ID, Name                          \n\
867
895
                                                                           \n\