diff --git a/src/performanceMgr/c_program/cstaCollector/csta.c b/src/performanceMgr/c_program/cstaCollector/csta.c index 38d44ec..7ce5ab5 100644 --- a/src/performanceMgr/c_program/cstaCollector/csta.c +++ b/src/performanceMgr/c_program/cstaCollector/csta.c @@ -72,6 +72,10 @@ char csv_sent_dir[128]; char csv_sending_dir[128]; int csv_send_flag=0; +// csta keep days setting, by simon begin --- +int max_keep_days = RECORD_KEEP_DAY +// --- end + int csta_init() { csta_log("cstaCollector starting ..."); @@ -698,6 +702,24 @@ int cstasrc_init() } csta_log("CSV sent direcory=%s",csv_sent_dir); + // Get max_keep_days + sprintf(sqlstr, "SELECT pubVarValue FROM %s.cstaPubVarConf WHERE pubVarName='max_keep_days' ", CSTA_DB); + res_set = mysql_getres(pCstaConn, sqlstr); + if (res_set == NULL) + { + csta_log("max_keep_days, set default: %d", max_keep_days); + } + else + { + row = mysql_fetch_row(res_set); + if (row != NULL && strlen(row[0]) != 0) + { + max_keep_days = atoi(row[0]); + } + mysql_free_result(res_set); + } + csta_log("max_keep_days=%d", max_keep_days); + csv_send_flag=0; sprintf(sqlstr,"SELECT pubVarValue FROM OMC_PUB.omcPubVarConf WHERE pubVarName='csta_store_server'"); res_set=mysql_getres(pCstaConn,sqlstr); @@ -1667,9 +1689,11 @@ int csta_create_csv() } } } - - //Delete the over-time record - l_time=time(NULL) - RECORD_KEEP_DAY * 24 * 60 * 60; + + // by simon begin --- + // Delete the over-time record + l_time = time(NULL) - max_keep_days * 24 * 60 * 60; + // --- end t=localtime(&l_time); sprintf(tablename,"%sData",pcsta->objects[0].detail_table); sprintf(sqlstr,"DELETE FROM %s.%s WHERE csta_datetime < '%04d-%02d-%02d 00:00:00' ", @@ -1686,7 +1710,9 @@ int csta_create_csv() if(pcsta->sum_flag) { - l_time=time(NULL) - RECORD_KEEP_DAY * 24 * 60 * 60; + // by simon begin --- + l_time = time(NULL) - max_keep_days * 24 * 60 * 60; + // --- end t=localtime(&l_time); sprintf(tablename,"%sData",pcsta->objects[0].sum_table); sprintf(sqlstr,"DELETE FROM %s.%s WHERE csta_datetime < '%04d-%02d-%02d 00:00:00' ",