Wizard first and second step, clusters functions - #1478
This commit is contained in:
parent
cce92cc961
commit
099cd3bbe8
|
@ -1503,13 +1503,16 @@ create table IF NOT EXISTS `tcluster`(
|
|||
-- ---------------------------------------------------------------------
|
||||
|
||||
create table IF NOT EXISTS `tcluster_item`(
|
||||
`id_cluster` int unsigned not null auto_increment,
|
||||
`id` int unsigned not null auto_increment,
|
||||
`name` tinytext not null default '',
|
||||
`item_type` enum('AA','AP') not null default 'AA',
|
||||
`critical_limit` int unsigned NOT NULL default '0',
|
||||
`warning_limit` int unsigned NOT NULL default '0',
|
||||
`is_critical` tinyint(2) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id_cluster`)
|
||||
`id_cluster` int unsigned,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_cluster`) REFERENCES tcluster(`id`)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) engine=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
|
@ -1517,9 +1520,11 @@ create table IF NOT EXISTS `tcluster_item`(
|
|||
-- ---------------------------------------------------------------------
|
||||
|
||||
create table IF NOT EXISTS `tcluster_agent`(
|
||||
`id_cluster` int unsigned not null auto_increment,
|
||||
`id_agent` int unsigned,
|
||||
PRIMARY KEY (`id_cluster`),
|
||||
`id_cluster` int unsigned not null,
|
||||
`id_agent` int(10) unsigned not null,
|
||||
PRIMARY KEY (`id_cluster`,`id_agent`),
|
||||
FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE
|
||||
ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`id_cluster`) REFERENCES tcluster(`id`)
|
||||
ON UPDATE CASCADE
|
||||
) engine=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
|
@ -40,7 +40,7 @@ ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no cl
|
|||
echo __('<b>Clusters to guarantee service</b>: these are active - passive (A/P) mode clusters. It means that one of the nodes (or machines that make up the cluster) will be running (primary) and another won\'t (secondary). When the primary goes down, the secondary must take over and give the service instead. Although many of the elements of this cluster are active-passive, it will also have active elements in both of them that indicate that the passive node is "online", so that in the case of a service failure in the master, the active node collects this information.');
|
||||
|
||||
?></p>
|
||||
<form action="index.php?sec=reporting&sec2=godmode/reporting/graph_builder" method="post">
|
||||
<form action="index.php?sec=reporting&sec2=godmode/reporting/cluster_builder" method="post">
|
||||
<input type="submit" class="button_task" value="<?php echo __('Create Cluster'); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
global $config;
|
||||
|
||||
// -----------------------
|
||||
// CREATE/EDIT CLUSTER FORM
|
||||
// -----------------------
|
||||
|
||||
if($step == 1){
|
||||
|
||||
if ($edit_cluster)
|
||||
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&edit_cluster=1&update_cluster=1&id=" . $id_cluster . "'>";
|
||||
else
|
||||
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&edit_cluster=1&add_cluster=1'>";
|
||||
|
||||
echo "<table width='40%' cellpadding=4 cellspacing=4 class='databox filters'>";
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'><b>".__('Cluster name')."</b>".ui_print_help_tip (__("An agent with the same name of the cluster will be created, as well a special service with the same name"), true)."</td>";
|
||||
echo "<td class='datos'><input type='text' name='name' size='50'></td>";
|
||||
echo "<tr>";
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'><b>".__('Cluster type')."</b>";
|
||||
echo "<td class='datos'>";
|
||||
|
||||
$cluster_types = array(
|
||||
'AA' => __('Ative - Active'),
|
||||
'AP' => __('Active - Pasive')
|
||||
);
|
||||
|
||||
html_print_select ($cluster_types, 'cluster_type', 'AA');
|
||||
|
||||
echo "</td>";
|
||||
echo "<tr>";
|
||||
echo "</td>";
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'><b>".__('Description')."</b></td>";
|
||||
echo "<td class='datos'><input type='text' name='description' size='50'></td>";
|
||||
echo "</tr>";
|
||||
|
||||
echo "<td class='datos'><b>".__('Group')."</b></td>";
|
||||
echo" <td class='datos'>";
|
||||
if (check_acl ($config['id_user'], 0, "RW"))
|
||||
echo html_print_select_groups($config['id_user'], 'RW', $return_all_groups, 'cluster_id_group', $id_group, '', '', '', true);
|
||||
elseif (check_acl ($config['id_user'], 0, "RM"))
|
||||
echo html_print_select_groups($config['id_user'], 'RM', $return_all_groups, 'cluster_id_group', $id_group, '', '', '', true);
|
||||
echo "</td></tr>";
|
||||
|
||||
echo "</table>";
|
||||
|
||||
if ($edit_cluster) {
|
||||
echo "<div style='width:40%'><input style='float:right;' type=submit name='store' class='sub upd' value='".__('Update')."'></div>";
|
||||
}
|
||||
else {
|
||||
echo "<div style='width:40%'><input style='float:right;' type=submit name='store' class='sub next' value='".__('Create')."'></div>";
|
||||
}
|
||||
echo "</form>";
|
||||
|
||||
}
|
||||
elseif($step == 2){
|
||||
|
||||
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=2&id_cluster='".$id_cluster.">";
|
||||
|
||||
echo "<table width='50%' cellpadding=4 cellspacing=4 class='databox filters'>";
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'><b>".__('Cluster name')."</b></td>";
|
||||
echo "<td class='datos'>".clusters_get_name($id_cluster)."</td>";
|
||||
echo "</tr>";
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'><b>".__('Adding agents to the cluster')."</b></td>";
|
||||
echo "</tr>";
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'>";
|
||||
// $attr = array('id' => 'image-select_all_available', 'title' => __('Select all'), 'style' => 'cursor: pointer;');
|
||||
echo "<b>" . __('Agents')."</b> " . html_print_image ('images/tick.png', true, $attr, false, true);
|
||||
echo "</td>";
|
||||
|
||||
echo "<td class='datos'>";
|
||||
echo "</td>";
|
||||
|
||||
echo "<td class='datos'>";
|
||||
// $attr = array('id' => 'image-select_all_apply', 'title' => __('Select all'), 'style' => 'cursor: pointer;');
|
||||
echo "<b>" . __('Agents in Cluster')."</b> " . html_print_image ('images/tick.png', true, $attr, false, true);
|
||||
echo "</td>";
|
||||
echo "<tr>";
|
||||
echo "<td class='datos'>";
|
||||
|
||||
$option_style = array();
|
||||
$cluster_agents_in = agents_get_cluster_agents(8);
|
||||
|
||||
html_debug($cluster_agents_in);
|
||||
|
||||
$cluster_agents_all = agents_get_group_agents(0, false, '');
|
||||
$cluster_agents_out = array();
|
||||
$cluster_agents_out = array_diff_key($template_agents_all, $template_agents_in);
|
||||
|
||||
$cluster_agents_in_keys = array_keys($template_agents_in);
|
||||
$cluster_agents_out_keys = array_keys($template_agents_out);
|
||||
|
||||
html_print_select ($cluster_agents_all, 'id_agents[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style);
|
||||
|
||||
echo "</td>";
|
||||
|
||||
echo "<td class='datos'>";
|
||||
echo "<br />";
|
||||
html_print_image ('images/darrowright.png', false, array ('id' => 'right', 'title' => __('Add agents to cluster')));
|
||||
echo "<br /><br /><br />";
|
||||
html_print_image ('images/darrowleft.png', false, array ('id' => 'left', 'title' => __('Drop agents to cluster')));
|
||||
echo "<br /><br /><br />";
|
||||
echo "</td>";
|
||||
|
||||
echo "<td class='datos'>";
|
||||
|
||||
html_print_select ($cluster_agents_in, 'id_agents2[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style);
|
||||
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
echo "</table>";
|
||||
|
||||
echo "<div style='width:50%'><input style='float:right;' type=submit name='store' class='sub upd' value='".__('Next')."'></div>";
|
||||
echo "</form>";
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! check_acl ($config['id_user'], 0, "RW") && ! check_acl ($config['id_user'], 0, "RM")) {
|
||||
db_pandora_audit("ACL Violation",
|
||||
"Trying to access graph builder");
|
||||
include ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once ('include/functions_agents.php');
|
||||
require_once('include/functions_clusters.php');
|
||||
|
||||
$step = get_parameter('step',1);
|
||||
$id_cluster = get_parameter('id_cluster',0);
|
||||
|
||||
if($step == 1){
|
||||
|
||||
$add_cluster = (bool) get_parameter('add_cluster', false);
|
||||
$update_graph = (bool) get_parameter('update_cluster', false);
|
||||
$id_cluster = (int) get_parameter('id', 0);
|
||||
|
||||
if ($add_cluster) {
|
||||
$name = get_parameter_post ("name");
|
||||
$cluster_type = get_parameter_post ('cluster_type');
|
||||
$description = get_parameter_post ("description");
|
||||
$idGroup = get_parameter_post ('cluster_id_group');
|
||||
|
||||
// Create cluster
|
||||
$values_cluster = array(
|
||||
'name' => $name,
|
||||
'cluster_type' => $cluster_type,
|
||||
'description' => $description,
|
||||
'group' => $idGroup,
|
||||
);
|
||||
|
||||
// Create agent
|
||||
|
||||
$values_agent = array(
|
||||
'nombre' => hash("sha256",$name . "|" ."127.0.0.1" ."|". time() ."|". sprintf("%04d", rand(0,10000))),
|
||||
// 'nombre' => $name,
|
||||
'alias' => $name,
|
||||
'comentarios' => $description,
|
||||
'id_grupo' => $idGroup
|
||||
);
|
||||
|
||||
if (trim($name) != "") {
|
||||
$id_cluster = db_process_sql_insert('tcluster', $values_cluster);
|
||||
|
||||
$id_agent = db_process_sql_insert('tagente',$values_agent);
|
||||
|
||||
if ($id_cluster !== false)
|
||||
db_pandora_audit("Report management", "Create cluster #$id_cluster");
|
||||
else
|
||||
db_pandora_audit("Report management", "Fail try to create cluster");
|
||||
|
||||
if ($id_agent !== false)
|
||||
db_pandora_audit("Report management", "Create cluster #$id_agent");
|
||||
else
|
||||
db_pandora_audit("Report management", "Fail try to create agent");
|
||||
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=2&id_cluster=".$id_cluster);
|
||||
|
||||
}
|
||||
else {
|
||||
$id_cluster = false;
|
||||
}
|
||||
|
||||
if(!$id_cluster)
|
||||
$edit_cluster = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ui_print_page_header (__('Cluster')." » ".__('New'), "images/chart.png", false, "", false, $buttons);
|
||||
|
||||
|
||||
$active_tab = get_parameter('tab', 'main');
|
||||
|
||||
|
||||
|
||||
|
||||
switch ($active_tab) {
|
||||
case 'main':
|
||||
require_once('godmode/reporting/cluster_builder.main.php');
|
||||
break;
|
||||
case 'cluster_editor':
|
||||
require_once('godmode/reporting/cluster_builder.cluster_editor.php');
|
||||
break;
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
require_once($config['homedir'] . '/include/functions.php');
|
||||
|
||||
function clusters_get_name ($id_cluster, $case = 'none') {
|
||||
$name = (string) db_get_value ('name', 'tcluster', 'id', (int) $id_cluster);
|
||||
|
||||
switch ($case) {
|
||||
case 'upper':
|
||||
return mb_strtoupper($name, 'UTF-8');
|
||||
case 'lower':
|
||||
return mb_strtolower($name, 'UTF-8');
|
||||
case 'none':
|
||||
default:
|
||||
return ($name);
|
||||
}
|
||||
}
|
||||
|
||||
function agents_get_cluster_agents ($id_cluster){
|
||||
$agents = db_get_all_rows_filter("tcluster_agent", array("id_cluster" => $id_cluster), "id_agent");
|
||||
return ($agents);
|
||||
}
|
||||
|
||||
?>
|
|
@ -3049,13 +3049,16 @@ create table IF NOT EXISTS `tcluster`(
|
|||
-- ---------------------------------------------------------------------
|
||||
|
||||
create table IF NOT EXISTS `tcluster_item`(
|
||||
`id_cluster` int unsigned not null auto_increment,
|
||||
`id` int unsigned not null auto_increment,
|
||||
`name` tinytext not null default '',
|
||||
`item_type` enum('AA','AP') not null default 'AA',
|
||||
`critical_limit` int unsigned NOT NULL default '0',
|
||||
`warning_limit` int unsigned NOT NULL default '0',
|
||||
`is_critical` tinyint(2) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id_cluster`)
|
||||
`id_cluster` int unsigned,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_cluster`) REFERENCES tcluster(`id`)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) engine=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
|
@ -3063,10 +3066,12 @@ create table IF NOT EXISTS `tcluster_item`(
|
|||
-- ---------------------------------------------------------------------
|
||||
|
||||
create table IF NOT EXISTS `tcluster_agent`(
|
||||
`id_cluster` int unsigned not null auto_increment,
|
||||
`id_agent` int unsigned,
|
||||
PRIMARY KEY (`id_cluster`),
|
||||
`id_cluster` int unsigned not null,
|
||||
`id_agent` int(10) unsigned not null,
|
||||
PRIMARY KEY (`id_cluster`,`id_agent`),
|
||||
FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE
|
||||
ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`id_cluster`) REFERENCES tcluster(`id`)
|
||||
ON UPDATE CASCADE
|
||||
) engine=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
Loading…
Reference in New Issue