diff --git a/src/common/slurm_accounting_storage.c b/src/common/slurm_accounting_storage.c index 499641588daea397312b503bbe0b38d4172fa09f..663516f80ee4b4625a01af338dbeb51fde764437 100644 --- a/src/common/slurm_accounting_storage.c +++ b/src/common/slurm_accounting_storage.c @@ -1503,24 +1503,47 @@ extern void pack_cluster_accounting_rec(void *in, uint16_t rpc_version, { cluster_accounting_rec_t *object = (cluster_accounting_rec_t *)in; - if(!object) { - pack64(0, buffer); - pack32(0, buffer); - pack64(0, buffer); - pack64(0, buffer); - pack64(0, buffer); - pack_time(0, buffer); - pack64(0, buffer); - return; + if(rpc_version >= 5) { + if(!object) { + pack64(0, buffer); + pack32(0, buffer); + pack64(0, buffer); + pack64(0, buffer); + pack64(0, buffer); + pack64(0, buffer); + pack_time(0, buffer); + pack64(0, buffer); + return; + } + + pack64(object->alloc_secs, buffer); + pack32(object->cpu_count, buffer); + pack64(object->down_secs, buffer); + pack64(object->idle_secs, buffer); + pack64(object->over_secs, buffer); + pack64(object->pdown_secs, buffer); + pack_time(object->period_start, buffer); + pack64(object->resv_secs, buffer); + } else { + if(!object) { + pack64(0, buffer); + pack32(0, buffer); + pack64(0, buffer); + pack64(0, buffer); + pack64(0, buffer); + pack_time(0, buffer); + pack64(0, buffer); + return; + } + + pack64(object->alloc_secs, buffer); + pack32(object->cpu_count, buffer); + pack64(object->down_secs, buffer); + pack64(object->idle_secs, buffer); + pack64(object->over_secs, buffer); + pack_time(object->period_start, buffer); + pack64(object->resv_secs, buffer); } - - pack64(object->alloc_secs, buffer); - pack32(object->cpu_count, buffer); - pack64(object->down_secs, buffer); - pack64(object->idle_secs, buffer); - pack64(object->over_secs, buffer); - pack_time(object->period_start, buffer); - pack64(object->resv_secs, buffer); } extern int unpack_cluster_accounting_rec(void **object, uint16_t rpc_version, @@ -1530,13 +1553,25 @@ extern int unpack_cluster_accounting_rec(void **object, uint16_t rpc_version, xmalloc(sizeof(cluster_accounting_rec_t)); *object = object_ptr; - safe_unpack64(&object_ptr->alloc_secs, buffer); - safe_unpack32(&object_ptr->cpu_count, buffer); - safe_unpack64(&object_ptr->down_secs, buffer); - safe_unpack64(&object_ptr->idle_secs, buffer); - safe_unpack64(&object_ptr->over_secs, buffer); - safe_unpack_time(&object_ptr->period_start, buffer); - safe_unpack64(&object_ptr->resv_secs, buffer); + + if(rpc_version >= 5) { + safe_unpack64(&object_ptr->alloc_secs, buffer); + safe_unpack32(&object_ptr->cpu_count, buffer); + safe_unpack64(&object_ptr->down_secs, buffer); + safe_unpack64(&object_ptr->idle_secs, buffer); + safe_unpack64(&object_ptr->over_secs, buffer); + safe_unpack64(&object_ptr->pdown_secs, buffer); + safe_unpack_time(&object_ptr->period_start, buffer); + safe_unpack64(&object_ptr->resv_secs, buffer); + } else { + safe_unpack64(&object_ptr->alloc_secs, buffer); + safe_unpack32(&object_ptr->cpu_count, buffer); + safe_unpack64(&object_ptr->down_secs, buffer); + safe_unpack64(&object_ptr->idle_secs, buffer); + safe_unpack64(&object_ptr->over_secs, buffer); + safe_unpack_time(&object_ptr->period_start, buffer); + safe_unpack64(&object_ptr->resv_secs, buffer); + } return SLURM_SUCCESS; @@ -1779,33 +1814,16 @@ extern void pack_acct_accounting_rec(void *in, uint16_t rpc_version, Buf buffer) { acct_accounting_rec_t *object = (acct_accounting_rec_t *)in; - if(rpc_version >= 5) { - if(!object) { - pack64(0, buffer); - pack32(0, buffer); - pack64(0, buffer); - pack_time(0, buffer); - pack64(0, buffer); - return; - } - - pack64(object->alloc_secs, buffer); - pack32(object->id, buffer); - pack64(object->over_secs, buffer); - pack_time(object->period_start, buffer); - pack64(object->resv_secs, buffer); - } else { - if(!object) { - pack64(0, buffer); - pack32(0, buffer); - pack_time(0, buffer); - return; - } - - pack64(object->alloc_secs, buffer); - pack32(object->id, buffer); - pack_time(object->period_start, buffer); + if(!object) { + pack64(0, buffer); + pack32(0, buffer); + pack_time(0, buffer); + return; } + + pack64(object->alloc_secs, buffer); + pack32(object->id, buffer); + pack_time(object->period_start, buffer); } extern int unpack_acct_accounting_rec(void **object, uint16_t rpc_version, @@ -1815,18 +1833,11 @@ extern int unpack_acct_accounting_rec(void **object, uint16_t rpc_version, xmalloc(sizeof(acct_accounting_rec_t)); *object = object_ptr; - if(rpc_version >= 5) { - safe_unpack64(&object_ptr->alloc_secs, buffer); - safe_unpack32(&object_ptr->id, buffer); - safe_unpack64(&object_ptr->over_secs, buffer); - safe_unpack_time(&object_ptr->period_start, buffer); - safe_unpack64(&object_ptr->resv_secs, buffer); - } else { - safe_unpack64(&object_ptr->alloc_secs, buffer); - safe_unpack32(&object_ptr->id, buffer); - safe_unpack_time(&object_ptr->period_start, buffer); - } + safe_unpack64(&object_ptr->alloc_secs, buffer); + safe_unpack32(&object_ptr->id, buffer); + safe_unpack_time(&object_ptr->period_start, buffer); + return SLURM_SUCCESS; unpack_error: diff --git a/src/common/slurm_accounting_storage.h b/src/common/slurm_accounting_storage.h index 970b33562eafb549c550874a2e16dec99c6fa8e5..80bf138ab8dccc9cc7c810145667a5b14f4cd947 100644 --- a/src/common/slurm_accounting_storage.h +++ b/src/common/slurm_accounting_storage.h @@ -134,9 +134,7 @@ typedef struct { typedef struct { uint64_t alloc_secs; /* number of cpu seconds allocated */ uint32_t id; /* association/wckey ID */ - uint64_t over_secs; /* number of cpu seconds overcommitted */ time_t period_start; /* when this record was started */ - uint64_t resv_secs; /* number of cpu seconds reserved */ } acct_accounting_rec_t; typedef struct acct_association_rec { @@ -476,6 +474,7 @@ typedef struct { uint64_t down_secs; /* number of cpu seconds down */ uint64_t idle_secs; /* number of cpu seconds idle */ uint64_t over_secs; /* number of cpu seconds overcommitted */ + uint64_t pdown_secs; /* number of cpu seconds planned down */ time_t period_start; /* when this record was started */ uint64_t resv_secs; /* number of cpu seconds reserved */ } cluster_accounting_rec_t; diff --git a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c index 8e5c5b2397694ec956542bf7f7ea13f9817faebf..22043798a837900f02aca2645bcdc541f4497ac0 100644 --- a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c +++ b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c @@ -2560,8 +2560,6 @@ static int _mysql_acct_check_tables(MYSQL *db_conn) { "id", "int not null" }, { "period_start", "int unsigned not null" }, { "alloc_cpu_secs", "bigint default 0" }, - { "resv_cpu_secs", "bigint default 0" }, - { "over_cpu_secs", "bigint default 0" }, { NULL, NULL} }; @@ -2586,6 +2584,7 @@ static int _mysql_acct_check_tables(MYSQL *db_conn) { "cpu_count", "int default 0" }, { "alloc_cpu_secs", "bigint default 0" }, { "down_cpu_secs", "bigint default 0" }, + { "pdown_cpu_secs", "bigint default 0" }, { "idle_cpu_secs", "bigint default 0" }, { "resv_cpu_secs", "bigint default 0" }, { "over_cpu_secs", "bigint default 0" }, @@ -9179,16 +9178,12 @@ extern int acct_storage_p_get_usage(mysql_conn_t *mysql_conn, uid_t uid, "t1.id", "t1.period_start", "t1.alloc_cpu_secs", - "t1.resv_cpu_secs", - "t1.over_cpu_secs", }; enum { USAGE_ID, USAGE_START, USAGE_ACPU, - USAGE_RCPU, - USAGE_OCPU, USAGE_COUNT }; @@ -9339,8 +9334,6 @@ is_user: accounting_rec->id = atoi(row[USAGE_ID]); accounting_rec->period_start = atoi(row[USAGE_START]); accounting_rec->alloc_secs = atoll(row[USAGE_ACPU]); - accounting_rec->resv_secs = atoll(row[USAGE_RCPU]); - accounting_rec->over_secs = atoll(row[USAGE_OCPU]); list_append((*my_list), accounting_rec); } mysql_free_result(result); @@ -9839,6 +9832,7 @@ extern int clusteracct_storage_p_get_usage( char *cluster_req_inx[] = { "alloc_cpu_secs", "down_cpu_secs", + "pdown_cpu_secs", "idle_cpu_secs", "resv_cpu_secs", "over_cpu_secs", @@ -9849,6 +9843,7 @@ extern int clusteracct_storage_p_get_usage( enum { CLUSTER_ACPU, CLUSTER_DCPU, + CLUSTER_PDCPU, CLUSTER_ICPU, CLUSTER_RCPU, CLUSTER_OCPU, @@ -9897,6 +9892,7 @@ extern int clusteracct_storage_p_get_usage( xmalloc(sizeof(cluster_accounting_rec_t)); accounting_rec->alloc_secs = atoll(row[CLUSTER_ACPU]); accounting_rec->down_secs = atoll(row[CLUSTER_DCPU]); + accounting_rec->pdown_secs = atoll(row[CLUSTER_PDCPU]); accounting_rec->idle_secs = atoll(row[CLUSTER_ICPU]); accounting_rec->over_secs = atoll(row[CLUSTER_OCPU]); accounting_rec->resv_secs = atoll(row[CLUSTER_RCPU]); diff --git a/src/plugins/accounting_storage/mysql/mysql_rollup.c b/src/plugins/accounting_storage/mysql/mysql_rollup.c index 15aa4f062eca6c6a3c8b364b0ed8877fc1ca166a..76a8000f5cad8e3f6b04f4742d1a45ea42c7a709 100644 --- a/src/plugins/accounting_storage/mysql/mysql_rollup.c +++ b/src/plugins/accounting_storage/mysql/mysql_rollup.c @@ -45,8 +45,6 @@ typedef struct { int id; uint64_t a_cpu; - uint64_t o_cpu; - uint64_t r_cpu; } local_id_usage_t; typedef struct { @@ -772,32 +770,26 @@ extern int mysql_hourly_rollup(mysql_conn_t *mysql_conn, /* a_usage->a_cpu); */ if(query) { xstrfmtcat(query, - ", (%d, %d, %d, %d, " - "%llu, %llu, %llu)", + ", (%d, %d, %d, %d, %llu)", now, now, a_usage->id, curr_start, - a_usage->a_cpu, a_usage->o_cpu, - a_usage->r_cpu); + a_usage->a_cpu); } else { xstrfmtcat(query, "insert into %s (creation_time, " "mod_time, id, period_start, " - "alloc_cpu_secs, over_cpu_secs, " - "resv_cpu_secs) values " - "(%d, %d, %d, %d, %llu, %llu, %llu)", + "alloc_cpu_secs) values " + "(%d, %d, %d, %d, %llu)", assoc_hour_table, now, now, a_usage->id, curr_start, - a_usage->a_cpu, a_usage->o_cpu, - a_usage->r_cpu); + a_usage->a_cpu); } } if(query) { xstrfmtcat(query, " on duplicate key update " "mod_time=%d, " - "alloc_cpu_secs=VALUES(alloc_cpu_secs), " - "over_cpu_secs=VALUES(over_cpu_secs), " - "resv_cpu_secs=VALUES(resv_cpu_secs);", + "alloc_cpu_secs=VALUES(alloc_cpu_secs);", now); debug3("%d(%d) query\n%s", @@ -820,32 +812,26 @@ extern int mysql_hourly_rollup(mysql_conn_t *mysql_conn, /* w_usage->a_cpu); */ if(query) { xstrfmtcat(query, - ", (%d, %d, %d, %d, " - "%llu, %llu, %llu)", + ", (%d, %d, %d, %d, %llu)", now, now, w_usage->id, curr_start, - w_usage->a_cpu, w_usage->o_cpu, - w_usage->r_cpu); + w_usage->a_cpu); } else { xstrfmtcat(query, "insert into %s (creation_time, " "mod_time, id, period_start, " - "alloc_cpu_secs, over_cpu_secs, " - "resv_cpu_secs) values " - "(%d, %d, %d, %d, %llu, %llu, %llu)", + "alloc_cpu_secs) values " + "(%d, %d, %d, %d, %llu)", wckey_hour_table, now, now, w_usage->id, curr_start, - w_usage->a_cpu, w_usage->o_cpu, - w_usage->r_cpu); + w_usage->a_cpu); } } if(query) { xstrfmtcat(query, " on duplicate key update " "mod_time=%d, " - "alloc_cpu_secs=VALUES(alloc_cpu_secs), " - "over_cpu_secs=VALUES(over_cpu_secs), " - "resv_cpu_secs=VALUES(resv_cpu_secs);", + "alloc_cpu_secs=VALUES(alloc_cpu_secs);", now); debug3("%d(%d) query\n%s", @@ -915,27 +901,24 @@ extern int mysql_daily_rollup(mysql_conn_t *mysql_conn, /* info("end %s", ctime(&curr_end)); */ query = xstrdup_printf( "insert into %s (creation_time, mod_time, id, " - "period_start, alloc_cpu_secs, over_cpu_secs, " - "resv_cpu_secs) select %d, %d, id, " - "%d, @ASUM:=SUM(alloc_cpu_secs), " - "@OSUM:=SUM(over_cpu_secs), " - "@RSUM:=SUM(resv_cpu_secs) from %s where " + "period_start, alloc_cpu_secs) select %d, %d, id, " + "%d, @ASUM:=SUM(alloc_cpu_secs) from %s where " "(period_start < %d && period_start >= %d) " "group by id on duplicate key update mod_time=%d, " - "alloc_cpu_secs=@ASUM, over_cpu_secs=@OSUM, " - "resv_cpu_secs=@RSUM;", + "alloc_cpu_secs=@ASUM;", assoc_day_table, now, now, curr_start, assoc_hour_table, curr_end, curr_start, now); xstrfmtcat(query, "insert into %s (creation_time, " "mod_time, cluster, period_start, cpu_count, " - "alloc_cpu_secs, down_cpu_secs, idle_cpu_secs, " - "over_cpu_secs, resv_cpu_secs) " + "alloc_cpu_secs, down_cpu_secs, pdown_cpu_secs, " + "idle_cpu_secs, over_cpu_secs, resv_cpu_secs) " "select %d, %d, cluster, " "%d, @CPU:=MAX(cpu_count), " "@ASUM:=SUM(alloc_cpu_secs), " "@DSUM:=SUM(down_cpu_secs), " + "@PDSUM:=SUM(pdown_cpu_secs), " "@ISUM:=SUM(idle_cpu_secs), " "@OSUM:=SUM(over_cpu_secs), " "@RSUM:=SUM(resv_cpu_secs) from %s where " @@ -943,8 +926,8 @@ extern int mysql_daily_rollup(mysql_conn_t *mysql_conn, "group by cluster on duplicate key update " "mod_time=%d, cpu_count=@CPU, " "alloc_cpu_secs=@ASUM, down_cpu_secs=@DSUM, " - "idle_cpu_secs=@ISUM, over_cpu_secs=@OSUM, " - "resv_cpu_secs=@RSUM;", + "pdown_cpu_secs=@DSUM, idle_cpu_secs=@ISUM, " + "over_cpu_secs=@OSUM, resv_cpu_secs=@RSUM;", cluster_day_table, now, now, curr_start, cluster_hour_table, curr_end, curr_start, now); @@ -952,16 +935,12 @@ extern int mysql_daily_rollup(mysql_conn_t *mysql_conn, xstrfmtcat(query, "insert into %s (creation_time, " "mod_time, id, period_start, " - "alloc_cpu_secs, over_cpu_secs, " - "resv_cpu_secs) select %d, %d, " - "id, %d, @ASUM:=SUM(alloc_cpu_secs), " - "@OSUM:=SUM(over_cpu_secs), " - "@RSUM:=SUM(resv_cpu_secs) from %s " - "where (period_start < %d && " + "alloc_cpu_secs) select %d, %d, " + "id, %d, @ASUM:=SUM(alloc_cpu_secs) " + "from %s where (period_start < %d && " "period_start >= %d) " "group by id on duplicate key update " - "mod_time=%d, alloc_cpu_secs=@ASUM, " - "over_cpu_secs=@OSUM, resv_cpu_secs=@RSUM;", + "mod_time=%d, alloc_cpu_secs=@ASUM;", wckey_day_table, now, now, curr_start, wckey_hour_table, curr_end, curr_start, now); @@ -1041,27 +1020,24 @@ extern int mysql_monthly_rollup(mysql_conn_t *mysql_conn, /* info("end %s", ctime(&curr_end)); */ query = xstrdup_printf( "insert into %s (creation_time, mod_time, id, " - "period_start, alloc_cpu_secs, over_cpu_secs, " - "resv_cpu_secs) select %d, %d, id, " - "%d, @ASUM:=SUM(alloc_cpu_secs), " - "@OSUM:=SUM(over_cpu_secs), " - "@RSUM:=SUM(resv_cpu_secs) from %s where " + "period_start, alloc_cpu_secs) select %d, %d, id, " + "%d, @ASUM:=SUM(alloc_cpu_secs) from %s where " "(period_start < %d && period_start >= %d) " "group by id on duplicate key update mod_time=%d, " - "alloc_cpu_secs=@ASUM, over_cpu_secs=@OSUM, " - "resv_cpu_secs=@RSUM;", + "alloc_cpu_secs=@ASUM;", assoc_month_table, now, now, curr_start, assoc_day_table, curr_end, curr_start, now); xstrfmtcat(query, "insert into %s (creation_time, " "mod_time, cluster, period_start, cpu_count, " - "alloc_cpu_secs, down_cpu_secs, idle_cpu_secs, " - "over_cpu_secs, resv_cpu_secs) " + "alloc_cpu_secs, down_cpu_secs, pdown_cpu_secs, " + "idle_cpu_secs, over_cpu_secs, resv_cpu_secs) " "select %d, %d, cluster, " "%d, @CPU:=MAX(cpu_count), " "@ASUM:=SUM(alloc_cpu_secs), " "@DSUM:=SUM(down_cpu_secs), " + "@PDSUM:=SUM(pdown_cpu_secs), " "@ISUM:=SUM(idle_cpu_secs), " "@OSUM:=SUM(over_cpu_secs), " "@RSUM:=SUM(resv_cpu_secs) from %s where " @@ -1069,24 +1045,21 @@ extern int mysql_monthly_rollup(mysql_conn_t *mysql_conn, "group by cluster on duplicate key update " "mod_time=%d, cpu_count=@CPU, " "alloc_cpu_secs=@ASUM, down_cpu_secs=@DSUM, " - "idle_cpu_secs=@ISUM, over_cpu_secs=@OSUM, " - "resv_cpu_secs=@RSUM;", + "pdown_cpu_secs=@DSUM, idle_cpu_secs=@ISUM, " + "over_cpu_secs=@OSUM, resv_cpu_secs=@RSUM;", cluster_month_table, now, now, curr_start, cluster_day_table, curr_end, curr_start, now); if(track_wckey) { xstrfmtcat(query, "insert into %s (creation_time, mod_time, " - "id, period_start, alloc_cpu_secs, " - "over_cpu_secs, resv_cpu_secs) select %d, " - "%d, id, %d, @ASUM:=SUM(alloc_cpu_secs), " - "@OSUM:=SUM(over_cpu_secs), " - "@RSUM:=SUM(resv_cpu_secs) " + "id, period_start, alloc_cpu_secs) " + "select %d, %d, id, %d, " + "@ASUM:=SUM(alloc_cpu_secs) " "from %s where (period_start < %d && " "period_start >= %d) " "group by id on duplicate key update " - "mod_time=%d, alloc_cpu_secs=@ASUM, " - "over_cpu_secs=@OSUM, resv_cpu_secs=@RSUM;", + "mod_time=%d, alloc_cpu_secs=@ASUM;", wckey_month_table, now, now, curr_start, wckey_day_table, curr_end, curr_start, now);