2022-02-25 09:41:32 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Heatmap.
|
|
|
|
*
|
|
|
|
* @category Heatmap
|
|
|
|
* @package Pandora FMS
|
|
|
|
* @subpackage Community
|
|
|
|
* @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.
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (is_ajax() === true) {
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
// Login check.
|
|
|
|
check_login();
|
|
|
|
|
|
|
|
$getFilters = (bool) get_parameter('getFilters', 0);
|
|
|
|
$getFilterType = (bool) get_parameter('getFilterType', 0);
|
|
|
|
$getInfo = (bool) get_parameter('getInfo', 0);
|
|
|
|
$type = get_parameter('type', 0);
|
|
|
|
|
|
|
|
if ($getFilters === true) {
|
2022-03-31 09:46:30 +02:00
|
|
|
$refresh = get_parameter('refresh', SECONDS_5MINUTES);
|
2022-02-25 09:41:32 +01:00
|
|
|
$search = get_parameter('search', '');
|
2022-03-07 13:11:54 +01:00
|
|
|
$group = get_parameter('group', true);
|
2022-02-25 09:41:32 +01:00
|
|
|
|
|
|
|
echo '<form id="form_dialog" method="post">';
|
|
|
|
echo '<div class="div-dialog">';
|
|
|
|
echo '<p class="label-dialog">'.__('Refresh').'</p>';
|
|
|
|
echo html_print_select(
|
|
|
|
[
|
|
|
|
'30' => __('30 seconds'),
|
|
|
|
(string) SECONDS_1MINUTE => __('1 minute'),
|
2022-03-31 09:46:30 +02:00
|
|
|
'180' => __('3 minutes'),
|
2022-02-25 09:41:32 +01:00
|
|
|
(string) SECONDS_5MINUTES => __('5 minutes'),
|
|
|
|
],
|
|
|
|
'refresh',
|
|
|
|
$refresh,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
'margin-top: 3px;'
|
|
|
|
);
|
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
echo '<div class="div-dialog">';
|
|
|
|
echo '<p class="label-dialog">'.__('Search').'</p>';
|
|
|
|
echo html_print_input_text('search', $search, '', 30, 255, true);
|
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
echo '<div class="div-dialog">';
|
|
|
|
echo '<p class="label-dialog">'.__('Type').'</p>';
|
|
|
|
echo html_print_select(
|
|
|
|
[
|
|
|
|
0 => __('Group agents'),
|
|
|
|
1 => __('Group modules by tag'),
|
|
|
|
2 => __('Group modules by module group'),
|
2022-10-14 13:53:05 +02:00
|
|
|
3 => __('Group modules by agents'),
|
2022-02-25 09:41:32 +01:00
|
|
|
],
|
|
|
|
'type',
|
|
|
|
$type,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
'margin-top: 3px;width:70%'
|
|
|
|
);
|
|
|
|
echo '</div>';
|
2022-03-07 13:11:54 +01:00
|
|
|
|
|
|
|
echo '<div class="div-dialog">';
|
|
|
|
echo '<p class="label-dialog">'.__('Show groups').'</p>';
|
|
|
|
echo html_print_checkbox('group', 1, $group, true);
|
|
|
|
echo '</div>';
|
2022-02-25 09:41:32 +01:00
|
|
|
echo '</form>';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($getFilterType === true) {
|
|
|
|
$filter = get_parameter('filter', 0);
|
|
|
|
echo '<div id="filter_type" class="div-dialog">';
|
|
|
|
switch ($type) {
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
echo '<p style="width:42%;font-weight: bold;">'.__('Group').'</p>';
|
|
|
|
echo html_print_input(
|
|
|
|
[
|
|
|
|
'type' => 'select_groups',
|
|
|
|
'returnAllGroup' => true,
|
|
|
|
'name' => 'filter[]',
|
|
|
|
'selected' => $filter,
|
|
|
|
'return' => true,
|
|
|
|
'required' => true,
|
|
|
|
'privilege' => 'AR',
|
2022-03-30 10:21:30 +02:00
|
|
|
'multiple' => true,
|
2022-02-25 09:41:32 +01:00
|
|
|
]
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
echo '<p class="label-dialog">'.__('Tag').'</p>';
|
|
|
|
if (tags_has_user_acl_tags($config['id_user']) === false) {
|
|
|
|
echo html_print_select_from_sql(
|
|
|
|
'SELECT id_tag, name
|
|
|
|
FROM ttag
|
2022-03-07 13:11:54 +01:00
|
|
|
WHERE id_tag
|
|
|
|
ORDER BY name',
|
2022-02-25 09:41:32 +01:00
|
|
|
'filter[]',
|
|
|
|
$filter,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
'width: 200px',
|
|
|
|
'5'
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$user_tags = tags_get_user_tags($config['id_user'], 'AR');
|
|
|
|
if (!empty($user_tags)) {
|
|
|
|
$id_user_tags = array_keys($user_tags);
|
|
|
|
|
|
|
|
echo html_print_select_from_sql(
|
|
|
|
'SELECT id_tag, name
|
|
|
|
FROM ttag
|
2022-03-07 13:11:54 +01:00
|
|
|
WHERE id_tag IN ('.implode(',', $id_user_tags).')
|
|
|
|
ORDER BY name',
|
2022-02-25 09:41:32 +01:00
|
|
|
'filter[]',
|
|
|
|
$filter,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
'width: 200px',
|
|
|
|
'5'
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
echo html_print_select_from_sql(
|
|
|
|
'SELECT id_tag, name
|
|
|
|
FROM ttag
|
2022-03-07 13:11:54 +01:00
|
|
|
WHERE id_tag
|
|
|
|
ORDER BY name',
|
2022-02-25 09:41:32 +01:00
|
|
|
'filter[]',
|
|
|
|
$filter,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
'width: 200px',
|
|
|
|
'5'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
echo '<p class="label-dialog">'.__('Module group').'</p>';
|
2022-03-30 10:21:30 +02:00
|
|
|
echo html_print_select_from_sql(
|
|
|
|
'SELECT id_mg, name FROM tmodule_group ORDER BY name',
|
2022-02-25 09:41:32 +01:00
|
|
|
'filter[]',
|
|
|
|
$filter,
|
|
|
|
'',
|
2022-03-30 10:21:30 +02:00
|
|
|
__('Not assigned'),
|
|
|
|
'0',
|
|
|
|
true,
|
|
|
|
true,
|
2022-02-25 09:41:32 +01:00
|
|
|
true,
|
|
|
|
false,
|
2022-03-30 10:21:30 +02:00
|
|
|
'width: 200px',
|
|
|
|
'5'
|
2022-02-25 09:41:32 +01:00
|
|
|
);
|
|
|
|
break;
|
2022-10-14 13:53:05 +02:00
|
|
|
|
|
|
|
case 3:
|
|
|
|
// Empty.
|
|
|
|
break;
|
2022-02-25 09:41:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($getInfo === true) {
|
2022-03-30 10:21:30 +02:00
|
|
|
enterprise_include_once('include/functions_agents.php');
|
2022-02-25 09:41:32 +01:00
|
|
|
$id = get_parameter('id', 0);
|
|
|
|
switch ($type) {
|
2022-10-14 13:53:05 +02:00
|
|
|
case 3:
|
2022-02-25 09:41:32 +01:00
|
|
|
case 2:
|
2022-03-07 13:11:54 +01:00
|
|
|
$data = db_get_row('tagente_modulo', 'id_agente_modulo', $id);
|
2022-03-30 10:21:30 +02:00
|
|
|
|
2022-03-07 13:11:54 +01:00
|
|
|
// Nombre.
|
2022-03-30 10:21:30 +02:00
|
|
|
$link = sprintf(
|
|
|
|
'index.php?sec=view&sec2=operation/agentes/status_monitor%s&ag_modulename=%s',
|
|
|
|
'&refr=0&ag_group=0&module_option=1&status=-1',
|
|
|
|
$data['nombre']
|
|
|
|
);
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '<div class="div-dialog">';
|
|
|
|
echo '<p class="title-dialog">'.__('Module name').'</p>';
|
2022-03-30 10:21:30 +02:00
|
|
|
echo '<a href="'.$link.'" class="info-dialog">'.$data['nombre'].'</a>';
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
// Descripcion.
|
2022-03-30 10:21:30 +02:00
|
|
|
$description = (empty($data['descripcion']) === true) ? '-' : $data['descripcion'];
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '<div class="div-dialog">';
|
|
|
|
echo '<p class="title-dialog">'.__('Description').'</p>';
|
2022-03-30 10:21:30 +02:00
|
|
|
echo '<p class="info-dialog">'.$description.'</p>';
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
// Agent.
|
|
|
|
echo '<div class="div-dialog">';
|
|
|
|
echo '<p class="title-dialog">'.__('Agent').'</p>';
|
|
|
|
echo '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$data['id_agente'].'"
|
|
|
|
class="info-dialog" target="_blank">'.agents_get_alias($data['id_agente']).'</a>';
|
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
// Group.
|
2022-03-30 10:21:30 +02:00
|
|
|
$group = (empty($data['id_module_group']) === true)
|
|
|
|
? '-'
|
|
|
|
: modules_get_modulegroup_name($data['id_module_group']);
|
|
|
|
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '<div class="div-dialog">';
|
2022-03-30 10:21:30 +02:00
|
|
|
echo '<p class="title-dialog">'.__('Module group').'</p>';
|
|
|
|
echo '<p class="info-dialog">'.$group.'</p>';
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '</div>';
|
2022-02-25 09:41:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2022-03-07 13:11:54 +01:00
|
|
|
$data = db_get_row('tagente_modulo', 'id_agente_modulo', $id);
|
2022-03-30 10:21:30 +02:00
|
|
|
|
2022-03-07 13:11:54 +01:00
|
|
|
// Nombre.
|
2022-03-30 10:21:30 +02:00
|
|
|
$link = sprintf(
|
|
|
|
'index.php?sec=view&sec2=operation/agentes/status_monitor%s&ag_modulename=%s',
|
|
|
|
'&refr=0&ag_group=0&module_option=1&status=-1',
|
|
|
|
$data['nombre']
|
|
|
|
);
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '<div class="div-dialog">';
|
|
|
|
echo '<p class="title-dialog">'.__('Module name').'</p>';
|
2022-03-30 10:21:30 +02:00
|
|
|
echo '<a href="'.$link.'" class="info-dialog" target="_blank">'.$data['nombre'].'</a>';
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
// Descripcion.
|
2022-03-30 10:21:30 +02:00
|
|
|
$description = (empty($data['descripcion']) === true) ? '-' : $data['descripcion'];
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '<div class="div-dialog">';
|
2022-03-30 10:21:30 +02:00
|
|
|
echo '<p class="title-dialog">'.__('Description').'</p>';
|
|
|
|
echo '<p class="info-dialog">'.$description.'</p>';
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
// Agent.
|
|
|
|
echo '<div class="div-dialog">';
|
|
|
|
echo '<p class="title-dialog">'.__('Agent').'</p>';
|
|
|
|
echo '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$data['id_agente'].'"
|
|
|
|
class="info-dialog" target="_blank">'.agents_get_alias($data['id_agente']).'</a>';
|
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
// Group.
|
2022-03-30 10:21:30 +02:00
|
|
|
$group = (empty($data['id_module_group']) === true)
|
|
|
|
? '-'
|
|
|
|
: modules_get_modulegroup_name($data['id_module_group']);
|
|
|
|
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '<div class="div-dialog">';
|
2022-03-30 10:21:30 +02:00
|
|
|
echo '<p class="title-dialog">'.__('Module group').'</p>';
|
|
|
|
echo '<p class="info-dialog">'.$group.'</p>';
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
// Tag.
|
|
|
|
$tags = db_get_all_rows_sql('SELECT id_tag FROM ttag_module WHERE id_agente_modulo ='.$id);
|
|
|
|
$tags_name = '';
|
|
|
|
echo '<div class="div-dialog">';
|
|
|
|
echo '<p class="title-dialog">'.__('Tag').'</p>';
|
|
|
|
foreach ($tags as $key => $tag) {
|
|
|
|
$tags_name .= tags_get_name($tag['id_tag']).', ';
|
|
|
|
}
|
|
|
|
|
|
|
|
$tags_name = trim($tags_name, ', ');
|
|
|
|
echo '<p class="info-dialog">'.$tags_name.'</p>';
|
|
|
|
echo '</div>';
|
2022-02-25 09:41:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
$data = agents_get_agent($id);
|
|
|
|
|
|
|
|
// Alias.
|
|
|
|
echo '<div class="div-dialog">';
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '<p class="title-dialog">'.__('Agent').'</p>';
|
|
|
|
echo '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$data['id_agente'].'"
|
|
|
|
class="info-dialog" target="_blank">'.$data['alias'].'</a>';
|
2022-02-25 09:41:32 +01:00
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
// Ip.
|
|
|
|
echo '<div class="div-dialog">';
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '<p class="title-dialog">'.__('IP').'</p>';
|
|
|
|
echo '<p class="info-dialog">'.$data['direccion'].'</p>';
|
2022-02-25 09:41:32 +01:00
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
// OS.
|
|
|
|
echo '<div class="div-dialog">';
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '<p class="title-dialog">'.__('OS').'</p>';
|
|
|
|
echo '<p class="info-dialog">'.ui_print_os_icon($data['id_os'], true, true).'</p>';
|
2022-02-25 09:41:32 +01:00
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
// Description.
|
|
|
|
echo '<div class="div-dialog">';
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '<p class="title-dialog">'.__('Description').'</p>';
|
|
|
|
echo '<p class="info-dialog">'.$data['comentarios'].'</p>';
|
2022-02-25 09:41:32 +01:00
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
// Group.
|
2022-03-30 10:21:30 +02:00
|
|
|
$secondary_groups = '';
|
2023-01-23 13:58:06 +01:00
|
|
|
$secondary = enterprise_hook('agents_get_secondary_groups', [$data['id_agente']]);
|
2022-03-30 10:21:30 +02:00
|
|
|
if (isset($secondary['for_select']) === true && empty($secondary['for_select']) === false) {
|
|
|
|
$secondary_groups = implode(', ', $secondary['for_select']);
|
|
|
|
$secondary_groups = ', '.$secondary_groups;
|
|
|
|
}
|
|
|
|
|
2022-02-25 09:41:32 +01:00
|
|
|
echo '<div class="div-dialog">';
|
2022-03-07 13:11:54 +01:00
|
|
|
echo '<p class="title-dialog">'.__('Group').'</p>';
|
2022-03-30 10:21:30 +02:00
|
|
|
echo '<p class="info-dialog">'.groups_get_name($data['id_grupo']).$secondary_groups.'</p>';
|
2022-02-25 09:41:32 +01:00
|
|
|
echo '</div>';
|
|
|
|
|
2022-03-30 10:21:30 +02:00
|
|
|
|
2022-02-25 09:41:32 +01:00
|
|
|
// Events.
|
2023-01-23 13:58:06 +01:00
|
|
|
$result_graph_event = enterprise_hook(
|
|
|
|
'graph_graphic_agentevents',
|
|
|
|
[
|
|
|
|
$id,
|
|
|
|
100,
|
|
|
|
40,
|
|
|
|
SECONDS_1DAY,
|
|
|
|
'',
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
1,
|
|
|
|
]
|
2022-02-25 09:41:32 +01:00
|
|
|
);
|
2023-01-23 13:58:06 +01:00
|
|
|
|
|
|
|
if ($result_graph_event !== -1) {
|
|
|
|
echo '<div class="div-dialog">';
|
|
|
|
echo $result_graph_event;
|
|
|
|
echo '</div>';
|
|
|
|
}
|
2022-02-25 09:41:32 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|