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

« back to all changes in this revision

Viewing changes to src/sstat/sstat.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:
4
4
 *  Copyright (C) 2008 Lawrence Livermore National Security.
5
5
 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
6
6
 *  Written by Morris Jette <jette1@llnl.gov>
7
 
 *  LLNL-CODE-402394.
 
7
 *  CODE-OCEC-09-009. All rights reserved.
8
8
 *  
9
9
 *  This file is part of SLURM, a resource management program.
10
 
 *  For details, see <http://www.llnl.gov/linux/slurm/>.
 
10
 *  For details, see <https://computing.llnl.gov/linux/slurm/>.
 
11
 *  Please also read the included file: DISCLAIMER.
11
12
 *  
12
13
 *  SLURM is free software; you can redistribute it and/or modify it under
13
14
 *  the terms of the GNU General Public License as published by the Free
49
50
 * Globals
50
51
 */
51
52
sstat_parameters_t params;
52
 
fields_t fields[] = {{"cputime", print_cputime}, 
53
 
                     {"jobid", print_jobid}, 
54
 
                     {"ntasks", print_ntasks}, 
55
 
                     {"pages", print_pages}, 
56
 
                     {"rss", print_rss},
57
 
                     {"state", print_state}, 
58
 
                     {"vsize", print_vsize}, 
59
 
                     {NULL, NULL}};
 
53
print_field_t fields[] = {
 
54
        {10, "AveCPU", print_fields_str, PRINT_AVECPU}, 
 
55
        {10, "AvePages", print_fields_str, PRINT_AVEPAGES}, 
 
56
        {10, "AveRSS", print_fields_str, PRINT_AVERSS}, 
 
57
        {10, "AveVMSize", print_fields_str, PRINT_AVEVSIZE}, 
 
58
        {10, "JobID", print_fields_str, PRINT_JOBID}, 
 
59
        {8, "MaxPages", print_fields_str, PRINT_MAXPAGES}, 
 
60
        {12, "MaxPagesNode", print_fields_str, PRINT_MAXPAGESNODE}, 
 
61
        {14, "MaxPagesTask", print_fields_int, PRINT_MAXPAGESTASK}, 
 
62
        {10, "MaxRSS", print_fields_str, PRINT_MAXRSS},
 
63
        {10, "MaxRSSNode", print_fields_str, PRINT_MAXRSSNODE},
 
64
        {10, "MaxRSSTask", print_fields_int, PRINT_MAXRSSTASK},
 
65
        {10, "MaxVMSize", print_fields_str, PRINT_MAXVSIZE}, 
 
66
        {14, "MaxVMSizeNode", print_fields_str, PRINT_MAXVSIZENODE}, 
 
67
        {14, "MaxVMSizeTask", print_fields_int, PRINT_MAXVSIZETASK}, 
 
68
        {10, "MinCPU", print_fields_str, PRINT_MINCPU}, 
 
69
        {10, "MinCPUNode", print_fields_str, PRINT_MINCPUNODE}, 
 
70
        {10, "MinCPUTask", print_fields_int, PRINT_MINCPUTASK}, 
 
71
        {8, "NTasks", print_fields_int, PRINT_NTASKS},
 
72
        {10, "SystemCPU", print_fields_str, PRINT_SYSTEMCPU}, 
 
73
        {10, "TotalCPU", print_fields_str, PRINT_TOTALCPU}, 
 
74
        {0, NULL, NULL, 0}};
60
75
 
61
76
List jobs = NULL;
 
77
jobacct_job_rec_t job;
62
78
jobacct_step_rec_t step;
63
 
 
64
 
int printfields[MAX_PRINTFIELDS],       /* Indexed into fields[] */
65
 
        nprintfields = 0;
66
 
 
67
 
void _print_header(void)
68
 
{
69
 
        int     i,j;
70
 
        for (i=0; i<nprintfields; i++) {
71
 
                if (i)
72
 
                        printf(" ");
73
 
                j=printfields[i];
74
 
                (fields[j].print_routine)(HEADLINE, 0);
75
 
        }
76
 
        printf("\n");
77
 
        for (i=0; i<nprintfields; i++) {
78
 
                if (i)
79
 
                        printf(" ");
80
 
                j=printfields[i];
81
 
                (fields[j].print_routine)(UNDERSCORE, 0);
82
 
        }
83
 
        printf("\n");
84
 
}
 
79
List print_fields_list = NULL;
 
80
ListIterator print_fields_itr = NULL;
 
81
int field_count = 0;
85
82
 
86
83
int _sstat_query(slurm_step_layout_t *step_layout, uint32_t job_id,
87
84
                 uint32_t step_id)
99
96
        debug("getting the stat of job %d on %d nodes", 
100
97
              job_id, step_layout->node_cnt);
101
98
 
 
99
        memset(&job, 0, sizeof(jobacct_job_rec_t));
 
100
        job.jobid = job_id;
 
101
 
 
102
        memset(&step, 0, sizeof(jobacct_step_rec_t));
 
103
        
102
104
        memset(&temp_sacct, 0, sizeof(sacct_t));
103
105
        temp_sacct.min_cpu = (float)NO_VAL;
104
106
        memset(&step.sacct, 0, sizeof(sacct_t));
105
107
        step.sacct.min_cpu = (float)NO_VAL;
106
108
 
107
 
        step.jobid = job_id;
 
109
        step.job_ptr = &job;
108
110
        step.stepid = step_id;
109
111
        step.nodes = step_layout->node_list;
110
112
        step.stepname = NULL;
166
168
                step.sacct.ave_rss /= tot_tasks;
167
169
                step.sacct.ave_vsize /= tot_tasks;
168
170
                step.sacct.ave_pages /= tot_tasks;
 
171
                step.ntasks = tot_tasks;
169
172
        }
170
173
        jobacct_gather_g_destroy(r.jobacct);    
171
174
        return SLURM_SUCCESS;
172
175
}
173
176
 
174
 
int _process_results()
175
 
{
176
 
        print_fields(JOBSTEP, &step);
177
 
        return SLURM_SUCCESS;
178
 
}
179
 
 
180
177
int _do_stat(uint32_t jobid, uint32_t stepid)
181
178
{
182
179
        slurm_msg_t req_msg;
219
216
 
220
217
        _sstat_query(step_layout, jobid, stepid);
221
218
        
222
 
        _process_results();
 
219
        print_fields(&step);
223
220
        
224
221
        slurm_step_layout_destroy(step_layout); 
225
222
        
232
229
        uint32_t stepid = 0;
233
230
        jobacct_selected_step_t *selected_step = NULL;
234
231
        
 
232
        print_fields_list = list_create(NULL);
 
233
        print_fields_itr = list_iterator_create(print_fields_list);
 
234
 
235
235
        parse_command_line(argc, argv);
236
236
        if(!params.opt_job_list || !list_count(params.opt_job_list)) {
237
237
                error("You didn't give me any jobs to stat.");
238
238
                return 1;
239
239
        }
240
240
 
241
 
        if (!params.opt_noheader)       /* give them something to look */
242
 
                _print_header();/* at while we think...        */
 
241
        print_fields_header(print_fields_list);
243
242
        itr = list_iterator_create(params.opt_job_list);
244
243
        while((selected_step = list_next(itr))) {
245
244
                if(selected_step->stepid != NO_VAL)
265
264
                _do_stat(selected_step->jobid, stepid);
266
265
        }
267
266
        list_iterator_destroy(itr);
268
 
                
269
 
        list_destroy(params.opt_job_list);
 
267
 
 
268
        xfree(params.opt_field_list);
 
269
        if(params.opt_job_list) 
 
270
                list_destroy(params.opt_job_list);
 
271
 
 
272
        if(print_fields_itr)
 
273
                list_iterator_destroy(print_fields_itr);
 
274
        if(print_fields_list)
 
275
                list_destroy(print_fields_list);
270
276
 
271
277
        return 0;
272
278
}