From de8fcda7e8d8afa9485f178d0188e522de622cbe Mon Sep 17 00:00:00 2001 From: Danny Auble <da@llnl.gov> Date: Thu, 22 May 2008 17:16:26 +0000 Subject: [PATCH] ok for real good times now on hour/day/month --- .../mysql/accounting_storage_mysql.c | 16 +++++++++------- .../accounting_storage/mysql/mysql_rollup.c | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c index 5738f8effbe..490216118f9 100644 --- a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c +++ b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c @@ -4329,9 +4329,9 @@ extern int acct_storage_p_roll_usage(mysql_conn_t *mysql_conn) /* the last times were one second before the next * period so increment here 1 */ - last_hour = atoi(row[UPDATE_HOUR])+1; - last_day = atoi(row[UPDATE_DAY])+1; - last_month = atoi(row[UPDATE_MONTH])+1; + last_hour = atoi(row[UPDATE_HOUR]); + last_day = atoi(row[UPDATE_DAY]); + last_month = atoi(row[UPDATE_MONTH]); } else { query = xstrdup_printf( "insert into %s " @@ -4344,10 +4344,10 @@ extern int acct_storage_p_roll_usage(mysql_conn_t *mysql_conn) if(rc == SLURM_ERROR) return rc; } -/* last_hour = 1211403600; */ -/* // last_hour = 1206946800; */ -/* last_day = 1206946800; */ -/* last_month = 1206946800; */ + last_hour = 1211403599; + // last_hour = 1206946800; + last_day = 1207033199; + last_month = 1204358399; if(!localtime_r(&last_hour, &start_tm)) { error("Couldn't get localtime from hour start %d", last_hour); @@ -4367,6 +4367,7 @@ extern int acct_storage_p_roll_usage(mysql_conn_t *mysql_conn) start_tm.tm_sec = 0; start_tm.tm_min = 0; + start_tm.tm_isdst = -1; start_tm.tm_hour++; start_tm.tm_isdst = -1; start_time = mktime(&start_tm); @@ -4422,6 +4423,7 @@ extern int acct_storage_p_roll_usage(mysql_conn_t *mysql_conn) start_tm.tm_min = 0; start_tm.tm_hour = 0; start_tm.tm_mday = 1; + start_tm.tm_mon++; start_tm.tm_isdst = -1; start_time = mktime(&start_tm); end_tm.tm_sec = -1; diff --git a/src/plugins/accounting_storage/mysql/mysql_rollup.c b/src/plugins/accounting_storage/mysql/mysql_rollup.c index 87eea025d45..aeda3153dd9 100644 --- a/src/plugins/accounting_storage/mysql/mysql_rollup.c +++ b/src/plugins/accounting_storage/mysql/mysql_rollup.c @@ -49,12 +49,16 @@ extern int mysql_hourly_rollup(mysql_conn_t *mysql_conn, time_t curr_start = start; time_t curr_end = curr_start + add_sec; +/* info("begin start %s", ctime(&curr_start)); */ +/* info("begin end %s", ctime(&curr_end)); */ while(curr_start < end) { curr_start = curr_end+1; curr_end = curr_start + add_sec; debug3("curr hour is now %d-%d", curr_start, curr_end); } +/* info("stop start %s", ctime(&curr_start)); */ +/* info("stop end %s", ctime(&curr_end)); */ return SLURM_SUCCESS; } extern int mysql_daily_rollup(mysql_conn_t *mysql_conn, @@ -64,12 +68,16 @@ extern int mysql_daily_rollup(mysql_conn_t *mysql_conn, time_t curr_start = start; time_t curr_end = curr_start + add_sec; +/* info("begin start %s", ctime(&curr_start)); */ +/* info("begin end %s", ctime(&curr_end)); */ while(curr_start < end) { curr_start = curr_end+1; curr_end = curr_start + add_sec; debug3("curr day is now %d-%d", curr_start, curr_end); } +/* info("stop start %s", ctime(&curr_start)); */ +/* info("stop end %s", ctime(&curr_end)); */ return SLURM_SUCCESS; } @@ -80,6 +88,8 @@ extern int mysql_monthly_rollup(mysql_conn_t *mysql_conn, time_t curr_start = start; time_t curr_end; +/* info("begin month start %s", ctime(&start)); */ +/* info("begin month end %s", ctime(&end)); */ if(!localtime_r(&curr_start, &start_tm)) { error("Couldn't get localtime from month start %d", curr_start); return SLURM_ERROR; @@ -88,8 +98,11 @@ extern int mysql_monthly_rollup(mysql_conn_t *mysql_conn, start_tm.tm_min = 0; start_tm.tm_hour = 0; start_tm.tm_mday = 1; + start_tm.tm_mon++; start_tm.tm_isdst = -1; curr_end = mktime(&start_tm); +/* info("begin start %s", ctime(&curr_start)); */ +/* info("begin end %s", ctime(&curr_end)); */ while(curr_start < end) { curr_start = curr_end+1; @@ -106,6 +119,8 @@ extern int mysql_monthly_rollup(mysql_conn_t *mysql_conn, curr_end = mktime(&start_tm); debug3("curr month is now %d-%d", curr_start, curr_end); } +/* info("stop start %s", ctime(&curr_start)); */ +/* info("stop end %s", ctime(&curr_end)); */ return SLURM_SUCCESS; } -- GitLab