From: Florian G. <re...@us...> - 2006-12-02 21:31:16
|
Update of /cvsroot/perfparse/_perfparse-phpgui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20640/phpgui Modified Files: Makefile.in perfparse.php utils.php Log Message: Changes in database schema: delete policy uses a id instead of name and in the other tables are only 2 entries for the delete policy. Made group editing work in php gui, started phpgui delete policy editing. Started database conversion program for new schema .... Index: utils.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/utils.php,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** utils.php 29 Nov 2006 14:06:02 -0000 1.30 --- utils.php 2 Dec 2006 21:31:11 -0000 1.31 *************** *** 153,156 **** --- 153,163 ---- } + function have_group_id(&$db,$group) { + $query='SELECT count(*) FROM perfdata_groups where group_id=?'; + $ret=$db->GetOne($query,array($group)); + return($ret); + } + + function get_metric_props(&$db,$metricId) { $query ='SELECT s.service_id, s.service_description, m.metric_id, m.metric, '; *************** *** 275,282 **** where hg.group_id=? and h.host_id=hg.host_id'; ! $ret=$db->GetCol($query,array($groupId)); return($ret); } // get all metrics and the metric details for all hosts of a given group Id. --- 282,299 ---- where hg.group_id=? and h.host_id=hg.host_id'; ! $ret=$db->GetAll($query,array($groupId)); return($ret); } + // get hostids and hostnames not in a given groupid + function get_notin_groupId_hostinfos(&$db,$groupId) { + $query ='SELECT h.host_name, h.host_id from perfdata_host h + where h.host_id not in + (select host_id from perfdata_host_groups where group_id=?)'; + $ret=$db->GetAll($query,array($groupId)); + return($ret); + } + + // get all metrics and the metric details for all hosts of a given group Id. *************** *** 448,451 **** --- 465,515 ---- } + function add_hostid_to_groupid(&$db,$group_id,$host_id) { + $query='insert into perfdata_host_groups (group_id,host_id) + values(?,?)'; + $db->Execute($query,array($group_id,$host_id)); + if ($db->ErrorNo() != 0) { + return(false); + } else { + return(true); + } + } + + + function remove_hostid_from_groupid(&$db,$group_id,$host_id) { + $query='delete from perfdata_host_groups where group_id=? and + host_id=?'; + $db->Execute($query,array($group_id,$host_id)); + if ($db->ErrorNo() != 0) { + return(false); + } else { + return(true); + } + } + + + // Delete policy functions + + + function get_delete_policies(&$db) { + $query='select policy_id,policy_name,delete_policy_seconds + from perfdata_delete_policy'; + $res=$db->GetAll($query); + return($res); + } + + function create_delete_policy(&$db,$policy,$seconds) { + $query='insert into perfdata_delete_policy + (policy_name,delete_policy_seconds) values (?,?)'; + $db->Execute($query,array($policy,$seconds)); + return($db->ErrorNo()); + } + + function delete_delete_policy(&$db,$policy_id) { + $query='delete from perfdata_delete_policy where policy_id=?'; + $db->Execute($query,array($policy_id)); + return($db->ErrorNo()); + } + function get_graph_details(&$db,$id) { $query='SELECT * from perfdata_graphs where id=?'; Index: Makefile.in =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/Makefile.in,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile.in 17 Aug 2006 13:57:17 -0000 1.6 --- Makefile.in 2 Dec 2006 21:31:11 -0000 1.7 *************** *** 1,3 **** ! # Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ --- 1,3 ---- ! # Makefile.in generated by automake 1.9.5 from Makefile.am. # @configure_input@ Index: perfparse.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/perfparse.php,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** perfparse.php 29 Nov 2006 14:06:02 -0000 1.42 --- perfparse.php 2 Dec 2006 21:31:11 -0000 1.43 *************** *** 430,446 **** get_request_var('host_id','int',''); - $groups=get_groups($db); - if(!($group_name)) $group_name=''; ! if(!empty($group_name)) { ! $group_hosts=get_group_hosts($db,$group_name); $group_hosts_count=count($group_hosts); $smarty->assign_by_ref('group_hosts',$group_hosts); $smarty->assign('group_hosts_count',$group_hosts_count); } ! // TODO: handle add host, remove host actions ! ! $smarty->display($config['PHP_Style'].$_REQUEST['page'].'.tpl.html'); break; --- 430,461 ---- get_request_var('host_id','int',''); ! ! // handle add host and remove host action ! ! if(have_host_id($db,$host_id) && have_group_id($db,$group_id)) { ! switch($action) { ! case "add_host": ! add_hostid_to_groupid($db,$group_id,$host_id); ! break; ! case "remove_host": ! remove_hostid_from_groupid($db,$group_id,$host_id); ! break; ! } ! } ! ! // get group and host infos ! $groups=get_groups($db); ! if(!empty($group_id)) { ! $group_hosts=get_groupId_hostinfos($db,$group_id); ! $notin_group_hosts=get_notin_groupId_hostinfos($db,$group_id); $group_hosts_count=count($group_hosts); $smarty->assign_by_ref('group_hosts',$group_hosts); + $smarty->assign_by_ref('notin_group_hosts',$notin_group_hosts); $smarty->assign('group_hosts_count',$group_hosts_count); } ! // print_r($groups); ! $smarty->assign_by_ref('groups',$groups); $smarty->display($config['PHP_Style'].$_REQUEST['page'].'.tpl.html'); break; *************** *** 474,477 **** --- 489,523 ---- $smarty->display($config['PHP_Style'].$_REQUEST['page'].'.tpl.html'); break; + case 'edit_delete_policies': + // handle create policy template: + get_request_var('create_policy','string',''); + if(!empty($create_policy)) { + get_request_var('create_policy_days','int',0); + get_request_var('create_policy_hours','int',0); + get_request_var('create_policy_minutes','int',0); + get_request_var('create_policy_seconds','int',0); + $create_policy_seconds=$create_policy_seconds+ + 60*$create_policy_minutes+ + 3600*$create_policy_hours+ + 86400*$create_policy_days; + if(create_delete_policy($db,$create_policy,$create_policy_seconds)!=0) { + $smarty->assign('sql_error',$db->ErrorMsg()); + } + } + + // handle delete policy template + get_request_var('delete_policy','int',false); + if($delete_policy) { + if(delete_delete_policy($db,$delete_policy)!=0) { + $smarty->assign('sql_error',$db->ErrorMsg()); + } + } + + // load infos for display + $policies=get_delete_policies($db); + $smarty->assign_by_ref('policies',$policies); + + $smarty->display($config['PHP_Style'].$_REQUEST['page'].'.tpl.html'); + break; case 'read_nag_config': // load modified naupy class |