Merge branch 'ent-9662-second-round' of brutus.artica.es:artica/pandorafms into ent-9662-second-round
This commit is contained in:
commit
f7aab35082
|
@ -301,12 +301,11 @@ function dbmgr_extension_main()
|
|||
if (is_metaconsole() === true) {
|
||||
// This adds a option in the operation menu.
|
||||
extensions_add_meta_menu_option(
|
||||
'DB interface',
|
||||
__('DB interface'),
|
||||
'PM',
|
||||
'gextensions',
|
||||
'database.png',
|
||||
'v1r1',
|
||||
'gdbman'
|
||||
'v1r1'
|
||||
);
|
||||
|
||||
extensions_add_meta_function('dbmgr_extension_main');
|
||||
|
|
|
@ -897,8 +897,9 @@ if ($tab == 'tree') {
|
|||
$table->data = [];
|
||||
|
||||
foreach ($groups as $key => $group) {
|
||||
$url = 'index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group='.$group['id_grupo'];
|
||||
if (is_metaconsole() === true) {
|
||||
$url_edit = 'index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group='.$group['id_grupo'];
|
||||
$url_tactical = 'index.php?sec=gagente&sec2=godmode/groups/tactical&id_group='.$group['id_grupo'];
|
||||
if (is_metaconsole()) {
|
||||
$url_delete = 'index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group='.$group['id_grupo'].'&tab=groups';
|
||||
} else {
|
||||
$url_delete = 'index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group='.$group['id_grupo'];
|
||||
|
@ -906,7 +907,7 @@ if ($tab == 'tree') {
|
|||
|
||||
$table->data[$key][0] = $group['id_grupo'];
|
||||
if ($is_management_allowed === true) {
|
||||
$table->data[$key][1] = '<a href="'.$url.'">'.$group['nombre'].'</a>';
|
||||
$table->data[$key][1] = '<a href="'.$url_tactical.'">'.$group['nombre'].'</a>';
|
||||
} else {
|
||||
$table->data[$key][1] = $group['nombre'];
|
||||
}
|
||||
|
@ -937,7 +938,7 @@ if ($tab == 'tree') {
|
|||
$table->data[$key][5] = $group['description'];
|
||||
if ($is_management_allowed === true) {
|
||||
$table->cellclass[$key][6] = 'table_action_buttons';
|
||||
$table->data[$key][6] = '<a href="'.$url.'">'.html_print_image(
|
||||
$table->data[$key][6] = '<a href="'.$url_edit.'">'.html_print_image(
|
||||
'images/edit.svg',
|
||||
true,
|
||||
[
|
||||
|
@ -961,9 +962,9 @@ if ($tab == 'tree') {
|
|||
'images/delete.svg',
|
||||
true,
|
||||
[
|
||||
'alt' => __('Delete'),
|
||||
'title' => __('Delete'),
|
||||
'border' => '0',
|
||||
'alt' => __('Delete'),
|
||||
'title' => __('Delete'),
|
||||
'class' => 'main_menu_icon invert_filter',
|
||||
]
|
||||
).'</a>';
|
||||
}
|
||||
|
|
|
@ -0,0 +1,248 @@
|
|||
<?php
|
||||
/**
|
||||
* Group tactic view.
|
||||
*
|
||||
* @category Group Tactic View
|
||||
* @package Pandora FMS
|
||||
* @subpackage Opensource
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 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, 'AR')) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access Tactical View Group'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$id_group = get_parameter('id_group', '');
|
||||
if (empty($id_group) === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
$user_groups_acl = users_get_groups(false, 'AR');
|
||||
if (in_array(groups_get_name($id_group), $user_groups_acl) === false) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access Tactical View Group'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_metaconsole() === false) {
|
||||
// Header.
|
||||
ui_print_standard_header(
|
||||
__(groups_get_name($id_group)),
|
||||
'images/group.png',
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
[],
|
||||
[
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Monitoring'),
|
||||
],
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Tactic group'),
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
ui_require_css_file('tactical_groups');
|
||||
ui_require_javascript_file('tactical_groups');
|
||||
$groups = groups_get_children($id_group);
|
||||
$id_groups = [];
|
||||
if (count($groups) > 0) {
|
||||
foreach ($groups as $key => $value) {
|
||||
$id_groups[] = $value['id_grupo'];
|
||||
}
|
||||
} else {
|
||||
$id_groups[] = $id_group;
|
||||
}
|
||||
|
||||
|
||||
echo '<div id="tactic_view">';
|
||||
echo '<table style="width: 100%;">';
|
||||
echo '<tr>';
|
||||
echo '<td class="tactical_group_left_column">';
|
||||
$table_col1 = new stdClass();
|
||||
$table_col1->class = 'no-class';
|
||||
$table_col1->data = [];
|
||||
$table_col1->rowclass[] = '';
|
||||
$table_col1->headstyle[0] = 'text-align:center;';
|
||||
$table_col1->width = '100%';
|
||||
$table_col1->data[0][0] = groups_get_heat_map_agents($id_groups, 450, 100);
|
||||
$table_col1->data[1][0] = tactical_groups_get_agents_and_monitoring($id_groups);
|
||||
|
||||
$distribution_by_so = '<table cellpadding=0 cellspacing=0 class="databox pies graph-distribution-so" width=100%><tr><td style="width:50%;">';
|
||||
$distribution_by_so .= '<fieldset class="padding-0 databox tactical_set" id="distribution_by_so_graph">';
|
||||
$distribution_by_so .= '<legend>'.__('Distribution by os').'</legend>';
|
||||
$distribution_by_so .= html_print_image('images/spinner.gif', true, ['id' => 'spinner_distribution_by_so_graph']);
|
||||
$distribution_by_so .= '</fieldset>';
|
||||
$distribution_by_so .= '</td></tr></table>';
|
||||
|
||||
|
||||
$table_col1->data[2][0] = $distribution_by_so;
|
||||
|
||||
|
||||
ui_toggle(
|
||||
html_print_table($table_col1, true),
|
||||
__('Monitoring'),
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
echo '</td>';
|
||||
echo '<td class="tactical_group_left_column">';
|
||||
$table_col2 = new stdClass();
|
||||
$table_col2->class = 'no-class';
|
||||
$table_col2->data = [];
|
||||
$table_col2->rowclass[] = '';
|
||||
$table_col2->headstyle[0] = 'text-align:center;';
|
||||
$table_col2->width = '100%';
|
||||
$table_col2->data[0][0] = tactical_groups_get_stats_alerts($id_groups);
|
||||
$table_col2->data[1][0] = groups_get_stats_modules_status($id_groups);
|
||||
|
||||
$events_by_agents_group = '<table cellpadding=0 cellspacing=0 class="databox pies mrgn_top_15px" width=100%><tr><td style="width:50%;">';
|
||||
$events_by_agents_group .= '<fieldset class="padding-0 databox tactical_set" id="events_by_agents_group_graph">';
|
||||
$events_by_agents_group .= '<legend>'.__('Events by agent').'</legend>';
|
||||
$events_by_agents_group .= html_print_image('images/spinner.gif', true, ['id' => 'spinner_events_by_agents_group_graph']);
|
||||
$events_by_agents_group .= '</fieldset>';
|
||||
$events_by_agents_group .= '</td></tr></table>';
|
||||
|
||||
|
||||
$table_col2->data[2][0] = $events_by_agents_group;
|
||||
ui_toggle(
|
||||
html_print_table($table_col2, true),
|
||||
__('Alerts and events'),
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
false
|
||||
);
|
||||
echo '</td>';
|
||||
echo '<td class="tactical_group_right_column">';
|
||||
$table_col3 = new stdClass();
|
||||
$table_col3->class = 'no-class';
|
||||
$table_col3->data = [];
|
||||
$table_col3->rowclass[] = '';
|
||||
$table_col3->headstyle[0] = 'text-align:center;';
|
||||
$table_col3->width = '100%';
|
||||
|
||||
try {
|
||||
$columns = [
|
||||
'alias',
|
||||
'status',
|
||||
'alerts',
|
||||
'ultimo_contacto_remoto',
|
||||
];
|
||||
|
||||
$columnNames = [
|
||||
__('Alias'),
|
||||
__('Status'),
|
||||
__('Alerts'),
|
||||
__('Ultimo contacto remoto'),
|
||||
];
|
||||
|
||||
// Load datatables user interface.
|
||||
$table_col3->data[3][0] = ui_print_datatable(
|
||||
[
|
||||
'id' => 'list_agents_tactical',
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $columnNames,
|
||||
'return' => true,
|
||||
'ajax_url' => 'include/ajax/group',
|
||||
'ajax_data' => [
|
||||
'method' => 'getAgentsByGroup',
|
||||
'id_group' => $id_group,
|
||||
],
|
||||
'no_sortable_columns' => [-1],
|
||||
'order' => [
|
||||
'field' => 'alias',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
ui_toggle(
|
||||
html_print_table($table_col3, true),
|
||||
__('Agents'),
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
false
|
||||
);
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
echo '<div id="modal-info-agent"></div>'
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
var parameters = {};
|
||||
parameters["page"] = "include/ajax/group";
|
||||
parameters["method"] = 'distributionBySoGraph';
|
||||
parameters["id_group"] = <?php echo $id_group; ?>;
|
||||
|
||||
$.ajax({type: "GET",url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",data: parameters,
|
||||
success: function(data) {
|
||||
$("#spinner_distribution_by_so_graph").hide();
|
||||
$("#distribution_by_so_graph").append(data);
|
||||
}
|
||||
});
|
||||
|
||||
parameters["method"] = 'groupEventsByAgent';
|
||||
$.ajax({type: "GET",url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",data: parameters,
|
||||
success: function(data) {
|
||||
$("#spinner_events_by_agents_group_graph").hide();
|
||||
$("#events_by_agents_group_graph").append(data);
|
||||
const canvas = $('#events_by_agents_group_graph canvas')[0];
|
||||
canvas.addEventListener('click', function(event) {
|
||||
var middle_canvas = $('#events_by_agents_group_graph canvas').width() / 2;
|
||||
if(event.layerX < middle_canvas){
|
||||
window.location.replace("index.php?sec=eventos&sec2=operation/events/events&filter[id_group_filter]=<?php echo $id_group; ?>")
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
|
@ -5339,3 +5339,199 @@ function get_baseline_data(
|
|||
$result['agent_alias'] = $array_data[0]['sum0']['agent_alias'];
|
||||
return ['sum0' => $result];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw graph SO agents by group.
|
||||
*
|
||||
* @param [type] $id_group
|
||||
* @param integer $width
|
||||
* @param integer $height
|
||||
* @param boolean $recursive
|
||||
* @param boolean $noWaterMark
|
||||
* @return string Graph
|
||||
*/
|
||||
function graph_so_by_group($id_group, $width=300, $height=200, $recursive=true, $noWaterMark=true)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$id_groups = [$id_group];
|
||||
|
||||
if ($recursive == true) {
|
||||
$groups = groups_get_children($id_group);
|
||||
if (count($groups) > 0) {
|
||||
$id_groups = [];
|
||||
foreach ($groups as $key => $value) {
|
||||
$id_groups[] = $value['id_grupo'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT COUNT(id_agente) AS count,
|
||||
os.name
|
||||
FROM tagente a
|
||||
LEFT JOIN tconfig_os os ON a.id_os = os.id_os
|
||||
WHERE a.id_grupo IN (%s)
|
||||
GROUP BY os.id_os',
|
||||
implode(',', $id_groups)
|
||||
);
|
||||
|
||||
$result = db_get_all_rows_sql($sql, false, false);
|
||||
if ($result === false) {
|
||||
$result = [];
|
||||
}
|
||||
|
||||
$labels = [];
|
||||
$data = [];
|
||||
foreach ($result as $key => $row) {
|
||||
$labels[] = $row['name'];
|
||||
$data[] = $row['count'];
|
||||
}
|
||||
|
||||
if ($noWaterMark === true) {
|
||||
$water_mark = [
|
||||
'file' => $config['homedir'].'/images/logo_vertical_water.png',
|
||||
'url' => ui_get_full_url('images/logo_vertical_water.png', false, false, false),
|
||||
];
|
||||
} else {
|
||||
$water_mark = [];
|
||||
}
|
||||
|
||||
$options = [
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'waterMark' => $water_mark,
|
||||
'legend' => [
|
||||
'display' => true,
|
||||
'position' => 'right',
|
||||
'align' => 'center',
|
||||
],
|
||||
'labels' => $labels,
|
||||
];
|
||||
|
||||
return pie_graph(
|
||||
$data,
|
||||
$options
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw graph events by group
|
||||
*
|
||||
* @param [type] $id_group
|
||||
* @param integer $width
|
||||
* @param integer $height
|
||||
* @param boolean $noWaterMark
|
||||
* @param boolean $time_limit
|
||||
* @param boolean $recursive
|
||||
* @return string Graph
|
||||
*/
|
||||
function graph_events_agent_by_group($id_group, $width=300, $height=200, $noWaterMark=true, $time_limit=false, $recursive=true)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$data = [];
|
||||
$labels = [];
|
||||
$loop = 0;
|
||||
define('NUM_PIECES_PIE_2', 6);
|
||||
|
||||
// Add tags condition to filter.
|
||||
$tags_condition = '';
|
||||
if ($time_limit && $config['event_view_hr']) {
|
||||
$tags_condition .= ' AND utimestamp > (UNIX_TIMESTAMP(NOW()) - '.($config['event_view_hr'] * SECONDS_1HOUR).')';
|
||||
}
|
||||
|
||||
$id_groups = [$id_group];
|
||||
if ($recursive === true) {
|
||||
$groups = groups_get_children($id_group);
|
||||
if (count($groups) > 0) {
|
||||
$id_groups = [];
|
||||
foreach ($groups as $key => $value) {
|
||||
$id_groups[] = $value['id_grupo'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$filter_groups = ' AND te.id_grupo IN ('.implode(',', $id_groups).') ';
|
||||
|
||||
// This will give the distinct id_agente, give the id_grupo that goes
|
||||
// with it and then the number of times it occured. GROUP BY statement
|
||||
// is required if both DISTINCT() and COUNT() are in the statement.
|
||||
$sql = sprintf(
|
||||
'SELECT DISTINCT(id_agente) AS id_agente,
|
||||
COUNT(id_agente) AS count
|
||||
FROM tevento te
|
||||
WHERE 1=1 AND estado = 0
|
||||
%s %s
|
||||
GROUP BY id_agente
|
||||
ORDER BY count DESC LIMIT 8',
|
||||
$tags_condition,
|
||||
$filter_groups
|
||||
);
|
||||
$result = db_get_all_rows_sql($sql, false, false);
|
||||
if ($result === false) {
|
||||
$result = [];
|
||||
}
|
||||
|
||||
$system_events = 0;
|
||||
$other_events = 0;
|
||||
|
||||
foreach ($result as $row) {
|
||||
$row['id_grupo'] = agents_get_agent_group($row['id_agente']);
|
||||
if (!check_acl($config['id_user'], $row['id_grupo'], 'ER') == 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($loop >= NUM_PIECES_PIE_2) {
|
||||
$other_events += $row['count'];
|
||||
} else {
|
||||
if ($row['id_agente'] == 0) {
|
||||
$system_events += $row['count'];
|
||||
} else {
|
||||
$alias = agents_get_alias($row['id_agente']);
|
||||
$name = mb_substr($alias, 0, 25).' #'.$row['id_agente'].' ('.$row['count'].')';
|
||||
$labels[] = io_safe_output($name);
|
||||
$data[] = $row['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$loop++;
|
||||
}
|
||||
|
||||
if ($system_events > 0) {
|
||||
$name = __('SYSTEM').' ('.$system_events.')';
|
||||
$labels[] = io_safe_output($name);
|
||||
$data[] = $system_events;
|
||||
}
|
||||
|
||||
// Sort the data.
|
||||
arsort($data);
|
||||
if ($noWaterMark === true) {
|
||||
$water_mark = [
|
||||
'file' => $config['homedir'].'/images/logo_vertical_water.png',
|
||||
'url' => ui_get_full_url('images/logo_vertical_water.png', false, false, false),
|
||||
];
|
||||
} else {
|
||||
$water_mark = [];
|
||||
}
|
||||
|
||||
$options = [
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'waterMark' => $water_mark,
|
||||
'legend' => [
|
||||
'display' => true,
|
||||
'position' => 'right',
|
||||
'align' => 'center',
|
||||
],
|
||||
'labels' => $labels,
|
||||
];
|
||||
|
||||
return pie_graph(
|
||||
$data,
|
||||
$options
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1276,7 +1276,7 @@ function groups_get_not_init_agents($group, $agent_filter=[], $module_filter=[],
|
|||
*
|
||||
* @return integer Number of monitors.
|
||||
*/
|
||||
function groups_get_monitors_counter($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false)
|
||||
function groups_get_monitors_counter($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true)
|
||||
{
|
||||
if (empty($group)) {
|
||||
return 0;
|
||||
|
@ -1291,7 +1291,11 @@ function groups_get_monitors_counter($group, $agent_filter=[], $module_filter=[]
|
|||
}
|
||||
|
||||
$group_str = implode(',', $groups);
|
||||
$groups_clause = "AND (ta.id_grupo IN ($group_str) OR tasg.id_group IN ($group_str))";
|
||||
if ($secondary_group === true) {
|
||||
$groups_clause = "AND (ta.id_grupo IN ($group_str) OR tasg.id_group IN ($group_str))";
|
||||
} else {
|
||||
$groups_clause = "AND (ta.id_grupo IN ($group_str))";
|
||||
}
|
||||
|
||||
$tags_clause = '';
|
||||
|
||||
|
@ -1401,10 +1405,12 @@ function groups_get_monitors_counter($group, $agent_filter=[], $module_filter=[]
|
|||
ON tam.id_agente_modulo = tae.id_agente_modulo
|
||||
$modules_clause
|
||||
INNER JOIN tagente ta
|
||||
ON tam.id_agente = ta.id_agente
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
AND ta.disabled = 0
|
||||
ON tam.id_agente = ta.id_agente";
|
||||
if ($secondary_group === true) {
|
||||
$sql .= ' LEFT JOIN tagent_secondary_group tasg ON ta.id_agente = tasg.id_agent';
|
||||
}
|
||||
|
||||
$sql .= "AND ta.disabled = 0
|
||||
$agent_name_filter
|
||||
$agents_clause
|
||||
WHERE tam.disabled = 0
|
||||
|
@ -1450,8 +1456,9 @@ function groups_get_monitors_counter($group, $agent_filter=[], $module_filter=[]
|
|||
}
|
||||
|
||||
$status_columns_str = implode(',', $status_columns_array);
|
||||
$status_columns_str_sum = implode('+', $status_columns_array);
|
||||
|
||||
$sql = "SELECT SUM($status_columns_str) FROM
|
||||
$sql = "SELECT SUM($status_columns_str_sum) FROM
|
||||
(SELECT DISTINCT(ta.id_agente), $status_columns_str
|
||||
FROM tagente ta LEFT JOIN tagent_secondary_group tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
|
@ -1486,11 +1493,11 @@ function groups_get_monitors_counter($group, $agent_filter=[], $module_filter=[]
|
|||
*
|
||||
* @return integer Number of monitors.
|
||||
*/
|
||||
function groups_get_total_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false)
|
||||
function groups_get_total_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true)
|
||||
{
|
||||
// Always modify the module status filter
|
||||
$module_filter['status'] = AGENT_MODULE_STATUS_ALL;
|
||||
return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime);
|
||||
return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime, $secondary_group);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1511,11 +1518,11 @@ function groups_get_total_monitors($group, $agent_filter=[], $module_filter=[],
|
|||
*
|
||||
* @return integer Number of monitors.
|
||||
*/
|
||||
function groups_get_normal_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false)
|
||||
function groups_get_normal_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true)
|
||||
{
|
||||
// Always modify the module status filter
|
||||
$module_filter['status'] = AGENT_MODULE_STATUS_NORMAL;
|
||||
return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime);
|
||||
return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime, $secondary_group);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1536,11 +1543,11 @@ function groups_get_normal_monitors($group, $agent_filter=[], $module_filter=[],
|
|||
*
|
||||
* @return integer Number of monitors.
|
||||
*/
|
||||
function groups_get_critical_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false)
|
||||
function groups_get_critical_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true)
|
||||
{
|
||||
// Always modify the module status filter
|
||||
$module_filter['status'] = AGENT_MODULE_STATUS_CRITICAL_BAD;
|
||||
return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime);
|
||||
return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime, $secondary_group);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1561,11 +1568,11 @@ function groups_get_critical_monitors($group, $agent_filter=[], $module_filter=[
|
|||
*
|
||||
* @return integer Number of monitors.
|
||||
*/
|
||||
function groups_get_warning_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false)
|
||||
function groups_get_warning_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true)
|
||||
{
|
||||
// Always modify the module status filter
|
||||
$module_filter['status'] = AGENT_MODULE_STATUS_WARNING;
|
||||
return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime);
|
||||
return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime, $secondary_group);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1586,11 +1593,11 @@ function groups_get_warning_monitors($group, $agent_filter=[], $module_filter=[]
|
|||
*
|
||||
* @return integer Number of monitors.
|
||||
*/
|
||||
function groups_get_unknown_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false)
|
||||
function groups_get_unknown_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true)
|
||||
{
|
||||
// Always modify the module status filter
|
||||
$module_filter['status'] = AGENT_MODULE_STATUS_UNKNOWN;
|
||||
return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime);
|
||||
return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime, $secondary_group);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1611,11 +1618,11 @@ function groups_get_unknown_monitors($group, $agent_filter=[], $module_filter=[]
|
|||
*
|
||||
* @return integer Number of monitors.
|
||||
*/
|
||||
function groups_get_not_init_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false)
|
||||
function groups_get_not_init_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true)
|
||||
{
|
||||
// Always modify the module status filter
|
||||
$module_filter['status'] = AGENT_MODULE_STATUS_NOT_INIT;
|
||||
return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime);
|
||||
return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime, $secondary_group);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1635,7 +1642,7 @@ function groups_monitor_fired_alerts($group_array)
|
|||
}
|
||||
|
||||
|
||||
function groups_monitor_alerts_total_counters($group_array)
|
||||
function groups_monitor_alerts_total_counters($group_array, $secondary_group=true)
|
||||
{
|
||||
// If there are not groups to query, we jump to nextone
|
||||
$default_total = [
|
||||
|
@ -1649,26 +1656,32 @@ function groups_monitor_alerts_total_counters($group_array)
|
|||
}
|
||||
|
||||
$group_clause = implode(',', $group_array);
|
||||
$group_clause = "(tasg.id_group IN ($group_clause) OR ta.id_grupo IN ($group_clause))";
|
||||
if ($secondary_group === true) {
|
||||
$group_clause = "(tasg.id_group IN ($group_clause) OR ta.id_grupo IN ($group_clause))";
|
||||
} else {
|
||||
$group_clause = "(ta.id_grupo IN ($group_clause))";
|
||||
}
|
||||
|
||||
$alerts = db_get_row_sql(
|
||||
"SELECT
|
||||
COUNT(tatm.id) AS total,
|
||||
SUM(IF(tatm.times_fired > 0, 1, 0)) AS fired
|
||||
FROM talert_template_modules tatm
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tatm.id_agent_module = tam.id_agente_modulo
|
||||
INNER JOIN tagente ta
|
||||
ON ta.id_agente = tam.id_agente
|
||||
WHERE ta.id_agente IN (
|
||||
SELECT ta.id_agente
|
||||
FROM tagente ta
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
WHERE ta.disabled = 0
|
||||
AND $group_clause
|
||||
) AND tam.disabled = 0"
|
||||
);
|
||||
$sql = 'SELECT
|
||||
COUNT(tatm.id) AS total,
|
||||
SUM(IF(tatm.times_fired > 0, 1, 0)) AS fired
|
||||
FROM talert_template_modules tatm
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON tatm.id_agent_module = tam.id_agente_modulo
|
||||
INNER JOIN tagente ta
|
||||
ON ta.id_agente = tam.id_agente
|
||||
WHERE ta.id_agente IN (
|
||||
SELECT ta.id_agente
|
||||
FROM tagente ta';
|
||||
if ($secondary_group === true) {
|
||||
$sql .= ' LEFT JOIN tagent_secondary_group tasg ON ta.id_agente = tasg.id_agent';
|
||||
}
|
||||
|
||||
$sql .= " WHERE ta.disabled = 0
|
||||
AND $group_clause
|
||||
) AND tam.disabled = 0";
|
||||
|
||||
$alerts = db_get_row_sql($sql);
|
||||
|
||||
return ($alerts === false) ? $default_total : $alerts;
|
||||
}
|
||||
|
@ -1746,7 +1759,7 @@ function groups_monitor_total_counters($group_array, $search_in_testado=false)
|
|||
}
|
||||
|
||||
|
||||
function groups_agents_total_counters($group_array)
|
||||
function groups_agents_total_counters($group_array, $secondary_groups=true)
|
||||
{
|
||||
$default_total = [
|
||||
'ok' => 0,
|
||||
|
@ -1763,30 +1776,36 @@ function groups_agents_total_counters($group_array)
|
|||
}
|
||||
|
||||
$group_clause = implode(',', $group_array);
|
||||
$group_clause = "(tasg.id_group IN ($group_clause) OR ta.id_grupo IN ($group_clause))";
|
||||
if ($secondary_groups === true) {
|
||||
$group_clause = "(tasg.id_group IN ($group_clause) OR ta.id_grupo IN ($group_clause))";
|
||||
} else {
|
||||
$group_clause = "(ta.id_grupo IN ($group_clause))";
|
||||
}
|
||||
|
||||
$condition_critical = agents_get_status_clause(AGENT_STATUS_CRITICAL);
|
||||
$condition_warning = agents_get_status_clause(AGENT_STATUS_WARNING);
|
||||
$condition_unknown = agents_get_status_clause(AGENT_STATUS_UNKNOWN);
|
||||
$condition_not_init = agents_get_status_clause(AGENT_STATUS_NOT_INIT);
|
||||
$condition_normal = agents_get_status_clause(AGENT_STATUS_NORMAL);
|
||||
|
||||
$sql = "SELECT SUM(IF($condition_normal, 1, 0)) AS ok,
|
||||
SUM(IF($condition_critical, 1, 0)) AS critical,
|
||||
SUM(IF($condition_warning, 1, 0)) AS warning,
|
||||
SUM(IF($condition_unknown, 1, 0)) AS unknown,
|
||||
SUM(IF($condition_not_init, 1, 0)) AS not_init,
|
||||
COUNT(ta.id_agente) AS total
|
||||
FROM tagente ta
|
||||
WHERE ta.disabled = 0
|
||||
FROM tagente ta
|
||||
WHERE ta.disabled = 0
|
||||
AND ta.id_agente IN (
|
||||
SELECT ta.id_agente FROM tagente ta
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
WHERE ta.disabled = 0
|
||||
AND $group_clause
|
||||
GROUP BY ta.id_agente
|
||||
)
|
||||
";
|
||||
SELECT ta.id_agente FROM tagente ta";
|
||||
if ($secondary_groups === true) {
|
||||
$sql .= ' LEFT JOIN tagent_secondary_group tasg ON ta.id_agente = tasg.id_agent';
|
||||
}
|
||||
|
||||
$sql .= " WHERE ta.disabled = 0
|
||||
AND $group_clause
|
||||
GROUP BY ta.id_agente
|
||||
)";
|
||||
|
||||
$agents = db_get_row_sql($sql);
|
||||
|
||||
|
@ -2438,3 +2457,390 @@ function groups_get_group_deep($id_group)
|
|||
|
||||
return $deep;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Heat map from agents by group
|
||||
*
|
||||
* @param array $id_group
|
||||
* @param integer $width
|
||||
* @param integer $height
|
||||
*
|
||||
* @return string Html Graph.
|
||||
*/
|
||||
function groups_get_heat_map_agents(array $id_group, float $width=0, float $height=0)
|
||||
{
|
||||
ui_require_css_file('heatmap');
|
||||
|
||||
if (is_array($id_group) === false) {
|
||||
$id_group = [$id_group];
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM tagente WHERE id_grupo IN('.implode(',', $id_group).')';
|
||||
|
||||
$all_agents = db_get_all_rows_sql($sql);
|
||||
if (empty($all_agents)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$total_agents = count($all_agents);
|
||||
|
||||
// Best square.
|
||||
$high = (float) max($width, $height);
|
||||
$low = 0.0;
|
||||
|
||||
while (abs($high - $low) > 0.000001) {
|
||||
$mid = (($high + $low) / 2.0);
|
||||
$midval = (floor($width / $mid) * floor($height / $mid));
|
||||
if ($midval >= $total_agents) {
|
||||
$low = $mid;
|
||||
} else {
|
||||
$high = $mid;
|
||||
}
|
||||
}
|
||||
|
||||
$square_length = min(($width / floor($width / $low)), ($height / floor($height / $low)));
|
||||
|
||||
// Print starmap.
|
||||
$html = sprintf(
|
||||
'<svg id="svg_%s" style="width: %spx; height: %spx;">',
|
||||
$id_group,
|
||||
$width,
|
||||
$height
|
||||
);
|
||||
|
||||
$html .= '<g>';
|
||||
$row = 0;
|
||||
$column = 0;
|
||||
$x = 0;
|
||||
$y = 0;
|
||||
$cont = 1;
|
||||
|
||||
foreach ($all_agents as $key => $value) {
|
||||
// Colour by status.
|
||||
$status = agents_get_status_from_counts($value);
|
||||
|
||||
switch ($status) {
|
||||
case 5:
|
||||
// Not init status.
|
||||
$status = 'notinit';
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// Critical status.
|
||||
$status = 'critical';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// Warning status.
|
||||
$status = 'warning';
|
||||
break;
|
||||
|
||||
case 0:
|
||||
// Normal status.
|
||||
$status = 'normal';
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case -1:
|
||||
default:
|
||||
// Unknown status.
|
||||
$status = 'unknown';
|
||||
break;
|
||||
}
|
||||
|
||||
$html .= sprintf(
|
||||
'<rect id="%s" x="%s" y="%s" row="%s" col="%s" width="%s" height="%s" class="%s_%s" onclick="showInfoAgent('.$value['id_agente'].')"></rect>',
|
||||
'rect_'.$cont,
|
||||
$x,
|
||||
$y,
|
||||
$row,
|
||||
$column,
|
||||
$square_length,
|
||||
$square_length,
|
||||
$status,
|
||||
random_int(1, 10)
|
||||
);
|
||||
|
||||
$y += $square_length;
|
||||
$row++;
|
||||
if ((int) ($y + $square_length) > (int) $height) {
|
||||
$y = 0;
|
||||
$x += $square_length;
|
||||
$row = 0;
|
||||
$column++;
|
||||
}
|
||||
|
||||
if ((int) ($x + $square_length) > (int) $width) {
|
||||
$x = 0;
|
||||
$y += $square_length;
|
||||
$column = 0;
|
||||
$row++;
|
||||
}
|
||||
|
||||
$cont++;
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
const total_agents = '<?php echo $total_agents; ?>';
|
||||
|
||||
function getRandomInteger(min, max) {
|
||||
return Math.floor(Math.random() * max) + min;
|
||||
}
|
||||
|
||||
function oneSquare(solid, time) {
|
||||
var randomPoint = getRandomInteger(1, total_agents);
|
||||
let target = $(`#rect_${randomPoint}`);
|
||||
let class_name = target.attr('class');
|
||||
class_name = class_name.split('_')[0];
|
||||
setTimeout(function() {
|
||||
target.removeClass();
|
||||
target.addClass(`${class_name}_${solid}`);
|
||||
oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900));
|
||||
}, time);
|
||||
}
|
||||
|
||||
let cont = 0;
|
||||
while (cont < Math.ceil(total_agents / 3)) {
|
||||
oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900));
|
||||
cont ++;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
$html .= '</g>';
|
||||
$html .= '</svg>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return html count from agents and monitoring by group.
|
||||
*
|
||||
* @param [type] $id_groups
|
||||
*
|
||||
* @return string Html
|
||||
*/
|
||||
function tactical_groups_get_agents_and_monitoring($id_groups)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$data = [
|
||||
'total_agents' => groups_agents_total_counters($id_groups, false)['total'],
|
||||
'monitor_total' => groups_get_total_monitors($id_groups, [], [], false, false, false, false),
|
||||
];
|
||||
|
||||
// Link URLS
|
||||
$urls = [];
|
||||
$urls['total_agents'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$id_groups[0].'&recursion=1';
|
||||
$urls['monitor_total'] = $config['homeurl'].'index.php?sec=view&sec2=operation/agentes/status_monitor&refr=60&status=-1&ag_group='.$id_groups[0].'&recursion=1';
|
||||
|
||||
$table_am = html_get_predefined_table();
|
||||
$tdata = [];
|
||||
$tdata[0] = html_print_image('images/agent.png', true, ['title' => __('Total agents'), 'class' => 'invert_filter'], false, false, false, true);
|
||||
$tdata[1] = $data['total_agents'] <= 0 ? '-' : $data['total_agents'];
|
||||
$tdata[1] = '<a class="big_data" href="'.$urls['total_agents'].'">'.$tdata[1].'</a>';
|
||||
|
||||
if ($data['total_agents'] > 500 && !enterprise_installed()) {
|
||||
$tdata[2] = "<div id='agentsmodal' class='publienterprise' title='".__('Enterprise version not installed')."'><img data-title='Enterprise version' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>";
|
||||
}
|
||||
|
||||
$tdata[3] = html_print_image('images/module.png', true, ['title' => __('Monitor checks'), 'class' => 'invert_filter'], false, false, false, true);
|
||||
$tdata[4] = $data['monitor_total'] <= 0 ? '-' : $data['monitor_total'];
|
||||
$tdata[4] = '<a class="big_data" href="'.$urls['monitor_total'].'">'.$tdata[4].'</a>';
|
||||
|
||||
/*
|
||||
Hello there! :)
|
||||
We added some of what seems to be "buggy" messages to the openSource version recently. This is not to force open-source users to move to the enterprise version, this is just to inform people using Pandora FMS open source that it requires skilled people to maintain and keep it running smoothly without professional support. This does not imply open-source version is limited in any way. If you check the recently added code, it contains only warnings and messages, no limitations except one: we removed the option to add custom logo in header. In the Update Manager section, it warns about the 'danger’ of applying automated updates without a proper backup, remembering in the process that the Enterprise version comes with a human-tested package. Maintaining an OpenSource version with more than 500 agents is not so easy, that's why someone using a Pandora with 8000 agents should consider asking for support. It's not a joke, we know of many setups with a huge number of agents, and we hate to hear that “its becoming unstable and slow” :(
|
||||
You can of course remove the warnings, that's why we include the source and do not use any kind of trick. And that's why we added here this comment, to let you know this does not reflect any change in our opensource mentality of does the last 14 years.
|
||||
*/
|
||||
if ($data['total_agents']) {
|
||||
if (($data['monitor_total'] / $data['total_agents'] > 100) && !enterprise_installed()) {
|
||||
$tdata[5] = "<div id='monitorcheckmodal' class='publienterprise' title='Community version' ><img data-title='".__('Enterprise version not installed')."' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>";
|
||||
}
|
||||
}
|
||||
|
||||
$table_am->rowclass[] = '';
|
||||
$table_am->data[] = $tdata;
|
||||
|
||||
$output = '<fieldset class="databox tactical_set">
|
||||
<legend>'.__('Total agents and monitors').'</legend>'.html_print_table($table_am, true).'</fieldset>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return html count from stats alerts by group.
|
||||
*
|
||||
* @param [type] $id_groups
|
||||
* @return string Html.
|
||||
*/
|
||||
function tactical_groups_get_stats_alerts($id_groups)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$alerts = groups_monitor_alerts_total_counters($id_groups, false);
|
||||
$data = [
|
||||
'monitor_alerts' => $alerts['total'],
|
||||
'monitor_alerts_fired' => $alerts['fired'],
|
||||
|
||||
];
|
||||
|
||||
$urls = [];
|
||||
$urls['monitor_alerts'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&ag_group='.$id_groups[0];
|
||||
$urls['monitor_alerts_fired'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&disabled=fired&ag_group='.$id_groups[0];
|
||||
|
||||
// Alerts table.
|
||||
$table_al = html_get_predefined_table();
|
||||
|
||||
$tdata = [];
|
||||
$tdata[0] = html_print_image('images/bell.png', true, ['title' => __('Defined alerts'), 'class' => 'invert_filter'], false, false, false, true);
|
||||
$tdata[1] = $data['monitor_alerts'] <= 0 ? '-' : $data['monitor_alerts'];
|
||||
$tdata[1] = '<a class="big_data" href="'.$urls['monitor_alerts'].'">'.$tdata[1].'</a>';
|
||||
|
||||
/*
|
||||
Hello there! :)
|
||||
We added some of what seems to be "buggy" messages to the openSource version recently. This is not to force open-source users to move to the enterprise version, this is just to inform people using Pandora FMS open source that it requires skilled people to maintain and keep it running smoothly without professional support. This does not imply open-source version is limited in any way. If you check the recently added code, it contains only warnings and messages, no limitations except one: we removed the option to add custom logo in header. In the Update Manager section, it warns about the 'danger’ of applying automated updates without a proper backup, remembering in the process that the Enterprise version comes with a human-tested package. Maintaining an OpenSource version with more than 500 agents is not so easy, that's why someone using a Pandora with 8000 agents should consider asking for support. It's not a joke, we know of many setups with a huge number of agents, and we hate to hear that “its becoming unstable and slow” :(
|
||||
You can of course remove the warnings, that's why we include the source and do not use any kind of trick. And that's why we added here this comment, to let you know this does not reflect any change in our opensource mentality of does the last 14 years.
|
||||
*/
|
||||
|
||||
if ($data['monitor_alerts'] > $data['total_agents'] && !enterprise_installed()) {
|
||||
$tdata[2] = "<div id='alertagentmodal' class='publienterprise' title='Community version' ><img data-title='".__('Enterprise version not installed')."' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>";
|
||||
}
|
||||
|
||||
$tdata[3] = html_print_image(
|
||||
'images/bell_error.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Fired alerts'),
|
||||
'class' => 'invert_filter',
|
||||
],
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
);
|
||||
$tdata[4] = $data['monitor_alerts_fired'] <= 0 ? '-' : $data['monitor_alerts_fired'];
|
||||
$tdata[4] = '<a style="color: '.COL_ALERTFIRED.';" class="big_data" href="'.$urls['monitor_alerts_fired'].'">'.$tdata[4].'</a>';
|
||||
$table_al->rowclass[] = '';
|
||||
$table_al->data[] = $tdata;
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
$output = '<fieldset class="databox tactical_set">
|
||||
<legend>'.__('Defined and fired alerts').'</legend>'.html_print_table($table_al, true).'</fieldset>';
|
||||
} else {
|
||||
// Remove the defined alerts cause with the new cache table is difficult to retrieve them.
|
||||
unset($table_al->data[0][0], $table_al->data[0][1]);
|
||||
|
||||
$table_al->class = 'tactical_view';
|
||||
$table_al->style = [];
|
||||
$output = '<fieldset class="tactical_set">
|
||||
<legend>'.__('Fired alerts').'</legend>'.html_print_table($table_al, true).'</fieldset>';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return html count from stats modules by group.
|
||||
*
|
||||
* @param [type] $id_groups
|
||||
* @param integer $graph_width
|
||||
* @param integer $graph_height
|
||||
* @param boolean $links
|
||||
* @param boolean $data_agents
|
||||
* @return void
|
||||
*/
|
||||
function groups_get_stats_modules_status($id_groups, $graph_width=250, $graph_height=150, $links=false, $data_agents=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$data = [
|
||||
'monitor_critical' => groups_get_critical_monitors($id_groups, [], [], false, false, false, false),
|
||||
'monitor_warning' => groups_get_warning_monitors($id_groups, [], [], false, false, false, false),
|
||||
'monitor_ok' => groups_get_normal_monitors($id_groups, [], [], false, false, false, false),
|
||||
'monitor_unknown' => groups_get_unknown_monitors($id_groups, [], [], false, false, false, false),
|
||||
'monitor_not_init' => groups_get_not_init_monitors($id_groups, [], [], false, false, false, false),
|
||||
];
|
||||
|
||||
// Link URLS.
|
||||
if ($links === false) {
|
||||
$urls = [];
|
||||
$urls['monitor_critical'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_CRITICAL_BAD.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0];
|
||||
$urls['monitor_warning'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_WARNING.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0];
|
||||
$urls['monitor_ok'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_NORMAL.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0];
|
||||
$urls['monitor_unknown'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_UNKNOWN.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0];
|
||||
$urls['monitor_not_init'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_NOT_INIT.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0];
|
||||
} else {
|
||||
$urls = [];
|
||||
$urls['monitor_critical'] = $links['monitor_critical'];
|
||||
$urls['monitor_warning'] = $links['monitor_warning'];
|
||||
$urls['monitor_ok'] = $links['monitor_ok'];
|
||||
$urls['monitor_unknown'] = $links['monitor_unknown'];
|
||||
$urls['monitor_not_init'] = $links['monitor_not_init'];
|
||||
}
|
||||
|
||||
// Fixed width non interactive charts
|
||||
$status_chart_width = $graph_width;
|
||||
|
||||
// Modules by status table
|
||||
$table_mbs = html_get_predefined_table();
|
||||
|
||||
$tdata = [];
|
||||
$tdata[0] = html_print_image('images/module_critical.png', true, ['title' => __('Monitor critical')], false, false, false, true);
|
||||
$tdata[1] = $data['monitor_critical'] <= 0 ? '-' : $data['monitor_critical'];
|
||||
$tdata[1] = '<a style="color: '.COL_CRITICAL.';" class="big_data line_heigth_initial" href="'.$urls['monitor_critical'].'">'.$tdata[1].'</a>';
|
||||
|
||||
$tdata[2] = html_print_image('images/module_warning.png', true, ['title' => __('Monitor warning')], false, false, false, true);
|
||||
$tdata[3] = $data['monitor_warning'] <= 0 ? '-' : $data['monitor_warning'];
|
||||
$tdata[3] = '<a style="color: '.COL_WARNING_DARK.';" class="big_data line_heigth_initial" href="'.$urls['monitor_warning'].'">'.$tdata[3].'</a>';
|
||||
$table_mbs->rowclass[] = '';
|
||||
$table_mbs->data[] = $tdata;
|
||||
|
||||
$tdata = [];
|
||||
$tdata[0] = html_print_image('images/module_ok.png', true, ['title' => __('Monitor normal')], false, false, false, true);
|
||||
$tdata[1] = $data['monitor_ok'] <= 0 ? '-' : $data['monitor_ok'];
|
||||
$tdata[1] = '<a style="color: '.COL_NORMAL.';" class="big_data" href="'.$urls['monitor_ok'].'">'.$tdata[1].'</a>';
|
||||
|
||||
$tdata[2] = html_print_image('images/module_unknown.png', true, ['title' => __('Monitor unknown')], false, false, false, true);
|
||||
$tdata[3] = $data['monitor_unknown'] <= 0 ? '-' : $data['monitor_unknown'];
|
||||
$tdata[3] = '<a style="color: '.COL_UNKNOWN.';" class="big_data line_heigth_initial" href="'.$urls['monitor_unknown'].'">'.$tdata[3].'</a>';
|
||||
$table_mbs->rowclass[] = '';
|
||||
$table_mbs->data[] = $tdata;
|
||||
|
||||
$tdata = [];
|
||||
$tdata[0] = html_print_image('images/module_notinit.png', true, ['title' => __('Monitor not init')], false, false, false, true);
|
||||
$tdata[1] = $data['monitor_not_init'] <= 0 ? '-' : $data['monitor_not_init'];
|
||||
$tdata[1] = '<a style="color: '.COL_NOTINIT.';" class="big_data line_heigth_initial" href="'.$urls['monitor_not_init'].'">'.$tdata[1].'</a>';
|
||||
|
||||
$tdata[2] = $tdata[3] = '';
|
||||
$table_mbs->rowclass[] = '';
|
||||
$table_mbs->data[] = $tdata;
|
||||
|
||||
if ($data['monitor_checks'] > 0) {
|
||||
$tdata = [];
|
||||
$table_mbs->colspan[count($table_mbs->data)][0] = 4;
|
||||
$table_mbs->cellstyle[count($table_mbs->data)][0] = 'text-align: center;';
|
||||
$tdata[0] = '<div id="outter_status_pie" style="height: '.$graph_height.'px">'.'<div id="status_pie" style="margin: auto; width: '.$status_chart_width.'px;">'.graph_agent_status(false, $graph_width, $graph_height, true, true, $data_agents).'</div></div>';
|
||||
$table_mbs->rowclass[] = '';
|
||||
$table_mbs->data[] = $tdata;
|
||||
}
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
$output = '
|
||||
<fieldset class="databox tactical_set">
|
||||
<legend>'.__('Monitors by status').'</legend>'.html_print_table($table_mbs, true).'</fieldset>';
|
||||
} else {
|
||||
$table_mbs->class = 'tactical_view';
|
||||
$table_mbs->style = [];
|
||||
$output = '
|
||||
<fieldset class="tactical_set">
|
||||
<legend>'.__('Monitors by status').'</legend>'.html_print_table($table_mbs, true).'</fieldset>';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
|
@ -7488,7 +7488,7 @@ function reporting_sql($report, $content)
|
|||
|
||||
foreach ($results as $id_node => $items) {
|
||||
foreach ($items['result']['data'] as $key => $item) {
|
||||
$items['result']['data'][$key] = ['node_id' => $id_node] + $items['result']['data'][$key];
|
||||
$items['result']['data'][$key] = (['node_id' => $id_node] + $items['result']['data'][$key]);
|
||||
}
|
||||
|
||||
if ((int) $items['result']['correct'] !== 1) {
|
||||
|
@ -7537,7 +7537,8 @@ function reporting_sql($report, $content)
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
function reporting_sql_auxiliary($report, $content) {
|
||||
function reporting_sql_auxiliary($report, $content)
|
||||
{
|
||||
if ($content['treport_custom_sql_id'] != 0) {
|
||||
$sql = io_safe_output(
|
||||
db_get_value_filter(
|
||||
|
|
|
@ -693,7 +693,7 @@ function ui_print_tags_warning($return=false)
|
|||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
function ui_print_group_icon($id_group, $return=false, $path='', $style='', $link=true, $force_show_image=false, $show_as_image=false, $class='')
|
||||
function ui_print_group_icon($id_group, $return=false, $path='', $style='', $link=true, $force_show_image=false, $show_as_image=false, $class='', $tactical_view=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
@ -707,7 +707,11 @@ function ui_print_group_icon($id_group, $return=false, $path='', $style='', $lin
|
|||
}
|
||||
|
||||
if ($link === true) {
|
||||
$output = '<a href="'.$config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$id_group.'">';
|
||||
if ($tactical_view === true) {
|
||||
$output = '<a href="'.$config['homeurl'].'index.php?sec=gagente&sec2=godmode/groups/tactical&id_group='.$id_group.'">';
|
||||
} else {
|
||||
$output = '<a href="'.$config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$id_group.'">';
|
||||
}
|
||||
}
|
||||
|
||||
if ((bool) $config['show_group_name'] === true) {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
/* global $, load_modal */
|
||||
function showInfoAgent(id_agent) {
|
||||
load_modal({
|
||||
target: $("#modal-info-agent"),
|
||||
url: "ajax.php",
|
||||
modal: {
|
||||
title: "Info agent",
|
||||
cancel: "close"
|
||||
},
|
||||
onshow: {
|
||||
page: "include/ajax/group",
|
||||
method: "loadInfoAgent",
|
||||
extradata: {
|
||||
idAgent: id_agent
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
|
@ -43,7 +43,13 @@ class Group extends Entity
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $ajaxMethods = ['getGroupsForSelect'];
|
||||
private static $ajaxMethods = [
|
||||
'getGroupsForSelect',
|
||||
'distributionBySoGraph',
|
||||
'groupEventsByAgent',
|
||||
'loadInfoAgent',
|
||||
'getAgentsByGroup',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
|
@ -473,4 +479,271 @@ class Group extends Entity
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw a graph distribution so by group.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function distributionBySoGraph()
|
||||
{
|
||||
global $config;
|
||||
$id_group = get_parameter('id_group', '');
|
||||
include_once $config['homedir'].'/include/functions_graph.php';
|
||||
|
||||
$out = '<div style="flex: 0 0 300px; width:99%; height:100%;">';
|
||||
$out .= graph_so_by_group($id_group, 300, 200, false, false);
|
||||
$out .= '<div>';
|
||||
echo $out;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw a graph events agent by group.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function groupEventsByAgent()
|
||||
{
|
||||
global $config;
|
||||
$id_group = get_parameter('id_group', '');
|
||||
include_once $config['homedir'].'/include/functions_graph.php';
|
||||
|
||||
$out = '<div style="flex: 0 0 300px; width:99%; height:100%;">';
|
||||
$out .= graph_events_agent_by_group($id_group, 300, 200, false, true, true);
|
||||
$out .= '<div>';
|
||||
echo $out;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw in modal a agent info
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function loadInfoAgent()
|
||||
{
|
||||
$extradata = get_parameter('extradata', '');
|
||||
echo '<div class="info-agent">';
|
||||
|
||||
if (empty($extradata) === false) {
|
||||
$extradata = json_decode(io_safe_output($extradata), true);
|
||||
$agent = agents_get_agent($extradata['idAgent']);
|
||||
|
||||
if (is_array($agent)) {
|
||||
$status_img = agents_tree_view_status_img(
|
||||
$agent['critical_count'],
|
||||
$agent['warning_count'],
|
||||
$agent['unknown_count'],
|
||||
$agent['total_count'],
|
||||
$agent['notinit_count']
|
||||
);
|
||||
$table = new \stdClass();
|
||||
$table->class = 'table_modal_alternate';
|
||||
$table->data = [
|
||||
[
|
||||
__('Id'),
|
||||
$agent['id_agente'],
|
||||
],
|
||||
[
|
||||
__('Agent name'),
|
||||
'<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente='.$agent['id_agente'].'"><b>'.$agent['nombre'].'</b></a>',
|
||||
],
|
||||
[
|
||||
__('Alias'),
|
||||
$agent['alias'],
|
||||
],
|
||||
[
|
||||
__('Ip Address'),
|
||||
$agent['direccion'],
|
||||
],
|
||||
[
|
||||
__('Status'),
|
||||
$status_img,
|
||||
],
|
||||
[
|
||||
__('Group'),
|
||||
groups_get_name($agent['id_grupo']),
|
||||
],
|
||||
[
|
||||
__('Interval'),
|
||||
$agent['intervalo'],
|
||||
],
|
||||
[
|
||||
__('Operative system'),
|
||||
get_os_name($agent['id_os']),
|
||||
],
|
||||
[
|
||||
__('Server name'),
|
||||
$agent['server_name'],
|
||||
],
|
||||
[
|
||||
__('Description'),
|
||||
$agent['comentarios'],
|
||||
],
|
||||
];
|
||||
|
||||
html_print_table($table);
|
||||
}
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get agents by group for datatable.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function getAgentsByGroup()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$data = [];
|
||||
$id_group = get_parameter('id_group', '');
|
||||
$id_groups = [$id_group];
|
||||
$groups = groups_get_children($id_group);
|
||||
|
||||
if (count($groups) > 0) {
|
||||
$id_groups = [];
|
||||
foreach ($groups as $key => $value) {
|
||||
$id_groups[] = $value['id_grupo'];
|
||||
}
|
||||
}
|
||||
|
||||
$start = get_parameter('start', 0);
|
||||
$length = get_parameter('length', $config['block_size']);
|
||||
$orderDatatable = get_datatable_order(true);
|
||||
$pagination = '';
|
||||
$order = '';
|
||||
|
||||
try {
|
||||
ob_start();
|
||||
if (isset($orderDatatable)) {
|
||||
switch ($orderDatatable['field']) {
|
||||
case 'alerts':
|
||||
$orderDatatable['field'] = 'fired_count';
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
$orderDatatable['field'] = 'total_count';
|
||||
|
||||
default:
|
||||
$orderDatatable['field'] = $orderDatatable['field'];
|
||||
break;
|
||||
}
|
||||
|
||||
$order = sprintf(
|
||||
' ORDER BY %s %s',
|
||||
$orderDatatable['field'],
|
||||
$orderDatatable['direction']
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($length) && $length > 0
|
||||
&& isset($start) && $start >= 0
|
||||
) {
|
||||
$pagination = sprintf(
|
||||
' LIMIT %d OFFSET %d ',
|
||||
$length,
|
||||
$start
|
||||
);
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT id_agente,
|
||||
alias,
|
||||
critical_count,
|
||||
warning_count,
|
||||
unknown_count,
|
||||
total_count,
|
||||
notinit_count,
|
||||
ultimo_contacto_remoto,
|
||||
fired_count
|
||||
FROM tagente t
|
||||
WHERE disabled = 0 AND
|
||||
total_count <> notinit_count AND
|
||||
id_grupo IN (%s)
|
||||
%s %s',
|
||||
implode(',', $id_groups),
|
||||
$order,
|
||||
$pagination
|
||||
);
|
||||
|
||||
$data = db_get_all_rows_sql($sql);
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT
|
||||
id_agente,
|
||||
alias,
|
||||
critical_count,
|
||||
warning_count,
|
||||
unknown_count,
|
||||
total_count,
|
||||
notinit_count,
|
||||
ultimo_contacto_remoto,
|
||||
fired_count
|
||||
FROM tagente t
|
||||
WHERE disabled = 0 AND
|
||||
total_count <> notinit_count AND
|
||||
id_grupo IN (%s)
|
||||
%s',
|
||||
implode(',', $id_groups),
|
||||
$order,
|
||||
);
|
||||
|
||||
$count_agents = db_get_num_rows($sql);
|
||||
|
||||
foreach ($data as $key => $agent) {
|
||||
$status_img = agents_tree_view_status_img(
|
||||
$agent['critical_count'],
|
||||
$agent['warning_count'],
|
||||
$agent['unknown_count'],
|
||||
$agent['total_count'],
|
||||
$agent['notinit_count']
|
||||
);
|
||||
$data[$key]['alias'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente='.$agent['id_agente'].'"><b>'.$agent['alias'].'</b></a>';
|
||||
$data[$key]['status'] = $status_img;
|
||||
$data[$key]['alerts'] = agents_tree_view_alert_img($agent['fired_count']);
|
||||
}
|
||||
|
||||
if (empty($data) === true) {
|
||||
$total = 0;
|
||||
$data = [];
|
||||
} else {
|
||||
$total = $count_agents;
|
||||
}
|
||||
|
||||
echo json_encode(
|
||||
[
|
||||
'data' => $data,
|
||||
'recordsTotal' => $total,
|
||||
'recordsFiltered' => $total,
|
||||
]
|
||||
);
|
||||
// Capture output.
|
||||
$response = ob_get_clean();
|
||||
} catch (\Exception $e) {
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
json_decode($response);
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
echo $response;
|
||||
} else {
|
||||
echo json_encode(
|
||||
[
|
||||
'success' => false,
|
||||
'error' => $response,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -647,6 +647,10 @@ select:-internal-list-box {
|
|||
width: 20%;
|
||||
}
|
||||
|
||||
.w21p {
|
||||
width: 21%;
|
||||
}
|
||||
|
||||
.w22p {
|
||||
width: 22%;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
.tactical_group_left_column {
|
||||
vertical-align: top;
|
||||
min-width: 30em;
|
||||
width: 30%;
|
||||
padding-top: 0px;
|
||||
}
|
||||
.tactical_group_right_column {
|
||||
width: 40%;
|
||||
vertical-align: top;
|
||||
min-width: 30em;
|
||||
padding-top: 0px;
|
||||
}
|
||||
rect {
|
||||
cursor: pointer;
|
||||
}
|
||||
.info-agent {
|
||||
width: 100%;
|
||||
max-height: 400px;
|
||||
}
|
||||
.info-agent table {
|
||||
width: 100%;
|
||||
}
|
||||
#modal-info-agent {
|
||||
display: none;
|
||||
}
|
||||
#list_agents_tactical_wrapper {
|
||||
max-height: 600px;
|
||||
}
|
||||
.graph-distribution-so {
|
||||
margin-top: 55px;
|
||||
}
|
|
@ -131,7 +131,7 @@
|
|||
<div style='padding-bottom: 50px'>
|
||||
<?php
|
||||
$version = '7.0NG.769';
|
||||
$build = '230307';
|
||||
$build = '230228';
|
||||
$banner = "v$version Build $build";
|
||||
error_reporting(0);
|
||||
|
||||
|
|
|
@ -106,7 +106,12 @@ $agentIconGroup = ((bool) $config['show_group_name'] === false) ? ui_print_group
|
|||
$agent['id_grupo'],
|
||||
true,
|
||||
'',
|
||||
'padding-right: 6px;'
|
||||
'padding-right: 6px;',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
true
|
||||
) : '';
|
||||
|
||||
$agentIconStatus = agents_detail_view_status_img(
|
||||
|
@ -488,7 +493,7 @@ $data = [];
|
|||
$data[0] = '<b>'.__('Group').'</b>';
|
||||
$data[1] = html_print_anchor(
|
||||
[
|
||||
'href' => 'index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$agent['id_grupo'],
|
||||
'href' => 'index.php?sec=gagente&sec2=godmode/groups/tactical&id_group='.$agent['id_grupo'],
|
||||
'content' => groups_get_name($agent['id_grupo']),
|
||||
],
|
||||
true
|
||||
|
|
Loading…
Reference in New Issue