2022-10-20 13:17:26 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Cluster View: View
|
|
|
|
*
|
|
|
|
* @category View
|
|
|
|
* @package Pandora FMS
|
|
|
|
* @subpackage Cluster View
|
|
|
|
* @version 1.0.0
|
|
|
|
* @license See below
|
|
|
|
*
|
|
|
|
* ______ ___ _______ _______ ________
|
2023-06-08 12:42:10 +02:00
|
|
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
|
|
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
2022-10-20 13:17:26 +02:00
|
|
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
|
|
|
*
|
|
|
|
* ============================================================================
|
2023-06-08 11:53:13 +02:00
|
|
|
* Copyright (c) 2005-2023 Pandora FMS
|
2023-06-08 13:10:16 +02:00
|
|
|
* Please see http://pandorafms.com/community/ for full contribution list
|
2022-10-20 13:17:26 +02:00
|
|
|
* 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.
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
ui_require_css_file('discovery');
|
|
|
|
ui_require_css_file('agent_view');
|
|
|
|
ui_require_css_file('cluster_view');
|
|
|
|
|
|
|
|
$html = new HTML();
|
|
|
|
|
|
|
|
// Begin.
|
|
|
|
// Prepare header and breadcrums.
|
|
|
|
$i = 0;
|
|
|
|
$bc = [];
|
|
|
|
|
|
|
|
$bc[] = [
|
|
|
|
'link' => $model->url,
|
|
|
|
'label' => __('Cluster list'),
|
|
|
|
'selected' => false,
|
|
|
|
];
|
|
|
|
|
|
|
|
$bc[] = [
|
|
|
|
'link' => $model->url.'&op=view&id='.$cluster->id(),
|
|
|
|
'label' => __('Cluster details'),
|
|
|
|
'selected' => true,
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
$html->prepareBreadcrum($bc);
|
|
|
|
|
|
|
|
// Header.
|
|
|
|
$main_page = '<a href="'.$model->url.'">';
|
|
|
|
$main_page .= html_print_image(
|
2023-03-09 23:31:40 +01:00
|
|
|
'images/logs@svg.svg',
|
2022-10-20 13:17:26 +02:00
|
|
|
true,
|
|
|
|
[
|
|
|
|
'title' => __('Cluster list'),
|
2023-03-09 23:31:40 +01:00
|
|
|
'class' => 'main_menu_icon invert_filter',
|
2022-10-20 13:17:26 +02:00
|
|
|
]
|
|
|
|
);
|
|
|
|
$main_page .= '</a>';
|
|
|
|
|
|
|
|
$edit = '<a href="'.$model->url.'&op=update&id='.$cluster->id().'">';
|
|
|
|
$edit .= html_print_image(
|
2023-03-09 23:31:40 +01:00
|
|
|
'images/configuration@svg.svg',
|
2022-10-20 13:17:26 +02:00
|
|
|
true,
|
|
|
|
[
|
|
|
|
'title' => __('Edit this cluster'),
|
2023-03-09 23:31:40 +01:00
|
|
|
'class' => 'main_menu_icon invert_filter',
|
2022-10-20 13:17:26 +02:00
|
|
|
]
|
|
|
|
);
|
|
|
|
$edit .= '</a>';
|
|
|
|
|
|
|
|
ui_print_page_header(
|
|
|
|
__('Cluster details').' » '.$cluster->name(),
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
// Help link.
|
|
|
|
'cluster_view',
|
|
|
|
true,
|
|
|
|
// Buttons.
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'active' => false,
|
|
|
|
'text' => $main_page,
|
2023-01-11 13:46:15 +01:00
|
|
|
],
|
|
|
|
[
|
2022-10-20 13:17:26 +02:00
|
|
|
'active' => false,
|
|
|
|
'text' => $edit,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
GENERIC_SIZE_TEXT,
|
|
|
|
'',
|
|
|
|
$html->printHeader(true)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($error) === false) {
|
|
|
|
echo $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($message) === false) {
|
|
|
|
echo $message;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($critical === true) {
|
|
|
|
// Print always go back button.
|
|
|
|
HTML::printForm($model->getGoBackForm(), false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* All this block has been retrieved from 'estado_generalagente.php' as
|
|
|
|
* described in issue #5755.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* CLUSTER AGENT DETAILS.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Prepare information for view.
|
|
|
|
$alive_animation = agents_get_status_animation(
|
|
|
|
agents_get_interval_status($cluster->agent()->toArray(), false)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$agent_name = ui_print_agent_name(
|
|
|
|
$cluster->agent()->id_agente(),
|
|
|
|
true,
|
|
|
|
500,
|
|
|
|
'font-size: medium;font-weight:bold',
|
|
|
|
true,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
false
|
|
|
|
);
|
|
|
|
$in_planned_downtime = db_get_sql(
|
|
|
|
'SELECT executed FROM tplanned_downtime
|
|
|
|
INNER JOIN tplanned_downtime_agents
|
|
|
|
ON tplanned_downtime.id = tplanned_downtime_agents.id_downtime
|
|
|
|
WHERE tplanned_downtime_agents.id_agent = '.$cluster->agent()->id_agente().' AND tplanned_downtime.executed = 1'
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($cluster->agent()->disabled()) {
|
|
|
|
if ($in_planned_downtime) {
|
|
|
|
$agent_name = '<em>'.$agent_name.ui_print_help_tip(__('Disabled'), true);
|
|
|
|
} else {
|
|
|
|
$agent_name = '<em>'.$agent_name.'</em>'.ui_print_help_tip(__('Disabled'), true);
|
|
|
|
}
|
|
|
|
} else if ($cluster->agent()->quiet()) {
|
|
|
|
if ($in_planned_downtime) {
|
|
|
|
$agent_name = "<em'>".$agent_name.' '.html_print_image('images/dot_blue.png', true, ['border' => '0', 'title' => __('Quiet'), 'alt' => '']);
|
|
|
|
} else {
|
|
|
|
$agent_name = "<em'>".$agent_name.' '.html_print_image('images/dot_blue.png', true, ['border' => '0', 'title' => __('Quiet'), 'alt' => '']).'</em>';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$agent_name = $agent_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($in_planned_downtime && !$cluster->agent()->disabled() && !$cluster->agent()->quiet()) {
|
|
|
|
$agent_name .= '<em> '.ui_print_help_tip(
|
|
|
|
__('Agent in scheduled downtime'),
|
|
|
|
true,
|
|
|
|
'images/minireloj-16.png'
|
|
|
|
).'</em>';
|
|
|
|
} else if (($in_planned_downtime && !$cluster->agent()->disabled())
|
|
|
|
|| ($in_planned_downtime && !$cluster->agent()->quiet())
|
|
|
|
) {
|
|
|
|
$agent_name .= ' '.ui_print_help_tip(
|
|
|
|
__('Agent in scheduled downtime'),
|
|
|
|
true,
|
2023-03-09 23:31:40 +01:00
|
|
|
'images/clock.svg'
|
2022-10-20 13:17:26 +02:00
|
|
|
).'</em>';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$table_agent_header = '<div class="agent_details_agent_alias">';
|
|
|
|
$table_agent_header .= $agent_name;
|
|
|
|
$table_agent_header .= '</div>';
|
2023-03-16 14:07:12 +01:00
|
|
|
$table_agent_header .= '<div class="agent_details_agent_name mrgn_lft_10px">';
|
2022-10-20 13:17:26 +02:00
|
|
|
if (!$config['show_group_name']) {
|
|
|
|
$table_agent_header .= ui_print_group_icon(
|
|
|
|
$cluster->agent()->id_grupo(),
|
|
|
|
true,
|
|
|
|
'groups_small',
|
|
|
|
'padding-right: 6px;'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table_agent_header .= '</div>';
|
|
|
|
|
|
|
|
$status_img = agents_detail_view_status_img(
|
|
|
|
$cluster->agent()->critical_count(),
|
|
|
|
$cluster->agent()->warning_count(),
|
|
|
|
$cluster->agent()->unknown_count(),
|
|
|
|
$cluster->agent()->total_count(),
|
|
|
|
$cluster->agent()->notinit_count()
|
|
|
|
);
|
|
|
|
|
|
|
|
$table_agent_header .= '<div class="icono_right">'.$status_img.'</div>';
|
|
|
|
$table_agent_header .= ' ';
|
|
|
|
$table_agent_header .= '<a href="'.$model->url.'&op=force&id='.$cluster->id();
|
|
|
|
$table_agent_header .= '">'.html_print_image(
|
2023-03-30 08:43:23 +02:00
|
|
|
'images/force@svg.svg',
|
2022-10-20 13:17:26 +02:00
|
|
|
true,
|
|
|
|
[
|
|
|
|
'title' => __('Force cluster status calculation'),
|
|
|
|
'alt' => '',
|
2023-03-09 23:31:40 +01:00
|
|
|
'class' => 'main_menu_icon invert_filter',
|
2022-10-20 13:17:26 +02:00
|
|
|
|
|
|
|
]
|
|
|
|
).'</a>';
|
|
|
|
// Fixed width non interactive charts.
|
|
|
|
$status_chart_width = 180;
|
|
|
|
$graph_width = 180;
|
|
|
|
|
|
|
|
$table_agent_graph = '<div id="status_pie" style="width: '.$status_chart_width.'px;">';
|
|
|
|
$table_agent_graph .= graph_agent_status(
|
|
|
|
$cluster->agent()->id_agente(),
|
|
|
|
$graph_width,
|
|
|
|
$graph_width,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$table_agent_graph .= '</div>';
|
|
|
|
|
|
|
|
$table_agent_os = '<p>'.ui_print_os_icon(
|
|
|
|
$cluster->agent()->id_os(),
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
['title' => __('OS').': '.get_os_name($cluster->agent()->id_os())]
|
|
|
|
);
|
|
|
|
$table_agent_os .= (empty($cluster->agent()->os_version()) === true) ? get_os_name((int) $cluster->agent()->id_os()) : $cluster->agent()->os_version().'</p>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$addresses = agents_get_addresses($cluster->agent()->id_agente());
|
|
|
|
$address = agents_get_address($cluster->agent()->id_agente());
|
|
|
|
|
|
|
|
foreach ($addresses as $k => $add) {
|
|
|
|
if ($add == $address) {
|
|
|
|
unset($addresses[$k]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($address) === false) {
|
|
|
|
$table_agent_ip = '<p>'.html_print_image(
|
2023-03-09 23:31:40 +01:00
|
|
|
'images/web@groups.svg',
|
2022-10-20 13:17:26 +02:00
|
|
|
true,
|
|
|
|
[
|
|
|
|
'title' => __('IP address'),
|
2023-03-09 23:31:40 +01:00
|
|
|
'class' => 'main_menu_icon invert_filter',
|
2022-10-20 13:17:26 +02:00
|
|
|
]
|
|
|
|
);
|
|
|
|
$table_agent_ip .= '<span class="align-top inline">';
|
|
|
|
$table_agent_ip .= empty($address) ? '<em>'.__('N/A').'</em>' : $address;
|
|
|
|
$table_agent_ip .= '</span></p>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$table_agent_description = '<p>'.html_print_image(
|
2023-03-09 23:31:40 +01:00
|
|
|
'images/logs@svg.svg',
|
2022-10-20 13:17:26 +02:00
|
|
|
true,
|
|
|
|
[
|
|
|
|
'title' => __('Description'),
|
2023-03-09 23:31:40 +01:00
|
|
|
'class' => 'main_menu_icon invert_filter',
|
2022-10-20 13:17:26 +02:00
|
|
|
]
|
|
|
|
);
|
|
|
|
$table_agent_description .= '<span class="align-top inline">';
|
|
|
|
$table_agent_description .= empty(
|
|
|
|
$cluster->description()
|
|
|
|
) ? '<em>'.__('N/A').'</em>' : $cluster->description();
|
|
|
|
$table_agent_description .= '</span></p>';
|
|
|
|
|
|
|
|
$table_agent_count_modules = reporting_tiny_stats(
|
|
|
|
$cluster->agent()->toArray(),
|
|
|
|
true,
|
|
|
|
'agent',
|
|
|
|
// Useless.
|
|
|
|
':',
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
$table_agent_version = '<p>'.html_print_image(
|
|
|
|
'images/version.png',
|
|
|
|
true,
|
|
|
|
[
|
|
|
|
'title' => __('Agent Version'),
|
|
|
|
'class' => 'invert_filter',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$table_agent_version .= '<span class="align-top inline">';
|
|
|
|
$table_agent_version .= empty($cluster->agent()->agent_version()) ? '<i>'.__('Cluster agent').'</i>' : $cluster->agent()->agent_version();
|
|
|
|
$table_agent_version .= '</span></p>';
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* MAP
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
$nodes = $cluster->getNodes();
|
|
|
|
|
|
|
|
$font_size = 20;
|
|
|
|
$width = '45%';
|
|
|
|
$height = '500';
|
|
|
|
$node_radius = 40;
|
|
|
|
|
|
|
|
// Generate map.
|
|
|
|
$map_manager = new NetworkMap(
|
|
|
|
[
|
|
|
|
'nodes' => $nodes,
|
|
|
|
'no_pandora_node' => 1,
|
|
|
|
'pure' => 1,
|
|
|
|
'map_options' => [
|
|
|
|
'generation_method' => LAYOUT_SPRING1,
|
|
|
|
'font_size' => $font_size,
|
|
|
|
'node_radius' => $node_radius,
|
|
|
|
'height' => $height,
|
|
|
|
'width' => '100%',
|
|
|
|
'tooltip' => true,
|
|
|
|
'size_image' => 50,
|
|
|
|
'z_dash' => 0.5,
|
|
|
|
'map_filter' => [
|
|
|
|
'node_sep' => 7,
|
|
|
|
'node_radius' => 50,
|
|
|
|
'x_offs' => 130,
|
|
|
|
'y_offs' => -70,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* EVENTS 24h
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2023-03-15 13:53:23 +01:00
|
|
|
$table_events = '<div class="white_table_graph" id="table_events" style="width:100%">';
|
|
|
|
$table_events .= '<div class="agent_details_header">';
|
|
|
|
$table_events .= '<b><span style="font-size: medium;font-weight:bold">';
|
2022-10-20 13:17:26 +02:00
|
|
|
$table_events .= __('Events (Last 24h)');
|
2023-03-15 13:53:23 +01:00
|
|
|
$table_events .= '</span></b>';
|
2022-10-20 13:17:26 +02:00
|
|
|
$table_events .= '</div>';
|
2023-03-15 13:53:23 +01:00
|
|
|
$table_events .= '<div class="white-table-graph-content">';
|
2022-10-20 13:17:26 +02:00
|
|
|
$table_events .= graph_graphic_agentevents(
|
|
|
|
$cluster->agent()->id_agente(),
|
|
|
|
95,
|
|
|
|
70,
|
|
|
|
SECONDS_1DAY,
|
|
|
|
'',
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
500
|
|
|
|
);
|
|
|
|
$table_events .= '</div>';
|
|
|
|
$table_events .= '</div>';
|
|
|
|
|
|
|
|
?>
|
|
|
|
<div id="agent_details_first_row" class="w100p cluster-agent-data">
|
2023-03-15 13:53:23 +01:00
|
|
|
<div class="flex">
|
|
|
|
<div class="box-flat agent_details_col agent_details_col_left" style="width:50%">
|
|
|
|
<div class="agent_details_header">
|
|
|
|
<?php echo $table_agent_header; ?>
|
2022-10-20 13:17:26 +02:00
|
|
|
</div>
|
2023-03-16 14:10:48 +01:00
|
|
|
<div class="agent_details_content pdd_l_50px">
|
2023-03-15 13:53:23 +01:00
|
|
|
<div class="agent_details_graph">
|
|
|
|
<?php echo $table_agent_graph; ?>
|
|
|
|
<div class="agent_details_bullets">
|
|
|
|
<?php echo $table_agent_count_modules; ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="agent_details_info">
|
|
|
|
<?php
|
|
|
|
echo $alive_animation;
|
|
|
|
echo $table_agent_os;
|
|
|
|
echo $table_agent_ip;
|
|
|
|
echo $table_agent_version;
|
|
|
|
echo $table_agent_description;
|
|
|
|
?>
|
|
|
|
</div>
|
2022-10-20 13:17:26 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-03-15 13:53:23 +01:00
|
|
|
<div class="box-flat agent_details_col" style="width:50%">
|
|
|
|
<?php echo $table_events; ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-14 14:06:51 +01:00
|
|
|
<div class="box-flat agent_details_col agent_details_col_right">
|
2022-10-20 13:17:26 +02:00
|
|
|
<div class="cluster-map">
|
|
|
|
<?php $map_manager->printMap(); ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id='cluster-modules' class="w100p modules">
|
|
|
|
<?php
|
|
|
|
$id_agente = $cluster->agent()->id_agente();
|
|
|
|
require_once $config['homedir'].'/operation/agentes/estado_monitores.php';
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
2023-03-15 13:53:23 +01:00
|
|
|
$buttons[] = html_print_submit_button(
|
|
|
|
__('Reload'),
|
|
|
|
'submit',
|
|
|
|
false,
|
2022-10-20 13:17:26 +02:00
|
|
|
[
|
2023-03-15 13:53:23 +01:00
|
|
|
'class' => 'sub ok',
|
|
|
|
'icon' => 'next',
|
2022-10-20 13:17:26 +02:00
|
|
|
],
|
2023-03-15 13:53:23 +01:00
|
|
|
true
|
2022-10-20 13:17:26 +02:00
|
|
|
);
|
2023-03-15 13:53:23 +01:00
|
|
|
echo '<form action="'.$model->url.'&op=view&id='.$cluster->id().'" method="POST">';
|
|
|
|
html_print_action_buttons(
|
|
|
|
implode('', $buttons),
|
|
|
|
['type' => 'form_action']
|
|
|
|
);
|
|
|
|
echo '</form>';
|
2022-10-20 13:17:26 +02:00
|
|
|
|
|
|
|
// Print always go back button.
|
|
|
|
HTML::printForm($model->getGoBackForm(), false);
|