From e1669ded9d8d73aad703331e92d4ddc7eae61dbf Mon Sep 17 00:00:00 2001 From: enriquecd Date: Thu, 1 Feb 2018 11:35:23 +0100 Subject: [PATCH] Change branch to enterprise - #1748 --- .../general/firts_task/cluster_builder.php | 2 +- .../godmode/reporting/cluster_agent_check.php | 10 - .../reporting/cluster_builder.main.php | 1084 ----------------- .../godmode/reporting/cluster_builder.php | 577 --------- .../godmode/reporting/cluster_list.php | 250 ---- .../godmode/reporting/cluster_name_agents.php | 136 --- .../godmode/reporting/cluster_view.php | 668 ---------- .../include/functions_clusters.php | 331 ----- 8 files changed, 1 insertion(+), 3057 deletions(-) delete mode 100644 pandora_console/godmode/reporting/cluster_agent_check.php delete mode 100644 pandora_console/godmode/reporting/cluster_builder.main.php delete mode 100644 pandora_console/godmode/reporting/cluster_builder.php delete mode 100644 pandora_console/godmode/reporting/cluster_list.php delete mode 100644 pandora_console/godmode/reporting/cluster_name_agents.php delete mode 100644 pandora_console/godmode/reporting/cluster_view.php delete mode 100644 pandora_console/include/functions_clusters.php diff --git a/pandora_console/general/firts_task/cluster_builder.php b/pandora_console/general/firts_task/cluster_builder.php index e0ca22576a..7cc3bdf30d 100644 --- a/pandora_console/general/firts_task/cluster_builder.php +++ b/pandora_console/general/firts_task/cluster_builder.php @@ -40,7 +40,7 @@ ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no cl echo __('Clusters to guarantee service: 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.'); ?>

-
+
diff --git a/pandora_console/godmode/reporting/cluster_agent_check.php b/pandora_console/godmode/reporting/cluster_agent_check.php deleted file mode 100644 index 2060c8d92c..0000000000 --- a/pandora_console/godmode/reporting/cluster_agent_check.php +++ /dev/null @@ -1,10 +0,0 @@ - \ No newline at end of file diff --git a/pandora_console/godmode/reporting/cluster_builder.main.php b/pandora_console/godmode/reporting/cluster_builder.main.php deleted file mode 100644 index a5e2aec8ce..0000000000 --- a/pandora_console/godmode/reporting/cluster_builder.main.php +++ /dev/null @@ -1,1084 +0,0 @@ -'; - -$pure = get_parameter('pure', 0); - -/* Step 1 */ -if ($step == 1) - echo '
  • '; -elseif ($step > 1) - echo '
  • '; -else - echo '
  • '; - -if ($step > 1 && !$update) { - - echo __('Step') . ' 1 » '; - echo '' . __('Cluster settings') . ''; - -} -elseif ($update) { - echo ''; - echo __('Step') . ' 1 » '; - echo '' . __('Cluster settings') . ''; - echo ''; -} -else { - echo __('Step') . ' 1 » '; - echo '' . __('Cluster settings') . ''; -} -echo '
  • '; - - - - - -/* Step 2 */ -if ($step == 2) - echo '
  • '; -elseif ($step > 2) - echo '
  • '; -else - echo '
  • '; - -if ($step > 2 && !$update) { - echo ''; - echo __('Step') . ' 2 » '; - echo '' . __('Cluster agents') . ''; - echo ''; -} -elseif ($update) { - echo ''; - echo __('Step') . ' 2 » '; - echo '' . __('Cluster agents') . ''; - echo ''; -} -else { - echo __('Step') . ' 2 » '; - echo '' . __('Cluster agents') . ''; -} -echo '
  • '; - - - - - - -/* Step 3 */ -if ($step == 3) - echo '
  • '; -elseif ($step > 3) - echo '
  • '; -else - echo '
  • '; - -if ($step > 3 && !$update) { - echo ''; - echo __('Step') . ' 3 » '; - echo '' . __('A/A modules') . ''; - echo ''; -} -elseif ($update) { - echo ''; - echo __('Step') . ' 3 » '; - echo '' . __('A/A modules') . ''; - echo ''; -} -else { - echo __('Step') . ' 3 » '; - echo '' . __('A/A modules') . ''; -} -echo '
  • '; - - - - - - - - -/* Step 3 */ -if ($step == 4) - echo '
  • '; -elseif ($step > 4) - echo '
  • '; -else - echo '
  • '; - -if ($step > 4 && !$update) { - echo ''; - echo __('Step') . ' 4 » '; - echo '' . __('A/A modules limits') . ''; - echo ''; -} -elseif ($update) { - echo ''; - echo __('Step') . ' 4 » '; - echo '' . __('A/A modules limits') . ''; - echo ''; -} -else { - echo __('Step') . ' 4 » '; - echo '' . __('A/A modules limits') . ''; -} -echo '
  • '; - - - - - - - -$type_cluster = clusters_get_cluster_id_type($id_cluster); - -if($type_cluster[$id_cluster] == 'AP'){ - -/* Step 3 */ -if ($step == 5) - echo '
  • '; -elseif ($step > 5) - echo '
  • '; -else - echo '
  • '; - -if ($step > 5 && !$update) { - echo ''; - echo __('Step') . ' 5 » '; - echo '' . __('A/P modules') . ''; - echo ''; -} -elseif ($update) { - echo ''; - echo __('Step') . ' 5 » '; - echo '' . __('A/P modules') . ''; - echo ''; -} -else { - echo __('Step') . ' 5 » '; - echo '' . __('A/P modules') . ''; -} -echo '
  • '; - - - - - - - -/* Step 3 */ -if ($step == 6) - echo '
  • '; -elseif ($step > 6) - echo '
  • '; -else - echo '
  • '; - -if ($step > 6 && !$update) { - echo ''; - echo __('Step') . ' 6 » '; - echo '' . __('Critical A/P modules') . ''; - echo ''; -} -elseif ($update) { - echo ''; - echo __('Step') . ' 6 » '; - echo '' . __('Critical A/P modules') . ''; - echo ''; -} -else { - echo __('Step') . ' 6 » '; - echo '' . __('Critical A/P modules') . ''; -} -echo '
  • '; - - -} - -echo ''; -echo '
    '; - -if($step == 1){ - - if(!$update){ - echo "
    "; - } - else{ - echo ""; - } - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - if(!$update){ - - echo ""; - echo ""; - echo ""; - echo ""; - - } - - echo ""; - echo ""; - echo ""; - echo ""; - - echo ""; - - echo ""; - echo" "; - - echo "
    ".__('Cluster name')."".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).""; - - if(!$update){ - echo " - "; - } - - echo "
    ".__('Cluster type').""; - echo ""; - - $cluster_types = array( - 'AA' => __('Ative - Active'), - 'AP' => __('Active - Pasive') - ); - - html_print_select ($cluster_types, 'cluster_type', 'AA'); - - echo "
    ".__('Description')."
    ".__('Group').""; - if (check_acl ($config['id_user'], 0, "RW")) - echo html_print_select_groups($config['id_user'], 'RW', $return_all_groups, 'cluster_id_group', clusters_get_group($id_cluster), '', '', '', true); - elseif (check_acl ($config['id_user'], 0, "RM")) - echo html_print_select_groups($config['id_user'], 'RM', $return_all_groups, 'cluster_id_group', clusters_get_group($id_cluster), '', '', '', true); - echo "
    "; - - if(!$update){ - echo "
    "; - } - else{ - echo "
    "; - } - echo "
    "; - -} -elseif($step == 2){ - - if(!$update){ - echo "
    "; - } - else{ - echo ""; - } - - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - - echo ""; - - echo ""; - echo ""; - echo ""; - - echo ""; - - echo ""; - echo ""; - echo "
    ".__('Cluster name')."".clusters_get_name($id_cluster)."
    ".__('Adding agents to the cluster')."
    "; - $attr = array('id' => 'select_all_left_agents', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); - echo "" . __('Agents')."  " . html_print_image ('images/tick.png', true, $attr, false, true); - echo ""; - echo ""; - $attr = array('id' => 'select_all_right_agents', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); - echo "" . __('Agents in Cluster')."  " . html_print_image ('images/tick.png', true, $attr, false, true); - echo "
    "; - - $option_style = array(); - $cluster_agents_in = agents_get_cluster_agents_alias($id_cluster); - // $cluster_agents_all = agents_get_group_agents(0, false, ''); - - $cluster_agents_all_pre = db_get_all_rows_sql('select * from tagente where id_os != 21'); - - foreach ($cluster_agents_all_pre as $key => $value) { - $cluster_agents_all[$value['id_agente']] = $value['alias']; - } - - $cluster_agents_out = array_diff_key($cluster_agents_all,$cluster_agents_in); - - html_print_select ($cluster_agents_out, 'id_agents[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - - echo ""; - echo "
    "; - html_print_image ('images/darrowright.png', false, array ('id' => 'agent_right', 'title' => __('Add agents to cluster'))); - echo "


    "; - html_print_image ('images/darrowleft.png', false, array ('id' => 'agent_left', 'title' => __('Drop agents to cluster'))); - echo "


    "; - echo "
    "; - - html_print_select ($cluster_agents_in, 'id_agents2[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - - echo "
    "; - - if(!$update){ - echo "
    "; - } - else{ - echo "
    "; - } - - echo "
    "; - -} -elseif ($step == 3) { - - if(!$update){ - echo "
    "; - } - else{ - echo ""; - } - - - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - - echo ""; - - echo ""; - echo ""; - echo ""; - - echo ""; - - echo ""; - echo ""; - echo "
    ".__('Cluster name')."".clusters_get_name($id_cluster)."
    ".__('Adding common modules').ui_print_help_tip('Attention: the cluster is configured using module names,
    so that in order to add an agent to a cluster later on,
    you will not have to select its modules one by one,
    but instead, you only need to have a series of modules
    that are called the same, so do not rename the names
    of a module once you configure the cluster.', true)."
    "; - $attr = array('id' => 'select_all_left_modules', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); - echo "" . __('Common in agents')."  " . html_print_image ('images/tick.png', true, $attr, false, true); - echo ""; - echo ""; - $attr = array('id' => 'select_all_right_modules', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); - echo "" . __('Added common modules')."  " . html_print_image ('images/tick.png', true, $attr, false, true); - echo "
    "; - - - $cluster_agents_in_id = agents_get_cluster_agents_id($id_cluster); - - $serialize_agents = ''; - - foreach ($cluster_agents_in_id as $value) { - - if ($value === end($cluster_agents_in_id)) { - $serialize_agents .= $value; - } - else{ - $serialize_agents .= $value.','; - } - - } - $cluster_modules_in = items_get_cluster_items_name($id_cluster); - - $cluster_modules_all = db_get_all_rows_sql('select count(nombre) as total ,nombre, id_agente_modulo,id_agente FROM - tagente_modulo where id_agente in ('.$serialize_agents.') group by nombre having total = '.count($cluster_agents_in_id)); - - foreach ($cluster_modules_all as $key => $value) { - $cluster_modules_all_name[$value['nombre']] = $value['nombre']; - } - - $cluster_modules_all_diff = array_diff($cluster_modules_all_name,$cluster_modules_in); - - html_print_select ($cluster_modules_all_diff, 'name_modules[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - - echo ""; - echo "
    "; - html_print_image ('images/darrowright.png', false, array ('id' => 'module_right', 'title' => __('Add modules to cluster'))); - echo "


    "; - html_print_image ('images/darrowleft.png', false, array ('id' => 'module_left', 'title' => __('Drop modules to cluster'))); - echo "


    "; - echo "
    "; - - html_print_select ($cluster_modules_in, 'name_modules2[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - - echo "
    "; - - if(!$update){ - echo "
    "; - } - else{ - echo "
    "; - } - - echo "
    "; - -} -elseif ($step == 4) { - - if(!$update){ - echo "
    "; - } - else{ - echo ""; - } - - - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - $cluster_items = items_get_cluster_items_id_name($id_cluster); - - foreach ($cluster_items as $key => $value) { - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - } - - - echo "
    ".__('Common modules')."".__('Critical if equal or greater than')."".__('Warning if equal or greater than')."".__('Actions')."
    ".$value."   % are down   % are down"; - - if(!$update){ - echo ""; - } - else{ - echo ""; - } - - - echo "
    "; - - if(!$update){ - echo "
    "; - } - else{ - echo "
    "; - } - - echo "
    "; - - if(!$update){ - echo "
    "; - } - else{ - echo ""; - } - - echo "
    "; - - echo "
    "; - -} -elseif ($step == 5) { - - if(!$update){ - echo "
    "; - } - else{ - echo ""; - } - - - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - - echo ""; - - echo ""; - echo ""; - echo ""; - - echo ""; - - echo ""; - echo ""; - echo "
    ".__('Cluster name')."".clusters_get_name($id_cluster)."
    ".__('Adding balanced modules')."
    "; - $attr = array('id' => 'select_all_left_modules', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); - echo "" . __('Modules')."  " . html_print_image ('images/tick.png', true, $attr, false, true); - echo ""; - echo ""; - $attr = array('id' => 'select_all_right_modules', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); - echo "" . __('Added balanced modules')."  " . html_print_image ('images/tick.png', true, $attr, false, true); - echo "
    "; - - - $cluster_agents_in_id = agents_get_cluster_agents_id($id_cluster); - - $serialize_agents = ''; - - foreach ($cluster_agents_in_id as $value) { - - if ($value === end($cluster_agents_in_id)) { - $serialize_agents .= $value; - } - else{ - $serialize_agents .= $value.','; - } - - } - - $balanced_modules_all = db_get_all_rows_sql('select nombre from tagente_modulo where id_agente in ('.$serialize_agents.')'); - - foreach ($balanced_modules_all as $key => $value) { - $balanced_modules_all_name[$value['nombre']] = $value['nombre']; - } - - $balanced_modules_in = items_get_cluster_items_name($id_cluster,'AP'); - - $balanced_modules_all_diff = array_diff($balanced_modules_all_name,$balanced_modules_in); - - html_print_select ($balanced_modules_all_diff, 'name_modules[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - - echo ""; - echo "
    "; - html_print_image ('images/darrowright.png', false, array ('id' => 'module_right', 'title' => __('Add modules to cluster'))); - echo "


    "; - html_print_image ('images/darrowleft.png', false, array ('id' => 'module_left', 'title' => __('Drop modules to cluster'))); - echo "


    "; - echo "
    "; - - html_print_select ($balanced_modules_in, 'name_modules2[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - - echo "
    "; - - if(!$update){ - echo "
    "; - } - else{ - echo "
    "; - } - - - echo "
    "; - -} -elseif ($step == 6) { - - $cluster_agents_in_id = agents_get_cluster_agents_id($id_cluster); - - $serialize_agents = ''; - - foreach ($cluster_agents_in_id as $value) { - - if ($value === end($cluster_agents_in_id)) { - $serialize_agents .= $value; - } - else{ - $serialize_agents .= $value.','; - } - - } - - $balanced_modules_critical = items_get_cluster_items_id_critical($id_cluster); - - if(!$update){ - echo "
    "; - } - else{ - echo ""; - } - - - echo "

    ".__('Balanced modules settings')."

    "; - - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - foreach ($balanced_modules_critical as $key => $value) { - echo ""; - echo ""; - - - if($value){ - echo ""; - } - else{ - echo ""; - } - - if(!$update){ - echo ""; - } - else{ - echo ""; - } - - - echo ""; - - } - - echo "
    ".__('Balanced module')."".__('is critical module')."".__('Actions')."
    ".items_get_name($key)."
    "; - - if(!$update){ - echo "
    "; - } - else{ - echo "
    "; - } - - - echo "
    "; - - if(!$update){ - echo "
    "; - } - else{ - echo ""; - } - - echo "
    "; - - echo "
    "; -} - -?> - - diff --git a/pandora_console/godmode/reporting/cluster_builder.php b/pandora_console/godmode/reporting/cluster_builder.php deleted file mode 100644 index 303d03952f..0000000000 --- a/pandora_console/godmode/reporting/cluster_builder.php +++ /dev/null @@ -1,577 +0,0 @@ - false, - 'text' => '' . - html_print_image("images/list.png", true, array ("title" => __('Clusters list'))) .''); - -if($update){ - - $buttons['view'] = array('active' => false, - 'text' => '' . - html_print_image("images/operation.png", true, array ("title" => __('Cluster view'))) .''); - -} - -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; -} -?> diff --git a/pandora_console/godmode/reporting/cluster_list.php b/pandora_console/godmode/reporting/cluster_list.php deleted file mode 100644 index b80ea49061..0000000000 --- a/pandora_console/godmode/reporting/cluster_list.php +++ /dev/null @@ -1,250 +0,0 @@ - 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 '
    '; - -echo ''; - -echo ' - -'; - -echo '
    '; - -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 ''; - -echo __("Recursion") . ' '; -html_print_checkbox ("recursion", 1, $recursion, false, false, 'this.form.submit()'); - -echo ''; - -echo __('Search') . ' '; -html_print_input_text ("search", $search, '', 15); - -echo ''; - -$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 ''; - -html_print_submit_button (__('Search'), "srcbutton", '', - array ("class" => "sub search")); - -echo ' 
    '; - -// 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') . ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; - $table->head[1] = __('Description') . ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; - - $table->head[2] = __('Group') . ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; - - $table->head[3] = __('Type') . ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; - - - $table->head[4] = __('Nodes') . ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; - - $table->head[5] = __('Status') . ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; - - $table->head[6] = __('Actions') . ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; - - $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] = ''.$cluster["name"].''; - $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] = '
    '; - - break; - case 2: - - $data[5] = '
    '; - - break; - case 3: - - $data[5] = '
    '; - - break; - case 4: - - $data[5] = '
    '; - - break; - case 5: - - $data[5] = '
    '; - - break; - case 0: - - $data[5] = '
    '; - - break; - - default: - - break; - } - - $data[6] = " - "; - - array_push ($table->data, $data); - } - - html_print_table($table); - -} - - echo '
    '; - html_print_submit_button (__('Create cluster'), 'create', false, 'class="sub next" style="margin-right:5px;"'); - echo "
    "; - - -?> \ No newline at end of file diff --git a/pandora_console/godmode/reporting/cluster_name_agents.php b/pandora_console/godmode/reporting/cluster_name_agents.php deleted file mode 100644 index b4b3364aa1..0000000000 --- a/pandora_console/godmode/reporting/cluster_name_agents.php +++ /dev/null @@ -1,136 +0,0 @@ - $value) { - $module_agents_value[$module_agents[$key]['id_agente']] = $module_agents[$key]['id_agente_modulo']; - } - - - echo ' - - - - - - - - - - - - - '; - foreach ($module_agents_value as $key => $value) { - - if ($value === reset($module_agents_value) && $module_ap) { - echo ''; - } - else{ - echo ''; - } - - echo ''; - echo ''; - echo ''; - - echo ''; - - echo ''; - echo ''; - echo ''; - echo ''; - } - - echo ' - -
    Agent aliasModule nameStatusDataGraphLast contact
    '.agents_get_alias($key).''.modules_get_agentmodule_name($value).''; - - switch (modules_get_agentmodule_last_status($value)) { - case 1: - - echo 'CRITICAL: '.modules_get_last_value($value).''; - - break; - case 2: - - echo 'WARNING: '.modules_get_last_value($value).''; - - break; - case 4: - - echo 'NO DATA: '.modules_get_last_value($value).''; - - break; - case 3: - - echo 'UNKNOWN: '.modules_get_last_value($value).''; - - break; - case 5: - - echo 'NOT INIT: '.modules_get_last_value($value).''; - - break; - case 0: - - echo 'NORMAL: '.modules_get_last_value($value).''; - - break; - - default: - - break; - } - - - echo ''.modules_get_last_value($value).''; - echo ''; - echo ''; - echo '   '; - - $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 ''; - echo ''; - echo ''; - - - echo ''.date("d/m/Y - H:i:s",modules_get_last_contact($value)).''; - echo '
    -'; - - return; - -?> \ No newline at end of file diff --git a/pandora_console/godmode/reporting/cluster_view.php b/pandora_console/godmode/reporting/cluster_view.php deleted file mode 100644 index d76e1a241e..0000000000 --- a/pandora_console/godmode/reporting/cluster_view.php +++ /dev/null @@ -1,668 +0,0 @@ - false, - 'text' => '' . - html_print_image("images/list.png", true, array ("title" => __('Clusters list'))) .''); - - -$buttons['editor'] = array('active' => false, - 'text' => '' . - html_print_image("images/gm_setup.png", true, array ("title" => __('Cluster editor'))) .''); - - -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 ""; - echo ""; - - $cluster_type = clusters_get_cluster_id_type($id_cluster); - - - if($cluster_type[$id_cluster] == 'AP'){ - - echo ""; - - echo ""; - - echo ""; - - echo ""; - echo ""; - echo ""; -echo "
    "; - - } - else{ - - echo ""; - - } - - echo "
    "; - echo ''; - - echo '
    '; - echo "
    "; - - echo "
    "; - - echo "
    ".__('CLUSTER STATUS')."
    "; - - $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 "
    - -
    - -
    "; - - break; - case 2: - - echo "
    - -
    - -
    "; - - break; - case 4: - - echo "
    - -
    - -
    "; - - break; - case 3: - - echo "
    - -
    - -
    "; - - break; - case 5: - - echo "
    - -
    - -
    "; - - break; - case 0: - - echo "
    - -
    - -
    "; - - break; - - default: - - break; - } - - - - - if($cluster_type[$id_cluster] == 'AP'){ - - - echo "
    "; - - echo "
    ".__('Balanced modules')."
    "; - - echo "
    "; - - $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 "
    "; - - if($cluster_module_status == 0){ - echo ''; - } - else{ - echo ''; - } - - echo '
    '; - - } - - echo "
    "; - - echo "
    "; - - echo "
    "; - - } - // $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 "
    "; - - $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 "
    ".__('LAST UPDATE')."
    "; - - if($cluster_module_central_status == 4){ - echo "
    ".__('Not init')."
    "; - }else{ - echo "
    ".$last_run_difference."
    "; - } - - - - echo "
    "; - - echo "
    ".__('Common modules')."
    "; - - echo "
    "; - - $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 "
    "; - - if($cluster_module_status == 0){ - echo ''; - } - else{ - echo ''; - } - - echo '
    '; - - } - - echo "
    "; - - echo "
    "; - - echo "
    "; - - - echo "
    "; - - $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] .= - '
    - ' . - '' . - '
    ' . - __('Events (24h)') . - '

    ' . - graph_graphic_agentevents ($id_agent_value, 450, 40, SECONDS_1DAY, '', true, true) . - '
    '; - - $table->style[0] = 'width:100%; vertical-align:top;'; - $data[0][1] = html_print_table($table_contact, true); - $data[0][1] .= empty($table_data->data) ? - '' : - '
    ' . html_print_table($table_data, true); - $data[0][1] .= !isset($table_incident) ? - '' : - '
    ' . 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 "
    "; - - - echo "
    "; - echo "
    "; - echo "
    "; - echo "
    "; - -echo ""; - -$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 ""; - -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 '
    ' . __('No agents found') . '
    '; - 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; - } - } -} - -?> - -" . "\n"; -} - -echo '' . "\n"; - -?> - - \ No newline at end of file diff --git a/pandora_console/include/functions_clusters.php b/pandora_console/include/functions_clusters.php deleted file mode 100644 index 249f4a4fd0..0000000000 --- a/pandora_console/include/functions_clusters.php +++ /dev/null @@ -1,331 +0,0 @@ - $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; - } -} - - - -?> \ No newline at end of file