From: Florian G. <re...@us...> - 2007-09-06 22:59:50
|
Update of /cvsroot/perfparse/_perfparse-phpgui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28828/phpgui Modified Files: perfparse.php utils.php Log Message: more on policy ui Index: utils.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/utils.php,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** utils.php 5 Sep 2007 22:18:30 -0000 1.42 --- utils.php 6 Sep 2007 22:59:50 -0000 1.43 *************** *** 282,286 **** where hg.group_id=? and h.host_id=hg.host_id'; ! $ret=$db->GetAll($query,array($groupId)); return($ret); } --- 282,294 ---- where hg.group_id=? and h.host_id=hg.host_id'; ! $res=$db->Execute($query,array($groupId)); ! $ret=array(); ! if($res) { ! while($t=$res->FetchRow()) { ! $ret[$t['host_id']]=$t; ! } ! } else { ! echo "Error in query $query. Message: ".$db->ErrorMsg(); ! } return($ret); } *************** *** 629,633 **** perfdata_host h left join perfdata_delete_policy d on h.bin_delete_policy_id=d.policy_id where h.host_id=? '; ! if(!$res=$db->GetRow($query,array($metric_id))) { return(FALSE); } --- 637,641 ---- perfdata_host h left join perfdata_delete_policy d on h.bin_delete_policy_id=d.policy_id where h.host_id=? '; ! if(!$res=$db->GetRow($query,array($host_id))) { return(FALSE); } *************** *** 641,644 **** --- 649,669 ---- } + function get_host_raw_del_policy(&$db,$host_id) { + // if policy set in host + $query='select h.raw_delete_policy_individual,d.policy_name,d.delete_policy_seconds from + perfdata_host h left join + perfdata_delete_policy d on h.raw_delete_policy_id=d.policy_id where h.host_id=? '; + if(!$res=$db->GetRow($query,array($host_id))) { + return(FALSE); + } + if($res['raw_delete_policy_individual']!==NULL) { + return(array('source'=>'Host Individual','policy_seconds'=>$res['raw_delete_policy_individual'])); + } + if($res['policy_name']!==NULL) { + return(array('source'=>'Host Policy','policy_name'=>$res['policy_name'],'policy_seconds'=>$res['delete_policy_seconds'])); + } + return(array('source'=>'none')); + } + function get_group_bin_del_policy(&$db,$group_id) { // if policy set in group *************** *** 658,661 **** --- 683,704 ---- } + function get_group_raw_del_policy(&$db,$group_id) { + // if policy set in group + $query='select g.raw_delete_policy_individual,d.policy_name,d.delete_policy_seconds from + perfdata_groups g left join + perfdata_delete_policy d on g.raw_delete_policy_id=d.policy_id where g.group_id=? '; + if(!$res=$db->GetRow($query,array($group_id))) { + return(FALSE); + } + if($res['raw_delete_policy_individual']!==NULL) { + return(array('source'=>'Group Individual','policy_seconds'=>$res['raw_delete_policy_individual'])); + } + if($res['policy_name']!==NULL) { + return(array('source'=>'Group Policy','policy_name'=>$res['policy_name'],'policy_seconds'=>$res['delete_policy_seconds'])); + } + return(array('source'=>'none')); + } + + function get_group_bin_del_policy_from_hostid(&$db,$host_id) { // if policy is set in group. If more than one group match, then the group with the longest policy matches. Index: perfparse.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/perfparse.php,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** perfparse.php 5 Sep 2007 22:18:30 -0000 1.55 --- perfparse.php 6 Sep 2007 22:59:50 -0000 1.56 *************** *** 612,615 **** --- 612,621 ---- // get all needed object names and ids + // default delete policies + $default_bin_policy=get_delete_policy($db,0); + $default_raw_policy=get_delete_policy($db,1); + $smarty->assign_by_ref('default_bin_policy',$default_bin_policy); + $smarty->assign_by_ref('default_raw_policy',$default_raw_policy); + // group info $groupinfos=get_groups($db); *************** *** 620,641 **** $smarty->assign_by_ref('hostinfos',$hostinfos); ! if($bin_group_policy=get_group_bin_del_policy($db,$group_id)==FALSE) { $smarty->assign('sql_error',$db->ErrorMsg()); } $smarty->assign_by_ref('bin_group_policy',$bin_group_policy); - } get_request_var('host_id','int',FALSE); if($host_id != FALSE) { $metricsinfos=get_metrics_from_hostid($db,$host_id); } echo "<pre>groupinfos:\n"; print_r($groupinfos); echo "\n</pre>"; echo "<pre>hostinfos:\n"; print_r($hostinfos); echo "\n</pre>"; echo "<pre>metricsinfos:\n"; print_r($metricsinfos); echo "\n</pre>"; echo "<pre>bin_group_policy:\n"; print_r($bin_group_policy); echo "\n</pre>"; ! if($effectivepolicy=get_effective_bin_del_policy($db,1/* testing */)==FALSE) { $smarty->assign('sql_error',$db->ErrorMsg); //debug: --- 626,671 ---- $smarty->assign_by_ref('hostinfos',$hostinfos); ! if(($bin_group_policy=get_group_bin_del_policy($db,$group_id))==FALSE) { $smarty->assign('sql_error',$db->ErrorMsg()); } $smarty->assign_by_ref('bin_group_policy',$bin_group_policy); + if(($raw_group_policy=get_group_raw_del_policy($db,$group_id))==FALSE) { + $smarty->assign('sql_error',$db->ErrorMsg()); + } + $smarty->assign_by_ref('raw_group_policy',$raw_group_policy); + } + // host info get_request_var('host_id','int',FALSE); if($host_id != FALSE) { + $selected_host=$hostinfos[$host_id]['host_name']; // todo: check if in group? + $smarty->assign_by_ref('selected_host',$selected_host); $metricsinfos=get_metrics_from_hostid($db,$host_id); + $smarty->assign_by_ref('metricsinfos',$metricsinfos); + + if(($bin_host_policy=get_host_bin_del_policy($db,$host_id))==FALSE) { + $smarty->assign('sql_error',$db->ErrorMsg()); + } + $smarty->assign_by_ref('bin_host_policy',$bin_host_policy); + + if(($raw_host_policy=get_host_raw_del_policy($db,$host_id))==FALSE) { + $smarty->assign('sql_error',$db->ErrorMsg()); + } + $smarty->assign_by_ref('raw_host_policy',$raw_host_policy); + } + /* debug + echo "<pre>group_id: $group_id\n</pre>"; echo "<pre>groupinfos:\n"; print_r($groupinfos); echo "\n</pre>"; echo "<pre>hostinfos:\n"; print_r($hostinfos); echo "\n</pre>"; echo "<pre>metricsinfos:\n"; print_r($metricsinfos); echo "\n</pre>"; echo "<pre>bin_group_policy:\n"; print_r($bin_group_policy); echo "\n</pre>"; + echo "<pre>bin_host_policy:\n"; print_r($bin_host_policy); echo "\n</pre>"; + */ ! /* debug ! if($effectivepolicy=get_effective_bin_del_policy($db,1)==FALSE) { $smarty->assign('sql_error',$db->ErrorMsg); //debug: *************** *** 644,647 **** --- 674,678 ---- echo "<pre>effectivepolicy:\n"; print_r($effectivepolicy); echo "\n</pre>"; + */ |