From: Florian G. <re...@us...> - 2007-04-20 13:43:12
|
Update of /cvsroot/perfparse/_perfparse/db_tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3159 Modified Files: convert.c Log Message: better handling of big copy Index: convert.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/db_tools/convert.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** convert.c 19 Apr 2007 23:44:14 -0000 1.35 --- convert.c 20 Apr 2007 13:43:10 -0000 1.36 *************** *** 401,404 **** --- 401,406 ---- printw(_("You should have enough disk space to duplicate your old\ndatabase. ")); printw(_("To minimize downtime you can use the new schema with your new\nperfparse while old data are copied. ")); + printw(_("You should start the database copy with the old or no perfparse running.\n")); + printw(_("Before copying the data tables the update procedure will ask you to switch to the new perfparse.\n")); printw(_("For more information visit\nhttp://perfparse.de/tiki-index.php?page=DatabaseUpgrade \n")); printw(_("\nAre you sure to start the conversion (y/n)? ")); *************** *** 564,567 **** --- 566,571 ---- printw(_("Copying data of old perfdata_host_group to new perfdata_groups table.\n")); refresh(); + + int acttime=time(NULL); g_string_printf(gsODBSql, "select * from perfdata_host_group"); *************** *** 577,586 **** while ((result_row_old=mysql_fetch_row(query_result_old))) { i++; - move(y,x); piODBlengths=mysql_fetch_lengths(query_result_old); ! printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); g_string_printf(gsNDBSql, "insert ignore into perfdata_groups(group_name) values('%.*s')",(int) piODBlengths[0],result_row_old[0]); dbtool_mysql_query(gsNDBSql->str, &db_mysql_new, query_result_new); } printw(_("\ndone\n")); refresh(); --- 581,594 ---- while ((result_row_old=mysql_fetch_row(query_result_old))) { i++; piODBlengths=mysql_fetch_lengths(query_result_old); ! if(acttime != time(NULL)) { ! move(y,x); ! printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); ! acttime= time(NULL); ! } g_string_printf(gsNDBSql, "insert ignore into perfdata_groups(group_name) values('%.*s')",(int) piODBlengths[0],result_row_old[0]); dbtool_mysql_query(gsNDBSql->str, &db_mysql_new, query_result_new); } + printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); printw(_("\ndone\n")); refresh(); *************** *** 597,605 **** getyx(stdscr,y,x); i=0; while ((result_row_old=mysql_fetch_row(query_result_old))) { i++; - move(y,x); piODBlengths=mysql_fetch_lengths(query_result_old); ! printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); g_string_printf(gsNDBSql, \ "insert ignore into perfdata_delete_policy(policy_name,delete_policy_seconds) values ('%.*s',%d)",\ --- 605,617 ---- getyx(stdscr,y,x); i=0; + acttime=time(NULL); while ((result_row_old=mysql_fetch_row(query_result_old))) { i++; piODBlengths=mysql_fetch_lengths(query_result_old); ! if(acttime != time(NULL)) { ! move(y,x); ! printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); ! acttime= time(NULL); ! } g_string_printf(gsNDBSql, \ "insert ignore into perfdata_delete_policy(policy_name,delete_policy_seconds) values ('%.*s',%d)",\ *************** *** 607,610 **** --- 619,623 ---- dbtool_mysql_query(gsNDBSql->str, &db_mysql_new, query_result_new); } + printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); printw(_("\ndone\n")); refresh(); *************** *** 623,626 **** --- 636,640 ---- + acttime=time(NULL); while ((result_row_old=mysql_fetch_row(query_result_old))) { i++; *************** *** 629,636 **** int Hid=-1,Gid=-1; - move(y,x); piODBlengths=mysql_fetch_lengths(query_result_old); ! printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); g_string_printf(gsNDBSql, "insert ignore into perfdata_host(host_name,is_deleted"); g_string_printf(gsNDBSql2," values('%s',%s",result_row_old[0],result_row_old[8]); --- 643,653 ---- int Hid=-1,Gid=-1; piODBlengths=mysql_fetch_lengths(query_result_old); ! if(acttime != time(NULL)) { ! move(y,x); ! printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); ! acttime= time(NULL); ! } g_string_printf(gsNDBSql, "insert ignore into perfdata_host(host_name,is_deleted"); g_string_printf(gsNDBSql2," values('%s',%s",result_row_old[0],result_row_old[8]); *************** *** 675,678 **** --- 692,696 ---- } } + printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); printw(_("\ndone\n")); refresh(); *************** *** 697,700 **** --- 715,719 ---- + acttime= time(NULL); while ((result_row_old=mysql_fetch_row(query_result_old))) { i++; *************** *** 703,710 **** int Hid=-1; - move(y,x); piODBlengths=mysql_fetch_lengths(query_result_old); ! printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); Hid=get_hostId_from_name(result_row_old[0],&db_mysql_new); g_string_printf(gsNDBSql, "insert ignore into perfdata_service(host_id," --- 722,733 ---- int Hid=-1; piODBlengths=mysql_fetch_lengths(query_result_old); ! if(acttime != time(NULL)) { ! move(y,x); ! printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); ! acttime= time(NULL); ! } ! Hid=get_hostId_from_name(result_row_old[0],&db_mysql_new); g_string_printf(gsNDBSql, "insert ignore into perfdata_service(host_id," *************** *** 731,734 **** --- 754,758 ---- } //Todo: Handle last_perfdata row somewhere? Or does it "rapair itself automatically"? + printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); printw(_("\ndone\n")); refresh(); *************** *** 753,757 **** i=0; ! while ((result_row_old=mysql_fetch_row(query_result_old))) { i++; --- 777,782 ---- i=0; ! ! acttime= time(NULL); while ((result_row_old=mysql_fetch_row(query_result_old))) { i++; *************** *** 760,767 **** int Sid=-1; - move(y,x); piODBlengths=mysql_fetch_lengths(query_result_old); - printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); Sid=get_serviceId_from_desc(result_row_old[0],result_row_old[1],&db_mysql_new); if(Sid!=0) { // stale entry --- 785,795 ---- int Sid=-1; piODBlengths=mysql_fetch_lengths(query_result_old); + if(acttime != time(NULL)) { + move(y,x); + printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); + acttime= time(NULL); + } Sid=get_serviceId_from_desc(result_row_old[0],result_row_old[1],&db_mysql_new); if(Sid!=0) { // stale entry *************** *** 792,795 **** --- 820,824 ---- } } + printw(_("Copying entry %d/%d"),i,iODBnumrows); refresh(); printw(_("\ndone\n")); refresh(); *************** *** 800,806 **** printw(_("(Step %d of %d)\n"),iStep,iNumSteps); printw(_("Copying data of perfdata_service_bin table.\n")); printw(_("Since this table can be really huge i will copy the data in chunks.\n")); ! printw(_("Every 5 minutes i will make a 15 sec. break to give the database a chance to finish outstanding transactions.\n")); refresh(); --- 829,847 ---- printw(_("(Step %d of %d)\n"),iStep,iNumSteps); printw(_("Copying data of perfdata_service_bin table.\n")); + printw(_("You should now switch to the new perfparse. Keep this window open until the new perfparse system is running.\n")); printw(_("Since this table can be really huge i will copy the data in chunks.\n")); ! printw(_("For a online upgrade you should choose 1 or 2 below. For offline upgrade you can choose 3.\n")); ! printw(_("1: Pause 10 sec. every minute (default).\n")); ! printw(_("2: Pause 10 sec. every 5 minutes.\n")); ! printw(_("3: No pause.\n")); ! int iPause=0; ! while(iPause>3 || iPause<1) { ! printw(_("Choose: ")); refresh(); ! iPause=read_int_from_line(1); ! } + int iSleep=60; + if(iPause==2) iSleep=300; + refresh(); *************** *** 820,824 **** int starttime=time(NULL); ! int acttime=time(NULL); g_string_printf(gsODBSql, "select host_name, service_description,metric," "UNIX_TIMESTAMP(ctime),value,warn,critical," --- 861,865 ---- int starttime=time(NULL); ! acttime=time(NULL); g_string_printf(gsODBSql, "select host_name, service_description,metric," "UNIX_TIMESTAMP(ctime),value,warn,critical," *************** *** 876,882 **** dbtool_mysql_query(gsNDBSql->str, &db_mysql_new, query_result_new); } ! if((starttime-time(NULL))%300==0) { ! printw(_("Sleeping 15 Sec.")); ! sleep(15); } } --- 917,924 ---- dbtool_mysql_query(gsNDBSql->str, &db_mysql_new, query_result_new); } ! if(iPause != 3 && time(NULL)-starttime > 0 && (time(NULL)-starttime)%iSleep==0) { ! move(y-1,x); ! printw(_(" Sleeping 10 Sec. ")); refresh(); ! sleep(10); } } |