Change branch to enterprise - #1748
This commit is contained in:
parent
389c6aeada
commit
e1669ded9d
|
@ -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/cluster_builder&step=1" method="post">
|
||||
<form action="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&step=1" method="post">
|
||||
<input type="submit" class="button_task" value="<?php echo __('Create Cluster'); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
$name_agent = get_parameter('name_agent',0);
|
||||
|
||||
$exist_agent = agents_get_agent_id($name_agent);
|
||||
|
||||
echo $exist_agent;
|
||||
return;
|
||||
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,577 +0,0 @@
|
|||
<?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_modules.php');
|
||||
require_once('include/functions_clusters.php');
|
||||
|
||||
$step = get_parameter('step',0);
|
||||
$id_cluster = get_parameter('id_cluster',0);
|
||||
$delete_cluster = get_parameter('delete_cluster',0);
|
||||
$edit_cluster = get_parameter('edit_cluster',0);
|
||||
$delete_module_aa = get_parameter('delete_module_aa',0);
|
||||
$delete_module_ap = get_parameter('delete_module_ap',0);
|
||||
$update = get_parameter('update',0);
|
||||
|
||||
$buttons['list'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster">' .
|
||||
html_print_image("images/list.png", true, array ("title" => __('Clusters list'))) .'</a>');
|
||||
|
||||
if($update){
|
||||
|
||||
$buttons['view'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id='.$id_cluster.'">' .
|
||||
html_print_image("images/operation.png", true, array ("title" => __('Cluster view'))) .'</a>');
|
||||
|
||||
}
|
||||
|
||||
if($step == 1){
|
||||
|
||||
$add_cluster = (bool) get_parameter('add_cluster', false);
|
||||
|
||||
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 agent
|
||||
|
||||
$server_name = db_process_sql('select name from tserver where server_type=5 limit 1');
|
||||
|
||||
$server_name_agent = $server_name[0]['name'];
|
||||
|
||||
$values_agent = array(
|
||||
'nombre' => $name,
|
||||
'alias' => $name,
|
||||
'comentarios' => $description,
|
||||
'id_grupo' => $idGroup,
|
||||
'id_os' => 21,
|
||||
'server_name' => $server_name_agent
|
||||
);
|
||||
|
||||
if (trim($name) != "") {
|
||||
|
||||
// $id_agent = db_process_sql_insert('tagente',$values_agent);
|
||||
|
||||
$id_agent = agents_create_agent($values_agent['nombre'],$values_agent['id_grupo'],300,'127.0.0.1',$values_agent);
|
||||
|
||||
// Create cluster
|
||||
$values_cluster = array(
|
||||
'name' => $name,
|
||||
'cluster_type' => $cluster_type,
|
||||
'description' => $description,
|
||||
'group' => $idGroup,
|
||||
'id_agent' => $id_agent
|
||||
);
|
||||
|
||||
$id_cluster = db_process_sql_insert('tcluster', $values_cluster);
|
||||
|
||||
|
||||
$values_module = array(
|
||||
'nombre' => 'Cluster status',
|
||||
'id_modulo' => 5,
|
||||
'prediction_module' => 5,
|
||||
'id_agente' =>$id_agent,
|
||||
'custom_integer_1' =>$id_cluster,
|
||||
'id_tipo_modulo' => 1,
|
||||
'descripcion' => 'Cluster status information module',
|
||||
'min_warning' => 1,
|
||||
'min_critical' => 2
|
||||
);
|
||||
|
||||
$id_module = modules_create_agent_module($values_module['id_agente'],$values_module['nombre'],$values_module);
|
||||
|
||||
// $id_module = db_process_sql_insert('tagente_modulo', $values_module);
|
||||
|
||||
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;
|
||||
}
|
||||
elseif ($update && $edit_cluster) {
|
||||
|
||||
$name = get_parameter_post ("name");
|
||||
$description = get_parameter_post ("description");
|
||||
$idGroup = get_parameter_post ('cluster_id_group');
|
||||
|
||||
$id_agent_update = db_process_sql('update tagente set alias = "'.$name.'",comentarios = "'.$description.'",id_grupo = '.$idGroup.' where id_agente = (select id_agent from tcluster where id = '.$id_cluster.')');
|
||||
|
||||
$id_cluster_update = db_process_sql('update tcluster set name = "'.$name.'",description = "'.$description.'",`group` = '.$idGroup.' where id = '.$id_cluster);
|
||||
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster);
|
||||
|
||||
}
|
||||
|
||||
|
||||
ui_print_page_header (__('Cluster')." » ".__('New'), "images/chart.png", false, "", false, $buttons);
|
||||
|
||||
}
|
||||
elseif ($step == 2) {
|
||||
|
||||
$assign_agents = get_parameter('assign_agents',0);
|
||||
$cluster_agents = get_parameter('id_agents2',null); //abajao en assign
|
||||
|
||||
if($assign_agents){
|
||||
|
||||
$values_cluster_agents = array(
|
||||
'id_cluster' => $id_cluster,
|
||||
'id_agent' => $cluster_agents
|
||||
);
|
||||
|
||||
$agents_preasigned = db_get_all_rows_sql('select id_agent from tcluster_agent where id_cluster ='.$id_cluster);
|
||||
|
||||
foreach ($values_cluster_agents['id_agent'] as $key => $value) {
|
||||
|
||||
$tcluster_agent = db_process_sql('insert into tcluster_agent values ('.$id_cluster.','.$value.')');
|
||||
|
||||
if ($tcluster_agent !== false){
|
||||
db_pandora_audit("Report management", "Agent #$value assigned to cluster #$id_cluster");
|
||||
}
|
||||
else{
|
||||
db_pandora_audit("Report management", "Fail try to assign agent to cluster");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($agents_preasigned as $key => $value) {
|
||||
|
||||
if(!in_array($value['id_agent'],$values_cluster_agents['id_agent'])){
|
||||
$tcluster_agent_delete = db_process_sql('delete from tcluster_agent where id_agent = '.$value['id_agent'].' and id_cluster = '.$id_cluster);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!$update){
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=3&id_cluster=".$id_cluster);
|
||||
}
|
||||
else{
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ui_print_page_header (__('Cluster')." » ".__('New'), "images/chart.png", false, "", false, $buttons);
|
||||
|
||||
}
|
||||
elseif ($step == 3) {
|
||||
|
||||
$assign_modules = get_parameter('assign_modules',0);
|
||||
$cluster_modules = get_parameter('name_modules2',null); //abajao en assign
|
||||
|
||||
if($assign_modules){
|
||||
|
||||
if(!$cluster_modules || $cluster_modules[0] == ''){
|
||||
|
||||
$tcluster_agent_module_delete_id = db_process_sql('delete from tagente_modulo where custom_integer_1 = '.$id_cluster.' and prediction_module = 6');
|
||||
$tcluster_module_delete = db_process_sql('delete from tcluster_item where id_cluster = '.$id_cluster.' and item_type = "AA"');
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
$modules_preasigned = db_get_all_rows_sql('select id,name from tcluster_item where id_cluster ='.$id_cluster);
|
||||
|
||||
foreach ($cluster_modules as $key => $value) {
|
||||
|
||||
$tcluster_module_duplicate_check = db_get_all_rows_sql('select name,id_cluster from tcluster_item where name = "'.$value.'" and id_cluster = '.$id_cluster);
|
||||
|
||||
if($tcluster_module_duplicate_check){
|
||||
continue;
|
||||
}
|
||||
|
||||
// $tcluster_module = db_process_sql('insert into tcluster_item (name,id_cluster,critical_limit,warning_limit) values ("'.$value.'",'.$id_cluster.',100,0)');
|
||||
|
||||
$tcluster_module = db_process_sql_insert('tcluster_item',array('name'=>$value,'id_cluster'=>$id_cluster,'critical_limit'=>100,'warning_limit'=>0));
|
||||
|
||||
$id_agent = db_process_sql('select id_agent from tcluster where id = '.$id_cluster);
|
||||
|
||||
$id_parent_modulo = db_process_sql('select id_agente_modulo from tagente_modulo where id_agente = '.$id_agent[0]['id_agent'].' and nombre = "Cluster status"');
|
||||
|
||||
$get_module_type = db_process_sql('select id_tipo_modulo,descripcion,min_warning,min_critical from tagente_modulo where nombre = "'.$value.'" limit 1');
|
||||
|
||||
$get_module_type_value = $get_module_type[0]['id_tipo_modulo'];
|
||||
|
||||
$get_module_description_value = $get_module_type[0]['descripcion'];
|
||||
|
||||
$get_module_warning_value = $get_module_type[0]['min_warning'];
|
||||
|
||||
$get_module_critical_value = $get_module_type[0]['min_critical'];
|
||||
|
||||
$values_module = array(
|
||||
'nombre' => $value,
|
||||
'id_modulo' => 5,
|
||||
'prediction_module' => 6,
|
||||
'id_agente' => $id_agent[0]['id_agent'],
|
||||
'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'],
|
||||
'custom_integer_1' =>$id_cluster,
|
||||
'custom_integer_2' =>$tcluster_module,
|
||||
'id_tipo_modulo' =>1,
|
||||
'descripcion' => $get_module_description_value,
|
||||
'min_warning' => 0,
|
||||
'min_critical' => 0,
|
||||
'tcp_port' => 1
|
||||
);
|
||||
|
||||
|
||||
$id_module = modules_create_agent_module($values_module['id_agente'],$values_module['nombre'],$values_module);
|
||||
|
||||
// $id_module = db_process_sql_insert('tagente_modulo', $values_module);
|
||||
|
||||
if ($tcluster_module !== false){
|
||||
db_pandora_audit("Report management", "Module #$value assigned to cluster #$id_cluster");
|
||||
}
|
||||
else{
|
||||
db_pandora_audit("Report management", "Fail try to assign module to cluster");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($modules_preasigned as $key => $value) {
|
||||
|
||||
if(!in_array($value['name'],$cluster_modules)){
|
||||
|
||||
$tcluster_agent_module_delete_id = db_process_sql('select id_agente_modulo from tagente_modulo where nombre = "'.$value['name'].'" and custom_integer_1 = '.$id_cluster.' and prediction_module = 6');
|
||||
|
||||
$tcluster_agent_module_delete_id_value = $tcluster_agent_module_delete_id[0]['id_agente_modulo'];
|
||||
|
||||
$tcluster_agent_module_delete_result = modules_delete_agent_module($tcluster_agent_module_delete_id_value);
|
||||
|
||||
$tcluster_module_delete = db_process_sql('delete from tcluster_item where name = "'.$value['name'].'" and id_cluster = '.$id_cluster.' and item_type = "AA"');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!$update){
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=4&id_cluster=".$id_cluster);
|
||||
}
|
||||
else{
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ui_print_page_header (__('Cluster')." » ".__('New'), "images/chart.png", false, "", false, $buttons);
|
||||
|
||||
}
|
||||
elseif ($step == 4) {
|
||||
|
||||
$cluster_items = items_get_cluster_items_id($id_cluster);
|
||||
$assign_limits = get_parameter('assign_limits',0);
|
||||
|
||||
if($assign_limits == 1){
|
||||
|
||||
foreach ($cluster_items as $key => $value) {
|
||||
$critical_values[$value] = get_parameter('critical_item_'.$value,0);
|
||||
$warning_values[$value] = get_parameter('warning_item_'.$value,0);
|
||||
}
|
||||
|
||||
// $get_module_id_limit = db_process_sql('update tagente_modulo set min_critical = '.$value.' where nombre = (select name from tcluster_item where id = '.$key.') and cutom_integer_1 = '.$id_cluster);
|
||||
|
||||
foreach ($critical_values as $key => $value) {
|
||||
$titem_critical_limit = db_process_sql('update tcluster_item set critical_limit = '.$value.' where id = '.$key);
|
||||
|
||||
$get_module_critical_limit = db_process_sql('update tagente_modulo set min_critical = '.$value.' where nombre = (select name from tcluster_item where id = '.$key.') and custom_integer_1 = '.$id_cluster);
|
||||
|
||||
if ($titem_critical_limit !== false){
|
||||
db_pandora_audit("Report management", "Critical limit #$value assigned to item #$key");
|
||||
}
|
||||
else{
|
||||
db_pandora_audit("Report management", "Fail try to assign critical limit to item #$key");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($warning_values as $key => $value) {
|
||||
|
||||
$titem_warning_limit = db_process_sql('update tcluster_item set warning_limit = '.$value.' where id = '.$key);
|
||||
|
||||
$get_module_warning_limit = db_process_sql('update tagente_modulo set min_warning = '.$value.' where nombre = (select name from tcluster_item where id = '.$key.') and custom_integer_1 = '.$id_cluster);
|
||||
|
||||
|
||||
|
||||
|
||||
if ($titem_warning_limit !== false){
|
||||
db_pandora_audit("Report management", "Critical limit #$value assigned to item #$key");
|
||||
}
|
||||
else{
|
||||
db_pandora_audit("Report management", "Fail try to assign warning limit to item #$key");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$cluster_type = clusters_get_cluster_id_type($id_cluster);
|
||||
|
||||
if($cluster_type[$id_cluster] == 'AP' && !$update){
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=5&id_cluster=".$id_cluster);
|
||||
}
|
||||
elseif ($cluster_type[$id_cluster] == 'AA' || $update) {
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ui_print_page_header (__('Cluster')." » ".clusters_get_name($id_cluster), "images/chart.png", false, "", false, $buttons);
|
||||
|
||||
}
|
||||
elseif ($step == 5) {
|
||||
|
||||
$assign_balanced_modules = get_parameter('assign_balanced_modules',0);
|
||||
$balanced_modules = get_parameter('name_modules2',null); //abajao en assign
|
||||
|
||||
if($assign_balanced_modules){
|
||||
|
||||
if(!$balanced_modules || $balanced_modules[0] == ''){
|
||||
|
||||
$tcluster_agent_module_delete_id = db_process_sql('delete from tagente_modulo where custom_integer_1 = '.$id_cluster.' and prediction_module = 7');
|
||||
$tcluster_module_delete = db_process_sql('delete from tcluster_item where id_cluster = '.$id_cluster.' and item_type = "AP"');
|
||||
|
||||
}
|
||||
else{
|
||||
$balanced_modules_preasigned = db_get_all_rows_sql('select id,name,item_type from tcluster_item where id_cluster ='.$id_cluster.' and item_type = "AP"');
|
||||
|
||||
foreach ($balanced_modules as $key => $value) {
|
||||
|
||||
$tcluster_balanced_module_duplicate_check = db_get_all_rows_sql('select name,id_cluster,item_type from tcluster_item where name = "'.$value.'" and id_cluster = '.$id_cluster.' and item_type = "AP"');
|
||||
|
||||
if($tcluster_balanced_module_duplicate_check){
|
||||
continue;
|
||||
}
|
||||
|
||||
$id_agent = db_process_sql('select id_agent from tcluster where id = '.$id_cluster);
|
||||
|
||||
$id_parent_modulo = db_process_sql('select id_agente_modulo from tagente_modulo where id_agente = '.$id_agent[0]['id_agent'].' and nombre = "Cluster status"');
|
||||
|
||||
$tcluster_balanced_module = db_process_sql_insert('tcluster_item',array('name'=>$value,'id_cluster'=>$id_cluster,'item_type'=>"AP"));
|
||||
|
||||
$get_module_type = db_process_sql('select id_tipo_modulo,descripcion,min_warning,min_critical from tagente_modulo where nombre = "'.$value.'" limit 1');
|
||||
|
||||
$get_module_type_value = $get_module_type[0]['id_tipo_modulo'];
|
||||
|
||||
$get_module_description_value = $get_module_type[0]['descripcion'];
|
||||
|
||||
$get_module_warning_value = $get_module_type[0]['min_warning'];
|
||||
|
||||
$get_module_critical_value = $get_module_type[0]['min_critical'];
|
||||
|
||||
$get_module_type_nombre = db_process_sql('select nombre from ttipo_modulo where id_tipo = '.$get_module_type_value);
|
||||
|
||||
$get_module_type_nombre_value = $get_module_type_nombre[0]['nombre'];
|
||||
|
||||
|
||||
if(strpos($get_module_type_nombre_value,'inc') != false){
|
||||
$get_module_type_value_normal = 4;
|
||||
}
|
||||
elseif (strpos($get_module_type_nombre_value,'proc') != false) {
|
||||
$get_module_type_value_normal = 2;
|
||||
}
|
||||
elseif (strpos($get_module_type_nombre_value,'data') != false) {
|
||||
$get_module_type_value_normal = 1;
|
||||
}
|
||||
elseif (strpos($get_module_type_nombre_value,'string') != false) {
|
||||
$get_module_type_value_normal = 3;
|
||||
}
|
||||
else{
|
||||
$get_module_type_value_normal = 1;
|
||||
}
|
||||
|
||||
$values_module = array(
|
||||
'nombre' => $value,
|
||||
'id_modulo' => 5,
|
||||
'prediction_module' => 7,
|
||||
'id_agente' => $id_agent[0]['id_agent'],
|
||||
'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'],
|
||||
'custom_integer_1' => $id_cluster,
|
||||
'custom_integer_2' => $tcluster_balanced_module,
|
||||
'id_tipo_modulo' => $get_module_type_value_normal,
|
||||
'descripcion' => $get_module_description_value,
|
||||
'min_warning' => $get_module_warning_value,
|
||||
'min_critical' => $get_module_critical_value,
|
||||
'tcp_port' => 0
|
||||
);
|
||||
|
||||
// $id_module = db_process_sql_insert('tagente_modulo', $values_module);
|
||||
|
||||
$id_module = modules_create_agent_module($values_module['id_agente'],$values_module['nombre'],$values_module);
|
||||
|
||||
if ($tcluster_balanced_module !== false){
|
||||
db_pandora_audit("Report management", "Module #$value assigned to cluster #$id_cluster");
|
||||
}
|
||||
else{
|
||||
db_pandora_audit("Report management", "Fail try to assign module to cluster");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($balanced_modules_preasigned as $key => $value) {
|
||||
|
||||
if(!in_array($value['name'],$balanced_modules)){
|
||||
|
||||
$tcluster_agent_module_delete_id = db_process_sql('select id_agente_modulo from tagente_modulo where nombre = "'.$value['name'].'" and custom_integer_1 = '.$id_cluster.' and prediction_module = 7');
|
||||
|
||||
$tcluster_agent_module_delete_id_value = $tcluster_agent_module_delete_id[0]['id_agente_modulo'];
|
||||
|
||||
$tcluster_agent_module_delete_result = modules_delete_agent_module($tcluster_agent_module_delete_id_value);
|
||||
|
||||
$tcluster_balanced_module_delete = db_process_sql('delete from tcluster_item where name = "'.$value['name'].'" and id_cluster = '.$id_cluster.' and item_type = "AP"');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!$update){
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=6&id_cluster=".$id_cluster);
|
||||
}
|
||||
else{
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ui_print_page_header (__('Cluster')." » ".clusters_get_name($id_cluster), "images/chart.png", false, "", false, $buttons);
|
||||
|
||||
}
|
||||
elseif ($step == 6) {
|
||||
|
||||
$cluster_items = items_get_cluster_items_id($id_cluster,'AP');
|
||||
$assign_critical = get_parameter('assign_critical',0);
|
||||
|
||||
foreach ($cluster_items as $key => $value) {
|
||||
|
||||
$is_critical_values[$value] = get_parameter('is_critical_item_'.$value,0);
|
||||
}
|
||||
|
||||
if($assign_critical == 1){
|
||||
|
||||
foreach ($is_critical_values as $key => $value) {
|
||||
|
||||
$titem_is_critical = db_process_sql('update tcluster_item set is_critical = '.$value.' where id = '.$key);
|
||||
|
||||
$tagente_modulo_critical = db_process_sql('select id_agente_modulo from tagente_modulo where custom_integer_2 = '.$key);
|
||||
|
||||
$tagente_modulo_update_critical = db_process_sql('update tagente_modulo set tcp_port = '.$value.' where id_agente_modulo = '.$tagente_modulo_critical[0]['id_agente_modulo']);
|
||||
|
||||
if ($titem_is_critical !== false){
|
||||
db_pandora_audit("Report management", "Module #$key critical mode is now $value");
|
||||
}
|
||||
else{
|
||||
db_pandora_audit("Report management", "Fail try to assign critical mode to item #$key");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster);
|
||||
|
||||
}
|
||||
|
||||
ui_print_page_header (__('Cluster')." » ".__('New'), "images/chart.png", false, "", false, $buttons);
|
||||
|
||||
}
|
||||
elseif ($delete_cluster){
|
||||
|
||||
$temp_id_cluster = db_process_sql('select id_agent from tcluster where id ='.$delete_cluster);
|
||||
|
||||
// $tcluster_modules_delete = db_process_sql('delete from tagente_modulo where custom_integer_1 = '.$delete_cluster);
|
||||
|
||||
$tcluster_modules_delete_get = db_process_sql('select id_agente_modulo from tagente_modulo where custom_integer_1 = '.$delete_cluster);
|
||||
|
||||
foreach ($tcluster_modules_delete_get as $key => $value) {
|
||||
$tcluster_modules_delete_get_values[] = $value['id_agente_modulo'];
|
||||
}
|
||||
|
||||
$tcluster_modules_delete = modules_delete_agent_module($tcluster_modules_delete_get_values);
|
||||
|
||||
$tcluster_items_delete = db_process_sql('delete from tcluster_item where id_cluster = '.$delete_cluster);
|
||||
|
||||
$tcluster_agents_delete = db_process_sql('delete from tcluster_agent where id_cluster = '.$delete_cluster);
|
||||
|
||||
$tcluster_delete = db_process_sql('delete from tcluster where id = '.$delete_cluster);
|
||||
|
||||
// $tcluster_agent_delete = db_process_sql('delete from tagente where id_agente = '.$temp_id_cluster[0]['id_agent']);
|
||||
|
||||
$tcluster_agent_delete = agents_delete_agent($temp_id_cluster[0]['id_agent']);
|
||||
|
||||
header ("Location: index.php?sec=reporting&sec2=enterprise/operation/cluster/cluster");
|
||||
}
|
||||
elseif ($delete_module_aa) {
|
||||
|
||||
$delete_module_aa_get = db_process_sql('select id_agente_modulo from tagente_modulo where custom_integer_2 = '.$delete_module_aa);
|
||||
|
||||
$delete_module_aa_get_result = modules_delete_agent_module($delete_module_aa_get[0]['id_agente_modulo']);
|
||||
|
||||
$delete_item = db_process_sql('delete from tcluster_item where id = '.$delete_module_aa);
|
||||
|
||||
if(!$update){
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=4&id_cluster=".$id_cluster);
|
||||
}
|
||||
else{
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=4&id_cluster=".$id_cluster."&update=1");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
elseif($delete_module_ap){
|
||||
|
||||
$delete_module_ap_get = db_process_sql('select id_agente_modulo from tagente_modulo where custom_integer_2 = '.$delete_module_ap);
|
||||
|
||||
$delete_module_ap_get_result = modules_delete_agent_module($delete_module_ap_get[0]['id_agente_modulo']);
|
||||
|
||||
$delete_item = db_process_sql('delete from tcluster_item where id = '.$delete_module_ap);
|
||||
|
||||
if(!$update){
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=6&id_cluster=".$id_cluster);
|
||||
}
|
||||
else{
|
||||
header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=6&id_cluster=".$id_cluster."&update=1");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$active_tab = get_parameter('tab', 'main');
|
||||
|
||||
switch ($active_tab) {
|
||||
case 'main':
|
||||
require_once('godmode/reporting/cluster_builder.main.php');
|
||||
break;
|
||||
}
|
||||
?>
|
|
@ -1,250 +0,0 @@
|
|||
<?php
|
||||
// ______ __ _______ _______ _______
|
||||
//| __ \.---.-.-----.--| |.-----.----.---.-. | ___| | | __|
|
||||
//| __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
//|___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
//
|
||||
// ============================================================================
|
||||
// Copyright (c) 2007-2017 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
// This code is NOT free software. This code is NOT licenced under GPL2 licence
|
||||
// No he usado un cluster en mi vida huliooo.
|
||||
// You cannnot redistribute it without written permission of copyright holder.
|
||||
// ================================
|
||||
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! check_acl ($config['id_user'], 0, "AR")) {
|
||||
db_pandora_audit("ACL Violation", "Trying to access agent main list view");
|
||||
require ("general/noaccess.php");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ui_print_page_header (__('Monitoring')." » ".__('Clusters'), "images/chart.png", false, "", false, $buttons);
|
||||
|
||||
$group_id = (int) get_parameter ("cluster_group_id", 0);
|
||||
$search = trim(get_parameter ("search", ""));
|
||||
$offset = (int)get_parameter('offset', 0);
|
||||
$refr = get_parameter('refr', 0);
|
||||
$recursion = get_parameter('recursion', 0);
|
||||
$status = (int) get_parameter ('status', -1);
|
||||
|
||||
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||
$agent_a = (bool) check_acl ($config['id_user'], 0, "AR");
|
||||
$agent_w = (bool) check_acl ($config['id_user'], 0, "AW");
|
||||
$access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR');
|
||||
|
||||
|
||||
if ($group_id > 0) {
|
||||
$groups = array($group_id);
|
||||
if ($recursion) {
|
||||
$groups = groups_get_id_recursive($group_id, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$groups = array();
|
||||
$user_groups = users_get_groups($config["id_user"], $access);
|
||||
$groups = array_keys($user_groups);
|
||||
}
|
||||
|
||||
$groups_sql = '';
|
||||
|
||||
foreach ($groups as $value) {
|
||||
if ($value === end($groups)) {
|
||||
$groups_sql .= $value;
|
||||
}
|
||||
else{
|
||||
$groups_sql .= $value.',';
|
||||
}
|
||||
}
|
||||
|
||||
if($status == -1){
|
||||
$status = '0,1,2,3,4,5,6';
|
||||
}
|
||||
|
||||
$clusters = db_process_sql('select tcluster.id,tcluster.name,tcluster.cluster_type,tcluster.description,tcluster.group,tcluster.id_agent,tagente_estado.known_status from tcluster
|
||||
INNER JOIN tagente_modulo ON tcluster.id_agent = tagente_modulo.id_agente
|
||||
INNER JOIN tagente_estado ON tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo and tagente_modulo.nombre = "Cluster status"
|
||||
AND `group` in ('.$groups_sql.') and name like "%'.$search.'%" and known_status in ('.$status.')');
|
||||
|
||||
echo '<form method="post" action="?sec=estado&sec2=godmode/reporting/cluster_list">';
|
||||
|
||||
echo '<table cellpadding="4" cellspacing="4" class="databox filters" width="100%" style="font-weight: bold; margin-bottom: 10px;">';
|
||||
|
||||
echo '<tr><td style="white-space:nowrap;">';
|
||||
|
||||
echo __('Group') . ' ';
|
||||
|
||||
$groups = users_get_groups (false, $access);
|
||||
|
||||
html_print_select_groups($config['id_user'], "AR", $groups, "cluster_group_id", $group_id, 'this.form.submit();', '', 0, false, false, true, '', false);
|
||||
|
||||
|
||||
echo '</td><td style="white-space:nowrap;">';
|
||||
|
||||
echo __("Recursion") . ' ';
|
||||
html_print_checkbox ("recursion", 1, $recursion, false, false, 'this.form.submit()');
|
||||
|
||||
echo '</td><td style="white-space:nowrap;">';
|
||||
|
||||
echo __('Search') . ' ';
|
||||
html_print_input_text ("search", $search, '', 15);
|
||||
|
||||
echo '</td><td style="white-space:nowrap;">';
|
||||
|
||||
$fields = array ();
|
||||
$fields[AGENT_STATUS_NORMAL] = __('Normal');
|
||||
$fields[AGENT_STATUS_WARNING] = __('Warning');
|
||||
$fields[AGENT_STATUS_CRITICAL] = __('Critical');
|
||||
$fields[AGENT_STATUS_UNKNOWN] = __('Unknown');
|
||||
$fields[AGENT_STATUS_NOT_INIT] = __('Not init');
|
||||
|
||||
echo __('Status') . ' ';
|
||||
html_print_select ($fields, "status", $status, 'this.form.submit()', __('All'), AGENT_STATUS_ALL, false, false, true, '', false, 'width: 90px;');
|
||||
|
||||
echo '</td>
|
||||
|
||||
<td style="white-space:nowrap;">';
|
||||
|
||||
html_print_submit_button (__('Search'), "srcbutton", '',
|
||||
array ("class" => "sub search"));
|
||||
|
||||
echo '</td><td style="width:5%;"> </td>';
|
||||
|
||||
echo '</tr></table></form>';
|
||||
|
||||
// ui_pagination (count($graphs));
|
||||
|
||||
if($clusters){
|
||||
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox data';
|
||||
$table->align = array ();
|
||||
$table->head = array ();
|
||||
$table->head[0] = __('Cluster name') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=name&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=name&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
$table->head[1] = __('Description') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=description&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=description&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
|
||||
$table->head[2] = __('Group') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=group&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=group&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
|
||||
$table->head[3] = __('Type') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=type&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=type&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
|
||||
|
||||
$table->head[4] = __('Nodes') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=nodes&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=nodes&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
|
||||
$table->head[5] = __('Status') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=status&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=status&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
|
||||
$table->head[6] = __('Actions') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=actions&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=actions&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
|
||||
$table->size[0] = '25%';
|
||||
$table->size[1] = '25%';
|
||||
$table->size[2] = '10%';
|
||||
$table->size[3] = '10%';
|
||||
$table->size[4] = '15%';
|
||||
$table->size[5] = '10%';
|
||||
$table->size[6] = '5%';
|
||||
$table->align[2] = 'left';
|
||||
$table->align[3] = 'left';
|
||||
|
||||
$table->data = array ();
|
||||
|
||||
foreach ($clusters as $cluster) {
|
||||
$data = array ();
|
||||
|
||||
$data[0] = '<a href="index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id='.$cluster["id"].'">'.$cluster["name"].'</a>';
|
||||
$data[1] = ui_print_truncate_text($cluster["description"], 70);
|
||||
|
||||
$data[2] = ui_print_group_icon($cluster['group'],true,'groups_small','',false);
|
||||
|
||||
$data[3] = $cluster["cluster_type"];
|
||||
|
||||
$nodes_cluster = db_process_sql('select count(*) as number from tcluster_agent where id_cluster = '.$cluster['id']);
|
||||
|
||||
$data[4] = $nodes_cluster[0]['number'];
|
||||
|
||||
//agent status - open
|
||||
|
||||
$cluster_agent = db_process_sql('select id_agente from tagente where id_agente = (select id_agent from tcluster where id = '.$cluster['id'].')');
|
||||
|
||||
$cluster_agent_status = agents_get_status($cluster_agent[0]['id_agente']);
|
||||
|
||||
//agent status - close
|
||||
|
||||
|
||||
//cluster module status - open
|
||||
|
||||
$cluster_module = db_process_sql('select id_agente_modulo from tagente_modulo where id_agente = (select id_agent from tcluster where id = '.$cluster['id'].') and nombre = "Cluster status"');
|
||||
|
||||
$cluster_module_status = modules_get_agentmodule_last_status($cluster_module[0]['id_agente_modulo']);
|
||||
|
||||
//cluster module status - close
|
||||
|
||||
switch ($cluster_module_status) {
|
||||
case 1:
|
||||
|
||||
$data[5] = '<div title="'.__('Critical').'" style="width:35px;height:20px;background-color:red;"></div>';
|
||||
|
||||
break;
|
||||
case 2:
|
||||
|
||||
$data[5] = '<div title="'.__('Warning').'" style="width:35px;height:20px;background-color:yellow;"></div>';
|
||||
|
||||
break;
|
||||
case 3:
|
||||
|
||||
$data[5] = '<div title="'.__('Unknown').'" style="width:35px;height:20px;background-color:gray;"></div>';
|
||||
|
||||
break;
|
||||
case 4:
|
||||
|
||||
$data[5] = '<div title="'.__('No data').'" style="width:35px;height:20px;background-color:gray;"></div>';
|
||||
|
||||
break;
|
||||
case 5:
|
||||
|
||||
$data[5] = '<div title="'.__('Not init').'" style="width:35px;height:20px;background-color:blue;"></div>';
|
||||
|
||||
break;
|
||||
case 0:
|
||||
|
||||
$data[5] = '<div title="'.__('Normal').'" style="width:35px;height:20px;background-color:green;"></div>';
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$data[6] = "<a href='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&delete_cluster=".$cluster["id"]."' onclick='javascript: if (!confirm(\"Are you sure to delete?\")) return false;'><img src='images/cross.png'></a>
|
||||
<a href='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&id_cluster=".$cluster["id"]."&step=1&update=1'><img src='images/builder.png'></a>";
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
}
|
||||
|
||||
echo '<form method="post" style="float:right;" action="index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=1">';
|
||||
html_print_submit_button (__('Create cluster'), 'create', false, 'class="sub next" style="margin-right:5px;"');
|
||||
echo "</form>";
|
||||
|
||||
|
||||
?>
|
|
@ -1,136 +0,0 @@
|
|||
<?php
|
||||
|
||||
$name_module = get_parameter('name_module',0);
|
||||
$id_cluster = get_parameter('id_cluster',0);
|
||||
$module_ap = get_parameter('module_ap',0);
|
||||
//
|
||||
// $module_agents = db_process_sql('select id_agente_modulo,id_agente from tagente_modulo where nombre = "'.$name_module.'" and id_agente in
|
||||
// (select id_agent from tcluster_agent where id_cluster = '.$id_cluster.')');
|
||||
//
|
||||
//
|
||||
$module_agents = db_process_sql('select tagente_modulo.id_agente_modulo,tagente_modulo.id_agente,utimestamp from tagente_modulo,tagente_estado where tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo and nombre = "'.$name_module.'" and tagente_modulo.id_agente in
|
||||
(select id_agent from tcluster_agent where id_cluster = '.$id_cluster.') ORDER BY utimestamp DESC');
|
||||
|
||||
// $module_agents = db_process_sql('select id_agente_modulo,id_agente,utimestamp from tagente_modulo,tagente_estado');
|
||||
|
||||
foreach ($module_agents as $key => $value) {
|
||||
$module_agents_value[$module_agents[$key]['id_agente']] = $module_agents[$key]['id_agente_modulo'];
|
||||
}
|
||||
|
||||
|
||||
echo '
|
||||
<table style="width:100%;border:2px black solid" cellpadding="4" cellspacing="4" border="0" class="databox data" id="table2">
|
||||
<thead><tr>
|
||||
<th class="header c0" style="text-align: left;" scope="col">Agent alias</th>
|
||||
<th class="header c1" style="text-align: left;" scope="col">Module name</th>
|
||||
<th class="header c2" style="text-align: left;" scope="col">Status</th>
|
||||
<th class="header c3" style="text-align: left;" scope="col">Data</th>
|
||||
<th class="header c4" style="text-align: left;" scope="col">Graph</th>
|
||||
<th class="header c5" style="text-align: left;" scope="col">Last contact</th>
|
||||
<th id="modal_module_popup_close" onclick="$(\'#modal_module_popup\').css(\'display\',\'none\');" class="header c4" style="text-align: left;" scope="col"><img src="images/icono_cerrar.png"></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
|
||||
';
|
||||
foreach ($module_agents_value as $key => $value) {
|
||||
|
||||
if ($value === reset($module_agents_value) && $module_ap) {
|
||||
echo '<tr style="background-color:#e0eec9;" class="datos2">';
|
||||
}
|
||||
else{
|
||||
echo '<tr class="datos2">';
|
||||
}
|
||||
|
||||
echo '<td style=" text-align:left;" class="datos2 "><a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$key.'" target="_blank">'.agents_get_alias($key).'</a></td>';
|
||||
echo '<td style=" text-align:left;" class="datos2 ">'.modules_get_agentmodule_name($value).'</td>';
|
||||
echo '<td style=" text-align:left;" class="datos2 ">';
|
||||
|
||||
switch (modules_get_agentmodule_last_status($value)) {
|
||||
case 1:
|
||||
|
||||
echo '<img src="images/status_sets/default/module_critical.png" data-title="CRITICAL: '.modules_get_last_value($value).'" data-use_title_for_force_title="1" class="forced_title" alt="CRITICAL: '.modules_get_last_value($value).'">';
|
||||
|
||||
break;
|
||||
case 2:
|
||||
|
||||
echo '<img src="images/status_sets/default/module_warning.png" data-title="WARNING: '.modules_get_last_value($value).'" data-use_title_for_force_title="1" class="forced_title" alt="WARNING: '.modules_get_last_value($value).'">';
|
||||
|
||||
break;
|
||||
case 4:
|
||||
|
||||
echo '<img src="images/status_sets/default/module_no_data.png" data-title="NO DATA: '.modules_get_last_value($value).'" data-use_title_for_force_title="1" class="forced_title" alt="NO DATA: '.modules_get_last_value($value).'">';
|
||||
|
||||
break;
|
||||
case 3:
|
||||
|
||||
echo '<img src="images/status_sets/default/module_unknown.png" data-title="UNKNOWN: '.modules_get_last_value($value).'" data-use_title_for_force_title="1" class="forced_title" alt="UNKNOWN: '.modules_get_last_value($value).'">';
|
||||
|
||||
break;
|
||||
case 5:
|
||||
|
||||
echo '<img src="images/status_sets/default/module_ok.png" data-title="NOT INIT: '.modules_get_last_value($value).'" data-use_title_for_force_title="1" class="forced_title" alt="NOT INIT: '.modules_get_last_value($value).'">';
|
||||
|
||||
break;
|
||||
case 0:
|
||||
|
||||
echo '<img src="images/status_sets/default/module_ok.png" data-title="NORMAL: '.modules_get_last_value($value).'" data-use_title_for_force_title="1" class="forced_title" alt="NORMAL: '.modules_get_last_value($value).'">';
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
echo '</td>';
|
||||
|
||||
echo '<td style=" text-align:left;" class="datos2 ">'.modules_get_last_value($value).'</td>';
|
||||
|
||||
echo '<td style=" text-align:left;" class="datos2 ">';
|
||||
echo '<a href=\'javascript: show_module_detail_dialog('.$value.', '.$key.', "", 0, 86400, "'.modules_get_agentmodule_name($value).'")\'>';
|
||||
echo '<img src="images/binary.png" style="border:0px;" alt="">';
|
||||
echo '</a> ';
|
||||
|
||||
$nombre_tipo_modulo = modules_get_moduletype_name (modules_get_type_id($value));
|
||||
$handle = "stat".$nombre_tipo_modulo."_".$value;
|
||||
$url = 'include/procesos.php?agente='.$value;
|
||||
$win_handle=dechex(crc32($value.modules_get_agentmodule_name($value)));
|
||||
|
||||
if ($graph_type == 'boolean') {
|
||||
$draw_events = 1;
|
||||
} else {
|
||||
$draw_events = 0;
|
||||
}
|
||||
|
||||
$link ="winopeng('" .
|
||||
"operation/agentes/stat_win.php?" .
|
||||
"type=$graph_type&" .
|
||||
"period=" . SECONDS_1DAY . "&" .
|
||||
"id=" . $value . "&" .
|
||||
"label=" . rawurlencode(
|
||||
urlencode(
|
||||
base64_encode($module["nombre"]))) . "&" .
|
||||
"refresh=" . SECONDS_10MINUTES . "&" .
|
||||
"draw_events=$draw_events', 'day_".$win_handle."')";
|
||||
|
||||
echo '<a href="javascript:'.$link.'">';
|
||||
echo '<img src="images/chart_curve.png" style="border:0px;" alt="">';
|
||||
echo '</a>';
|
||||
|
||||
|
||||
echo '</td>';
|
||||
echo '<td style=" text-align:left;" class="datos2 ">'.date("d/m/Y - H:i:s",modules_get_last_contact($value)).'</td>';
|
||||
echo '<td>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>
|
||||
</table>
|
||||
';
|
||||
|
||||
return;
|
||||
|
||||
?>
|
|
@ -1,668 +0,0 @@
|
|||
<?php
|
||||
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! check_acl ($config['id_user'], 0, "AR")) {
|
||||
db_pandora_audit("ACL Violation", "Trying to access agent main list view");
|
||||
require ("general/noaccess.php");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
require_once ('include/functions_agents.php');
|
||||
require_once ('include/functions_modules.php');
|
||||
require_once ('include/functions_clusters.php');
|
||||
require_once ('enterprise/include/functions_clustermap.php');
|
||||
|
||||
$id_cluster = get_parameter('id',0);
|
||||
|
||||
$buttons['list'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster">' .
|
||||
html_print_image("images/list.png", true, array ("title" => __('Clusters list'))) .'</a>');
|
||||
|
||||
|
||||
$buttons['editor'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&id_cluster='.$id_cluster.'&step=1&update=1">' .
|
||||
html_print_image("images/gm_setup.png", true, array ("title" => __('Cluster editor'))) .'</a>');
|
||||
|
||||
|
||||
ui_print_page_header ( __("Cluster detail").' » '.clusters_get_name($id_cluster), "images/agent_mc.png", false, "agent_status", false, $buttons);
|
||||
|
||||
$font_size = 20;
|
||||
$width = "100%";
|
||||
$height = "500";
|
||||
$node_radius = 40;
|
||||
$baseurl = ui_get_full_url(false, false, false, false);
|
||||
|
||||
echo "<table style='width:100%;'>";
|
||||
echo "<tr>";
|
||||
|
||||
$cluster_type = clusters_get_cluster_id_type($id_cluster);
|
||||
|
||||
|
||||
if($cluster_type[$id_cluster] == 'AP'){
|
||||
|
||||
echo "<td style='border:1px solid black;min-width:900px;min-height:500px;vertical-align: top;width:55%;'>";
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
echo "<td style='border:1px solid black;min-width:1200px;min-height:500px;vertical-align: top;width:55%;'>";
|
||||
|
||||
}
|
||||
|
||||
echo "<div id='cluster_map' style='min-width:900px;width:100%;height:500px;'>";
|
||||
echo '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" pointer-events="all" width="' . $width . '" height="' . $height . 'px">';
|
||||
|
||||
echo '</svg></div>';
|
||||
echo "</td>";
|
||||
|
||||
echo "<td style='width:45%;min-width:390px;min-height:500px;vertical-align: top;'>";
|
||||
|
||||
echo "<div style='width:50%;min-width:390px;float:left;'>";
|
||||
|
||||
echo "<div style='float:left;width:100px;margin-left:25px;margin-top:25px;font-size:2em;text-align:center;'>".__('CLUSTER STATUS')."</div>";
|
||||
|
||||
$cluster_module_central = db_process_sql('select id_agente_modulo from tagente_modulo where id_agente = (select id_agent from tcluster where id = '.$id_cluster.') and nombre = "Cluster status"');
|
||||
|
||||
$cluster_module_central_status = modules_get_agentmodule_last_status($cluster_module_central[0]['id_agente_modulo']);
|
||||
|
||||
switch ($cluster_module_central_status) {
|
||||
case 1:
|
||||
|
||||
echo "<div style='border:3px gray groove;float:left;width:100px;margin-left:20px;margin-top:20px;height:50px;'>
|
||||
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:".COL_CRITICAL.";'></div>
|
||||
|
||||
</div>";
|
||||
|
||||
break;
|
||||
case 2:
|
||||
|
||||
echo "<div style='border:3px gray groove;float:left;width:100px;margin-left:20px;margin-top:20px;height:50px;'>
|
||||
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:".COL_WARNING.";'></div>
|
||||
|
||||
</div>";
|
||||
|
||||
break;
|
||||
case 4:
|
||||
|
||||
echo "<div style='border:3px gray groove;float:left;width:100px;margin-left:20px;margin-top:20px;height:50px;'>
|
||||
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:".COL_NOTINIT.";'></div>
|
||||
|
||||
</div>";
|
||||
|
||||
break;
|
||||
case 3:
|
||||
|
||||
echo "<div style='border:3px gray groove;float:left;width:100px;margin-left:20px;margin-top:20px;height:50px;'>
|
||||
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:".COL_UNKNOWN.";'></div>
|
||||
|
||||
</div>";
|
||||
|
||||
break;
|
||||
case 5:
|
||||
|
||||
echo "<div style='border:3px gray groove;float:left;width:100px;margin-left:20px;margin-top:20px;height:50px;'>
|
||||
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:".COL_NOTINIT.";'></div>
|
||||
|
||||
</div>";
|
||||
|
||||
break;
|
||||
case 0:
|
||||
|
||||
echo "<div style='border:3px gray groove;float:left;width:100px;margin-left:20px;margin-top:20px;height:50px;'>
|
||||
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:".COL_NORMAL.";'></div>
|
||||
|
||||
</div>";
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if($cluster_type[$id_cluster] == 'AP'){
|
||||
|
||||
|
||||
echo "<div style='border:1px solid lightgray;float:left;min-width:350px;width:350px;margin-left:20px;margin-right:20px;margin-top:20px;height:200px;margin-bottom:20px;'>";
|
||||
|
||||
echo "<div style='float:left;width:100%;height:25px;background-color:#373737;text-align:center;'><span style='color:#e7e9ea;display:block;margin:5px;font-size:1.5em;'>".__('Balanced modules')."</span></div>";
|
||||
|
||||
echo "<div style='float:left;width:100%;height:175px;text-align:center;overflow-y:auto;overflow-x:hidden;'>";
|
||||
|
||||
$balanced_modules_in = items_get_cluster_items_id_name($id_cluster,'AP',1);
|
||||
|
||||
foreach ($balanced_modules_in as $key => $value) {
|
||||
$cluster_module = db_process_sql('select id_agente_modulo from tagente_modulo where custom_integer_2 = '.$key);
|
||||
|
||||
$cluster_module_status = modules_get_agentmodule_last_status($cluster_module[0]['id_agente_modulo']);
|
||||
|
||||
echo "<div style='float:left;margin-left:20px;margin-top:10px;width:330px;'>";
|
||||
|
||||
if($cluster_module_status == 0){
|
||||
echo '<div class="modal_module_list" style="float:left;" onclick="modal_module(\''.$value.'\','.$id_cluster.',1,event);"><img style="width:18px;height:18px;margin-right:5px;vertical-align:middle;" src="images/exito.png">'.ui_print_truncate_text($value, 40,false).'</div>';
|
||||
}
|
||||
else{
|
||||
echo '<div class="modal_module_list" style="float:left;" onclick="modal_module(\''.$value.'\','.$id_cluster.',1,event);"><img style="width:18px;height:18px;margin-right:5px;vertical-align:middle;" src="images/error_1.png">'.ui_print_truncate_text($value, 40,false).'</div>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo "</div>";
|
||||
|
||||
echo "</div>";
|
||||
|
||||
echo "</div>";
|
||||
|
||||
}
|
||||
// $module_agents = db_process_sql('select tagente_modulo.id_agente_modulo,tagente_modulo.id_agente,utimestamp from tagente_modulo,tagente_estado where tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo and nombre = "CPU Load" and tagente_modulo.id_agente in
|
||||
// (select id_agent from tcluster_agent where id_cluster = 6)');
|
||||
// html_debug($module_agents);
|
||||
|
||||
echo "<div style='width:50%;min-width:390px;max-width:390px;float:left;'>";
|
||||
|
||||
$last_update = db_process_sql('select timestamp,id_agente_modulo from tagente_estado where id_agente_modulo = '.$cluster_module_central[0]['id_agente_modulo']);
|
||||
|
||||
$last_update_value = $last_update[0]['timestamp'];
|
||||
|
||||
$last_update_value_unix = strtotime($last_update_value);
|
||||
|
||||
$last_run_difference = '';
|
||||
|
||||
$diferencia = time() - $last_update_value_unix;
|
||||
|
||||
$last_run_difference_months = 0;
|
||||
$last_run_difference_weeks = 0;
|
||||
$last_run_difference_days = 0;
|
||||
$last_run_difference_minutos = 0;
|
||||
$last_run_difference_seconds = 0;
|
||||
|
||||
while($diferencia >= 2419200){
|
||||
$diferencia -= 2419200;
|
||||
$last_run_difference_months++;
|
||||
}
|
||||
|
||||
while($diferencia >= 604800){
|
||||
$diferencia -= 604800;
|
||||
$last_run_difference_weeks++;
|
||||
}
|
||||
|
||||
while($diferencia >= 86400){
|
||||
$diferencia -= 86400;
|
||||
$last_run_difference_days++;
|
||||
}
|
||||
|
||||
while($diferencia >= 3600){
|
||||
$diferencia -= 3600;
|
||||
$last_run_difference_hours++;
|
||||
}
|
||||
|
||||
while($diferencia >= 60){
|
||||
$diferencia -= 60;
|
||||
$last_run_difference_minutes++;
|
||||
}
|
||||
|
||||
$last_run_difference_seconds = $diferencia;
|
||||
|
||||
if($last_run_difference_months > 0){
|
||||
$last_run_difference .= $last_run_difference_months.'month/s ';
|
||||
}
|
||||
|
||||
if ($last_run_difference_weeks > 0) {
|
||||
$last_run_difference .= $last_run_difference_weeks.' week/s ';
|
||||
}
|
||||
|
||||
if ($last_run_difference_days > 0) {
|
||||
$last_run_difference .= $last_run_difference_days.' day/s ';
|
||||
}
|
||||
|
||||
if ($last_run_difference_hours > 0) {
|
||||
$last_run_difference .= $last_run_difference_hours.' hour/s ';
|
||||
}
|
||||
|
||||
if ($last_run_difference_minutes > 0) {
|
||||
$last_run_difference .= $last_run_difference_minutes.' minute/s ';
|
||||
}
|
||||
|
||||
$last_run_difference .= $last_run_difference_seconds.' second/s ago';
|
||||
|
||||
echo "<div style='float:left;width:100px;px;margin-left:20px;margin-top:25px;font-size:2em;text-align:center;'>".__('LAST UPDATE')."</div>";
|
||||
|
||||
if($cluster_module_central_status == 4){
|
||||
echo "<div style='float:left;width:220px;margin-left:20px;margin-top:40px;font-size:1.5em;text-align:center;'>".__('Not init')."</div>";
|
||||
}else{
|
||||
echo "<div style='float:left;width:220px;margin-left:20px;margin-top:40px;font-size:1.5em;text-align:center;'>".$last_run_difference."</div>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo "<div style='border:1px solid lightgray;float:left;width:350px;margin-left:20px;margin-right:20px;margin-top:20px;height:200px;margin-bottom:20px;'>";
|
||||
|
||||
echo "<div style='float:left;width:100%;height:25px;background-color:#373737;text-align:center;'><span style='color:#e7e9ea;display:block;margin:5px;font-size:1.5em;'>".__('Common modules')."</span></div>";
|
||||
|
||||
echo "<div style='float:left;width:100%;height:175px;text-align:center;overflow-y:auto;overflow-x:hidden;'>";
|
||||
|
||||
$modules_in = items_get_cluster_items_id_name($id_cluster,'AA');
|
||||
|
||||
foreach ($modules_in as $key => $value) {
|
||||
$cluster_module = db_process_sql('select id_agente_modulo from tagente_modulo where custom_integer_2 = '.$key);
|
||||
|
||||
$cluster_module_status = modules_get_agentmodule_last_status($cluster_module[0]['id_agente_modulo']);
|
||||
|
||||
echo "<div style='float:left;margin-left:20px;margin-top:10px;width:330px;'>";
|
||||
|
||||
if($cluster_module_status == 0){
|
||||
echo '<div class="modal_module_list" onclick="modal_module(\''.$value.'\','.$id_cluster.',0,event);" style="float:left;"><img style="width:18px;height:18px;margin-right:5px;vertical-align:middle;" src="images/exito.png">'.ui_print_truncate_text($value, 40,false).'</div>';
|
||||
}
|
||||
else{
|
||||
echo '<div class="modal_module_list" onclick="modal_module(\''.$value.'\','.$id_cluster.',0,event);" style="float:left;"><img style="width:18px;height:18px;margin-right:5px;vertical-align:middle;" src="images/error_1.png">'.ui_print_truncate_text($value, 40,false).'</div>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo "</div>";
|
||||
|
||||
echo "</div>";
|
||||
|
||||
echo "</div>";
|
||||
|
||||
|
||||
echo "<div style='width:100%;height:140px;min-width:390px;max-width:780px;float:left;margin-top:50px;'>";
|
||||
|
||||
$id_agent = db_process_sql('select id_agent from tcluster where id = '.$id_cluster);
|
||||
|
||||
$id_agent_value = $id_agent[0]['id_agent'];
|
||||
|
||||
$table = new stdClass();
|
||||
$table->id = 'agent_details';
|
||||
$table->width = '100%';
|
||||
$table->cellspacing = 0;
|
||||
$table->cellpadding = 0;
|
||||
$table->class = 'agents';
|
||||
$table->style = array_fill(0, 3, 'vertical-align: top;');
|
||||
|
||||
$data = array();
|
||||
$data[0][0] = html_print_table($table_agent, true);
|
||||
$data[0][0] .=
|
||||
'<br /> <table width=90% class="databox agente" style="margin-left:5%;">
|
||||
<tr><th>' .
|
||||
__('Events (24h)') .
|
||||
'</th></tr>' .
|
||||
'<tr><td style="text-align:center;padding-left:20px;padding-right:20px;"><br />' .
|
||||
graph_graphic_agentevents ($id_agent_value, 450, 40, SECONDS_1DAY, '', true, true) .
|
||||
'<br /></td></tr>' .
|
||||
'</table>';
|
||||
|
||||
$table->style[0] = 'width:100%; vertical-align:top;';
|
||||
$data[0][1] = html_print_table($table_contact, true);
|
||||
$data[0][1] .= empty($table_data->data) ?
|
||||
'' :
|
||||
'<br>' . html_print_table($table_data, true);
|
||||
$data[0][1] .= !isset($table_incident) ?
|
||||
'' :
|
||||
'<br>' . html_print_table($table_incident, true);
|
||||
|
||||
$table->rowspan[1][0] = 0;
|
||||
|
||||
$table->data = $data;
|
||||
$table->rowclass[] = '';
|
||||
|
||||
$table->cellstyle[1][0] = 'text-align:center;';
|
||||
|
||||
html_print_table($table);
|
||||
$data2[1][0] = !isset($table_interface) ?
|
||||
'' :
|
||||
html_print_table($table_interface, true);
|
||||
$table->data = $data2;
|
||||
$table->styleTable = '';
|
||||
html_print_table($table);
|
||||
|
||||
unset($table);
|
||||
|
||||
echo "</div>";
|
||||
|
||||
|
||||
echo "</td>";
|
||||
|
||||
echo "</tr>";
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td colspan='2' style='min-width:400px;min-height:600px;vertical-align: top;'>";
|
||||
echo "<div id='module_list' style='min-height:150px;margin-top:20px;'>";
|
||||
echo "</div>";
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
echo "</table>";
|
||||
|
||||
echo "<div id='modal_module_popup' style='position:absolute;'></div>";
|
||||
|
||||
$id_agent = db_process_sql('select id_agent from tcluster where id = '.$id_cluster);
|
||||
|
||||
$id_agent_value = $id_agent[0]['id_agent'];
|
||||
|
||||
|
||||
ui_require_css_file ('cluetip');
|
||||
ui_require_jquery_file ('cluetip');
|
||||
|
||||
echo "<div id='module_details_dialog' style='display: none;'></div>";
|
||||
|
||||
ui_include_time_picker();
|
||||
ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/");
|
||||
|
||||
|
||||
$layout = "fdp";
|
||||
|
||||
$graph = cluster_create_map($layout, $font_size, $zoom , $id_cluster);
|
||||
|
||||
if ($graph === false) {
|
||||
ui_print_error_message (__('Map could not be generated'));
|
||||
echo '<div class="nf">' . __('No agents found') . '</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate image and map
|
||||
// If image was generated just a few minutes ago, then don't regenerate (it takes long) unless regen checkbox is set
|
||||
$filename_map = safe_url_extraclean ($config["attachment_store"])."/cluster_map_" . $config['id_user'];
|
||||
$filename_img = "attachment/cluster_map_" . $config['id_user'];
|
||||
$filename_dot = safe_url_extraclean ($config["attachment_store"])."/cluster_map_" . $config['id_user'];
|
||||
|
||||
$filename_map .= ".map";
|
||||
$filename_img .= ".png";
|
||||
$filename_dot .= ".dot";
|
||||
|
||||
$filename_plain = sys_get_temp_dir() . "/plain.txt";
|
||||
|
||||
file_put_contents($filename_dot, $graph);
|
||||
|
||||
$cmd = "$layout -Tcmapx -o".$filename_map." -Tplain -o".$filename_plain." ".$filename_dot;
|
||||
|
||||
system ($cmd);
|
||||
|
||||
unlink($filename_dot);
|
||||
|
||||
$nodes = cluster_loadfile($filename_plain, $graph, $id_cluster);
|
||||
|
||||
// Colored main node (active-passive)
|
||||
$node_id_agent = array();
|
||||
foreach ($nodes['nodes'] as $key => $node) {
|
||||
if ($node['id'] !== '1') {
|
||||
$node_id_agent[$key] = $node['id_agent'];
|
||||
}
|
||||
}
|
||||
|
||||
$sql_AP = "SELECT am.nombre, am.id_agente_modulo,am.id_agente, am.post_process, ae.datos, ae.estado, ae.utimestamp FROM tagente_modulo am
|
||||
INNER JOIN tagente_estado ae ON am.id_agente_modulo = ae.id_agente_modulo
|
||||
WHERE am.nombre IN (SELECT name FROM tcluster_item WHERE id_cluster = ".$id_cluster." AND item_type like 'AP')
|
||||
AND am.id_agente IN (".implode(",",$node_id_agent).") ORDER BY ae.utimestamp DESC LIMIT 1";
|
||||
|
||||
$modules_AP = db_get_all_rows_sql ($sql_AP);
|
||||
|
||||
foreach ($nodes['nodes'] as $key => $node) {
|
||||
if ($node['id'] !== '1') {
|
||||
if ($node['id_agent'] == $modules_AP[0]['id_agente']) {
|
||||
$nodes['nodes'][$key]['passive'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var controller_map = null;
|
||||
<?php
|
||||
echo "var nodes = " . json_encode($nodes['nodes']) . ";";
|
||||
echo "var arrows = " . json_encode($nodes['arrows']) . ";";
|
||||
echo "var id_cluster = " . json_encode($id_cluster) . ";";
|
||||
echo "var height = " . json_encode($height) . ";";
|
||||
echo "var node_radius = " . json_encode($node_radius) . ";";
|
||||
echo "var font_size = " . json_encode($font_size) . ";";
|
||||
echo "var homedir = " . json_encode($baseurl) . ";";
|
||||
?>
|
||||
</script>
|
||||
<?php
|
||||
|
||||
$requires_js = array();
|
||||
$requires_js[] = "include/javascript/d3.3.5.14.js";
|
||||
$requires_js[] = "enterprise/include/javascript/ClusterMapController.js";
|
||||
$requires_js[] = "enterprise/include/javascript/tooltipster.bundle.min.js";
|
||||
$requires_js[] = "include/javascript/jquery.svg.js";
|
||||
$requires_js[] = "include/javascript/jquery.svgdom.js";
|
||||
|
||||
foreach ($requires_js as $js) {
|
||||
echo "<script type='text/javascript' src='$js'></script>" . "\n";
|
||||
}
|
||||
|
||||
echo '<link rel="stylesheet" type="text/css" href="' . $baseurl . 'enterprise/include/styles/tooltipster.bundle.min.css" />' . "\n";
|
||||
|
||||
?>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
function pagination_list_modules() {
|
||||
var parameters = {};
|
||||
|
||||
parameters["list_modules"] = 1;
|
||||
parameters["id_agente"] = <?php echo $id_agent_value; ?>;
|
||||
parameters["filter_monitors"] = 0;
|
||||
parameters["monitors_change_filter"] = 0;
|
||||
parameters["page"] = "include/ajax/module";
|
||||
|
||||
|
||||
$("#module_list").empty();
|
||||
$("#module_list_loading").show();
|
||||
|
||||
|
||||
jQuery.ajax ({
|
||||
data: parameters,
|
||||
type: 'POST',
|
||||
url: "ajax.php",
|
||||
dataType: 'html',
|
||||
success: function (data) {
|
||||
$("#module_list_loading").hide();
|
||||
|
||||
$("#module_list").empty();
|
||||
$("#module_list").html(data);
|
||||
|
||||
//hide filters
|
||||
|
||||
$('.forced_title[alt=Force]').css('display','none');
|
||||
$('.header a').css('display','none');
|
||||
|
||||
//hide filters
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
$("a.tag_details").cluetip ({
|
||||
arrows: true,
|
||||
clickThrough: false,
|
||||
attribute: 'href',
|
||||
cluetipClass: 'default'
|
||||
});
|
||||
$("a.relations_details").cluetip ({
|
||||
width: 500,
|
||||
arrows: true,
|
||||
clickThrough: false,
|
||||
attribute: 'href',
|
||||
cluetipClass: 'default',
|
||||
sticky: true,
|
||||
mouseOutClose: 'both',
|
||||
closeText: '<?php html_print_image("images/cancel.png") ?>'
|
||||
});
|
||||
|
||||
// Show the modal window of an module
|
||||
function show_module_detail_dialog(module_id, id_agent, server_name, offset, period,module_name) {
|
||||
var server_name = '';
|
||||
var extra_parameters = '';
|
||||
if ($('input[name=selection_mode]:checked').val()) {
|
||||
|
||||
period = $('#period').val();
|
||||
|
||||
var selection_mode = $('input[name=selection_mode]:checked').val();
|
||||
var date_from = $('#text-date_from').val();
|
||||
var time_from = $('#text-time_from').val();
|
||||
var date_to = $('#text-date_to').val();
|
||||
var time_to = $('#text-time_to').val();
|
||||
|
||||
extra_parameters = '&selection_mode=' + selection_mode + '&date_from=' + date_from + '&date_to=' + date_to + '&time_from=' + time_from + '&time_to=' + time_to;
|
||||
}
|
||||
|
||||
// Get the free text in both options
|
||||
var freesearch = $('#text-freesearch').val();
|
||||
if (freesearch != null && freesearch !== '') {
|
||||
var free_checkbox = $('input[name=free_checkbox]:checked').val();
|
||||
extra_parameters += '&freesearch=' + freesearch;
|
||||
if (free_checkbox == 1) {
|
||||
extra_parameters += '&free_checkbox=1';
|
||||
} else {
|
||||
extra_parameters += '&free_checkbox=0';
|
||||
}
|
||||
}
|
||||
|
||||
title = <?php echo "\"" . __("Module: ") . "\"" ?>;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
data: "page=include/ajax/module&get_module_detail=1&server_name="+server_name+"&id_agent="+id_agent+"&id_module=" + module_id+"&offset="+offset+"&period="+period + extra_parameters,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
$(".tooltipster-base").remove();
|
||||
$("#module_details_dialog").hide ()
|
||||
.empty ()
|
||||
.append (data)
|
||||
.dialog ({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
title: title + module_name,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
width: 650,
|
||||
height: 500
|
||||
})
|
||||
.show ();
|
||||
refresh_pagination_callback (module_id, id_agent, "",module_name);
|
||||
datetime_picker_callback();
|
||||
forced_title_callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
function datetime_picker_callback() {
|
||||
|
||||
$("#text-time_from, #text-time_to").timepicker({
|
||||
showSecond: true,
|
||||
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
|
||||
timeOnlyTitle: '<?php echo __('Choose time');?>',
|
||||
timeText: '<?php echo __('Time');?>',
|
||||
hourText: '<?php echo __('Hour');?>',
|
||||
minuteText: '<?php echo __('Minute');?>',
|
||||
secondText: '<?php echo __('Second');?>',
|
||||
currentText: '<?php echo __('Now');?>',
|
||||
closeText: '<?php echo __('Close');?>'});
|
||||
|
||||
$("#text-date_from, #text-date_to").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
|
||||
|
||||
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
|
||||
}
|
||||
datetime_picker_callback();
|
||||
|
||||
function refresh_pagination_callback (module_id, id_agent, server_name,module_name) {
|
||||
$(".binary_dialog").click( function() {
|
||||
|
||||
var classes = $(this).attr('class');
|
||||
classes = classes.split(' ');
|
||||
var offset_class = classes[2];
|
||||
offset_class = offset_class.split('_');
|
||||
var offset = offset_class[1];
|
||||
|
||||
var period = $('#period').val();
|
||||
|
||||
show_module_detail_dialog(module_id, id_agent, server_name, offset, period,module_name);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function modal_module(name,id_cluster,module_ap,event){
|
||||
|
||||
x=event.clientX-550;
|
||||
y=event.clientY-50;
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "ajax.php",
|
||||
data: {"page" : "godmode/reporting/cluster_name_agents",
|
||||
"name_module" : name,
|
||||
"id_cluster" : id_cluster,
|
||||
"module_ap" : module_ap
|
||||
},
|
||||
success: function(data) {
|
||||
|
||||
$('#modal_module_popup').css({'display':'block','width':'600px','left':x+'px','top': y+'px'});
|
||||
|
||||
$('#modal_module_popup').html(data);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$('.tooltip').tooltipster();
|
||||
var controller = null
|
||||
$(function() {
|
||||
controller = new ClusterMapController("#cluster_map");
|
||||
|
||||
controller.init_map();
|
||||
});
|
||||
pagination_list_modules();
|
||||
|
||||
$( ".status_animation" ).css({'height':'5px','top':'0px'});
|
||||
|
||||
$( ".status_animation" ).animate({
|
||||
top: "45px"
|
||||
}, 500, 'linear', function() {
|
||||
|
||||
$( ".status_animation" ).css({'height':'5px','top':'0px'});
|
||||
|
||||
$( ".status_animation" ).animate({
|
||||
top: "45px"
|
||||
}, 500, 'linear', function() {
|
||||
|
||||
$( ".status_animation" ).css({'height':'0px','top':'25px'});
|
||||
|
||||
$( ".status_animation" ).animate({
|
||||
top: "0px",
|
||||
height: "50px"
|
||||
}, 500, 'linear', function() {
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
|
@ -1,331 +0,0 @@
|
|||
<?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 clusters_get_description ($id_cluster, $case = 'none') {
|
||||
$description = (string) db_get_value ('description', 'tcluster', 'id', (int) $id_cluster);
|
||||
|
||||
switch ($case) {
|
||||
case 'upper':
|
||||
return mb_strtoupper($description, 'UTF-8');
|
||||
case 'lower':
|
||||
return mb_strtolower($description, 'UTF-8');
|
||||
case 'none':
|
||||
default:
|
||||
return ($description);
|
||||
}
|
||||
}
|
||||
|
||||
function clusters_get_group ($id_cluster) {
|
||||
$group = (int) db_get_value ('`group`', 'tcluster', 'id', (int) $id_cluster);
|
||||
return ($group);
|
||||
}
|
||||
|
||||
function items_get_name ($id, $case = 'none') {
|
||||
$name = (string) db_get_value ('name', 'tcluster_item', 'id', (int) $id);
|
||||
|
||||
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_alias ($id_cluster){
|
||||
$agents = db_get_all_rows_filter("tcluster_agent", array("id_cluster" => $id_cluster), "id_agent");
|
||||
|
||||
$post_agent = array();
|
||||
|
||||
foreach ($agents as $key => $value) {
|
||||
|
||||
$post_agent[$value['id_agent']] = agents_get_alias($value['id_agent']);
|
||||
}
|
||||
|
||||
return ($post_agent);
|
||||
}
|
||||
|
||||
function agents_get_cluster_agents_id ($id_cluster){
|
||||
$agents = db_get_all_rows_filter("tcluster_agent", array("id_cluster" => $id_cluster), "id_agent");
|
||||
|
||||
$post_agent = array();
|
||||
|
||||
foreach ($agents as $key => $value) {
|
||||
|
||||
$post_agent[] = $value['id_agent'];
|
||||
}
|
||||
|
||||
return ($post_agent);
|
||||
|
||||
}
|
||||
|
||||
// function items_get_cluster_items_id ($id_cluster){
|
||||
// $items = db_get_all_rows_filter("tcluster_item", array("id_cluster" => $id_cluster), array("id"));
|
||||
//
|
||||
// $post_items = array();
|
||||
//
|
||||
// foreach ($items as $key => $value) {
|
||||
//
|
||||
// $post_items[$value['id']] = items_get_name($value['id']);
|
||||
// }
|
||||
//
|
||||
// return ($post_items);
|
||||
// }
|
||||
|
||||
function items_get_cluster_items_id_critical ($id_cluster){
|
||||
$items = db_get_all_rows_filter("tcluster_item", array("id_cluster" => $id_cluster,"item_type" => "AP"), array("id","is_critical"));
|
||||
|
||||
$post_items = array();
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
|
||||
$post_items[$value['id']] = $value['is_critical'];
|
||||
}
|
||||
|
||||
return ($post_items);
|
||||
}
|
||||
|
||||
function items_get_cluster_items_name ($id_cluster,$item_type = 'AA'){
|
||||
$items = db_get_all_rows_filter("tcluster_item", array("id_cluster" => $id_cluster,"item_type" => $item_type), array("name","id"));
|
||||
|
||||
$post_items = array();
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
|
||||
$post_items[$value['name']] = items_get_name($value['id']);
|
||||
}
|
||||
|
||||
return ($post_items);
|
||||
}
|
||||
|
||||
function items_get_cluster_items_id ($id_cluster,$item_type = 'AA'){
|
||||
$items = db_get_all_rows_filter("tcluster_item", array("id_cluster" => $id_cluster,"item_type" => $item_type), array("id"));
|
||||
|
||||
$post_items = array();
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
|
||||
$post_items[] = $value['id'];
|
||||
}
|
||||
|
||||
return ($post_items);
|
||||
}
|
||||
|
||||
function items_get_cluster_items_id_name ($id_cluster,$item_type = 'AA',$is_critical = '%%'){
|
||||
$items = db_get_all_rows_filter("tcluster_item", array("id_cluster" => $id_cluster,"item_type" => $item_type,"is_critical" => $is_critical), array("id"));
|
||||
|
||||
$post_items = array();
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
|
||||
$post_items[$value['id']] = items_get_name($value['id']);
|
||||
}
|
||||
|
||||
return ($post_items);
|
||||
}
|
||||
|
||||
function get_item_critical_limit_by_item_id ($id){
|
||||
|
||||
$critical_limit = (string) db_get_value ('critical_limit', 'tcluster_item', 'id', (int) $id);
|
||||
|
||||
return $critical_limit;
|
||||
}
|
||||
|
||||
function get_item_warning_limit_by_item_id ($id){
|
||||
|
||||
$warning_limit = (string) db_get_value ('warning_limit', 'tcluster_item', 'id', (int) $id);
|
||||
|
||||
return $warning_limit;
|
||||
}
|
||||
|
||||
function clusters_get_cluster_id_type ($id){
|
||||
$clusters = db_get_all_rows_filter("tcluster", array("id" => $id), array("id","cluster_type"));
|
||||
|
||||
$post_clusters = array();
|
||||
|
||||
foreach ($clusters as $key => $value) {
|
||||
|
||||
$post_clusters[$value['id']] = $value['cluster_type'];
|
||||
}
|
||||
|
||||
return ($post_clusters);
|
||||
}
|
||||
|
||||
function clusters_get_user ($id_user = 0, $only_names = false, $returnAllGroup = true, $privileges = 'RR') {
|
||||
global $config;
|
||||
|
||||
if (!$id_user) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
$groups = users_get_groups ($id_user, $privileges, $returnAllGroup);
|
||||
|
||||
$all_clusters = db_get_all_rows_in_table ('tcluster', 'name');
|
||||
if ($all_clusters === false)
|
||||
return array ();
|
||||
|
||||
$clusters = array ();
|
||||
foreach ($all_clusters as $cluster) {
|
||||
if (!in_array($cluster['id_group'], array_keys($groups)))
|
||||
continue;
|
||||
|
||||
if ($cluster["id_user"] != $id_user && $cluster['private'])
|
||||
continue;
|
||||
|
||||
if ($cluster["id_group"] > 0)
|
||||
if (!isset($groups[$cluster["id_group"]])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($only_names) {
|
||||
$clusters[$cluster['id_cluster']] = $cluster['name'];
|
||||
}
|
||||
else {
|
||||
$clusters[$cluster['id_cluster']] = $cluster;
|
||||
$clustersCount = db_get_value_sql("SELECT COUNT(id_gs)
|
||||
FROM tcluster_source
|
||||
WHERE id_cluster = " . $cluster['id_cluster']);
|
||||
$clusters[$cluster['id_cluster']]['clusters_count'] = $clustersCount;
|
||||
}
|
||||
}
|
||||
|
||||
return $clusters;
|
||||
}
|
||||
|
||||
function cluster_get_status ($id_agente){
|
||||
$sql = sprintf("SELECT known_status FROM tagente_estado ae
|
||||
INNER JOIN tagente_modulo am ON ae.id_agente_modulo = am.id_agente_modulo
|
||||
WHERE am.nombre = 'Cluster status' AND am.id_agente = %d",$id_agente);
|
||||
|
||||
$status = db_get_all_rows_sql($sql);
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the worst status of all modules of a given cluster agent.
|
||||
*
|
||||
* @param int Id agent to check.
|
||||
* @param bool Whether the call check ACLs or not
|
||||
*
|
||||
* @return int Worst status of an cluster agent for all of its modules.
|
||||
* The value -1 is returned in case the agent has exceed its interval.
|
||||
*/
|
||||
function cluster_agents_get_status($id_agent = 0, $noACLs = false, $id_cluster = 0) {
|
||||
global $config;
|
||||
|
||||
if (!$noACLs) {
|
||||
$sql_module_cluster = "SELECT am.nombre,am.id_agente_modulo, ae.datos, ae.estado FROM tagente_modulo am
|
||||
INNER JOIN tagente_estado ae ON ae.id_agente_modulo = am.id_agente_modulo
|
||||
WHERE nombre IN (SELECT name FROM tcluster_item WHERE id_cluster = $id_cluster) AND am.id_agente = $id_agent";
|
||||
|
||||
$modules = db_get_all_rows_sql ($sql_module_cluster);
|
||||
}
|
||||
|
||||
if (!isset($modules) || empty($modules) || count($modules) == 0) {
|
||||
return AGENT_MODULE_STATUS_NOT_INIT;
|
||||
}
|
||||
|
||||
$modules_status = array();
|
||||
$modules_async = 0;
|
||||
foreach ($modules as $module) {
|
||||
|
||||
$modules_status[] = $module['estado'];
|
||||
|
||||
$module_type = modules_get_agentmodule_type($module['id_agente_modulo']);
|
||||
if (($module_type >= 21 && $module_type <= 23) || $module_type == 100) {
|
||||
$modules_async++;
|
||||
}
|
||||
}
|
||||
|
||||
// If all the modules are asynchronous or keep alive, the group cannot be unknown
|
||||
if ($modules_async < count($modules)) {
|
||||
$time = get_system_time ();
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$status = db_get_value_filter ('COUNT(*)',
|
||||
'tagente',
|
||||
array ('id_agente' => (int) $id_agent,
|
||||
'UNIX_TIMESTAMP(ultimo_contacto) + intervalo * 2 > '.$time));
|
||||
break;
|
||||
case "postgresql":
|
||||
$status = db_get_value_filter ('COUNT(*)',
|
||||
'tagente',
|
||||
array ('id_agente' => (int) $id_agent,
|
||||
'ceil(date_part(\'epoch\', ultimo_contacto)) + intervalo * 2 > '.$time));
|
||||
break;
|
||||
case "oracle":
|
||||
$status = db_get_value_filter ('count(*)',
|
||||
'tagente',
|
||||
array ('id_agente' => (int) $id_agent,
|
||||
'ceil((to_date(ultimo_contacto, \'YYYY-MM-DD HH24:MI:SS\') - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (' . SECONDS_1DAY . ')) > ' . $time));
|
||||
break;
|
||||
}
|
||||
|
||||
if (! $status)
|
||||
return AGENT_MODULE_STATUS_UNKNOWN;
|
||||
}
|
||||
|
||||
// Checking if any module has alert fired
|
||||
if (is_int(array_search(AGENT_MODULE_STATUS_CRITICAL_ALERT, $modules_status))) {
|
||||
return AGENT_MODULE_STATUS_CRITICAL_ALERT;
|
||||
}
|
||||
// Checking if any module has alert fired
|
||||
elseif (is_int(array_search(AGENT_MODULE_STATUS_WARNING_ALERT, $modules_status))) {
|
||||
return AGENT_MODULE_STATUS_WARNING_ALERT;
|
||||
}
|
||||
// Checking if any module has critical status
|
||||
elseif (is_int(array_search(AGENT_MODULE_STATUS_CRITICAL_BAD, $modules_status))) {
|
||||
return AGENT_MODULE_STATUS_CRITICAL_BAD;
|
||||
}
|
||||
// Checking if any module has critical status
|
||||
elseif (is_int(array_search(AGENT_MODULE_STATUS_NORMAL_ALERT, $modules_status))) {
|
||||
return AGENT_STATUS_ALERT_FIRED;
|
||||
}
|
||||
// Checking if any module has warning status
|
||||
elseif (is_int(array_search(AGENT_MODULE_STATUS_WARNING,$modules_status))) {
|
||||
return AGENT_MODULE_STATUS_WARNING;
|
||||
}
|
||||
// Checking if any module has unknown status
|
||||
elseif (is_int(array_search(AGENT_MODULE_STATUS_UNKNOWN, $modules_status))) {
|
||||
return AGENT_MODULE_STATUS_UNKNOWN;
|
||||
}
|
||||
else {
|
||||
return AGENT_MODULE_STATUS_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
Loading…
Reference in New Issue