From: Florian G. <re...@us...> - 2007-07-02 22:25:24
|
Update of /cvsroot/perfparse/_perfparse/cgi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24678/cgi Modified Files: perfchart.c Log Message: show saved graphs not yet finished Index: perfchart.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/cgi/perfchart.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** perfchart.c 1 Jun 2007 08:51:05 -0000 1.11 --- perfchart.c 2 Jul 2007 22:25:24 -0000 1.12 *************** *** 73,76 **** --- 73,77 ---- int bMin, bMax; char sFileName[128]; + int iGraphId = FALSE; /* Scale works on integers between 0 and 1000 */ *************** *** 1516,1520 **** /*************************************** * ! * Misk * ***************************************/ --- 1517,1521 ---- /*************************************** * ! * Misc * ***************************************/ *************** *** 1524,1527 **** --- 1525,1530 ---- { char *s; + char c; + time_t t; setlocale(LC_NUMERIC, "POSIX"); *************** *** 1529,1633 **** getCGIDBVars(); ! ! /* Graph details */ ! sMetricId=atoi(scgi("metric_id")); ! ! if ((s = scgi("max"))[0] > ' ') { ! sscanf(s, "%lf", &dMax); ! bMax = TRUE; ! } else { ! /* To be calculated */ ! bMax = FALSE; ! } ! ! if ((s = scgi("min"))[0] > ' ') { ! sscanf(s, "%lf", &dMin); ! bMin = TRUE; ! } else { ! /* To be calculated */ ! bMin = FALSE; ! } ! ! strncpy(sUnit, scgi("unit"),20); ! ! sscanf(scgi("size"), "%[^x]x%d", sLabel, &iHeight); ! iWidth = atoi(sLabel); ! if (!iWidth || !iHeight) ! iWidth = 585, iHeight = 300; ! ! s = scgi("output"); ! if (!strcmp(s, "Histogram")) iType = TYPE_HISTEROGRAM; ! else if (!strcmp(s, "Average")) iType = TYPE_AVERAGE; ! else if (!strcmp(s, "Diff")) iType = TYPE_DIFFERENTIAL; ! else if (!strcmp(s, "Int")) iType = TYPE_INTEGRAL; ! ! /* Time period and type */ ! strncpy(sTimeRange, scgi("timeperiod"),2); ! if (sTimeRange[0] == 'r') { ! ! /* Relative */ ! tRelativeTime = atoi(scgi("reldays")); ! tRelativeTime *= 3600 * 24; ! tRelativeTime += time2UnixTime(scgi("reltime")); ! getTimeRange(tRelativeTime); ! ! } else { ! ! /* Absolute */ ! strncpy(sFrom, scgi("from"),30); ! strncpy(sTo, scgi("to"),30); ! tRelativeTime = 0; ! ! } ! ! /* Scale */ ! /* New: */ ! bForceScale = icgi("forcescale", 0); ! /* Old: */ ! s = scgi("forcemax"); ! if (s && s[0]) bForceScale = TRUE; ! ! /* respect the max value */ ! bAccurateScale = icgi("accuratescale", 0); ! ! /* Show values as percent */ ! bPercent = icgi("percent", 0); ! ! /* Title */ ! sTitle = strdup(scgi("title")); ! ! /* Lines */ ! bSelectLine = icgi("select_line", 0); ! if (bSelectLine) { ! bVal = icgi("s_val", 0); ! bSmooth = icgi("s_smo", 0); ! bWarn = icgi("s_war", 0); ! bCrit = icgi("s_cri", 0); ! bStanDev = icgi("s_sta", 0); ! } else { ! bVal = TRUE; ! bSmooth = TRUE; ! bWarn = TRUE; ! bCrit = TRUE; ! bStanDev = TRUE; ! } ! ! /* Hide lines if type does not allow */ ! if (iType == TYPE_DIFFERENTIAL || iType == TYPE_INTEGRAL) { ! bWarn = FALSE; ! bCrit = FALSE; ! } ! if (iType != TYPE_AVERAGE) { ! bStanDev = FALSE; ! } else { ! bSmooth = FALSE; ! } ! ! /* Gaussian Theta */ ! fGaussianSigma = atof(scgi("g_sigma")) / 2; ! if (fGaussianSigma <= 0) fGaussianSigma = GAUSSIAN_SIGMA_DEFAULT; ! ! /* PID of calling code */ ! iParentPID = icgi("pid", 0); setlocale(LC_NUMERIC, ""); --- 1532,1693 ---- getCGIDBVars(); ! /* get graph id for stored graphs */ ! iGraphId=atoi(scgi("graph_id")); ! if(iGraphId>0) { ! /* get graph details from database */ ! g_string_printf(s_SQL, "SELECT metric_id,scale,minin,maxin,timerange,relativetime,fromtime,totime,output,sizex,sizey,s_val,s_war,s_cri,s_sta,graphtitle,g_sigma FROM perfdata_graphs WHERE id=%d",iGraphId); ! #ifdef USE_DB_MYSQL ! if (mysql_query(&db_mysql, s_SQL->str)) ! print_sql_failure_image(__FILE__,__LINE__, s_SQL->str, mysql_error(&db_mysql)); ! query_result = mysql_use_result(&db_mysql); ! while ((result_row = mysql_fetch_row(query_result))) { ! #elif defined USE_DB_POSTGRESQL ! /* pgsql untested here*/ ! query_result = PQexec(db_postgresql, s_SQL->str); ! if(PQresultStatus(query_result) == PGRES_BAD_RESPONSE || PQresultStatus(query_result) == PGRES_FATAL_ERROR) ! print_sql_failure_image(__FILE__,__LINE__, s_SQL->str, PQresultErrorMessage(query_result)); ! numberOfRows = rows(); ! for (currentRow = 0; currentRow<numberOfRows; currentRow++){ ! #endif ! sMetricId=iData(0); ! // scale ! // minin ! // maxin ! ! c=sData(4)[0]; // timerange ! if(c=='r') { ! getTimeRange(iData(5)); // relativetime ! } ! if(c=='a') { ! t=(time_t) iData(6); ! strftime(sFrom,30,"%Y-%m-%d %H:%M:%S",localtime(&t)); ! t=(time_t) iData(7); ! strftime(sTo,30,"%Y-%m-%d %H:%M:%S",localtime(&t)); ! } ! c=sData(8)[0]; // output ! switch(c) { ! case 'h': ! iType = TYPE_HISTEROGRAM; ! break; ! case 'a': ! iType = TYPE_AVERAGE; ! break; ! case 'd': ! iType = TYPE_DIFFERENTIAL; ! break; ! case 'i': ! iType = TYPE_INTEGRAL; ! break; ! default: ! iType = TYPE_HISTEROGRAM; ! break; ! } ! iWidth=iData(9); ! iHeight=iData(10); ! ! ! } ! } else { ! /* get graph details from cgi*/ ! sMetricId=atoi(scgi("metric_id")); ! ! if ((s = scgi("max"))[0] > ' ') { ! sscanf(s, "%lf", &dMax); ! bMax = TRUE; ! } else { ! /* To be calculated */ ! bMax = FALSE; ! } ! ! if ((s = scgi("min"))[0] > ' ') { ! sscanf(s, "%lf", &dMin); ! bMin = TRUE; ! } else { ! /* To be calculated */ ! bMin = FALSE; ! } ! ! strncpy(sUnit, scgi("unit"),20); ! ! sscanf(scgi("size"), "%[^x]x%d", sLabel, &iHeight); ! iWidth = atoi(sLabel); ! if (!iWidth || !iHeight) ! iWidth = 585, iHeight = 300; ! ! s = scgi("output"); ! if (!strcmp(s, "Histogram")) iType = TYPE_HISTEROGRAM; ! else if (!strcmp(s, "Average")) iType = TYPE_AVERAGE; ! else if (!strcmp(s, "Diff")) iType = TYPE_DIFFERENTIAL; ! else if (!strcmp(s, "Int")) iType = TYPE_INTEGRAL; ! ! /* Time period and type */ ! strncpy(sTimeRange, scgi("timeperiod"),2); ! if (sTimeRange[0] == 'r') { ! ! /* Relative */ ! tRelativeTime = atoi(scgi("reldays")); ! tRelativeTime *= 3600 * 24; ! tRelativeTime += time2UnixTime(scgi("reltime")); ! getTimeRange(tRelativeTime); ! ! } else { ! ! /* Absolute */ ! strncpy(sFrom, scgi("from"),30); ! strncpy(sTo, scgi("to"),30); ! tRelativeTime = 0; ! ! } ! ! /* Scale */ ! /* New: */ ! bForceScale = icgi("forcescale", 0); ! /* Old: */ ! s = scgi("forcemax"); ! if (s && s[0]) bForceScale = TRUE; ! ! /* respect the max value */ ! bAccurateScale = icgi("accuratescale", 0); ! ! /* Show values as percent */ ! bPercent = icgi("percent", 0); ! ! /* Title */ ! sTitle = strdup(scgi("title")); ! ! /* Lines */ ! bSelectLine = icgi("select_line", 0); ! if (bSelectLine) { ! bVal = icgi("s_val", 0); ! bSmooth = icgi("s_smo", 0); ! bWarn = icgi("s_war", 0); ! bCrit = icgi("s_cri", 0); ! bStanDev = icgi("s_sta", 0); ! } else { ! bVal = TRUE; ! bSmooth = TRUE; ! bWarn = TRUE; ! bCrit = TRUE; ! bStanDev = TRUE; ! } ! ! /* Hide lines if type does not allow */ ! if (iType == TYPE_DIFFERENTIAL || iType == TYPE_INTEGRAL) { ! bWarn = FALSE; ! bCrit = FALSE; ! } ! if (iType != TYPE_AVERAGE) { ! bStanDev = FALSE; ! } else { ! bSmooth = FALSE; ! } ! ! /* Gaussian Theta */ ! fGaussianSigma = atof(scgi("g_sigma")) / 2; ! if (fGaussianSigma <= 0) fGaussianSigma = GAUSSIAN_SIGMA_DEFAULT; ! ! /* PID of calling code */ ! iParentPID = icgi("pid", 0); ! } setlocale(LC_NUMERIC, ""); *************** *** 1744,1749 **** - - /*************************************** * --- 1804,1807 ---- |