From: Florian G. <re...@us...> - 2007-08-12 00:11:55
|
Update of /cvsroot/perfparse/_perfparse/cgi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7758/cgi Modified Files: cgi.c perfchart.c Log Message: Made saved graphs working - some bugs still unresolved Index: perfchart.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/cgi/perfchart.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** perfchart.c 2 Jul 2007 22:25:24 -0000 1.12 --- perfchart.c 12 Aug 2007 00:11:44 -0000 1.13 *************** *** 54,61 **** --- 54,72 ---- #define CHART_AREA_BORDER 1 + /* An enumeration for scale */ + #define SCALE_USER 0 + #define SCALE_USER_EXACT 1 + #define SCALE_USER_PERCENT 2 + #define SCALE_RANGE 3 + #define SCALE_RANGE_EXACT 4 + #define SCALE_RANGE_PERCENT 5 + #define SCALE_AUTO 6 + gdImagePtr graph = 0; void getCGI(); void doSQL(); + void getSavedGraphDetails(void); + /* CGI in */ *************** *** 67,70 **** --- 78,82 ---- char sTimeRange[2]; time_t tRelativeTime; + int iScale=SCALE_AUTO; int bForceScale = FALSE; int bAccurateScale = FALSE; *************** *** 215,218 **** --- 227,236 ---- getCGI(); + /* Handle SQL */ + doSQL(); + + /* get values for stored graphs */ + getSavedGraphDetails(); + /* Write tmp file reporting PID */ writePIDFile(); *************** *** 228,233 **** initChartGraphics(); - /* Handle SQL */ - doSQL(); /* Get the bounds of the graph */ --- 246,249 ---- *************** *** 1521,1540 **** ***************************************/ ! ! void getCGI() ! { ! char *s; char c; time_t t; - - setlocale(LC_NUMERIC, "POSIX"); - - 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)) --- 1537,1546 ---- ***************************************/ ! void getSavedGraphDetails() { char c; time_t t; if(iGraphId>0) { /* get graph details from database */ ! g_string_printf(s_SQL, "SELECT g.metric_id,scale,minin,maxin,timerange,relativetime,fromtime,totime,output,sizex,sizey,s_val,s_war,s_cri,s_sta,graphtitle,g_sigma,unit,percent,s_smo FROM perfdata_graphs g,perfdata_service_metric m WHERE id=%d and g.metric_id=m.metric_id",iGraphId); #ifdef USE_DB_MYSQL if (mysql_query(&db_mysql, s_SQL->str)) *************** *** 1552,1557 **** --- 1558,1604 ---- sMetricId=iData(0); // scale + // todo: switching from dropdown to checkboxes in html can make life easier here! + iScale=iData(1); + switch(iScale) { + case SCALE_USER: + bForceScale=FALSE; + bAccurateScale=FALSE; + bPercent=FALSE; + break; + case SCALE_USER_EXACT: + bForceScale=FALSE; + bAccurateScale=TRUE; + bPercent=FALSE; + break; + case SCALE_USER_PERCENT: + bForceScale=FALSE; + bAccurateScale=FALSE; + bPercent=TRUE; + break; + case SCALE_RANGE: /* todo */ + case SCALE_RANGE_EXACT: /* todo */ + case SCALE_RANGE_PERCENT: /* todo */ + case SCALE_AUTO: + default: + bForceScale=TRUE; + bAccurateScale=TRUE; + bPercent=FALSE; + break; + } // minin + if(strlen(sData(2))>0) { + dMin=dData(2); + bMin=TRUE; + } else { // to be calculated + bMin=FALSE; + } // maxin + if(strlen(sData(3))>0) { + dMax=dData(3); + bMax=TRUE; + } else { // to be calculated + bMax=FALSE; + } + c=sData(4)[0]; // timerange *************** *** 1585,1592 **** iWidth=iData(9); iHeight=iData(10); ! } ! } else { /* get graph details from cgi*/ sMetricId=atoi(scgi("metric_id")); --- 1632,1669 ---- iWidth=iData(9); iHeight=iData(10); + if (!iWidth || !iHeight) + iWidth = 585, iHeight = 300; + bVal = iData(11); + bSmooth = iData(19); + bWarn = iData(12); + bCrit = iData(13); + bStanDev = iData(14); + sTitle=strdup(sData(15)); + /* Gaussian Theta */ + fGaussianSigma = dData(16) / 2; + if (fGaussianSigma <= 0) fGaussianSigma = GAUSSIAN_SIGMA_DEFAULT; + + strncpy(sUnit, sData(17),20); ! /* Show values as percent */ ! bPercent = iData(18); ! ! // todo: check forcescale, accuratescale } ! } ! } ! ! void getCGI() ! { ! char *s; ! ! setlocale(LC_NUMERIC, "POSIX"); ! ! getCGIDBVars(); ! ! /* get graph id for stored graphs */ ! iGraphId=atoi(scgi("graph_id")); ! /* get graph detals for stored graphs is handled later */ ! if(iGraphId<=0) { /* get graph details from cgi*/ sMetricId=atoi(scgi("metric_id")); *************** *** 1698,1701 **** --- 1775,1781 ---- { + if(graph==0) { /*early error handling */ + initChartGraphics(); + } gdImageFilledRectangle(graph, 0, 0, iWidth, iHeight, white); *************** *** 1827,1830 **** --- 1907,1914 ---- tmpSQL = g_strdup(sql); tmpError = g_strdup(error); + + if(graph==0) { /*early error handling */ + initChartGraphics(); + } gdImageFilledRectangle(graph, 0, 0, iWidth, iHeight, white); Index: cgi.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/cgi/cgi.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cgi.c 20 Dec 2006 22:57:45 -0000 1.3 --- cgi.c 12 Aug 2007 00:11:44 -0000 1.4 *************** *** 3,7 **** * cgi.c - Common functions for cgi functions. * ! * Copyright (c) 2004 Ben Clewett * $Id$ * --- 3,7 ---- * cgi.c - Common functions for cgi functions. * ! * Copyright (c) 2004-2007 Ben Clewett, Florian Gleixner * $Id$ * *************** *** 231,235 **** } - - - --- 231,232 ---- |