View | Details | Raw Unified | Return to ticket 7306 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/sdiag/opts.c (-10 / +10 lines)
Lines 42-58 Link Here
42
42
43
#include "src/common/xstring.h"
43
#include "src/common/xstring.h"
44
#include "src/common/proc_args.h"
44
#include "src/common/proc_args.h"
45
#include "sdiag.h"
45
46
46
#define OPT_LONG_USAGE 0x101
47
#define OPT_LONG_USAGE 0x101
47
48
48
static void  _help( void );
49
static void  _help( void );
49
static void  _usage( void );
50
static void  _usage( void );
50
51
51
extern int  sdiag_param;
52
extern bool sort_by_id;
53
extern bool sort_by_time;
54
extern bool sort_by_time2;
55
56
/*
52
/*
57
 * parse_command_line, fill in params data structure with data
53
 * parse_command_line, fill in params data structure with data
58
 */
54
 */
Lines 72-98 extern void parse_command_line(int argc, char **argv) Link Here
72
		{NULL,		0,		0,	0}
68
		{NULL,		0,		0,	0}
73
	};
69
	};
74
70
71
	/* defalt options */
72
	params.mode = STAT_COMMAND_GET;
73
	params.sort = SORT_COUNT;
74
75
	while ((opt_char = getopt_long(argc, argv, "ahirtTV", long_options,
75
	while ((opt_char = getopt_long(argc, argv, "ahirtTV", long_options,
76
				       &option_index)) != -1) {
76
				       &option_index)) != -1) {
77
		switch (opt_char) {
77
		switch (opt_char) {
78
			case (int)'a':
78
			case (int)'a':
79
				sdiag_param = STAT_COMMAND_GET;
79
				params.mode = STAT_COMMAND_GET;
80
				break;
80
				break;
81
			case (int)'h':
81
			case (int)'h':
82
				_help();
82
				_help();
83
				exit(0);
83
				exit(0);
84
				break;
84
				break;
85
			case (int)'i':
85
			case (int)'i':
86
				sort_by_id = true;
86
				params.sort = SORT_ID;
87
				break;
87
				break;
88
			case (int)'r':
88
			case (int)'r':
89
				sdiag_param = STAT_COMMAND_RESET;
89
				params.mode = STAT_COMMAND_RESET;
90
				break;
90
				break;
91
			case (int)'t':
91
			case (int)'t':
92
				sort_by_time = true;
92
				params.sort = SORT_TIME;
93
				break;
93
				break;
94
			case (int)'T':
94
			case (int)'T':
95
				sort_by_time2 = true;
95
				params.sort = SORT_TIME2;
96
				break;
96
				break;
97
			case (int) 'V':
97
			case (int) 'V':
98
				print_slurm_version();
98
				print_slurm_version();
(-)a/src/sdiag/sdiag.c (-8 / +6 lines)
Lines 47-60 Link Here
47
#include "src/common/uid.h"
47
#include "src/common/uid.h"
48
#include "src/common/xmalloc.h"
48
#include "src/common/xmalloc.h"
49
#include "src/common/xstring.h"
49
#include "src/common/xstring.h"
50
#include "sdiag.h"
50
51
51
/********************
52
/********************
52
 * Global Variables *
53
 * Global Variables *
53
 ********************/
54
 ********************/
54
int sdiag_param = STAT_COMMAND_GET;
55
struct sdiag_parameters params;
55
bool sort_by_id    = false;
56
bool sort_by_time  = false;
57
bool sort_by_time2 = false;
58
56
59
stats_info_response_msg_t *buf;
57
stats_info_response_msg_t *buf;
60
uint32_t *rpc_type_ave_time = NULL, *rpc_user_ave_time = NULL;
58
uint32_t *rpc_type_ave_time = NULL, *rpc_user_ave_time = NULL;
Lines 73-79 int main(int argc, char **argv) Link Here
73
	slurm_conf_init(NULL);
71
	slurm_conf_init(NULL);
74
	parse_command_line(argc, argv);
72
	parse_command_line(argc, argv);
75
73
76
	if (sdiag_param == STAT_COMMAND_RESET) {
74
	if (params.mode == STAT_COMMAND_RESET) {
77
		req.command_id = STAT_COMMAND_RESET;
75
		req.command_id = STAT_COMMAND_RESET;
78
		rc = slurm_reset_statistics((stats_info_request_msg_t *)&req);
76
		rc = slurm_reset_statistics((stats_info_request_msg_t *)&req);
79
		if (rc == SLURM_SUCCESS)
77
		if (rc == SLURM_SUCCESS)
Lines 244-250 static void _sort_rpc(void) Link Here
244
	rpc_type_ave_time = xmalloc(sizeof(uint32_t) * buf->rpc_type_size);
242
	rpc_type_ave_time = xmalloc(sizeof(uint32_t) * buf->rpc_type_size);
245
	rpc_user_ave_time = xmalloc(sizeof(uint32_t) * buf->rpc_user_size);
243
	rpc_user_ave_time = xmalloc(sizeof(uint32_t) * buf->rpc_user_size);
246
244
247
	if (sort_by_id) {
245
	if (params.sort == SORT_ID) {
248
		for (i = 0; i < buf->rpc_type_size; i++) {
246
		for (i = 0; i < buf->rpc_type_size; i++) {
249
			for (j = i+1; j < buf->rpc_type_size; j++) {
247
			for (j = i+1; j < buf->rpc_type_size; j++) {
250
				if (buf->rpc_type_id[i] <= buf->rpc_type_id[j])
248
				if (buf->rpc_type_id[i] <= buf->rpc_type_id[j])
Lines 283-289 static void _sort_rpc(void) Link Here
283
						       buf->rpc_user_cnt[i];
281
						       buf->rpc_user_cnt[i];
284
			}
282
			}
285
		}
283
		}
286
	} else if (sort_by_time) {
284
	} else if (params.sort == SORT_TIME) {
287
		for (i = 0; i < buf->rpc_type_size; i++) {
285
		for (i = 0; i < buf->rpc_type_size; i++) {
288
			for (j = i+1; j < buf->rpc_type_size; j++) {
286
			for (j = i+1; j < buf->rpc_type_size; j++) {
289
				if (buf->rpc_type_time[i] >= buf->rpc_type_time[j])
287
				if (buf->rpc_type_time[i] >= buf->rpc_type_time[j])
Lines 322-328 static void _sort_rpc(void) Link Here
322
						       buf->rpc_user_cnt[i];
320
						       buf->rpc_user_cnt[i];
323
			}
321
			}
324
		}
322
		}
325
	} else if (sort_by_time2) {
323
	} else if (params.sort == SORT_TIME2) {
326
		for (i = 0; i < buf->rpc_type_size; i++) {
324
		for (i = 0; i < buf->rpc_type_size; i++) {
327
			if (buf->rpc_type_cnt[i]) {
325
			if (buf->rpc_type_cnt[i]) {
328
				rpc_type_ave_time[i] = buf->rpc_type_time[i] /
326
				rpc_type_ave_time[i] = buf->rpc_type_time[i] /
(-)a/src/sdiag/sdiag.h (-1 / +57 lines)
Line 0 Link Here
0
- 
1
/****************************************************************************\
2
 *  sdiag.h - Utility for getting information about slurmctld behaviour
3
 *****************************************************************************
4
 *  Produced at Barcelona Supercomputing Center, December 2011
5
 *  Written by Alejandro Lucero <alucero@bsc.es>
6
 *
7
 *  This file is part of Slurm, a resource management program.
8
 *  For details, see <https://slurm.schedmd.com/>.
9
 *  Please also read the included file: DISCLAIMER.
10
 *
11
 *  Slurm is free software; you can redistribute it and/or modify it under
12
 *  the terms of the GNU General Public License as published by the Free
13
 *  Software Foundation; either version 2 of the License, or (at your option)
14
 *  any later version.
15
 *
16
 *  In addition, as a special exception, the copyright holders give permission
17
 *  to link the code of portions of this program with the OpenSSL library under
18
 *  certain conditions as described in each individual source file, and
19
 *  distribute linked combinations including the two. You must obey the GNU
20
 *  General Public License in all respects for all of the code used other than
21
 *  OpenSSL. If you modify file(s) with this exception, you may extend this
22
 *  exception to your version of the file(s), but you are not obligated to do
23
 *  so. If you do not wish to do so, delete this exception statement from your
24
 *  version.  If you delete this exception statement from all source files in
25
 *  the program, then also delete it here.
26
 *
27
 *  Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
28
 *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
29
 *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
30
 *  details.
31
 *
32
 *  You should have received a copy of the GNU General Public License along
33
 *  with Slurm; if not, write to the Free Software Foundation, Inc.,
34
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
35
\*****************************************************************************/
36
37
#ifndef __SDIAG_H__
38
#define __SDIAG_H__
39
40
struct sdiag_parameters {
41
	int mode;
42
	int sort;
43
};
44
45
typedef enum {
46
	SORT_COUNT,
47
	SORT_ID,
48
	SORT_TIME,
49
	SORT_TIME2
50
} sdiag_sort_types_t;
51
52
/********************
53
 * Global Variables *
54
 ********************/
55
extern struct sdiag_parameters params;
56
57
#endif

Return to ticket 7306