2
2
* slurm_accounting_storage.h - Define accounting storage plugin functions.
3
3
*****************************************************************************
4
4
* Copyright (C) 2004-2007 The Regents of the University of California.
5
* Copyright (C) 2008 Lawrence Livermore National Security.
5
* Copyright (C) 2008-2009 Lawrence Livermore National Security.
6
6
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
7
7
* Written by Danny Auble <da@llnl.gov>
8
* CODE-OCEC-09-009. All rights reserved.
10
10
* This file is part of SLURM, a resource management program.
11
* For details, see <http://www.llnl.gov/linux/slurm/>.
11
* For details, see <https://computing.llnl.gov/linux/slurm/>.
12
* Please also read the included file: DISCLAIMER.
13
14
* SLURM is free software; you can redistribute it and/or modify it under
14
15
* the terms of the GNU General Public License as published by the Free
72
73
} acct_update_type_t;
76
ACCT_CLASS_NONE, /* no class given */
77
ACCT_CLASS_CAPABILITY, /* capability cluster */
78
ACCT_CLASS_CAPACITY, /* capacity cluster */
79
ACCT_CLASS_CAPAPACITY, /* a cluster that is both capability
81
} acct_classification_type_t;
83
#define ACCT_CLASSIFIED_FLAG 0x0100
84
#define ACCT_CLASS_BASE 0x00ff
74
86
/* Association conditions used for queries of the database */
76
88
List acct_list; /* list of char * */
135
147
uint64_t alloc_secs; /* number of cpu seconds allocated */
136
148
uint32_t id; /* association/wckey ID */
149
time_t period_start; /* when this record was started */
138
150
} acct_accounting_rec_t;
140
152
typedef struct acct_association_rec {
141
153
List accounting_list; /* list of acct_accounting_rec_t *'s */
142
154
char *acct; /* account/project associated to association */
155
List childern_list; /* list of childern associations
143
157
char *cluster; /* cluster associated to association
146
uint32_t fairshare; /* fairshare number */
148
uint64_t grp_cpu_mins; /* max number of cpu hours the
149
* underlying group of
150
* associations can run for */
160
uint64_t grp_cpu_mins; /* max number of cpu minutes the
161
* underlying group of
162
* associations can run for */
151
163
uint32_t grp_cpus; /* max number of cpus the
152
* underlying group of
153
* associations can allocate at one time */
164
* underlying group of
165
* associations can allocate at one time */
154
166
uint32_t grp_jobs; /* max number of jobs the
155
167
* underlying group of associations can run
157
169
uint32_t grp_nodes; /* max number of nodes the
158
* underlying group of
159
* associations can allocate at once */
170
* underlying group of
171
* associations can allocate at once */
160
172
uint32_t grp_submit_jobs; /* max number of jobs the
161
* underlying group of
162
* associations can submit at
173
* underlying group of
174
* associations can submit at
164
176
uint32_t grp_wall; /* total time in hours the
165
177
* underlying group of
166
178
* associations can run for */
168
uint32_t grp_used_cpu_mins; /* cpu mins the
169
* underlying group of
170
* associations has ran for
172
180
uint32_t grp_used_cpus; /* count of active jobs in the group
173
181
* (DON'T PACK) */
174
182
uint32_t grp_used_nodes; /* count of active jobs in the group
175
183
* (DON'T PACK) */
176
uint32_t grp_used_wall; /* group count of time used in
177
* running jobs (DON'T PACK) */
184
double grp_used_wall; /* group count of time used in
185
* running jobs (DON'T PACK) */
179
187
uint32_t id; /* id identifing a combination of
180
188
* user-account-cluster(-partition) */
182
190
uint32_t level_shares; /* number of shares on this level of
183
191
* the tree (DON'T PACK) */
189
197
uint64_t max_cpu_mins_pj; /* max number of cpu seconds this
190
198
* association can have per job */
191
199
uint32_t max_cpus_pj; /* max number of cpus this
192
* association can allocate per job */
200
* association can allocate per job */
193
201
uint32_t max_jobs; /* max number of jobs this association can run
195
203
uint32_t max_nodes_pj; /* max number of nodes this
196
* association can allocate per job */
204
* association can allocate per job */
197
205
uint32_t max_submit_jobs; /* max number of jobs that can be
198
206
submitted by association */
199
207
uint32_t max_wall_pj; /* longest time this
207
215
uint32_t parent_id; /* id of parent account */
208
216
char *partition; /* optional partition in a cluster
209
217
* associated to association */
211
219
List qos_list; /* list of char * */
213
221
uint32_t rgt; /* rgt used for grouping sub
214
222
* associations and jobs as a right
215
223
* most container used with lft */
225
double shares_norm; /* normalized shares (DON'T PACK) */
226
uint32_t shares_raw; /* number of shares allocated to association */
216
228
uint32_t uid; /* user ID */
230
long double usage_efctv;/* effective, normalized usage (DON'T PACK) */
231
long double usage_norm; /* normalized usage (DON'T PACK) */
232
long double usage_raw; /* measure of resource usage (DON'T PACK) */
218
234
uint32_t used_jobs; /* count of active jobs (DON'T PACK) */
219
uint32_t used_shares; /* measure of resource usage */
220
235
uint32_t used_submit_jobs; /* count of jobs pending or running
221
236
* (DON'T PACK) */
224
239
} acct_association_rec_t;
242
uint16_t classification; /* how this machine is classified */
227
243
List cluster_list; /* list of char * */
229
uint32_t usage_start;
230
246
uint16_t with_deleted;
231
247
uint16_t with_usage;
232
248
} acct_cluster_cond_t;
235
251
List accounting_list; /* list of cluster_accounting_rec_t *'s */
252
uint16_t classification; /* how this machine is classified */
236
253
char *control_host;
237
254
uint32_t control_port;
241
258
acct_association_rec_t *root_assoc; /* root association for cluster */
243
259
uint16_t rpc_version; /* version of rpc this cluter is running */
244
260
} acct_cluster_rec_t;
255
271
uint16_t duplicates; /* report duplicate job entries */
256
272
List groupid_list; /* list of char * */
257
273
List partition_list; /* list of char * */
274
List resv_list; /* list of char * */
275
List resvid_list; /* list of char * */
258
276
List step_list; /* list of jobacct_selected_step_t */
259
277
List state_list; /* list of char * */
261
uint32_t usage_start;
280
char *used_nodes; /* a ranged node string where jobs ran */
262
281
List userid_list; /* list of char * */
263
282
List wckey_list; /* list of char * */
264
283
uint16_t without_steps; /* don't give me step info */
284
uint16_t without_usage_truncation; /* give me the information
285
* without truncating the
286
* time to the usage_start
265
288
} acct_job_cond_t;
293
314
* (DON'T PACK) */
294
315
uint32_t grp_used_submit_jobs; /* count of jobs pending or running
295
316
* (DON'T PACK) */
296
uint32_t grp_used_wall; /* group count of time (minutes) used in
317
double grp_used_wall; /* group count of time (minutes) used in
297
318
* running jobs (DON'T PACK) */
299
320
uint64_t max_cpu_mins_pu; /* max number of cpu mins a user can
310
331
* qos can run a job */
334
double norm_priority;/* normalized priority (DON'T PACK) */
313
335
List preemptee_list; /* list of char * list of qos's that this
314
336
qos can preempt */
315
337
List preemptor_list; /* list of char * list of qos's that this
316
338
* qos is preempted by */
317
339
uint32_t priority; /* ranged int needs to be a unint for
318
340
* heterogeneous systems */
341
double usage_factor; /* factor to apply to usage in this qos */
342
long double usage_raw; /* measure of resource usage (DON'T PACK) */
319
344
List user_limit_list; /* acct_used_limits_t's */
320
345
} acct_qos_rec_t;
326
351
uint16_t with_deleted;
327
352
} acct_qos_cond_t;
355
List cluster_list; /* cluster reservations are on list of
357
uint16_t flags; /* flags for reservation. */
358
List id_list; /* ids of reservations. list of char * */
359
List name_list; /* name of reservations. list of char * */
360
char *nodes; /* list of nodes in reservation */
361
time_t time_end; /* end time of reservation */
362
time_t time_start; /* start time of reservation */
363
uint16_t with_usage; /* send usage for reservation */
364
} acct_reservation_cond_t;
367
uint64_t alloc_secs; /* number of cpu seconds allocated */
368
char *assocs; /* comma seperated list of associations */
369
char *cluster; /* cluster reservation is for */
370
uint32_t cpus; /* how many cpus are in reservation */
371
uint64_t down_secs; /* number of cpu seconds down */
372
uint16_t flags; /* flags for reservation. */
373
uint32_t id; /* id of reservation. */
374
char *name; /* name of reservation */
375
char *nodes; /* list of nodes in reservation */
376
char *node_inx; /* node index of nodes in reservation */
377
time_t time_end; /* end time of reservation */
378
time_t time_start; /* start time of reservation */
379
time_t time_start_prev; /* If start time was changed this is
380
* the pervious start time. Needed
382
} acct_reservation_rec_t;
329
384
/* Right now this is used in the acct_qos_rec_t structure. In the
330
385
* user_limit_list. */
376
431
List id_list; /* list of char * */
377
432
List info_list; /* list of char * */
378
433
List name_list; /* list of char * */
381
436
List user_list; /* list of char * */
382
437
uint16_t with_assoc_info;
383
438
} acct_txn_cond_t;
440
495
uint64_t down_secs; /* number of cpu seconds down */
441
496
uint64_t idle_secs; /* number of cpu seconds idle */
442
497
uint64_t over_secs; /* number of cpu seconds overcommitted */
498
uint64_t pdown_secs; /* number of cpu seconds planned down */
443
499
time_t period_start; /* when this record was started */
444
500
uint64_t resv_secs; /* number of cpu seconds reserved */
445
501
} cluster_accounting_rec_t;
450
505
char *print_name;
507
uint16_t user; /* set to 1 if it is a user i.e. if name[0] is
453
509
} acct_print_tree_t;
462
518
char *archive_dir; /* location to place archive file */
519
uint16_t archive_events; /* whether or not to keep an archive
520
file of events that can be loaded
463
522
uint16_t archive_jobs; /* whether or not to keep an archive
464
523
file of jobs that can be loaded
468
527
uint16_t archive_steps; /* whether or not to keep an archive
469
528
file of steps that can be loaded
530
uint16_t archive_suspend; /* whether or not to keep an archive
531
file of suspend data that can be loaded
471
533
acct_job_cond_t *job_cond; /* conditions for the jobs to archive */
472
uint16_t job_purge; /* purge jobs older than this in months */
473
uint16_t step_purge; /* purge steps older than this in months */
534
uint16_t purge_event; /* purge events older than this in months */
535
uint16_t purge_job; /* purge jobs older than this in months */
536
uint16_t purge_step; /* purge steps older than this in months */
537
uint16_t purge_suspend; /* purge suspend data older than this
474
539
} acct_archive_cond_t;
480
545
insert of jobs since past */
481
546
} acct_archive_rec_t;
548
extern uint32_t qos_max_priority; /* max priority in all qos's */
483
550
extern void destroy_acct_user_rec(void *object);
484
551
extern void destroy_acct_account_rec(void *object);
485
552
extern void destroy_acct_coord_rec(void *object);
488
555
extern void destroy_acct_accounting_rec(void *object);
489
556
extern void destroy_acct_association_rec(void *object);
490
557
extern void destroy_acct_qos_rec(void *object);
558
extern void destroy_acct_reservation_rec(void *object);
491
559
extern void destroy_acct_txn_rec(void *object);
492
560
extern void destroy_acct_wckey_rec(void *object);
493
561
extern void destroy_acct_archive_rec(void *object);
498
566
extern void destroy_acct_association_cond(void *object);
499
567
extern void destroy_acct_job_cond(void *object);
500
568
extern void destroy_acct_qos_cond(void *object);
569
extern void destroy_acct_reservation_cond(void *object);
501
570
extern void destroy_acct_txn_cond(void *object);
502
571
extern void destroy_acct_wckey_cond(void *object);
503
572
extern void destroy_acct_archive_cond(void *object);
539
608
extern void pack_acct_qos_rec(void *in, uint16_t rpc_version, Buf buffer);
540
609
extern int unpack_acct_qos_rec(void **object, uint16_t rpc_version, Buf buffer);
610
extern void pack_acct_reservation_rec(void *in, uint16_t rpc_version,
612
extern int unpack_acct_reservation_rec(void **object, uint16_t rpc_version,
541
614
extern void pack_acct_txn_rec(void *in, uint16_t rpc_version, Buf buffer);
542
615
extern int unpack_acct_txn_rec(void **object, uint16_t rpc_version, Buf buffer);
543
616
extern void pack_acct_wckey_rec(void *in, uint16_t rpc_version, Buf buffer);
566
639
extern void pack_acct_qos_cond(void *in, uint16_t rpc_version, Buf buffer);
567
640
extern int unpack_acct_qos_cond(void **object, uint16_t rpc_version,
642
extern void pack_acct_reservation_cond(void *in, uint16_t rpc_version,
644
extern int unpack_acct_reservation_cond(void **object, uint16_t rpc_version,
569
646
extern void pack_acct_txn_cond(void *in, uint16_t rpc_version, Buf buffer);
570
647
extern int unpack_acct_txn_cond(void **object, uint16_t rpc_version,
602
679
extern List get_acct_hierarchical_rec_list(List assoc_list);
604
681
/* IN/OUT: tree_list a list of acct_print_tree_t's */
605
extern char *get_tree_acct_name(char *name, char *parent, char *cluster,
682
extern char *get_tree_acct_name(char *name, char *parent, List tree_list);
608
684
extern char *get_qos_complete_str(List qos_list, List num_qos_list);
686
extern char *get_classification_str(uint16_t class);
687
extern uint16_t str_2_classification(char *class);
610
689
extern void log_assoc_rec(acct_association_rec_t *assoc_ptr, List qos_list);
612
691
extern int slurm_acct_storage_init(char *loc); /* load the plugin */
699
778
List wckey_list);
781
* add reservation's in accounting system
782
* IN: acct_reservation_rec_t *resv reservation to be added.
783
* RET: SLURM_SUCCESS on success SLURM_ERROR else
785
extern int acct_storage_g_add_reservation(void *db_conn,
786
acct_reservation_rec_t *resv);
702
789
* modify existing users in the accounting system
703
790
* IN: acct_user_cond_t *user_cond
704
791
* IN: acct_user_rec_t *user
760
847
acct_wckey_rec_t *wckey);
850
* modify reservation's in accounting system
851
* IN: acct_reservation_rec_t *resv
852
* RET: SLURM_SUCCESS on success SLURM_ERROR else
854
extern int acct_storage_g_modify_reservation(void *db_conn,
855
acct_reservation_rec_t *resv);
763
857
* remove users from accounting system
764
858
* IN: acct_user_cond_t *user_cond
765
859
* RET: List containing (char *'s) else NULL on error
818
912
void *db_conn, uint32_t uid, acct_wckey_cond_t *wckey_cond);
915
* remove reservation's in accounting system
916
* IN: acct_reservation_rec_t *resv
917
* RET: SLURM_SUCCESS on success SLURM_ERROR else
919
extern int acct_storage_g_remove_reservation(void *db_conn,
920
acct_reservation_rec_t *resv);
821
922
* get info from the storage
822
923
* IN: acct_user_cond_t *
823
924
* IN: params void *
847
948
extern List acct_storage_g_get_clusters(
848
949
void *db_conn, uint32_t uid, acct_cluster_cond_t *cluster_cond);
953
* get info from the storage
954
* RET: List of config_key_pairs_t *
955
* note List needs to be freed when called
957
extern List acct_storage_g_get_config(void *db_conn);
851
960
* get info from the storage
852
961
* IN: acct_association_cond_t *
879
987
* get info from the storage
988
* IN: acct_reservation_cond_t *
989
* RET: List of acct_reservation_rec_t *
990
* note List needs to be freed when called
992
extern List acct_storage_g_get_reservations(void *db_conn, uint32_t uid,
993
acct_reservation_cond_t *resv_cond);
996
* get info from the storage
880
997
* IN: acct_txn_cond_t *
881
998
* RET: List of acct_txn_rec_t *
882
999
* note List needs to be freed when called
900
1017
* roll up data in the storage
901
1018
* IN: sent_start (option time to do a re-roll or start from this point)
1019
* IN: sent_end (option time to do a re-roll or end at this point)
1020
* IN: archive_data (if 0 old data is not archived in a monthly rollup)
902
1021
* RET: SLURM_SUCCESS on success SLURM_ERROR else
904
1023
extern int acct_storage_g_roll_usage(void *db_conn,
1024
time_t sent_start, time_t sent_end,
1025
uint16_t archive_data);
907
1027
* record shares used information for backup in case slurmctld restarts
908
1028
* IN: account_list List of shares_used_object_t *