View | Details | Raw Unified | Return to ticket 360
Collapse All | Expand All

(-)a/slurm/slurmdb.h (+5 lines)
Lines 336-341 typedef struct { Link Here
336
	uint64_t alloc_secs; /* number of cpu seconds allocated */
336
	uint64_t alloc_secs; /* number of cpu seconds allocated */
337
	uint32_t id;	/* association/wckey ID		*/
337
	uint32_t id;	/* association/wckey ID		*/
338
	time_t period_start; /* when this record was started */
338
	time_t period_start; /* when this record was started */
339
	uint64_t consumed_energy; /* energy allocated in Joules */
339
} slurmdb_accounting_rec_t;
340
} slurmdb_accounting_rec_t;
340
341
341
typedef struct {
342
typedef struct {
Lines 497-502 typedef struct { Link Here
497
	uint64_t pdown_secs; /* number of cpu seconds planned down */
498
	uint64_t pdown_secs; /* number of cpu seconds planned down */
498
	time_t period_start; /* when this record was started */
499
	time_t period_start; /* when this record was started */
499
	uint64_t resv_secs; /* number of cpu seconds reserved */
500
	uint64_t resv_secs; /* number of cpu seconds reserved */
501
	uint64_t consumed_energy; /* energy allocated in Joules */
500
} slurmdb_cluster_accounting_rec_t;
502
} slurmdb_cluster_accounting_rec_t;
501
503
502
typedef struct {
504
typedef struct {
Lines 851-856 typedef struct { Link Here
851
	uint64_t cpu_secs;
853
	uint64_t cpu_secs;
852
	char *parent_acct;
854
	char *parent_acct;
853
	char *user;
855
	char *user;
856
	uint64_t consumed_energy;
854
} slurmdb_report_assoc_rec_t;
857
} slurmdb_report_assoc_rec_t;
855
858
856
typedef struct {
859
typedef struct {
Lines 860-865 typedef struct { Link Here
860
	uint64_t cpu_secs;
863
	uint64_t cpu_secs;
861
	char *name;
864
	char *name;
862
	uid_t uid;
865
	uid_t uid;
866
	uint64_t consumed_energy;
863
} slurmdb_report_user_rec_t;
867
} slurmdb_report_user_rec_t;
864
868
865
typedef struct {
869
typedef struct {
Lines 868-873 typedef struct { Link Here
868
	uint64_t cpu_secs;
872
	uint64_t cpu_secs;
869
	char *name;
873
	char *name;
870
	List user_list; /* list of slurmdb_report_user_rec_t *'s */
874
	List user_list; /* list of slurmdb_report_user_rec_t *'s */
875
	uint64_t consumed_energy;
871
} slurmdb_report_cluster_rec_t;
876
} slurmdb_report_cluster_rec_t;
872
877
873
typedef struct {
878
typedef struct {
(-)a/src/common/slurmdb_defs.c (+1 lines)
Lines 2264-2269 extern slurmdb_report_cluster_rec_t *slurmdb_cluster_rec_2_report( Link Here
2264
			+ accting->down_secs + accting->idle_secs
2264
			+ accting->down_secs + accting->idle_secs
2265
			+ accting->resv_secs + accting->pdown_secs;
2265
			+ accting->resv_secs + accting->pdown_secs;
2266
		slurmdb_report_cluster->cpu_count += accting->cpu_count;
2266
		slurmdb_report_cluster->cpu_count += accting->cpu_count;
2267
		slurmdb_report_cluster->consumed_energy += accting->consumed_energy;
2267
	}
2268
	}
2268
	list_iterator_destroy(cluster_itr);
2269
	list_iterator_destroy(cluster_itr);
2269
2270
(-)a/src/common/slurmdb_pack.c (+4 lines)
Lines 750-755 extern void slurmdb_pack_cluster_accounting_rec(void *in, uint16_t rpc_version, Link Here
750
		pack64(object->pdown_secs, buffer);
750
		pack64(object->pdown_secs, buffer);
751
		pack_time(object->period_start, buffer);
751
		pack_time(object->period_start, buffer);
752
		pack64(object->resv_secs, buffer);
752
		pack64(object->resv_secs, buffer);
753
		pack64(object->consumed_energy, buffer);
753
	}
754
	}
754
}
755
}
755
756
Lines 771-776 extern int slurmdb_unpack_cluster_accounting_rec(void **object, Link Here
771
		safe_unpack64(&object_ptr->pdown_secs, buffer);
772
		safe_unpack64(&object_ptr->pdown_secs, buffer);
772
		safe_unpack_time(&object_ptr->period_start, buffer);
773
		safe_unpack_time(&object_ptr->period_start, buffer);
773
		safe_unpack64(&object_ptr->resv_secs, buffer);
774
		safe_unpack64(&object_ptr->resv_secs, buffer);
775
		safe_unpack64(&object_ptr->consumed_energy, buffer);
774
	}
776
	}
775
777
776
	return SLURM_SUCCESS;
778
	return SLURM_SUCCESS;
Lines 991-996 extern void slurmdb_pack_accounting_rec(void *in, uint16_t rpc_version, Link Here
991
	pack64(object->alloc_secs, buffer);
993
	pack64(object->alloc_secs, buffer);
992
	pack32(object->id, buffer);
994
	pack32(object->id, buffer);
993
	pack_time(object->period_start, buffer);
995
	pack_time(object->period_start, buffer);
996
	pack64(object->consumed_energy, buffer);
994
}
997
}
995
998
996
extern int slurmdb_unpack_accounting_rec(void **object, uint16_t rpc_version,
999
extern int slurmdb_unpack_accounting_rec(void **object, uint16_t rpc_version,
Lines 1004-1009 extern int slurmdb_unpack_accounting_rec(void **object, uint16_t rpc_version, Link Here
1004
	safe_unpack64(&object_ptr->alloc_secs, buffer);
1007
	safe_unpack64(&object_ptr->alloc_secs, buffer);
1005
	safe_unpack32(&object_ptr->id, buffer);
1008
	safe_unpack32(&object_ptr->id, buffer);
1006
	safe_unpack_time(&object_ptr->period_start, buffer);
1009
	safe_unpack_time(&object_ptr->period_start, buffer);
1010
	safe_unpack64(&object_ptr->consumed_energy, buffer);
1007
1011
1008
	return SLURM_SUCCESS;
1012
	return SLURM_SUCCESS;
1009
1013
(-)a/src/db_api/cluster_report_functions.c (+10 lines)
Lines 99-104 static void _process_ua(List user_list, slurmdb_association_rec_t *assoc) Link Here
99
	while((accting = list_next(itr))) {
99
	while((accting = list_next(itr))) {
100
		slurmdb_report_user->cpu_secs +=
100
		slurmdb_report_user->cpu_secs +=
101
			(uint64_t)accting->alloc_secs;
101
			(uint64_t)accting->alloc_secs;
102
		slurmdb_report_user->consumed_energy +=
103
			(uint64_t)accting->consumed_energy;
102
	}
104
	}
103
	list_iterator_destroy(itr);
105
	list_iterator_destroy(itr);
104
}
106
}
Lines 123-128 static void _process_au(List assoc_list, slurmdb_association_rec_t *assoc) Link Here
123
	while((accting = list_next(itr))) {
125
	while((accting = list_next(itr))) {
124
		slurmdb_report_assoc->cpu_secs +=
126
		slurmdb_report_assoc->cpu_secs +=
125
			(uint64_t)accting->alloc_secs;
127
			(uint64_t)accting->alloc_secs;
128
		slurmdb_report_assoc->consumed_energy +=
129
			(uint64_t)accting->consumed_energy;
126
	}
130
	}
127
	list_iterator_destroy(itr);
131
	list_iterator_destroy(itr);
128
132
Lines 158-163 static void _process_uw(List user_list, slurmdb_wckey_rec_t *wckey) Link Here
158
	while((accting = list_next(itr))) {
162
	while((accting = list_next(itr))) {
159
		slurmdb_report_user->cpu_secs +=
163
		slurmdb_report_user->cpu_secs +=
160
			(uint64_t)accting->alloc_secs;
164
			(uint64_t)accting->alloc_secs;
165
		slurmdb_report_user->consumed_energy +=
166
			(uint64_t)accting->consumed_energy;
161
	}
167
	}
162
	list_iterator_destroy(itr);
168
	list_iterator_destroy(itr);
163
}
169
}
Lines 200-205 static void _process_wu(List assoc_list, slurmdb_wckey_rec_t *wckey) Link Here
200
			(uint64_t)accting->alloc_secs;
206
			(uint64_t)accting->alloc_secs;
201
		parent_assoc->cpu_secs +=
207
		parent_assoc->cpu_secs +=
202
			(uint64_t)accting->alloc_secs;
208
			(uint64_t)accting->alloc_secs;
209
		slurmdb_report_assoc->consumed_energy +=
210
			(uint64_t)accting->consumed_energy;
211
		parent_assoc->consumed_energy +=
212
			(uint64_t)accting->consumed_energy;
203
	}
213
	}
204
	list_iterator_destroy(itr);
214
	list_iterator_destroy(itr);
205
}
215
}
(-)a/src/db_api/user_report_functions.c (+2 lines)
Lines 256-261 extern List slurmdb_report_user_top_usage(void *db_conn, Link Here
256
			while((assoc_acct = list_next(itr3))) {
256
			while((assoc_acct = list_next(itr3))) {
257
				slurmdb_report_user->cpu_secs +=
257
				slurmdb_report_user->cpu_secs +=
258
					(uint64_t)assoc_acct->alloc_secs;
258
					(uint64_t)assoc_acct->alloc_secs;
259
				slurmdb_report_user->consumed_energy +=
260
					(uint64_t)assoc_acct->consumed_energy;
259
/* 				slurmdb_report_cluster->cpu_secs +=  */
261
/* 				slurmdb_report_cluster->cpu_secs +=  */
260
/* 					(uint64_t)assoc_acct->alloc_secs; */
262
/* 					(uint64_t)assoc_acct->alloc_secs; */
261
			}
263
			}
(-)a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c (+3 lines)
Lines 885-890 extern int create_cluster_tables(mysql_conn_t *mysql_conn, char *cluster_name) Link Here
885
		{ "id_assoc", "int not null" },
885
		{ "id_assoc", "int not null" },
886
		{ "time_start", "int unsigned not null" },
886
		{ "time_start", "int unsigned not null" },
887
		{ "alloc_cpu_secs", "bigint default 0 not null" },
887
		{ "alloc_cpu_secs", "bigint default 0 not null" },
888
		{ "consumed_energy", "bigint default 0 not null" },
888
		{ NULL, NULL}
889
		{ NULL, NULL}
889
	};
890
	};
890
891
Lines 900-905 extern int create_cluster_tables(mysql_conn_t *mysql_conn, char *cluster_name) Link Here
900
		{ "idle_cpu_secs", "bigint default 0 not null" },
901
		{ "idle_cpu_secs", "bigint default 0 not null" },
901
		{ "resv_cpu_secs", "bigint default 0 not null" },
902
		{ "resv_cpu_secs", "bigint default 0 not null" },
902
		{ "over_cpu_secs", "bigint default 0 not null" },
903
		{ "over_cpu_secs", "bigint default 0 not null" },
904
		{ "consumed_energy", "bigint default 0 not null" },
903
		{ NULL, NULL}
905
		{ NULL, NULL}
904
	};
906
	};
905
907
Lines 1056-1061 extern int create_cluster_tables(mysql_conn_t *mysql_conn, char *cluster_name) Link Here
1056
		{ "alloc_cpu_secs", "bigint default 0" },
1058
		{ "alloc_cpu_secs", "bigint default 0" },
1057
		{ "resv_cpu_secs", "bigint default 0" },
1059
		{ "resv_cpu_secs", "bigint default 0" },
1058
		{ "over_cpu_secs", "bigint default 0" },
1060
		{ "over_cpu_secs", "bigint default 0" },
1061
		{ "consumed_energy", "bigint default 0 not null" },
1059
		{ NULL, NULL}
1062
		{ NULL, NULL}
1060
	};
1063
	};
1061
1064
(-)a/src/plugins/accounting_storage/mysql/as_mysql_convert.c (+3 lines)
Lines 602-607 extern int as_mysql_convert_tables(mysql_conn_t *mysql_conn) Link Here
602
		{ "id", "int not null" },
602
		{ "id", "int not null" },
603
		{ "period_start", "int unsigned not null" },
603
		{ "period_start", "int unsigned not null" },
604
		{ "alloc_cpu_secs", "bigint default 0" },
604
		{ "alloc_cpu_secs", "bigint default 0" },
605
		{ "consumed_energy", "bigint default 0 not null" },
605
		{ NULL, NULL}
606
		{ NULL, NULL}
606
	};
607
	};
607
608
Lines 618-623 extern int as_mysql_convert_tables(mysql_conn_t *mysql_conn) Link Here
618
		{ "idle_cpu_secs", "bigint default 0" },
619
		{ "idle_cpu_secs", "bigint default 0" },
619
		{ "resv_cpu_secs", "bigint default 0" },
620
		{ "resv_cpu_secs", "bigint default 0" },
620
		{ "over_cpu_secs", "bigint default 0" },
621
		{ "over_cpu_secs", "bigint default 0" },
622
		{ "consumed_energy", "bigint default 0 not null" },
621
		{ NULL, NULL}
623
		{ NULL, NULL}
622
	};
624
	};
623
625
Lines 771-776 extern int as_mysql_convert_tables(mysql_conn_t *mysql_conn) Link Here
771
		{ "alloc_cpu_secs", "bigint default 0" },
773
		{ "alloc_cpu_secs", "bigint default 0" },
772
		{ "resv_cpu_secs", "bigint default 0" },
774
		{ "resv_cpu_secs", "bigint default 0" },
773
		{ "over_cpu_secs", "bigint default 0" },
775
		{ "over_cpu_secs", "bigint default 0" },
776
		{ "consumed_energy", "bigint default 0 not null" },
774
		{ NULL, NULL}
777
		{ NULL, NULL}
775
	};
778
	};
776
779
(-)a/src/plugins/accounting_storage/mysql/as_mysql_rollup.c (-50 / +80 lines)
Lines 45-50 Link Here
45
typedef struct {
45
typedef struct {
46
	int id;
46
	int id;
47
	uint64_t a_cpu;
47
	uint64_t a_cpu;
48
	uint64_t energy;
48
} local_id_usage_t;
49
} local_id_usage_t;
49
50
50
typedef struct {
51
typedef struct {
Lines 59-64 typedef struct { Link Here
59
	uint64_t r_cpu;
60
	uint64_t r_cpu;
60
	time_t start;
61
	time_t start;
61
	time_t end;
62
	time_t end;
63
	uint64_t energy;
62
} local_cluster_usage_t;
64
} local_cluster_usage_t;
63
65
64
typedef struct {
66
typedef struct {
Lines 269-285 static int _process_cluster_usage(mysql_conn_t *mysql_conn, Link Here
269
			       "cpu_count, alloc_cpu_secs, "
271
			       "cpu_count, alloc_cpu_secs, "
270
			       "down_cpu_secs, pdown_cpu_secs, "
272
			       "down_cpu_secs, pdown_cpu_secs, "
271
			       "idle_cpu_secs, over_cpu_secs, "
273
			       "idle_cpu_secs, over_cpu_secs, "
272
			       "resv_cpu_secs) "
274
			       "resv_cpu_secs, consumed_energy) "
273
			       "values (%ld, %ld, %ld, %d, "
275
			       "values (%ld, %ld, %ld, %d, "
274
			       "%"PRIu64", %"PRIu64", %"PRIu64", "
276
			       "%"PRIu64", %"PRIu64", %"PRIu64", "
275
			       "%"PRIu64", %"PRIu64", %"PRIu64")",
277
			       "%"PRIu64", %"PRIu64", %"PRIu64", "
278
			       "%"PRIu64")",
276
			       cluster_name, cluster_hour_table,
279
			       cluster_name, cluster_hour_table,
277
			       now, now,
280
			       now, now,
278
			       c_usage->start,
281
			       c_usage->start,
279
			       c_usage->cpu_count,
282
			       c_usage->cpu_count,
280
			       c_usage->a_cpu, c_usage->d_cpu,
283
			       c_usage->a_cpu, c_usage->d_cpu,
281
			       c_usage->pd_cpu, c_usage->i_cpu,
284
			       c_usage->pd_cpu, c_usage->i_cpu,
282
			       c_usage->o_cpu, c_usage->r_cpu);
285
			       c_usage->o_cpu, c_usage->r_cpu,
286
			       c_usage->energy);
283
287
284
	/* Spacing out the inserts here instead of doing them
288
	/* Spacing out the inserts here instead of doing them
285
	   all at once in the end proves to be faster.  Just FYI
289
	   all at once in the end proves to be faster.  Just FYI
Lines 294-300 static int _process_cluster_usage(mysql_conn_t *mysql_conn, Link Here
294
			   "pdown_cpu_secs=VALUES(pdown_cpu_secs), "
298
			   "pdown_cpu_secs=VALUES(pdown_cpu_secs), "
295
			   "idle_cpu_secs=VALUES(idle_cpu_secs), "
299
			   "idle_cpu_secs=VALUES(idle_cpu_secs), "
296
			   "over_cpu_secs=VALUES(over_cpu_secs), "
300
			   "over_cpu_secs=VALUES(over_cpu_secs), "
297
			   "resv_cpu_secs=VALUES(resv_cpu_secs)",
301
			   "resv_cpu_secs=VALUES(resv_cpu_secs), "
302
			   "consumed_energy=VALUES(consumed_energy)",
298
			   now);
303
			   now);
299
		debug3("%d(%s:%d) query\n%s",
304
		debug3("%d(%s:%d) query\n%s",
300
		       mysql_conn->conn, THIS_FILE, __LINE__, query);
305
		       mysql_conn->conn, THIS_FILE, __LINE__, query);
Lines 478-495 extern int as_mysql_hourly_rollup(mysql_conn_t *mysql_conn, Link Here
478
	/* char start_char[20], end_char[20]; */
483
	/* char start_char[20], end_char[20]; */
479
484
480
	char *job_req_inx[] = {
485
	char *job_req_inx[] = {
481
		"job_db_inx",
486
		"job.job_db_inx",
482
		"id_job",
487
		"job.id_job",
483
		"id_assoc",
488
		"job.id_assoc",
484
		"id_wckey",
489
		"job.id_wckey",
485
		"time_eligible",
490
		"job.time_eligible",
486
		"time_start",
491
		"job.time_start",
487
		"time_end",
492
		"job.time_end",
488
		"time_suspended",
493
		"job.time_suspended",
489
		"cpus_alloc",
494
		"job.cpus_alloc",
490
		"cpus_req",
495
		"job.cpus_req",
491
		"id_resv"
496
		"job.id_resv",
492
497
		"SUM(step.consumed_energy)"
493
	};
498
	};
494
	char *job_str = NULL;
499
	char *job_str = NULL;
495
	enum {
500
	enum {
Lines 504-509 extern int as_mysql_hourly_rollup(mysql_conn_t *mysql_conn, Link Here
504
		JOB_REQ_ACPU,
509
		JOB_REQ_ACPU,
505
		JOB_REQ_RCPU,
510
		JOB_REQ_RCPU,
506
		JOB_REQ_RESVID,
511
		JOB_REQ_RESVID,
512
		JOB_REQ_ENERGY,
507
		JOB_REQ_COUNT
513
		JOB_REQ_COUNT
508
	};
514
	};
509
515
Lines 687-697 extern int as_mysql_hourly_rollup(mysql_conn_t *mysql_conn, Link Here
687
		mysql_free_result(result);
693
		mysql_free_result(result);
688
694
689
		/* now get the jobs during this time only  */
695
		/* now get the jobs during this time only  */
690
		query = xstrdup_printf("select %s from \"%s_%s\" where "
696
		query = xstrdup_printf("select %s from \"%s_%s\" as job "
691
				       "(time_eligible < %ld && "
697
				       "left outer join \"%s_%s\" as step on "
692
				       "(time_end >= %ld || time_end = 0)) "
698
				       "job.job_db_inx=step.job_db_inx "
693
				       "order by id_assoc, time_eligible",
699
				       "where (job.time_eligible < %ld && "
700
				       "(job.time_end >= %ld || "
701
				       "job.time_end = 0)) and"
702
				       " (step.id_step>=0) "
703
				       "group by job.job_db_inx "
704
				       "order by job.id_assoc, "
705
				       "job.time_eligible",
694
				       job_str, cluster_name, job_table,
706
				       job_str, cluster_name, job_table,
707
				       cluster_name, step_table,
695
				       curr_end, curr_start);
708
				       curr_end, curr_start);
696
709
697
		debug3("%d(%s:%d) query\n%s",
710
		debug3("%d(%s:%d) query\n%s",
Lines 714-719 extern int as_mysql_hourly_rollup(mysql_conn_t *mysql_conn, Link Here
714
			time_t row_end = slurm_atoul(row[JOB_REQ_END]);
727
			time_t row_end = slurm_atoul(row[JOB_REQ_END]);
715
			uint32_t row_acpu = slurm_atoul(row[JOB_REQ_ACPU]);
728
			uint32_t row_acpu = slurm_atoul(row[JOB_REQ_ACPU]);
716
			uint32_t row_rcpu = slurm_atoul(row[JOB_REQ_RCPU]);
729
			uint32_t row_rcpu = slurm_atoul(row[JOB_REQ_RCPU]);
730
			uint32_t row_energy = slurm_atoul(row[JOB_REQ_ENERGY]);
717
			int loc_seconds = 0;
731
			int loc_seconds = 0;
718
			seconds = 0;
732
			seconds = 0;
719
733
Lines 791-796 extern int as_mysql_hourly_rollup(mysql_conn_t *mysql_conn, Link Here
791
			}
805
			}
792
806
793
			a_usage->a_cpu += seconds * row_acpu;
807
			a_usage->a_cpu += seconds * row_acpu;
808
			a_usage->energy+= row_energy;
794
809
795
			if (!track_wckey)
810
			if (!track_wckey)
796
				goto calc_cluster;
811
				goto calc_cluster;
Lines 813-818 extern int as_mysql_hourly_rollup(mysql_conn_t *mysql_conn, Link Here
813
				last_wckeyid = wckey_id;
828
				last_wckeyid = wckey_id;
814
			}
829
			}
815
			w_usage->a_cpu += seconds * row_acpu;
830
			w_usage->a_cpu += seconds * row_acpu;
831
			w_usage->energy+= row_energy;
816
			/* do the cluster allocated calculation */
832
			/* do the cluster allocated calculation */
817
		calc_cluster:
833
		calc_cluster:
818
834
Lines 910-915 extern int as_mysql_hourly_rollup(mysql_conn_t *mysql_conn, Link Here
910
				/*      row_acpu); */
926
				/*      row_acpu); */
911
927
912
				c_usage->a_cpu += seconds * row_acpu;
928
				c_usage->a_cpu += seconds * row_acpu;
929
				c_usage->energy+= row_energy;
913
			}
930
			}
914
931
915
			/* now reserved time */
932
			/* now reserved time */
Lines 1003-1030 extern int as_mysql_hourly_rollup(mysql_conn_t *mysql_conn, Link Here
1003
/* 			     a_usage->a_cpu); */
1020
/* 			     a_usage->a_cpu); */
1004
			if (query) {
1021
			if (query) {
1005
				xstrfmtcat(query,
1022
				xstrfmtcat(query,
1006
					   ", (%ld, %ld, %d, %ld, %"PRIu64")",
1023
					   ", (%ld, %ld, %d, %ld, %"PRIu64",%"PRIu64")",
1007
					   now, now,
1024
					   now, now,
1008
					   a_usage->id, curr_start,
1025
					   a_usage->id, curr_start,
1009
					   a_usage->a_cpu);
1026
					   a_usage->a_cpu, a_usage->energy);
1010
			} else {
1027
			} else {
1011
				xstrfmtcat(query,
1028
				xstrfmtcat(query,
1012
					   "insert into \"%s_%s\" "
1029
					   "insert into \"%s_%s\" "
1013
					   "(creation_time, "
1030
					   "(creation_time, "
1014
					   "mod_time, id_assoc, time_start, "
1031
					   "mod_time, id_assoc, time_start, "
1015
					   "alloc_cpu_secs) values "
1032
					   "alloc_cpu_secs, consumed_energy) values "
1016
					   "(%ld, %ld, %d, %ld, %"PRIu64")",
1033
					   "(%ld, %ld, %d, %ld, %"PRIu64",%"PRIu64")",
1017
					   cluster_name, assoc_hour_table,
1034
					   cluster_name, assoc_hour_table,
1018
					   now, now,
1035
					   now, now,
1019
					   a_usage->id, curr_start,
1036
					   a_usage->id, curr_start,
1020
					   a_usage->a_cpu);
1037
					   a_usage->a_cpu, a_usage->energy);
1021
			}
1038
			}
1022
		}
1039
		}
1023
		if (query) {
1040
		if (query) {
1024
			xstrfmtcat(query,
1041
			xstrfmtcat(query,
1025
				   " on duplicate key update "
1042
				   " on duplicate key update "
1026
				   "mod_time=%ld, "
1043
				   "mod_time=%ld, "
1027
				   "alloc_cpu_secs=VALUES(alloc_cpu_secs);",
1044
				   "alloc_cpu_secs=VALUES(alloc_cpu_secs), "
1045
				   "consumed_energy=VALUES(consumed_energy);",
1028
				   now);
1046
				   now);
1029
1047
1030
			debug3("%d(%s:%d) query\n%s",
1048
			debug3("%d(%s:%d) query\n%s",
Lines 1048-1075 extern int as_mysql_hourly_rollup(mysql_conn_t *mysql_conn, Link Here
1048
/* 			     w_usage->a_cpu); */
1066
/* 			     w_usage->a_cpu); */
1049
			if (query) {
1067
			if (query) {
1050
				xstrfmtcat(query,
1068
				xstrfmtcat(query,
1051
					   ", (%ld, %ld, %d, %ld, %"PRIu64")",
1069
					   ", (%ld, %ld, %d, %ld, "
1070
					   "%"PRIu64", %"PRIu64")",
1052
					   now, now,
1071
					   now, now,
1053
					   w_usage->id, curr_start,
1072
					   w_usage->id, curr_start,
1054
					   w_usage->a_cpu);
1073
					   w_usage->a_cpu, w_usage->energy);
1055
			} else {
1074
			} else {
1056
				xstrfmtcat(query,
1075
				xstrfmtcat(query,
1057
					   "insert into \"%s_%s\" "
1076
					   "insert into \"%s_%s\" "
1058
					   "(creation_time, "
1077
					   "(creation_time, "
1059
					   "mod_time, id_wckey, time_start, "
1078
					   "mod_time, id_wckey, time_start, "
1060
					   "alloc_cpu_secs) values "
1079
					   "alloc_cpu_secs, consumed_energy) "
1061
					   "(%ld, %ld, %d, %ld, %"PRIu64")",
1080
					   "values "
1081
					   "(%ld, %ld, %d, %ld, "
1082
					   "%"PRIu64", %"PRIu64")",
1062
					   cluster_name, wckey_hour_table,
1083
					   cluster_name, wckey_hour_table,
1063
					   now, now,
1084
					   now, now,
1064
					   w_usage->id, curr_start,
1085
					   w_usage->id, curr_start,
1065
					   w_usage->a_cpu);
1086
					   w_usage->a_cpu, w_usage->energy);
1066
			}
1087
			}
1067
		}
1088
		}
1068
		if (query) {
1089
		if (query) {
1069
			xstrfmtcat(query,
1090
			xstrfmtcat(query,
1070
				   " on duplicate key update "
1091
				   " on duplicate key update "
1071
				   "mod_time=%ld, "
1092
				   "mod_time=%ld, "
1072
				   "alloc_cpu_secs=VALUES(alloc_cpu_secs);",
1093
				   "alloc_cpu_secs=VALUES(alloc_cpu_secs), "
1094
				   "consumed_energy=VALUES(consumed_energy);",
1073
				   now);
1095
				   now);
1074
1096
1075
			debug3("%d(%s:%d) query\n%s",
1097
			debug3("%d(%s:%d) query\n%s",
Lines 1151-1162 extern int as_mysql_daily_rollup(mysql_conn_t *mysql_conn, Link Here
1151
		query = xstrdup_printf(
1173
		query = xstrdup_printf(
1152
			"insert into \"%s_%s\" (creation_time, mod_time, "
1174
			"insert into \"%s_%s\" (creation_time, mod_time, "
1153
			"id_assoc, "
1175
			"id_assoc, "
1154
			"time_start, alloc_cpu_secs) select %ld, %ld, "
1176
			"time_start, alloc_cpu_secs, consumed_energy) select %ld, %ld, "
1155
			"id_assoc, "
1177
			"id_assoc, "
1156
			"%ld, @ASUM:=SUM(alloc_cpu_secs) from \"%s_%s\" where "
1178
			"%ld, @ASUM:=SUM(alloc_cpu_secs), @ESUM:=SUM(consumed_energy) "
1179
			"from \"%s_%s\" where "
1157
			"(time_start < %ld && time_start >= %ld) "
1180
			"(time_start < %ld && time_start >= %ld) "
1158
			"group by id_assoc on duplicate key update "
1181
			"group by id_assoc on duplicate key update "
1159
			"mod_time=%ld, alloc_cpu_secs=@ASUM;",
1182
			"mod_time=%ld, alloc_cpu_secs=@ASUM, consumed_energy=@ESUM;",
1160
			cluster_name, assoc_day_table, now, now, curr_start,
1183
			cluster_name, assoc_day_table, now, now, curr_start,
1161
			cluster_name, assoc_hour_table,
1184
			cluster_name, assoc_hour_table,
1162
			curr_end, curr_start, now);
1185
			curr_end, curr_start, now);
Lines 1168-1174 extern int as_mysql_daily_rollup(mysql_conn_t *mysql_conn, Link Here
1168
			   "insert into \"%s_%s\" (creation_time, "
1191
			   "insert into \"%s_%s\" (creation_time, "
1169
			   "mod_time, time_start, cpu_count, "
1192
			   "mod_time, time_start, cpu_count, "
1170
			   "alloc_cpu_secs, down_cpu_secs, pdown_cpu_secs, "
1193
			   "alloc_cpu_secs, down_cpu_secs, pdown_cpu_secs, "
1171
			   "idle_cpu_secs, over_cpu_secs, resv_cpu_secs) "
1194
			   "idle_cpu_secs, over_cpu_secs, resv_cpu_secs, consumed_energy) "
1172
			   "select %ld, %ld, "
1195
			   "select %ld, %ld, "
1173
			   "%ld, @CPU:=MAX(cpu_count), "
1196
			   "%ld, @CPU:=MAX(cpu_count), "
1174
			   "@ASUM:=SUM(alloc_cpu_secs), "
1197
			   "@ASUM:=SUM(alloc_cpu_secs), "
Lines 1176-1189 extern int as_mysql_daily_rollup(mysql_conn_t *mysql_conn, Link Here
1176
			   "@PDSUM:=SUM(pdown_cpu_secs), "
1199
			   "@PDSUM:=SUM(pdown_cpu_secs), "
1177
			   "@ISUM:=SUM(idle_cpu_secs), "
1200
			   "@ISUM:=SUM(idle_cpu_secs), "
1178
			   "@OSUM:=SUM(over_cpu_secs), "
1201
			   "@OSUM:=SUM(over_cpu_secs), "
1179
			   "@RSUM:=SUM(resv_cpu_secs) from \"%s_%s\" where "
1202
			   "@RSUM:=SUM(resv_cpu_secs), "
1203
			   "@ESUM:=SUM(consumed_energy) from \"%s_%s\" where "
1180
			   "(time_start < %ld && time_start >= %ld) "
1204
			   "(time_start < %ld && time_start >= %ld) "
1181
			   "group by deleted "
1205
			   "group by deleted "
1182
			   "on duplicate key update "
1206
			   "on duplicate key update "
1183
			   "mod_time=%ld, cpu_count=@CPU, "
1207
			   "mod_time=%ld, cpu_count=@CPU, "
1184
			   "alloc_cpu_secs=@ASUM, down_cpu_secs=@DSUM, "
1208
			   "alloc_cpu_secs=@ASUM, down_cpu_secs=@DSUM, "
1185
			   "pdown_cpu_secs=@PDSUM, idle_cpu_secs=@ISUM, "
1209
			   "pdown_cpu_secs=@PDSUM, idle_cpu_secs=@ISUM, "
1186
			   "over_cpu_secs=@OSUM, resv_cpu_secs=@RSUM;",
1210
			   "over_cpu_secs=@OSUM, resv_cpu_secs=@RSUM, "
1211
			   "consumed_energy=@ESUM;",
1187
			   cluster_name, cluster_day_table,
1212
			   cluster_name, cluster_day_table,
1188
			   now, now, curr_start,
1213
			   now, now, curr_start,
1189
			   cluster_name, cluster_hour_table,
1214
			   cluster_name, cluster_hour_table,
Lines 1192-1203 extern int as_mysql_daily_rollup(mysql_conn_t *mysql_conn, Link Here
1192
			xstrfmtcat(query,
1217
			xstrfmtcat(query,
1193
				   "insert into \"%s_%s\" (creation_time, "
1218
				   "insert into \"%s_%s\" (creation_time, "
1194
				   "mod_time, id_wckey, time_start, "
1219
				   "mod_time, id_wckey, time_start, "
1195
				   "alloc_cpu_secs) select %ld, %ld, "
1220
				   "alloc_cpu_secs, consumed_energy) select %ld, %ld, "
1196
				   "id_wckey, %ld, @ASUM:=SUM(alloc_cpu_secs) "
1221
				   "id_wckey, %ld, @ASUM:=SUM(alloc_cpu_secs), "
1222
				   "@ESUM:=SUM(consumed_energy) "
1197
				   "from \"%s_%s\" where (time_start < %ld && "
1223
				   "from \"%s_%s\" where (time_start < %ld && "
1198
				   "time_start >= %ld) "
1224
				   "time_start >= %ld) "
1199
				   "group by id_wckey on duplicate key update "
1225
				   "group by id_wckey on duplicate key update "
1200
				   "mod_time=%ld, alloc_cpu_secs=@ASUM;",
1226
				   "mod_time=%ld, alloc_cpu_secs=@ASUM, "
1227
				   "consumed_energy=@ESUM;",
1201
				   cluster_name, wckey_day_table,
1228
				   cluster_name, wckey_day_table,
1202
				   now, now, curr_start,
1229
				   now, now, curr_start,
1203
				   cluster_name, wckey_hour_table,
1230
				   cluster_name, wckey_hour_table,
Lines 1267-1278 extern int as_mysql_monthly_rollup(mysql_conn_t *mysql_conn, Link Here
1267
		query = xstrdup_printf(
1294
		query = xstrdup_printf(
1268
			"insert into \"%s_%s\" (creation_time, "
1295
			"insert into \"%s_%s\" (creation_time, "
1269
			"mod_time, id_assoc, "
1296
			"mod_time, id_assoc, "
1270
			"time_start, alloc_cpu_secs) select "
1297
			"time_start, alloc_cpu_secs, consumed_energy) select "
1271
			"%ld, %ld, id_assoc, "
1298
			"%ld, %ld, id_assoc, "
1272
			"%ld, @ASUM:=SUM(alloc_cpu_secs) from \"%s_%s\" where "
1299
			"%ld, @ASUM:=SUM(alloc_cpu_secs), @ESUM:=SUM(consumed_energy) "
1300
			"from \"%s_%s\" where "
1273
			"(time_start < %ld && time_start >= %ld) "
1301
			"(time_start < %ld && time_start >= %ld) "
1274
			"group by id_assoc on duplicate key update "
1302
			"group by id_assoc on duplicate key update "
1275
			"mod_time=%ld, alloc_cpu_secs=@ASUM;",
1303
			"mod_time=%ld, alloc_cpu_secs=@ASUM, consumed_energy=@ESUM;",
1276
			cluster_name, assoc_month_table, now, now, curr_start,
1304
			cluster_name, assoc_month_table, now, now, curr_start,
1277
			cluster_name, assoc_day_table,
1305
			cluster_name, assoc_day_table,
1278
			curr_end, curr_start, now);
1306
			curr_end, curr_start, now);
Lines 1284-1290 extern int as_mysql_monthly_rollup(mysql_conn_t *mysql_conn, Link Here
1284
			   "insert into \"%s_%s\" (creation_time, "
1312
			   "insert into \"%s_%s\" (creation_time, "
1285
			   "mod_time, time_start, cpu_count, "
1313
			   "mod_time, time_start, cpu_count, "
1286
			   "alloc_cpu_secs, down_cpu_secs, pdown_cpu_secs, "
1314
			   "alloc_cpu_secs, down_cpu_secs, pdown_cpu_secs, "
1287
			   "idle_cpu_secs, over_cpu_secs, resv_cpu_secs) "
1315
			   "idle_cpu_secs, over_cpu_secs, resv_cpu_secs, consumed_energy) "
1288
			   "select %ld, %ld, "
1316
			   "select %ld, %ld, "
1289
			   "%ld, @CPU:=MAX(cpu_count), "
1317
			   "%ld, @CPU:=MAX(cpu_count), "
1290
			   "@ASUM:=SUM(alloc_cpu_secs), "
1318
			   "@ASUM:=SUM(alloc_cpu_secs), "
Lines 1292-1305 extern int as_mysql_monthly_rollup(mysql_conn_t *mysql_conn, Link Here
1292
			   "@PDSUM:=SUM(pdown_cpu_secs), "
1320
			   "@PDSUM:=SUM(pdown_cpu_secs), "
1293
			   "@ISUM:=SUM(idle_cpu_secs), "
1321
			   "@ISUM:=SUM(idle_cpu_secs), "
1294
			   "@OSUM:=SUM(over_cpu_secs), "
1322
			   "@OSUM:=SUM(over_cpu_secs), "
1295
			   "@RSUM:=SUM(resv_cpu_secs) from \"%s_%s\" where "
1323
			   "@RSUM:=SUM(resv_cpu_secs), "
1324
			   "@ESUM:=SUM(consumed_energy) from \"%s_%s\" where "
1296
			   "(time_start < %ld && time_start >= %ld) "
1325
			   "(time_start < %ld && time_start >= %ld) "
1297
			   "group by deleted "
1326
			   "group by deleted "
1298
			   "on duplicate key update "
1327
			   "on duplicate key update "
1299
			   "mod_time=%ld, cpu_count=@CPU, "
1328
			   "mod_time=%ld, cpu_count=@CPU, "
1300
			   "alloc_cpu_secs=@ASUM, down_cpu_secs=@DSUM, "
1329
			   "alloc_cpu_secs=@ASUM, down_cpu_secs=@DSUM, "
1301
			   "pdown_cpu_secs=@PDSUM, idle_cpu_secs=@ISUM, "
1330
			   "pdown_cpu_secs=@PDSUM, idle_cpu_secs=@ISUM, "
1302
			   "over_cpu_secs=@OSUM, resv_cpu_secs=@RSUM;",
1331
			   "over_cpu_secs=@OSUM, resv_cpu_secs=@RSUM, "
1332
			   "consumed_energy=@ESUM;",
1303
			   cluster_name, cluster_month_table,
1333
			   cluster_name, cluster_month_table,
1304
			   now, now, curr_start,
1334
			   now, now, curr_start,
1305
			   cluster_name, cluster_day_table,
1335
			   cluster_name, cluster_day_table,
Lines 1308-1320 extern int as_mysql_monthly_rollup(mysql_conn_t *mysql_conn, Link Here
1308
			xstrfmtcat(query,
1338
			xstrfmtcat(query,
1309
				   "insert into \"%s_%s\" "
1339
				   "insert into \"%s_%s\" "
1310
				   "(creation_time, mod_time, "
1340
				   "(creation_time, mod_time, "
1311
				   "id_wckey, time_start, alloc_cpu_secs) "
1341
				   "id_wckey, time_start, alloc_cpu_secs, consumed_energy) "
1312
				   "select %ld, %ld, id_wckey, %ld, "
1342
				   "select %ld, %ld, id_wckey, %ld, "
1313
				   "@ASUM:=SUM(alloc_cpu_secs) "
1343
				   "@ASUM:=SUM(alloc_cpu_secs), @ESUM:=SUM(consumed_energy) "
1314
				   "from \"%s_%s\" where (time_start < %ld && "
1344
				   "from \"%s_%s\" where (time_start < %ld && "
1315
				   "time_start >= %ld) "
1345
				   "time_start >= %ld) "
1316
				   "group by id_wckey on duplicate key update "
1346
				   "group by id_wckey on duplicate key update "
1317
				   "mod_time=%ld, alloc_cpu_secs=@ASUM;",
1347
				   "mod_time=%ld, alloc_cpu_secs=@ASUM, consumed_energy=@ESUM;",
1318
				   cluster_name, wckey_month_table,
1348
				   cluster_name, wckey_month_table,
1319
				   now, now, curr_start,
1349
				   now, now, curr_start,
1320
				   cluster_name, wckey_day_table,
1350
				   cluster_name, wckey_day_table,
(-)a/src/plugins/accounting_storage/mysql/as_mysql_usage.c (-5 / +14 lines)
Lines 425-431 static int _get_cluster_usage(mysql_conn_t *mysql_conn, uid_t uid, Link Here
425
		"resv_cpu_secs",
425
		"resv_cpu_secs",
426
		"over_cpu_secs",
426
		"over_cpu_secs",
427
		"cpu_count",
427
		"cpu_count",
428
		"time_start"
428
		"time_start",
429
		"consumed_energy"
429
	};
430
	};
430
431
431
	enum {
432
	enum {
Lines 437-442 static int _get_cluster_usage(mysql_conn_t *mysql_conn, uid_t uid, Link Here
437
		CLUSTER_OCPU,
438
		CLUSTER_OCPU,
438
		CLUSTER_CPU_COUNT,
439
		CLUSTER_CPU_COUNT,
439
		CLUSTER_START,
440
		CLUSTER_START,
441
		CLUSTER_ENERGY,
440
		CLUSTER_COUNT
442
		CLUSTER_COUNT
441
	};
443
	};
442
444
Lines 465-470 static int _get_cluster_usage(mysql_conn_t *mysql_conn, uid_t uid, Link Here
465
	xfree(tmp);
467
	xfree(tmp);
466
	debug4("%d(%s:%d) query\n%s",
468
	debug4("%d(%s:%d) query\n%s",
467
	       mysql_conn->conn, THIS_FILE, __LINE__, query);
469
	       mysql_conn->conn, THIS_FILE, __LINE__, query);
470
468
	if (!(result = mysql_db_query_ret(
471
	if (!(result = mysql_db_query_ret(
469
		      mysql_conn, query, 0))) {
472
		      mysql_conn, query, 0))) {
470
		xfree(query);
473
		xfree(query);
Lines 487-496 static int _get_cluster_usage(mysql_conn_t *mysql_conn, uid_t uid, Link Here
487
		accounting_rec->resv_secs = slurm_atoull(row[CLUSTER_RCPU]);
490
		accounting_rec->resv_secs = slurm_atoull(row[CLUSTER_RCPU]);
488
		accounting_rec->cpu_count = slurm_atoul(row[CLUSTER_CPU_COUNT]);
491
		accounting_rec->cpu_count = slurm_atoul(row[CLUSTER_CPU_COUNT]);
489
		accounting_rec->period_start = slurm_atoul(row[CLUSTER_START]);
492
		accounting_rec->period_start = slurm_atoul(row[CLUSTER_START]);
493
		accounting_rec->consumed_energy = slurm_atoull(row[CLUSTER_ENERGY]);
490
		list_append(cluster_rec->accounting_list, accounting_rec);
494
		list_append(cluster_rec->accounting_list, accounting_rec);
491
	}
495
	}
492
	mysql_free_result(result);
496
	mysql_free_result(result);
493
494
	return rc;
497
	return rc;
495
}
498
}
496
499
Lines 526-531 extern int get_usage_for_list(mysql_conn_t *mysql_conn, Link Here
526
		USAGE_ID,
529
		USAGE_ID,
527
		USAGE_START,
530
		USAGE_START,
528
		USAGE_ACPU,
531
		USAGE_ACPU,
532
		USAGE_ENERGY,
529
		USAGE_COUNT
533
		USAGE_COUNT
530
	};
534
	};
531
535
Lines 544-550 extern int get_usage_for_list(mysql_conn_t *mysql_conn, Link Here
544
		char *temp_usage[] = {
548
		char *temp_usage[] = {
545
			"t3.id_assoc",
549
			"t3.id_assoc",
546
			"t1.time_start",
550
			"t1.time_start",
547
			"t1.alloc_cpu_secs"
551
			"t1.alloc_cpu_secs",
552
			"t1.consumed_energy",
548
		};
553
		};
549
		usage_req_inx = temp_usage;
554
		usage_req_inx = temp_usage;
550
555
Lines 566-572 extern int get_usage_for_list(mysql_conn_t *mysql_conn, Link Here
566
		char *temp_usage[] = {
571
		char *temp_usage[] = {
567
			"id_wckey",
572
			"id_wckey",
568
			"time_start",
573
			"time_start",
569
			"alloc_cpu_secs"
574
			"alloc_cpu_secs",
575
			"consumed_energy"
570
		};
576
		};
571
		usage_req_inx = temp_usage;
577
		usage_req_inx = temp_usage;
572
578
Lines 648-653 extern int get_usage_for_list(mysql_conn_t *mysql_conn, Link Here
648
		accounting_rec->id = slurm_atoul(row[USAGE_ID]);
654
		accounting_rec->id = slurm_atoul(row[USAGE_ID]);
649
		accounting_rec->period_start = slurm_atoul(row[USAGE_START]);
655
		accounting_rec->period_start = slurm_atoul(row[USAGE_START]);
650
		accounting_rec->alloc_secs = slurm_atoull(row[USAGE_ACPU]);
656
		accounting_rec->alloc_secs = slurm_atoull(row[USAGE_ACPU]);
657
		accounting_rec->consumed_energy = slurm_atoull(row[USAGE_ENERGY]);
651
		list_append(usage_list, accounting_rec);
658
		list_append(usage_list, accounting_rec);
652
	}
659
	}
653
	mysql_free_result(result);
660
	mysql_free_result(result);
Lines 740-746 extern int as_mysql_get_usage(mysql_conn_t *mysql_conn, uid_t uid, Link Here
740
		USAGE_ID,
747
		USAGE_ID,
741
		USAGE_START,
748
		USAGE_START,
742
		USAGE_ACPU,
749
		USAGE_ACPU,
743
		USAGE_COUNT
750
		USAGE_COUNT,
751
		USAGE_ENERGY
744
	};
752
	};
745
753
746
	switch (type) {
754
	switch (type) {
Lines 902-907 is_user: Link Here
902
		accounting_rec->id = slurm_atoul(row[USAGE_ID]);
910
		accounting_rec->id = slurm_atoul(row[USAGE_ID]);
903
		accounting_rec->period_start = slurm_atoul(row[USAGE_START]);
911
		accounting_rec->period_start = slurm_atoul(row[USAGE_START]);
904
		accounting_rec->alloc_secs = slurm_atoull(row[USAGE_ACPU]);
912
		accounting_rec->alloc_secs = slurm_atoull(row[USAGE_ACPU]);
913
		accounting_rec->consumed_energy = slurm_atoull(row[USAGE_ENERGY]);
905
		list_append((*my_list), accounting_rec);
914
		list_append((*my_list), accounting_rec);
906
	}
915
	}
907
	mysql_free_result(result);
916
	mysql_free_result(result);
(-)a/src/sreport/cluster_reports.c (-2 / +37 lines)
Lines 56-61 enum { Link Here
56
	PRINT_CLUSTER_USER_PROPER,
56
	PRINT_CLUSTER_USER_PROPER,
57
	PRINT_CLUSTER_AMOUNT_USED,
57
	PRINT_CLUSTER_AMOUNT_USED,
58
	PRINT_CLUSTER_WCKEY,
58
	PRINT_CLUSTER_WCKEY,
59
	PRINT_CLUSTER_ENERGY,
59
};
60
};
60
61
61
typedef enum {
62
typedef enum {
Lines 507-512 static int _setup_print_fields_list(List format_list) Link Here
507
			else
508
			else
508
				field->len = 15;
509
				field->len = 15;
509
			field->print_routine = print_fields_str;
510
			field->print_routine = print_fields_str;
511
		} else if (!strncasecmp("Energy", object, MAX(command_len, 1))) {
512
			field->type = PRINT_CLUSTER_ENERGY;
513
			field->name = xstrdup("Energy");
514
			field->len = 10;
515
			field->print_routine = print_fields_int;
510
		} else {
516
		} else {
511
			exit_code=1;
517
			exit_code=1;
512
			fprintf(stderr, " Unknown field '%s'\n", object);
518
			fprintf(stderr, " Unknown field '%s'\n", object);
Lines 608-614 extern int cluster_account_by_user(int argc, char *argv[]) Link Here
608
614
609
	if (!list_count(format_list))
615
	if (!list_count(format_list))
610
		slurm_addto_char_list(format_list,
616
		slurm_addto_char_list(format_list,
611
				      "Cluster,Ac,Login,Proper,Used");
617
				      "Cluster,Ac,Login,Proper,Used,Energy");
612
618
613
	_setup_print_fields_list(format_list);
619
	_setup_print_fields_list(format_list);
614
	list_destroy(format_list);
620
	list_destroy(format_list);
Lines 739-744 extern int cluster_account_by_user(int argc, char *argv[]) Link Here
739
						slurmdb_report_cluster->cpu_secs,
745
						slurmdb_report_cluster->cpu_secs,
740
						(curr_inx == field_count));
746
						(curr_inx == field_count));
741
					break;
747
					break;
748
                                case PRINT_CLUSTER_ENERGY:
749
                                        field->print_routine(
750
                                                field,
751
                                                slurmdb_report_assoc->consumed_energy,
752
                                                slurmdb_report_cluster->consumed_energy,
753
                                                (curr_inx == field_count));
754
                                        break;
742
				default:
755
				default:
743
					field->print_routine(
756
					field->print_routine(
744
						field, NULL,
757
						field, NULL,
Lines 794-800 extern int cluster_user_by_account(int argc, char *argv[]) Link Here
794
807
795
	if (!list_count(format_list))
808
	if (!list_count(format_list))
796
		slurm_addto_char_list(format_list,
809
		slurm_addto_char_list(format_list,
797
				      "Cluster,Login,Proper,Ac,Used");
810
				      "Cluster,Login,Proper,Ac,Used,Energy");
798
811
799
	_setup_print_fields_list(format_list);
812
	_setup_print_fields_list(format_list);
800
	list_destroy(format_list);
813
	list_destroy(format_list);
Lines 893-898 extern int cluster_user_by_account(int argc, char *argv[]) Link Here
893
						slurmdb_report_cluster->cpu_secs,
906
						slurmdb_report_cluster->cpu_secs,
894
						(curr_inx == field_count));
907
						(curr_inx == field_count));
895
					break;
908
					break;
909
                                case PRINT_CLUSTER_ENERGY:
910
                                        field->print_routine(
911
                                                field,
912
                                                slurmdb_report_user->consumed_energy,
913
                                                slurmdb_report_cluster->consumed_energy,
914
                                                (curr_inx == field_count));
915
                                        break;
896
				default:
916
				default:
897
					field->print_routine(
917
					field->print_routine(
898
						field, NULL,
918
						field, NULL,
Lines 1047-1052 extern int cluster_user_by_wckey(int argc, char *argv[]) Link Here
1047
						slurmdb_report_cluster->cpu_secs,
1067
						slurmdb_report_cluster->cpu_secs,
1048
						(curr_inx == field_count));
1068
						(curr_inx == field_count));
1049
					break;
1069
					break;
1070
                                case PRINT_CLUSTER_ENERGY:
1071
                                        field->print_routine(
1072
                                                field,
1073
                                                slurmdb_report_user->consumed_energy,
1074
                                                slurmdb_report_cluster->consumed_energy,
1075
                                                (curr_inx == field_count));
1076
                                        break;
1077
1050
				default:
1078
				default:
1051
					field->print_routine(
1079
					field->print_routine(
1052
						field, NULL,
1080
						field, NULL,
Lines 1137-1142 extern int cluster_utilization(int argc, char *argv[]) Link Here
1137
			total_acct.resv_secs += accting->resv_secs;
1165
			total_acct.resv_secs += accting->resv_secs;
1138
			total_acct.over_secs += accting->over_secs;
1166
			total_acct.over_secs += accting->over_secs;
1139
			total_acct.cpu_count += accting->cpu_count;
1167
			total_acct.cpu_count += accting->cpu_count;
1168
			total_acct.consumed_energy += accting->consumed_energy;
1140
		}
1169
		}
1141
		list_iterator_destroy(itr3);
1170
		list_iterator_destroy(itr3);
1142
1171
Lines 1204-1209 extern int cluster_utilization(int argc, char *argv[]) Link Here
1204
						     (curr_inx ==
1233
						     (curr_inx ==
1205
						      field_count));
1234
						      field_count));
1206
				break;
1235
				break;
1236
			case PRINT_CLUSTER_ENERGY:
1237
				field->print_routine(field,
1238
				                     total_acct.consumed_energy,
1239
				                     (curr_inx ==
1240
				                      field_count));
1241
				break;
1207
			case PRINT_CLUSTER_TOTAL:
1242
			case PRINT_CLUSTER_TOTAL:
1208
				field->print_routine(field,
1243
				field->print_routine(field,
1209
						     total_reported,
1244
						     total_reported,
(-)a/src/sreport/user_reports.c (-1 / +13 lines)
Lines 46-51 enum { Link Here
46
	PRINT_USER_LOGIN,
46
	PRINT_USER_LOGIN,
47
	PRINT_USER_PROPER,
47
	PRINT_USER_PROPER,
48
	PRINT_USER_USED,
48
	PRINT_USER_USED,
49
	PRINT_USER_ENERGY,
49
};
50
};
50
51
51
static List print_fields_list = NULL; /* types are of print_field_t */
52
static List print_fields_list = NULL; /* types are of print_field_t */
Lines 221-226 static int _setup_print_fields_list(List format_list) Link Here
221
			else
222
			else
222
				field->len = 10;
223
				field->len = 10;
223
			field->print_routine = slurmdb_report_print_time;
224
			field->print_routine = slurmdb_report_print_time;
225
		}else if (!strncasecmp("Energy", object, MAX(command_len, 1))) {
226
			field->type = PRINT_USER_ENERGY;
227
			field->name = xstrdup("Energy");
228
			field->len = 10;
229
			field->print_routine = print_fields_int;
224
		} else {
230
		} else {
225
			exit_code=1;
231
			exit_code=1;
226
			fprintf(stderr, " Unknown field '%s'\n", object);
232
			fprintf(stderr, " Unknown field '%s'\n", object);
Lines 261-267 extern int user_top(int argc, char *argv[]) Link Here
261
	_set_cond(&i, argc, argv, user_cond, format_list);
267
	_set_cond(&i, argc, argv, user_cond, format_list);
262
268
263
	if (!list_count(format_list))
269
	if (!list_count(format_list))
264
		slurm_addto_char_list(format_list, "Cl,L,P,A,U");
270
		slurm_addto_char_list(format_list, "Cl,L,P,A,U,Energy");
265
271
266
	_setup_print_fields_list(format_list);
272
	_setup_print_fields_list(format_list);
267
	list_destroy(format_list);
273
	list_destroy(format_list);
Lines 369-374 extern int user_top(int argc, char *argv[]) Link Here
369
						slurmdb_report_cluster->cpu_secs,
375
						slurmdb_report_cluster->cpu_secs,
370
						(curr_inx == field_count));
376
						(curr_inx == field_count));
371
					break;
377
					break;
378
				case PRINT_USER_ENERGY:
379
					field->print_routine(
380
						field,
381
						slurmdb_report_user->consumed_energy,
382
						(curr_inx ==field_count));
383
					break;
372
				default:
384
				default:
373
					field->print_routine(
385
					field->print_routine(
374
						field, NULL,
386
						field, NULL,

Return to ticket 360