From: Florian G. <re...@us...> - 2006-09-14 14:02:10
|
Update of /cvsroot/perfparse/_perfparse-phpgui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5652 Modified Files: perfparse.php utils.php Log Message: graph page works half - with some debug enabled Index: utils.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/utils.php,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** utils.php 13 Sep 2006 20:30:03 -0000 1.25 --- utils.php 14 Sep 2006 14:02:06 -0000 1.26 *************** *** 153,156 **** --- 153,170 ---- } + function get_metric_props(&$db,$metricId) { + $query ='SELECT s.service_id, s.service_description, m.metric_id, m.metric, '; + $query.='m.unit, m.notes, m.value_max, m.value_min, h.host_id, h.host_name FROM '; + $query.='perfdata_service_metric m, perfdata_service s, perfdata_host h '; + $query.='WHERE h.host_id=s.host_id AND s.service_id=m.service_id '; + $query.='AND m.metric_id=?'; + $ret=$db->GetRow($query,array($metricId)); + if(!$ret) { + echo $db->ErrorMsg(); + } + return($ret); + } + + function have_service_metric(&$db,$host,$service,$metric) { $where=array(); *************** *** 212,222 **** } - function get_metric_props(&$db,$host,$service,$metric) { - $query ='SELECT value_max, value_min, unit FROM perfdata_service_metric WHERE host_name = ? '; - $query.='AND service_description = ? AND metric = ?'; - $ret=$db->GetRow($query,array($host,$service,$metric)); - return($ret); - } - function get_groups(&$db) { $query ='SELECT group_name from perfdata_host_group'; --- 226,229 ---- Index: perfparse.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/perfparse.php,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** perfparse.php 14 Sep 2006 09:15:29 -0000 1.35 --- perfparse.php 14 Sep 2006 14:02:06 -0000 1.36 *************** *** 214,229 **** if(get_request_var('graphs','array')) { ! // echo "<pre>\ngraphs from Request:\n";print_r($graphs); echo "</pre>"; ! foreach($graphs as $host_name => $hostarray) { ! foreach($hostarray as $service => $servicearray) { ! foreach($servicearray as $metric => $metricarray) { ! if(have_service_metric($db,$host_name,$service,$metric)>0) { $numgraphs++; // build a array that holds all information. // make code better readable ! $actgraph=&$graphs[$host_name][$service][$metric]; // make code better readable ! ! $tmparr=get_metric_props($db,$host_name,$service,$metric); $actgraph['value_max']=$tmparr['value_max']; $actgraph['value_min']=$tmparr['value_min']; --- 214,238 ---- if(get_request_var('graphs','array')) { ! echo "<pre>\ngraphs from Request:\n";print_r($graphs); echo "</pre>"; ! echo "<pre>\nRequest:\n";print_r($_REQUEST); echo "</pre>"; ! get_request_var('displaygraphs','array'); ! echo "<pre>\ndisplaygraphs from Request:\n";print_r($diaplaygraphs); echo "</pre>"; ! foreach($graphs as $metric_id => $metricarray) { ! //foreach($hostarray as $service => $servicearray) { ! // foreach($servicearray as $metric => $metricarray) { ! $tmparr=get_metric_props($db,$metric_id); ! if($tmparr!=FALSE) { ! echo "<pre>tmparr:\n";print_r($tmparr);echo "</pre>"; $numgraphs++; // build a array that holds all information. + $host_name=$tmparr['host_name']; + $service=$tmparr['service_description']; + $metric=$tmparr['metric']; + if (!isset($displaygraphs[$host_name][$service][$metric]) { + $displaygraphs[$host_name][$service][$metric]=array(); + } // make code better readable ! $actgraph=&$displaygraphs[$host_name][$service][$metric]; $actgraph['value_max']=$tmparr['value_max']; $actgraph['value_min']=$tmparr['value_min']; *************** *** 233,238 **** $actgraph['id']=$id; $deftitle='Host \''.$host_name.'\' Service \''.$service.'\' Metric \''.$metric.'\''; ! $actgraph['title']= ! 'Host \''.$host_name.'\' Service \''.$service.'\' Metric \''.$metric.'\''; // get_request_var(variable, type, default value) // check_setdefault(variable, type, default value) --- 242,246 ---- $actgraph['id']=$id; $deftitle='Host \''.$host_name.'\' Service \''.$service.'\' Metric \''.$metric.'\''; ! $actgraph['title']=$deftitle; // get_request_var(variable, type, default value) // check_setdefault(variable, type, default value) *************** *** 323,337 **** } else { // if(have_service_metric ... // should we write a error message??? ! unset($graphs[$host_name][$service][$metric]); } } // foreach($metricarray as $metric) { ! } // foreach($servicearray as ... ! } // foreach($graphs ... } // if(get_request_var('graphs' ... ! // echo "<pre>\ngraphs:\n";print_r($graphs); echo "</pre>"; if($numgraphs>0) { $smarty->assign_by_ref('graphs',$graphs); // handle saving graph --- 331,346 ---- } else { // if(have_service_metric ... // should we write a error message??? ! unset($graphs[$metric_id]); } } // foreach($metricarray as $metric) { ! // } // foreach($servicearray as ... ! // } // foreach($graphs ... } // if(get_request_var('graphs' ... ! echo "<pre>\ndisplaygraphs:\n";print_r($displaygraphs); echo "</pre>"; if($numgraphs>0) { $smarty->assign_by_ref('graphs',$graphs); + $smarty->assign_by_ref('displaygraphs',$displaygraphs); // handle saving graph |