From: Florian G. <re...@us...> - 2006-09-13 10:14:55
|
Update of /cvsroot/perfparse/_perfparse-phpgui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19708/phpgui Modified Files: README.perfparse_phpui perfparse.php utils.php Log Message: rework phpui for new db schema ongoing Index: utils.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/utils.php,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** utils.php 12 Sep 2006 15:30:49 -0000 1.22 --- utils.php 13 Sep 2006 10:14:51 -0000 1.23 *************** *** 100,104 **** function get_hosts(&$db) { ! $query='SELECT h.host_name, g.group_name FROM perfdata_host h LEFT JOIN perfdata_host_groups hg ON h.host_id=hg.host_id LEFT JOIN perfdata_groups g ON g.group_id=hg.group_id --- 100,104 ---- function get_hosts(&$db) { ! $query='SELECT h.host_name, g.group_name, h.host_id FROM perfdata_host h LEFT JOIN perfdata_host_groups hg ON h.host_id=hg.host_id LEFT JOIN perfdata_groups g ON g.group_id=hg.group_id *************** *** 109,115 **** while($t=$res->FetchRow()) { if($t['group_name'] == '') { ! $t['group_name'] = 'Unassigned'; } ! $ret[$t['group_name']][]=$t['host_name']; } } --- 109,115 ---- while($t=$res->FetchRow()) { if($t['group_name'] == '') { ! $t['group_name'] = 'Unassigned'; } ! $ret[$t['group_name']][$t['host_id']]=$t['host_name']; } } *************** *** 124,127 **** --- 124,133 ---- } + function have_host_id(&$db,$hostID) { + $query='SELECT count(*) FROM perfdata_host where host_id=?'; + $ret=$db->GetOne($query,array($hostID)); + return($ret); + } + function have_group(&$db,$group) { $query='SELECT count(*) FROM perfdata_groups where group_name=?'; *************** *** 170,177 **** // mark: continue here ! function get_metrics(&$db,$host) { ! $query ='SELECT service_description,metric FROM perfdata_service_metric '; ! $query.='WHERE host_name=? order by service_description, metric'; ! $res=$db->Execute($query,array($host)); $ret=array(); if($res) { --- 176,185 ---- // mark: continue here ! function get_metrics_from_hostid(&$db,$host_id) { ! $query ='SELECT s.service_description,m.metric FROM '; ! $query.='perfdata_service_metric m, perfdata_service s '; ! $query.='WHERE s.service_id=m.service_id AND s.host_id=? '; ! $query.='order by s.service_description, m.metric'; ! $res=$db->Execute($query,array($host_id)); $ret=array(); if($res) { Index: perfparse.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/perfparse.php,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** perfparse.php 12 Sep 2006 15:30:49 -0000 1.31 --- perfparse.php 13 Sep 2006 10:14:51 -0000 1.32 *************** *** 144,154 **** // display the page $smarty->display($config['PHP_Style'].'select_host.tpl.html'); ! // print_r($hosts); // for debug break; case 'select_metric': // get host array ! get_request_var('host_name','array'); ! $numhosts=count($host_name); $smarty->assign('numhosts',$numhosts); --- 144,154 ---- // display the page $smarty->display($config['PHP_Style'].'select_host.tpl.html'); ! // echo "<pre>"; print_r($hosts); echo "</pre>";// for debug break; case 'select_metric': // get host array ! get_request_var('host_id','array'); ! $numhosts=count($host_id); $smarty->assign('numhosts',$numhosts); *************** *** 160,176 **** } ! foreach($host_name as $host) { ! if(!have_host($db,$host)) { ! $smarty->assign('message','Unknown Hostname'); $smarty->display($config['PHP_Style'].'error.tpl.html'); die(); } // get metrics and save them in a array ! $metrics[$host]=get_metrics($db,$host); } ! // echo "<pre>"; ! // print_r($metrics); ! // echo "</pre>"; $smarty->assign_by_ref('metrics',$metrics); --- 160,174 ---- } ! foreach($host_id as $hostId) { ! if(!have_host_id($db,$hostId)) { ! $smarty->assign('message','Unknown Host ID '.$hostId); $smarty->display($config['PHP_Style'].'error.tpl.html'); die(); } // get metrics and save them in a array ! $metrics[$hostId]=get_metrics_from_hostid($db,$hostId); } ! // echo "<pre>"; print_r($metrics); echo "</pre>"; $smarty->assign_by_ref('metrics',$metrics); *************** *** 178,192 **** // used for selecting all metrics of a type via js $diffmetrics=array(); ! foreach($metrics as $host => $servicearray) { foreach($servicearray as $service => $metricarray) { foreach($metricarray as $metric ) { ! $diffmetrics[$service][$metric]["hosts"][]=$host; ! $diffmetrics[$service][$metric]["count"]=count($diffmetrics[$service][$metric]["hosts"]); } } } ! // echo "<pre>"; ! // print_r($diffmetrics); ! // echo "</pre>"; $smarty->assign_by_ref('diffmetrics',$diffmetrics); --- 176,188 ---- // used for selecting all metrics of a type via js $diffmetrics=array(); ! foreach($metrics as $hostId => $servicearray) { foreach($servicearray as $service => $metricarray) { foreach($metricarray as $metric ) { ! $diffmetrics[$service][$metric]["hostids"][]=$hostId; ! $diffmetrics[$service][$metric]["count"]=count($diffmetrics[$service][$metric]["hostids"]); } } } ! echo "diffmetrics array:<br /><pre>"; print_r($diffmetrics); echo "</pre>"; $smarty->assign_by_ref('diffmetrics',$diffmetrics); Index: README.perfparse_phpui =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/README.perfparse_phpui,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** README.perfparse_phpui 8 Apr 2006 23:59:47 -0000 1.3 --- README.perfparse_phpui 13 Sep 2006 10:14:51 -0000 1.4 *************** *** 24,29 **** If you want to install the ui manually: ! Unpack all in your /usr/local/nagios/share folder. Then make the templates_c ! folder writable for your apache. Example: chgrp www templates_c --- 24,29 ---- If you want to install the ui manually: ! Unpack all in your /usr/local/nagios/share/phpui folder. Then make the ! templates_c folder writable for your apache. Example: chgrp www templates_c *************** *** 32,36 **** -- Configuration -- ! Edit the ../etc/perfparse.cfg and add to your Database configurateion the Database Type (example): DB_Type="mysql" --- 32,36 ---- -- Configuration -- ! Edit the ../../etc/perfparse.cfg and add to your Database configuration the Database Type (example): DB_Type="mysql" *************** *** 41,45 **** Note: only mysql is tested for now! ! Optional: edit the ../etc/perfparse.cfg and add PHP-GUI specific parameters: PHP_Lang = "de" --- 41,46 ---- Note: only mysql is tested for now! ! Optional: edit the ../../etc/perfparse.cfg and add PHP-GUI specific ! parameters: PHP_Lang = "de" *************** *** 49,53 **** (omit PHP_Style parameter) or the Style "flo". ! if your webserver devilvers images other than from /nagios/images, then you should add the parameter --- 50,54 ---- (omit PHP_Style parameter) or the Style "flo". ! if your webserver delivers images other than from /nagios/images, then you should add the parameter *************** *** 57,58 **** --- 58,61 ---- fl...@re... + + $Id$ |