mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 09:15:15 +02:00
Merge remote-tracking branch 'origin/develop' into ent-8540-contel-nuevo-informe-custom-render
This commit is contained in:
commit
863e6c887f
@ -1,5 +1,5 @@
|
|||||||
package: pandorafms-agent-unix
|
package: pandorafms-agent-unix
|
||||||
Version: 7.0NG.760-220401
|
Version: 7.0NG.760-220404
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: admin
|
Section: admin
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
pandora_version="7.0NG.760-220401"
|
pandora_version="7.0NG.760-220404"
|
||||||
|
|
||||||
echo "Test if you has the tools for to make the packages."
|
echo "Test if you has the tools for to make the packages."
|
||||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||||
|
@ -1015,7 +1015,7 @@ my $Sem = undef;
|
|||||||
my $ThreadSem = undef;
|
my $ThreadSem = undef;
|
||||||
|
|
||||||
use constant AGENT_VERSION => '7.0NG.760';
|
use constant AGENT_VERSION => '7.0NG.760';
|
||||||
use constant AGENT_BUILD => '220401';
|
use constant AGENT_BUILD => '220404';
|
||||||
|
|
||||||
# Agent log default file size maximum and instances
|
# Agent log default file size maximum and instances
|
||||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
%define name pandorafms_agent_unix
|
%define name pandorafms_agent_unix
|
||||||
%define version 7.0NG.760
|
%define version 7.0NG.760
|
||||||
%define release 220401
|
%define release 220404
|
||||||
|
|
||||||
Summary: Pandora FMS Linux agent, PERL version
|
Summary: Pandora FMS Linux agent, PERL version
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
%define name pandorafms_agent_unix
|
%define name pandorafms_agent_unix
|
||||||
%define version 7.0NG.760
|
%define version 7.0NG.760
|
||||||
%define release 220401
|
%define release 220404
|
||||||
|
|
||||||
Summary: Pandora FMS Linux agent, PERL version
|
Summary: Pandora FMS Linux agent, PERL version
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# **********************************************************************
|
# **********************************************************************
|
||||||
|
|
||||||
PI_VERSION="7.0NG.760"
|
PI_VERSION="7.0NG.760"
|
||||||
PI_BUILD="220401"
|
PI_BUILD="220404"
|
||||||
OS_NAME=`uname -s`
|
OS_NAME=`uname -s`
|
||||||
|
|
||||||
FORCE=0
|
FORCE=0
|
||||||
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
Version
|
Version
|
||||||
{220401}
|
{220404}
|
||||||
|
|
||||||
ViewReadme
|
ViewReadme
|
||||||
{Yes}
|
{Yes}
|
||||||
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||||||
using namespace Pandora_Strutils;
|
using namespace Pandora_Strutils;
|
||||||
|
|
||||||
#define PATH_SIZE _MAX_PATH+1
|
#define PATH_SIZE _MAX_PATH+1
|
||||||
#define PANDORA_VERSION ("7.0NG.760 Build 220401")
|
#define PANDORA_VERSION ("7.0NG.760 Build 220404")
|
||||||
|
|
||||||
string pandora_path;
|
string pandora_path;
|
||||||
string pandora_dir;
|
string pandora_dir;
|
||||||
|
@ -11,7 +11,7 @@ BEGIN
|
|||||||
VALUE "LegalCopyright", "Artica ST"
|
VALUE "LegalCopyright", "Artica ST"
|
||||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||||
VALUE "ProductVersion", "(7.0NG.760(Build 220401))"
|
VALUE "ProductVersion", "(7.0NG.760(Build 220404))"
|
||||||
VALUE "FileVersion", "1.0.0.0"
|
VALUE "FileVersion", "1.0.0.0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package: pandorafms-console
|
package: pandorafms-console
|
||||||
Version: 7.0NG.760-220401
|
Version: 7.0NG.760-220404
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: admin
|
Section: admin
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
pandora_version="7.0NG.760-220401"
|
pandora_version="7.0NG.760-220404"
|
||||||
|
|
||||||
package_pear=0
|
package_pear=0
|
||||||
package_pandora=1
|
package_pandora=1
|
||||||
|
@ -114,6 +114,7 @@ function pandora_realtime_graphs()
|
|||||||
$canvas .= '</div>';
|
$canvas .= '</div>';
|
||||||
echo $canvas;
|
echo $canvas;
|
||||||
|
|
||||||
|
$table = new stdClass();
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
$table->id = 'table-form';
|
$table->id = 'table-form';
|
||||||
$table->class = 'databox filters';
|
$table->class = 'databox filters';
|
||||||
|
368
pandora_console/include/ajax/heatmap.ajax.php
Normal file
368
pandora_console/include/ajax/heatmap.ajax.php
Normal file
@ -0,0 +1,368 @@
|
|||||||
|
<?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) {
|
||||||
|
$refresh = get_parameter('refresh', SECONDS_5MINUTES);
|
||||||
|
$search = get_parameter('search', '');
|
||||||
|
$group = get_parameter('group', true);
|
||||||
|
|
||||||
|
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'),
|
||||||
|
'180' => __('3 minutes'),
|
||||||
|
(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'),
|
||||||
|
],
|
||||||
|
'type',
|
||||||
|
$type,
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
0,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
'margin-top: 3px;width:70%'
|
||||||
|
);
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
echo '<div class="div-dialog">';
|
||||||
|
echo '<p class="label-dialog">'.__('Show groups').'</p>';
|
||||||
|
echo html_print_checkbox('group', 1, $group, true);
|
||||||
|
echo '</div>';
|
||||||
|
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',
|
||||||
|
'multiple' => true,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
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
|
||||||
|
WHERE id_tag
|
||||||
|
ORDER BY name',
|
||||||
|
'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
|
||||||
|
WHERE id_tag IN ('.implode(',', $id_user_tags).')
|
||||||
|
ORDER BY name',
|
||||||
|
'filter[]',
|
||||||
|
$filter,
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
'width: 200px',
|
||||||
|
'5'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
echo html_print_select_from_sql(
|
||||||
|
'SELECT id_tag, name
|
||||||
|
FROM ttag
|
||||||
|
WHERE id_tag
|
||||||
|
ORDER BY name',
|
||||||
|
'filter[]',
|
||||||
|
$filter,
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
'width: 200px',
|
||||||
|
'5'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
echo '<p class="label-dialog">'.__('Module group').'</p>';
|
||||||
|
echo html_print_select_from_sql(
|
||||||
|
'SELECT id_mg, name FROM tmodule_group ORDER BY name',
|
||||||
|
'filter[]',
|
||||||
|
$filter,
|
||||||
|
'',
|
||||||
|
__('Not assigned'),
|
||||||
|
'0',
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
'width: 200px',
|
||||||
|
'5'
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($getInfo === true) {
|
||||||
|
enterprise_include_once('include/functions_agents.php');
|
||||||
|
$id = get_parameter('id', 0);
|
||||||
|
switch ($type) {
|
||||||
|
case 2:
|
||||||
|
$data = db_get_row('tagente_modulo', 'id_agente_modulo', $id);
|
||||||
|
|
||||||
|
// Nombre.
|
||||||
|
$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']
|
||||||
|
);
|
||||||
|
echo '<div class="div-dialog">';
|
||||||
|
echo '<p class="title-dialog">'.__('Module name').'</p>';
|
||||||
|
echo '<a href="'.$link.'" class="info-dialog">'.$data['nombre'].'</a>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
// Descripcion.
|
||||||
|
$description = (empty($data['descripcion']) === true) ? '-' : $data['descripcion'];
|
||||||
|
echo '<div class="div-dialog">';
|
||||||
|
echo '<p class="title-dialog">'.__('Description').'</p>';
|
||||||
|
echo '<p class="info-dialog">'.$description.'</p>';
|
||||||
|
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.
|
||||||
|
$group = (empty($data['id_module_group']) === true)
|
||||||
|
? '-'
|
||||||
|
: modules_get_modulegroup_name($data['id_module_group']);
|
||||||
|
|
||||||
|
echo '<div class="div-dialog">';
|
||||||
|
echo '<p class="title-dialog">'.__('Module group').'</p>';
|
||||||
|
echo '<p class="info-dialog">'.$group.'</p>';
|
||||||
|
echo '</div>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
$data = db_get_row('tagente_modulo', 'id_agente_modulo', $id);
|
||||||
|
|
||||||
|
// Nombre.
|
||||||
|
$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']
|
||||||
|
);
|
||||||
|
echo '<div class="div-dialog">';
|
||||||
|
echo '<p class="title-dialog">'.__('Module name').'</p>';
|
||||||
|
echo '<a href="'.$link.'" class="info-dialog" target="_blank">'.$data['nombre'].'</a>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
// Descripcion.
|
||||||
|
$description = (empty($data['descripcion']) === true) ? '-' : $data['descripcion'];
|
||||||
|
echo '<div class="div-dialog">';
|
||||||
|
echo '<p class="title-dialog">'.__('Description').'</p>';
|
||||||
|
echo '<p class="info-dialog">'.$description.'</p>';
|
||||||
|
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.
|
||||||
|
$group = (empty($data['id_module_group']) === true)
|
||||||
|
? '-'
|
||||||
|
: modules_get_modulegroup_name($data['id_module_group']);
|
||||||
|
|
||||||
|
echo '<div class="div-dialog">';
|
||||||
|
echo '<p class="title-dialog">'.__('Module group').'</p>';
|
||||||
|
echo '<p class="info-dialog">'.$group.'</p>';
|
||||||
|
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>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
$data = agents_get_agent($id);
|
||||||
|
|
||||||
|
// Alias.
|
||||||
|
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">'.$data['alias'].'</a>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
// Ip.
|
||||||
|
echo '<div class="div-dialog">';
|
||||||
|
echo '<p class="title-dialog">'.__('IP').'</p>';
|
||||||
|
echo '<p class="info-dialog">'.$data['direccion'].'</p>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
// OS.
|
||||||
|
echo '<div class="div-dialog">';
|
||||||
|
echo '<p class="title-dialog">'.__('OS').'</p>';
|
||||||
|
echo '<p class="info-dialog">'.ui_print_os_icon($data['id_os'], true, true).'</p>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
// Description.
|
||||||
|
echo '<div class="div-dialog">';
|
||||||
|
echo '<p class="title-dialog">'.__('Description').'</p>';
|
||||||
|
echo '<p class="info-dialog">'.$data['comentarios'].'</p>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
// Group.
|
||||||
|
$secondary_groups = '';
|
||||||
|
$secondary = agents_get_secondary_groups($data['id_agente']);
|
||||||
|
if (isset($secondary['for_select']) === true && empty($secondary['for_select']) === false) {
|
||||||
|
$secondary_groups = implode(', ', $secondary['for_select']);
|
||||||
|
$secondary_groups = ', '.$secondary_groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<div class="div-dialog">';
|
||||||
|
echo '<p class="title-dialog">'.__('Group').'</p>';
|
||||||
|
echo '<p class="info-dialog">'.groups_get_name($data['id_grupo']).$secondary_groups.'</p>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
|
||||||
|
// Events.
|
||||||
|
echo '<div class="div-dialog">';
|
||||||
|
echo graph_graphic_agentevents(
|
||||||
|
$id,
|
||||||
|
100,
|
||||||
|
40,
|
||||||
|
SECONDS_1DAY,
|
||||||
|
'',
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
echo '</div>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
964
pandora_console/include/class/Heatmap.class.php
Normal file
964
pandora_console/include/class/Heatmap.class.php
Normal file
@ -0,0 +1,964 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Heatmap class.
|
||||||
|
*
|
||||||
|
* @category Heatmap
|
||||||
|
* @package Pandora FMS
|
||||||
|
* @subpackage Community
|
||||||
|
* @version 1.0.0
|
||||||
|
* @license See below
|
||||||
|
*
|
||||||
|
* ______ ___ _______ _______ ________
|
||||||
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* Copyright (c) 2005-2022 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.
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
class Heatmap
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Heatmap type.
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
protected $type = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Heatmap filter.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $filter = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allowed methods to be called using AJAX request.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $AJAXMethods = [
|
||||||
|
'showHeatmap',
|
||||||
|
'updateHeatmap',
|
||||||
|
'getDataJson',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Heatmap random id.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $randomId = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Heatmap refresh.
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
protected $refresh = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Heatmap width.
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
protected $width = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Heatmap height.
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
protected $height = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Heatmap search.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $search = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Heatmap group.
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
protected $group = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor function
|
||||||
|
*
|
||||||
|
* @param integer $type Heatmap type.
|
||||||
|
* @param array $filter Heatmap filter.
|
||||||
|
* @param string $randomId Heatmap random id.
|
||||||
|
* @param integer $refresh Heatmap refresh.
|
||||||
|
* @param integer $width Width.
|
||||||
|
* @param integer $height Height.
|
||||||
|
* @param string $search Heatmap search.
|
||||||
|
* @param integer $group Heatmap group.
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
int $type=0,
|
||||||
|
array $filter=[],
|
||||||
|
string $randomId=null,
|
||||||
|
int $refresh=300,
|
||||||
|
int $width=0,
|
||||||
|
int $height=0,
|
||||||
|
string $search=null,
|
||||||
|
int $group=1
|
||||||
|
) {
|
||||||
|
$this->type = $type;
|
||||||
|
$this->filter = $filter;
|
||||||
|
(empty($randomId) === true) ? $this->randomId = uniqid() : $this->randomId = $randomId;
|
||||||
|
$this->refresh = $refresh;
|
||||||
|
$this->width = $width;
|
||||||
|
$this->height = $height;
|
||||||
|
$this->search = $search;
|
||||||
|
$this->group = $group;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
ui_require_css_file('heatmap');
|
||||||
|
|
||||||
|
$settings = [
|
||||||
|
'type' => 'POST',
|
||||||
|
'dataType' => 'html',
|
||||||
|
'url' => ui_get_full_url(
|
||||||
|
'ajax.php',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
),
|
||||||
|
'data' => [
|
||||||
|
'page' => 'operation/heatmap',
|
||||||
|
'method' => 'showHeatmap',
|
||||||
|
'randomId' => $this->randomId,
|
||||||
|
'type' => $this->type,
|
||||||
|
'filter' => $this->filter,
|
||||||
|
'refresh' => $this->refresh,
|
||||||
|
'search' => $this->search,
|
||||||
|
'group' => $this->group,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
echo '<div id="div_'.$this->randomId.'" class="mainDiv">';
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
const randomId = '<?php echo $this->randomId; ?>';
|
||||||
|
const refresh = '<?php echo $this->refresh; ?>';
|
||||||
|
let setting = <?php echo json_encode($settings); ?>;
|
||||||
|
setting['data']['height'] = $(`#div_${randomId}`).height() + 10;
|
||||||
|
setting['data']['width'] = $(`#div_${randomId}`).width();
|
||||||
|
|
||||||
|
// Initial charge.
|
||||||
|
ajaxRequest(
|
||||||
|
`div_${randomId}`,
|
||||||
|
setting
|
||||||
|
);
|
||||||
|
|
||||||
|
// Refresh.
|
||||||
|
setInterval(
|
||||||
|
function() {
|
||||||
|
refreshMap();
|
||||||
|
},
|
||||||
|
(refresh * 1000)
|
||||||
|
);
|
||||||
|
|
||||||
|
function refreshMap() {
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||||
|
data: {
|
||||||
|
page: "operation/heatmap",
|
||||||
|
method: 'getDataJson',
|
||||||
|
randomId: randomId,
|
||||||
|
type: setting['data']['type'],
|
||||||
|
refresh: setting['data']['refresh'],
|
||||||
|
filter: setting['data']['filter'],
|
||||||
|
search: setting['data']['search'],
|
||||||
|
group: setting['data']['group']
|
||||||
|
},
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data) {
|
||||||
|
const total = Object.keys(data).length;
|
||||||
|
if (total === $(`#svg_${randomId} rect`).length) {
|
||||||
|
// Object to array.
|
||||||
|
let lista = Object.values(data);
|
||||||
|
// randomly sort.
|
||||||
|
lista = lista.sort(function() {return Math.random() - 0.5});
|
||||||
|
|
||||||
|
const countPerSecond = total / refresh;
|
||||||
|
|
||||||
|
let cont = 0;
|
||||||
|
let limit = countPerSecond - 1;
|
||||||
|
|
||||||
|
const timer = setInterval(
|
||||||
|
function() {
|
||||||
|
while (cont <= limit) {
|
||||||
|
$(`#${randomId}_${lista[cont]['id']}`).removeClass();
|
||||||
|
$(`#${randomId}_${lista[cont]['id']}`).addClass(`${lista[cont]['status']} hover`);
|
||||||
|
|
||||||
|
cont++;
|
||||||
|
}
|
||||||
|
limit = limit + countPerSecond;
|
||||||
|
},
|
||||||
|
1000
|
||||||
|
);
|
||||||
|
|
||||||
|
setTimeout(
|
||||||
|
function(){
|
||||||
|
clearInterval(timer);
|
||||||
|
},
|
||||||
|
(refresh * 1000)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for filter
|
||||||
|
*
|
||||||
|
* @param array $filter Filter.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setFilter(array $filter)
|
||||||
|
{
|
||||||
|
$this->filter = $filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for type
|
||||||
|
*
|
||||||
|
* @param integer $type Type.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setType(int $type)
|
||||||
|
{
|
||||||
|
$this->type = $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for refresh
|
||||||
|
*
|
||||||
|
* @param integer $refresh Refresh.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setRefresh(int $refresh)
|
||||||
|
{
|
||||||
|
$this->refresh = $refresh;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for randomId
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRandomId()
|
||||||
|
{
|
||||||
|
return $this->randomId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all agents
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getAllAgents()
|
||||||
|
{
|
||||||
|
$filter['disabled'] = 0;
|
||||||
|
|
||||||
|
$alias = '';
|
||||||
|
if (empty($this->search) === false) {
|
||||||
|
$alias = ' AND alias LIKE "%'.$this->search.'%"';
|
||||||
|
}
|
||||||
|
|
||||||
|
$id_grupo = '';
|
||||||
|
if (empty($this->filter) === false && current($this->filter) != 0) {
|
||||||
|
$id_grupo = ' AND id_grupo IN ('.implode(',', $this->filter).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
// All agents.
|
||||||
|
$sql = sprintf(
|
||||||
|
'SELECT DISTINCT id_agente as id,alias,id_grupo,normal_count,warning_count,critical_count, unknown_count,notinit_count,total_count,fired_count,
|
||||||
|
(SELECT last_status_change FROM tagente_estado WHERE id_agente = tagente.id_agente ORDER BY last_status_change DESC LIMIT 1) AS last_status_change
|
||||||
|
FROM tagente WHERE `disabled` = 0 %s %s ORDER BY id_grupo,id_agente ASC',
|
||||||
|
$alias,
|
||||||
|
$id_grupo
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
|
$agents = [];
|
||||||
|
// Agent status.
|
||||||
|
foreach ($result as $key => $agent) {
|
||||||
|
if ($agent['total_count'] === 0 || $agent['total_count'] === $agent['notinit_count']) {
|
||||||
|
$status = 'notinit';
|
||||||
|
} else if ($agent['critical_count'] > 0) {
|
||||||
|
$status = 'critical';
|
||||||
|
} else if ($agent['warning_count'] > 0) {
|
||||||
|
$status = 'warning';
|
||||||
|
} else if ($agent['unknown_count'] > 0) {
|
||||||
|
$status = 'unknown';
|
||||||
|
} else {
|
||||||
|
$status = 'normal';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($agent['last_status_change'] != 0) {
|
||||||
|
$seconds = (time() - $agent['last_status_change']);
|
||||||
|
|
||||||
|
if ($seconds >= SECONDS_1DAY) {
|
||||||
|
$status .= '_10';
|
||||||
|
} else if ($seconds >= 77760) {
|
||||||
|
$status .= '_9';
|
||||||
|
} else if ($seconds >= 69120) {
|
||||||
|
$status .= '_8';
|
||||||
|
} else if ($seconds >= 60480) {
|
||||||
|
$status .= '_7';
|
||||||
|
} else if ($seconds >= 51840) {
|
||||||
|
$status .= '_6';
|
||||||
|
} else if ($seconds >= 43200) {
|
||||||
|
$status .= '_5';
|
||||||
|
} else if ($seconds >= 34560) {
|
||||||
|
$status .= '_4';
|
||||||
|
} else if ($seconds >= 25920) {
|
||||||
|
$status .= '_3';
|
||||||
|
} else if ($seconds >= 17280) {
|
||||||
|
$status .= '_2';
|
||||||
|
} else if ($seconds >= 8640) {
|
||||||
|
$status .= '_1';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$agents[$key] = $agent;
|
||||||
|
$agents[$key]['status'] = $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $agents;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all modules
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getAllModulesByGroup()
|
||||||
|
{
|
||||||
|
$filter_group = '';
|
||||||
|
if (empty($this->filter) === false && current($this->filter) != -1) {
|
||||||
|
$filter_group = 'AND am.id_module_group IN ('.implode(',', $this->filter).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
$filter_name = '';
|
||||||
|
if (empty($this->search) === false) {
|
||||||
|
$filter_name = 'AND nombre LIKE "%'.$this->search.'%"';
|
||||||
|
}
|
||||||
|
|
||||||
|
// All modules.
|
||||||
|
$sql = sprintf(
|
||||||
|
'SELECT am.id_agente_modulo AS id, ae.known_status AS `status`, am.id_module_group AS id_grupo, ae.last_status_change FROM tagente_modulo am
|
||||||
|
INNER JOIN tagente_estado ae ON am.id_agente_modulo = ae.id_agente_modulo
|
||||||
|
WHERE am.disabled = 0 %s %s GROUP BY am.id_module_group, am.id_agente_modulo',
|
||||||
|
$filter_group,
|
||||||
|
$filter_name
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
|
// Module status.
|
||||||
|
foreach ($result as $key => $module) {
|
||||||
|
$status = '';
|
||||||
|
switch ($module['status']) {
|
||||||
|
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||||
|
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
|
||||||
|
case 1:
|
||||||
|
case 100:
|
||||||
|
$status = 'critical';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AGENT_MODULE_STATUS_NORMAL:
|
||||||
|
case AGENT_MODULE_STATUS_NORMAL_ALERT:
|
||||||
|
case 0:
|
||||||
|
case 300:
|
||||||
|
$status = 'normal';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AGENT_MODULE_STATUS_WARNING:
|
||||||
|
case AGENT_MODULE_STATUS_WARNING_ALERT:
|
||||||
|
case 2:
|
||||||
|
case 200:
|
||||||
|
$status = 'warning';
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case AGENT_MODULE_STATUS_UNKNOWN:
|
||||||
|
case 3:
|
||||||
|
$status = 'unknown';
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_NOT_INIT:
|
||||||
|
case 5:
|
||||||
|
$status = 'notinit';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($module['last_status_change'] != 0) {
|
||||||
|
$seconds = (time() - $module['last_status_change']);
|
||||||
|
|
||||||
|
if ($seconds >= SECONDS_1DAY) {
|
||||||
|
$status .= '_10';
|
||||||
|
} else if ($seconds >= 77760) {
|
||||||
|
$status .= '_9';
|
||||||
|
} else if ($seconds >= 69120) {
|
||||||
|
$status .= '_8';
|
||||||
|
} else if ($seconds >= 60480) {
|
||||||
|
$status .= '_7';
|
||||||
|
} else if ($seconds >= 51840) {
|
||||||
|
$status .= '_6';
|
||||||
|
} else if ($seconds >= 43200) {
|
||||||
|
$status .= '_5';
|
||||||
|
} else if ($seconds >= 34560) {
|
||||||
|
$status .= '_4';
|
||||||
|
} else if ($seconds >= 25920) {
|
||||||
|
$status .= '_3';
|
||||||
|
} else if ($seconds >= 17280) {
|
||||||
|
$status .= '_2';
|
||||||
|
} else if ($seconds >= 8640) {
|
||||||
|
$status .= '_1';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result[$key]['status'] = $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all modules
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getAllModulesByTag()
|
||||||
|
{
|
||||||
|
$filter_tag = '';
|
||||||
|
if (empty($this->filter) === false && $this->filter[0] !== '0') {
|
||||||
|
$tags = implode(',', $this->filter);
|
||||||
|
$filter_tag .= ' AND tm.id_tag IN ('.$tags.')';
|
||||||
|
}
|
||||||
|
|
||||||
|
$filter_name = '';
|
||||||
|
if (empty($this->search) === false) {
|
||||||
|
$filter_name = 'AND nombre LIKE "%'.$this->search.'%"';
|
||||||
|
}
|
||||||
|
|
||||||
|
// All modules.
|
||||||
|
$sql = sprintf(
|
||||||
|
'SELECT ae.id_agente_modulo AS id, ae.known_status AS `status`, tm.id_tag AS id_grupo, ae.last_status_change FROM tagente_estado ae
|
||||||
|
INNER JOIN ttag_module tm ON tm.id_agente_modulo = ae.id_agente_modulo
|
||||||
|
WHERE 1=1 %s %s GROUP BY tm.id_tag, ae.id_agente_modulo',
|
||||||
|
$filter_tag,
|
||||||
|
$filter_name
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
|
// Module status.
|
||||||
|
foreach ($result as $key => $module) {
|
||||||
|
$status = '';
|
||||||
|
switch ($module['status']) {
|
||||||
|
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||||
|
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
|
||||||
|
case 1:
|
||||||
|
case 100:
|
||||||
|
$status = 'critical';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AGENT_MODULE_STATUS_NORMAL:
|
||||||
|
case AGENT_MODULE_STATUS_NORMAL_ALERT:
|
||||||
|
case 0:
|
||||||
|
case 300:
|
||||||
|
$status = 'normal';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AGENT_MODULE_STATUS_WARNING:
|
||||||
|
case AGENT_MODULE_STATUS_WARNING_ALERT:
|
||||||
|
case 2:
|
||||||
|
case 200:
|
||||||
|
$status = 'warning';
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case AGENT_MODULE_STATUS_UNKNOWN:
|
||||||
|
case 3:
|
||||||
|
$status = 'unknown';
|
||||||
|
break;
|
||||||
|
case AGENT_MODULE_STATUS_NOT_INIT:
|
||||||
|
case 5:
|
||||||
|
$status = 'notinit';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($module['last_status_change'] != 0) {
|
||||||
|
$seconds = (time() - $module['last_status_change']);
|
||||||
|
|
||||||
|
if ($seconds >= SECONDS_1DAY) {
|
||||||
|
$status .= '_10';
|
||||||
|
} else if ($seconds >= 77760) {
|
||||||
|
$status .= '_9';
|
||||||
|
} else if ($seconds >= 69120) {
|
||||||
|
$status .= '_8';
|
||||||
|
} else if ($seconds >= 60480) {
|
||||||
|
$status .= '_7';
|
||||||
|
} else if ($seconds >= 51840) {
|
||||||
|
$status .= '_6';
|
||||||
|
} else if ($seconds >= 43200) {
|
||||||
|
$status .= '_5';
|
||||||
|
} else if ($seconds >= 34560) {
|
||||||
|
$status .= '_4';
|
||||||
|
} else if ($seconds >= 25920) {
|
||||||
|
$status .= '_3';
|
||||||
|
} else if ($seconds >= 17280) {
|
||||||
|
$status .= '_2';
|
||||||
|
} else if ($seconds >= 8640) {
|
||||||
|
$status .= '_1';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result[$key]['status'] = $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetData
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getData()
|
||||||
|
{
|
||||||
|
switch ($this->type) {
|
||||||
|
case 2:
|
||||||
|
$data = $this->getAllModulesByGroup();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
$data = $this->getAllModulesByTag();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
$data = $this->getAllAgents();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetDataJson
|
||||||
|
*
|
||||||
|
* @return json
|
||||||
|
*/
|
||||||
|
public function getDataJson()
|
||||||
|
{
|
||||||
|
$return = $this->getData();
|
||||||
|
echo json_encode($return);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get class by status
|
||||||
|
*
|
||||||
|
* @param integer $status Status.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function statusColour(int $status)
|
||||||
|
{
|
||||||
|
switch ($status) {
|
||||||
|
case AGENT_STATUS_CRITICAL:
|
||||||
|
$return = 'critical';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AGENT_STATUS_WARNING:
|
||||||
|
$return = 'warning';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AGENT_STATUS_UNKNOWN:
|
||||||
|
$return = 'unknown';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AGENT_STATUS_NOT_INIT:
|
||||||
|
$return = 'notinit';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AGENT_STATUS_NORMAL:
|
||||||
|
default:
|
||||||
|
$return = 'normal';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get max. number of y-axis
|
||||||
|
*
|
||||||
|
* @param integer $total Total.
|
||||||
|
* @param float $relation Aspect relation.
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
protected function getYAxis(int $total, float $relation)
|
||||||
|
{
|
||||||
|
$yAxis = sqrt(($total / $relation));
|
||||||
|
return $yAxis;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if target method is available to be called using AJAX.
|
||||||
|
*
|
||||||
|
* @param string $method Target method.
|
||||||
|
*
|
||||||
|
* @return boolean True allowed, false not.
|
||||||
|
*/
|
||||||
|
public function ajaxMethod(string $method):bool
|
||||||
|
{
|
||||||
|
return in_array($method, $this->AJAXMethods);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ShowHeatmap
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function showHeatmap()
|
||||||
|
{
|
||||||
|
$result = $this->getData();
|
||||||
|
|
||||||
|
if (empty($result) === true) {
|
||||||
|
echo '<div style="position: absolute; top:70px; left:20px">'.__('No data found').'</div>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$count_result = count($result);
|
||||||
|
|
||||||
|
$scale = ($this->width / $this->height);
|
||||||
|
$Yaxis = $this->getYAxis($count_result, $scale);
|
||||||
|
if ($count_result <= 3) {
|
||||||
|
$Xaxis = $count_result;
|
||||||
|
$Yaxis = 1;
|
||||||
|
} else {
|
||||||
|
$Xaxis = (int) ceil($Yaxis * $scale);
|
||||||
|
$Yaxis = ceil($Yaxis);
|
||||||
|
}
|
||||||
|
|
||||||
|
$viewBox = sprintf(
|
||||||
|
'0 0 %d %d',
|
||||||
|
$Xaxis,
|
||||||
|
$Yaxis
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '<svg id="svg_'.$this->randomId.'" width="'.$this->width.'"
|
||||||
|
height="'.$this->height.'" viewBox="'.$viewBox.'">';
|
||||||
|
|
||||||
|
$groups = [];
|
||||||
|
$contX = 0;
|
||||||
|
$contY = 0;
|
||||||
|
foreach ($result as $value) {
|
||||||
|
echo '<rect id="'.$this->randomId.'_'.$value['id'].'" class="'.$value['status'].' hover"
|
||||||
|
width="1" height="1" x ="'.$contX.' "y="'.$contY.'" />';
|
||||||
|
|
||||||
|
$contX++;
|
||||||
|
if ($contX >= $Xaxis) {
|
||||||
|
$contY++;
|
||||||
|
$contX = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($groups[$value['id_grupo']]) === true) {
|
||||||
|
$groups[$value['id_grupo']] = 1;
|
||||||
|
} else {
|
||||||
|
$groups[$value['id_grupo']] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$('rect').click(function() {
|
||||||
|
const type = <?php echo $this->type; ?>;
|
||||||
|
const hash = '<?php echo $this->randomId; ?>';
|
||||||
|
const id = this.id.replace(`${hash}_`, '');
|
||||||
|
|
||||||
|
$("#info_dialog").dialog({
|
||||||
|
resizable: true,
|
||||||
|
draggable: true,
|
||||||
|
modal: true,
|
||||||
|
closeOnEscape: true,
|
||||||
|
height: 400,
|
||||||
|
width: 530,
|
||||||
|
title: '<?php echo __('Info'); ?>',
|
||||||
|
open: function() {
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||||
|
data: {
|
||||||
|
page: "include/ajax/heatmap.ajax",
|
||||||
|
getInfo: 1,
|
||||||
|
type: type,
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
dataType: 'html',
|
||||||
|
success: function(data) {
|
||||||
|
$('#info_dialog').empty();
|
||||||
|
$('#info_dialog').append(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
if (count($groups) > 1 && $this->group === 1) {
|
||||||
|
$x_back = 0;
|
||||||
|
$y_back = 0;
|
||||||
|
|
||||||
|
if ($count_result <= 100) {
|
||||||
|
$fontSize = 'small-size';
|
||||||
|
$stroke = 'small-stroke';
|
||||||
|
} else {
|
||||||
|
$fontSize = 'big-size';
|
||||||
|
$stroke = 'big-stroke';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<polyline points="0,0 '.$Xaxis.',0" class="polyline '.$stroke.'" />';
|
||||||
|
foreach ($groups as $key => $group) {
|
||||||
|
$name = '';
|
||||||
|
switch ($this->type) {
|
||||||
|
case 2:
|
||||||
|
$name = modules_get_modulegroup_name($key);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
$name = tags_get_name($key);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
$name = groups_get_name($key);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($x_back + $group) <= $Xaxis) {
|
||||||
|
$x_position = ($x_back + $group);
|
||||||
|
$y_position = $y_back;
|
||||||
|
|
||||||
|
if ($y_back === 0 && $x_back === 0) {
|
||||||
|
$points = sprintf(
|
||||||
|
'%d,%d %d,%d',
|
||||||
|
$x_back,
|
||||||
|
$y_back,
|
||||||
|
$x_back,
|
||||||
|
($y_back + 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
|
||||||
|
}
|
||||||
|
|
||||||
|
$points = sprintf(
|
||||||
|
'%d,%d %d,%d %d,%d',
|
||||||
|
$x_back,
|
||||||
|
($y_position + 1),
|
||||||
|
$x_position,
|
||||||
|
($y_position + 1),
|
||||||
|
$x_position,
|
||||||
|
$y_back
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
|
||||||
|
|
||||||
|
// Name.
|
||||||
|
echo '<text x="'.((($x_position - $x_back) / 2) + $x_back).'" y="'.($y_position + 1).'"
|
||||||
|
class="'.$fontSize.'">'.$name.'</text>';
|
||||||
|
|
||||||
|
$x_back = $x_position;
|
||||||
|
if ($x_position === $Xaxis) {
|
||||||
|
$points = sprintf(
|
||||||
|
'%d,%d %d,%d',
|
||||||
|
$x_position,
|
||||||
|
$y_back,
|
||||||
|
$x_position,
|
||||||
|
($y_back + 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
|
||||||
|
|
||||||
|
$y_back++;
|
||||||
|
$x_back = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$round = (int) floor(($x_back + $group) / $Xaxis);
|
||||||
|
$y_position = ($round + $y_back);
|
||||||
|
|
||||||
|
if ($round === 1) {
|
||||||
|
// One line.
|
||||||
|
$x_position = (($x_back + $group) - $Xaxis);
|
||||||
|
|
||||||
|
if ($x_position <= $x_back) {
|
||||||
|
// Bottom line.
|
||||||
|
$points = sprintf(
|
||||||
|
'%d,%d %d,%d',
|
||||||
|
$x_back,
|
||||||
|
$y_position,
|
||||||
|
$Xaxis,
|
||||||
|
($y_position)
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bottom of last line.
|
||||||
|
$points = sprintf(
|
||||||
|
'%d,%d %d,%d',
|
||||||
|
0,
|
||||||
|
($y_position + 1),
|
||||||
|
$x_position,
|
||||||
|
($y_position + 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
|
||||||
|
|
||||||
|
// Name.
|
||||||
|
echo '<text x="'.(($x_position) / 2).'" y="'.($y_position + 1).'"
|
||||||
|
class="'.$fontSize.'">'.$name.'</text>';
|
||||||
|
|
||||||
|
// Bottom-right of last line.
|
||||||
|
$points = sprintf(
|
||||||
|
'%d,%d %d,%d',
|
||||||
|
$x_position,
|
||||||
|
($y_position),
|
||||||
|
$x_position,
|
||||||
|
($y_position + 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
|
||||||
|
|
||||||
|
if ($x_position > $x_back) {
|
||||||
|
// Bottom-top of last line.
|
||||||
|
$points = sprintf(
|
||||||
|
'%d,%d %d,%d',
|
||||||
|
$x_position,
|
||||||
|
($y_position),
|
||||||
|
$Xaxis,
|
||||||
|
($y_position)
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Two or more lines.
|
||||||
|
$x_position = (($x_back + $group) - ($Xaxis * $round));
|
||||||
|
|
||||||
|
if ($x_position === 0) {
|
||||||
|
$x_position = $Xaxis;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bottom of last line.
|
||||||
|
$points = sprintf(
|
||||||
|
'%d,%d %d,%d',
|
||||||
|
0,
|
||||||
|
($y_position + 1),
|
||||||
|
$x_position,
|
||||||
|
($y_position + 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
|
||||||
|
|
||||||
|
// Bottom-right of last line.
|
||||||
|
$points = sprintf(
|
||||||
|
'%d,%d %d,%d',
|
||||||
|
$x_position,
|
||||||
|
($y_position),
|
||||||
|
$x_position,
|
||||||
|
($y_position + 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
|
||||||
|
|
||||||
|
// Name.
|
||||||
|
echo '<text x="'.(($x_position) / 2).'" y="'.($y_position + 1).'"
|
||||||
|
class="'.$fontSize.'">'.$name.'</text>';
|
||||||
|
|
||||||
|
// Bottom-top of last line.
|
||||||
|
$points = sprintf(
|
||||||
|
'%d,%d %d,%d',
|
||||||
|
$x_position,
|
||||||
|
($y_position),
|
||||||
|
$Xaxis,
|
||||||
|
($y_position)
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($x_position === $Xaxis) {
|
||||||
|
$x_position = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$x_back = $x_position;
|
||||||
|
$y_back = $y_position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</svg>';
|
||||||
|
|
||||||
|
// Dialog.
|
||||||
|
echo '<div id="info_dialog" style="padding:15px" class="invisible"></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -20,7 +20,7 @@
|
|||||||
/**
|
/**
|
||||||
* Pandora build version and version
|
* Pandora build version and version
|
||||||
*/
|
*/
|
||||||
$build_version = 'PC220401';
|
$build_version = 'PC220404';
|
||||||
$pandora_version = 'v7.0NG.760';
|
$pandora_version = 'v7.0NG.760';
|
||||||
|
|
||||||
// Do not overwrite default timezone set if defined.
|
// Do not overwrite default timezone set if defined.
|
||||||
|
271
pandora_console/include/styles/heatmap.css
Normal file
271
pandora_console/include/styles/heatmap.css
Normal file
@ -0,0 +1,271 @@
|
|||||||
|
.mainDiv {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 750px;
|
||||||
|
height: 100%;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normal_10 {
|
||||||
|
fill: #82b92e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normal_9 {
|
||||||
|
fill: #89be38;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normal_8 {
|
||||||
|
fill: #8dc13d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normal_7 {
|
||||||
|
fill: #90c342;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normal_6 {
|
||||||
|
fill: #97c84c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normal_5 {
|
||||||
|
fill: #9dcc55;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normal_4 {
|
||||||
|
fill: #a4d15f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normal_3 {
|
||||||
|
fill: #aad569;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normal_2 {
|
||||||
|
fill: #b1da73;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normal_1 {
|
||||||
|
fill: #b7de7c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normal {
|
||||||
|
fill: #c0e28d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.critical_10 {
|
||||||
|
fill: #e63c52;
|
||||||
|
}
|
||||||
|
|
||||||
|
.critical_9 {
|
||||||
|
fill: #e8475c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.critical_8 {
|
||||||
|
fill: #e95266;
|
||||||
|
}
|
||||||
|
|
||||||
|
.critical_7 {
|
||||||
|
fill: #ea586b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.critical_6 {
|
||||||
|
fill: #eb5d70;
|
||||||
|
}
|
||||||
|
|
||||||
|
.critical_5 {
|
||||||
|
fill: #ec6879;
|
||||||
|
}
|
||||||
|
|
||||||
|
.critical_4 {
|
||||||
|
fill: #ee7383;
|
||||||
|
}
|
||||||
|
|
||||||
|
.critical_3 {
|
||||||
|
fill: #ef7e8c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.critical_2 {
|
||||||
|
fill: #f08996;
|
||||||
|
}
|
||||||
|
|
||||||
|
.critical_1 {
|
||||||
|
fill: #f1939f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.critical {
|
||||||
|
fill: #f3a5af;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning_10 {
|
||||||
|
fill: #f3b200;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning_9 {
|
||||||
|
fill: #f5b70e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning_8 {
|
||||||
|
fill: #f6ba15;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning_7 {
|
||||||
|
fill: #f6bc1c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning_6 {
|
||||||
|
fill: #f8c12a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning_5 {
|
||||||
|
fill: #f9c638;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning_4 {
|
||||||
|
fill: #fbcb46;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning_3 {
|
||||||
|
fill: #fcd054;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning_2 {
|
||||||
|
fill: #fed562;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning_1 {
|
||||||
|
fill: #ffd970;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning {
|
||||||
|
fill: #ffde85;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unknown_10,
|
||||||
|
.unknown_9,
|
||||||
|
.unknown_8,
|
||||||
|
.unknown_7 {
|
||||||
|
fill: #b2b2b2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unknown_6,
|
||||||
|
.unknown_5,
|
||||||
|
.unknown_4,
|
||||||
|
.unknown_3 {
|
||||||
|
fill: #c2c2c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unknown_2,
|
||||||
|
.unknown_1,
|
||||||
|
.unknown {
|
||||||
|
fill: #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notinit {
|
||||||
|
fill: #4a83f3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hover:hover {
|
||||||
|
filter: brightness(1.5);
|
||||||
|
stroke-width: 0.009;
|
||||||
|
stroke: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group {
|
||||||
|
fill: none;
|
||||||
|
stroke-width: 0.03;
|
||||||
|
stroke: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.pure {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#main_pure {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#heatmap-controls {
|
||||||
|
position: fixed;
|
||||||
|
top: 30px;
|
||||||
|
right: 20px;
|
||||||
|
width: 350px;
|
||||||
|
background-color: #ececec;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: 5px;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#heatmap-controls div#menu_tab {
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#heatmap-controls ul.white-box-content {
|
||||||
|
background-color: #ececec;
|
||||||
|
border: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#heatmap-controls div.heatmap-title,
|
||||||
|
div#heatmap-controls div.heatmap-refr {
|
||||||
|
margin-top: 15px;
|
||||||
|
margin-left: 3px;
|
||||||
|
margin-right: 3px;
|
||||||
|
}
|
||||||
|
div#heatmap-controls div.heatmap-refr > div {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.refr-form {
|
||||||
|
margin-bottom: 0 !important;
|
||||||
|
padding: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-dialog {
|
||||||
|
width: 30%;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.div-dialog {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: left;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title-dialog {
|
||||||
|
width: 40%;
|
||||||
|
font-weight: bold;
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-dialog {
|
||||||
|
width: 60%;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.polyline {
|
||||||
|
fill: none;
|
||||||
|
stroke: black;
|
||||||
|
stroke-width: 0.05;
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-stroke {
|
||||||
|
stroke-width: 0.03;
|
||||||
|
}
|
||||||
|
|
||||||
|
.big-stroke {
|
||||||
|
stroke-width: 0.05;
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-size {
|
||||||
|
font-size: 0.2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.big-size {
|
||||||
|
font-size: 0.4px;
|
||||||
|
}
|
@ -129,7 +129,7 @@
|
|||||||
<div style='height: 10px'>
|
<div style='height: 10px'>
|
||||||
<?php
|
<?php
|
||||||
$version = '7.0NG.760';
|
$version = '7.0NG.760';
|
||||||
$build = '220401';
|
$build = '220404';
|
||||||
$banner = "v$version Build $build";
|
$banner = "v$version Build $build";
|
||||||
|
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
|
346
pandora_console/operation/heatmap.php
Normal file
346
pandora_console/operation/heatmap.php
Normal file
@ -0,0 +1,346 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Tree view.
|
||||||
|
*
|
||||||
|
* @category Operation
|
||||||
|
* @package Pandora FMS
|
||||||
|
* @subpackage Community
|
||||||
|
* @version 1.0.0
|
||||||
|
* @license See below
|
||||||
|
*
|
||||||
|
* ______ ___ _______ _______ ________
|
||||||
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* Copyright (c) 2005-2022 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;
|
||||||
|
// Login check.
|
||||||
|
check_login();
|
||||||
|
|
||||||
|
$agent_a = (bool) check_acl($config['id_user'], 0, 'AR');
|
||||||
|
$agent_w = (bool) check_acl($config['id_user'], 0, 'AW');
|
||||||
|
|
||||||
|
if ($agent_a === false && $agent_w === false) {
|
||||||
|
db_pandora_audit('ACL Violation', 'Trying to access agent main list view');
|
||||||
|
include 'general/noaccess.php';
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once $config['homedir'].'/include/class/Heatmap.class.php';
|
||||||
|
|
||||||
|
$pure = (bool) get_parameter('pure', false);
|
||||||
|
$type = get_parameter('type', 0);
|
||||||
|
$randomId = get_parameter('randomId', null);
|
||||||
|
$refresh = get_parameter('refresh', SECONDS_5MINUTES);
|
||||||
|
$height = get_parameter('height', 0);
|
||||||
|
$width = get_parameter('width', 0);
|
||||||
|
$search = get_parameter('search', '');
|
||||||
|
$filter = get_parameter('filter', []);
|
||||||
|
if (is_array($filter) === false) {
|
||||||
|
$filter = explode(',', $filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
$group_sent = (bool) get_parameter('group_sent');
|
||||||
|
if ($group_sent === true) {
|
||||||
|
$group = (int) get_parameter('group');
|
||||||
|
} else {
|
||||||
|
$group = (int) get_parameter('group', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$is_ajax = is_ajax();
|
||||||
|
if ($is_ajax === false && $pure === false) {
|
||||||
|
$viewtab['config'] = '<a id="config" href="">'.html_print_image(
|
||||||
|
'images/setup.png',
|
||||||
|
true,
|
||||||
|
[
|
||||||
|
'title' => __('Config'),
|
||||||
|
'class' => 'invert_filter',
|
||||||
|
]
|
||||||
|
).'</a>';
|
||||||
|
|
||||||
|
$url = sprintf(
|
||||||
|
'index.php?sec=view&sec2=operation/heatmap&pure=1&type=%s&refresh=%s&search=%s&filter=%s',
|
||||||
|
$type,
|
||||||
|
$refresh,
|
||||||
|
$search,
|
||||||
|
implode(',', $filter)
|
||||||
|
);
|
||||||
|
|
||||||
|
$viewtab['full_screen'] = '<a id="full_screen" href="'.$url.'">'.html_print_image(
|
||||||
|
'images/full_screen.png',
|
||||||
|
true,
|
||||||
|
[
|
||||||
|
'title' => __('Full screen'),
|
||||||
|
'class' => 'invert_filter',
|
||||||
|
]
|
||||||
|
).'</a>';
|
||||||
|
|
||||||
|
$header_name = __('Heatmap view');
|
||||||
|
switch ($type) {
|
||||||
|
case 2:
|
||||||
|
if (current($filter) == 0) {
|
||||||
|
$header_name .= ' - '.__('Module group').': '.__('Not assigned');
|
||||||
|
} else {
|
||||||
|
$header_name .= ' - '.__('Module group').': '.modules_get_modulegroup_name(current($filter));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
$tags_name = '';
|
||||||
|
foreach ($filter as $key => $tag) {
|
||||||
|
$tags_name .= tags_get_name($tag).', ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$tags_name = trim($tags_name, ', ');
|
||||||
|
$header_name .= ' - '.__('Tag').': '.$tags_name;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
if (current($filter) == 0) {
|
||||||
|
$header_name .= ' - '.__('Group').': '.__('All');
|
||||||
|
} else {
|
||||||
|
$header_name .= ' - '.__('Group').': '.groups_get_name(current($filter));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Header.
|
||||||
|
ui_print_standard_header(
|
||||||
|
$header_name,
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
$viewtab,
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'link' => '',
|
||||||
|
'label' => __('Monitoring'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'link' => '',
|
||||||
|
'label' => __('Views'),
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($is_ajax === false && $pure === true) {
|
||||||
|
// Floating menu - Start.
|
||||||
|
echo '<div id="heatmap-controls" class="zindex999">';
|
||||||
|
|
||||||
|
echo '<div id="menu_tab" method="post">';
|
||||||
|
echo '<ul class="mn white-box-content box-shadow flex-row">';
|
||||||
|
|
||||||
|
// Name.
|
||||||
|
echo '<li class="nomn">';
|
||||||
|
|
||||||
|
html_print_div(
|
||||||
|
[
|
||||||
|
'class' => 'heatmap-title',
|
||||||
|
'content' => 'Heatmap',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '</li>';
|
||||||
|
|
||||||
|
// Countdown.
|
||||||
|
echo '<li class="nomn">';
|
||||||
|
echo '<div class="heatmap-refr">';
|
||||||
|
|
||||||
|
echo '<div id="heatmap-refr-form">';
|
||||||
|
echo '<form id="refr-form" class="refr-form" method="post">';
|
||||||
|
echo __('Refresh').':';
|
||||||
|
echo html_print_select(
|
||||||
|
[
|
||||||
|
'30' => __('30 seconds'),
|
||||||
|
(string) SECONDS_1MINUTE => __('1 minute'),
|
||||||
|
'180' => __('3 minutes'),
|
||||||
|
(string) SECONDS_5MINUTES => __('5 minutes'),
|
||||||
|
],
|
||||||
|
'refresh-control',
|
||||||
|
$refresh,
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
0,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
// Hidden.
|
||||||
|
html_print_input_hidden('refresh', $refresh);
|
||||||
|
html_print_input_hidden('type', $type);
|
||||||
|
html_print_input_hidden('search', $search);
|
||||||
|
html_print_input_hidden('filter', implode(',', $filter));
|
||||||
|
echo '</form>';
|
||||||
|
echo '</div>';
|
||||||
|
echo '</div>';
|
||||||
|
echo '</li>';
|
||||||
|
|
||||||
|
// Quit fullscreen.
|
||||||
|
echo '<li class="nomn">';
|
||||||
|
$urlNoFull = sprintf(
|
||||||
|
'index.php?sec=view&sec2=operation/heatmap&pure=0&type=%s&refresh=%s&search=%s&filter=%s',
|
||||||
|
$type,
|
||||||
|
$refresh,
|
||||||
|
$search,
|
||||||
|
implode(',', $filter)
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '<a href="'.$urlNoFull.'">';
|
||||||
|
echo html_print_image(
|
||||||
|
'images/normal_screen.png',
|
||||||
|
true,
|
||||||
|
[
|
||||||
|
'title' => __('Back to normal mode'),
|
||||||
|
'class' => 'invert_filter',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
echo '</a>';
|
||||||
|
echo '</li>';
|
||||||
|
|
||||||
|
echo '</ul>';
|
||||||
|
|
||||||
|
// Hidden.
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Control call flow.
|
||||||
|
try {
|
||||||
|
// Heatmap construct.
|
||||||
|
$heatmap = new Heatmap($type, $filter, $randomId, $refresh, $width, $height, $search, $group);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
if (is_ajax() === true) {
|
||||||
|
echo json_encode(['error' => '[Heatmap]'.$e->getMessage() ]);
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
echo '[Heatmap]'.$e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop this execution, but continue 'globally'.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AJAX controller.
|
||||||
|
if ($is_ajax === true) {
|
||||||
|
$method = get_parameter('method');
|
||||||
|
|
||||||
|
if (method_exists($heatmap, $method) === true) {
|
||||||
|
if ($heatmap->ajaxMethod($method) === true) {
|
||||||
|
$heatmap->{$method}();
|
||||||
|
} else {
|
||||||
|
echo 'Unavailable method';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo 'Method not found';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop any execution.
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
// Run.
|
||||||
|
$heatmap->run();
|
||||||
|
|
||||||
|
// Dialog.
|
||||||
|
echo '<div id="config_dialog" style="padding:15px" class="invisible"></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#config').click(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$('#config_dialog').empty();
|
||||||
|
$("#config_dialog").dialog({
|
||||||
|
resizable: false,
|
||||||
|
draggable: false,
|
||||||
|
modal: true,
|
||||||
|
closeOnEscape: true,
|
||||||
|
height: 410,
|
||||||
|
width: 330,
|
||||||
|
title: '<?php echo __('Config'); ?>',
|
||||||
|
position: {
|
||||||
|
my: "right top",
|
||||||
|
at: "right bottom",
|
||||||
|
of: $('#config')
|
||||||
|
},
|
||||||
|
overlay: {
|
||||||
|
opacity: 0.5,
|
||||||
|
background: "black"
|
||||||
|
},
|
||||||
|
buttons:[{
|
||||||
|
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-next',
|
||||||
|
text: "<?php echo __('Show'); ?>",
|
||||||
|
click: function() {
|
||||||
|
// Dialog close.
|
||||||
|
$(this).dialog("close");
|
||||||
|
$("#form_dialog").submit();
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
open: function() {
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||||
|
data: {
|
||||||
|
page: "include/ajax/heatmap.ajax",
|
||||||
|
getFilters: 1,
|
||||||
|
type: '<?php echo $type; ?>',
|
||||||
|
refresh: '<?php echo $refresh; ?>',
|
||||||
|
search: '<?php echo $search; ?>',
|
||||||
|
group: '<?php echo $group; ?>',
|
||||||
|
},
|
||||||
|
dataType: 'html',
|
||||||
|
success: function(data) {
|
||||||
|
$('#config_dialog').append(data);
|
||||||
|
$('#type').on('change', function() {
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||||
|
data: {
|
||||||
|
page: "include/ajax/heatmap.ajax",
|
||||||
|
getFilterType: 1,
|
||||||
|
type: this.value,
|
||||||
|
filter: <?php echo json_encode($filter); ?>
|
||||||
|
},
|
||||||
|
dataType: 'html',
|
||||||
|
success: function(data) {
|
||||||
|
$('#filter_type').remove();
|
||||||
|
$('#form_dialog').append(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#type').trigger('change');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const controls = document.getElementById('heatmap-controls');
|
||||||
|
autoHideElement(controls, 1000);
|
||||||
|
|
||||||
|
$('#refresh-control').change(function(e) {
|
||||||
|
$('#hidden-refresh').val(this.value);
|
||||||
|
$('#refr-form').submit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
@ -66,6 +66,9 @@ if (check_acl($config['id_user'], 0, 'AR')) {
|
|||||||
$sub2['operation/agentes/alerts_status']['text'] = __('Alert detail');
|
$sub2['operation/agentes/alerts_status']['text'] = __('Alert detail');
|
||||||
$sub2['operation/agentes/alerts_status']['refr'] = 0;
|
$sub2['operation/agentes/alerts_status']['refr'] = 0;
|
||||||
|
|
||||||
|
$sub2['operation/heatmap']['text'] = __('Heatmap view');
|
||||||
|
$sub2['operation/heatmap']['refr'] = 0;
|
||||||
|
|
||||||
$sub['view']['sub2'] = $sub2;
|
$sub['view']['sub2'] = $sub2;
|
||||||
|
|
||||||
enterprise_hook('inventory_menu');
|
enterprise_hook('inventory_menu');
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
%define name pandorafms_console
|
%define name pandorafms_console
|
||||||
%define version 7.0NG.760
|
%define version 7.0NG.760
|
||||||
%define release 220401
|
%define release 220404
|
||||||
|
|
||||||
# User and Group under which Apache is running
|
# User and Group under which Apache is running
|
||||||
%define httpd_name httpd
|
%define httpd_name httpd
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
%define name pandorafms_console
|
%define name pandorafms_console
|
||||||
%define version 7.0NG.760
|
%define version 7.0NG.760
|
||||||
%define release 220401
|
%define release 220404
|
||||||
|
|
||||||
# User and Group under which Apache is running
|
# User and Group under which Apache is running
|
||||||
%define httpd_name httpd
|
%define httpd_name httpd
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
%define name pandorafms_console
|
%define name pandorafms_console
|
||||||
%define version 7.0NG.760
|
%define version 7.0NG.760
|
||||||
%define release 220401
|
%define release 220404
|
||||||
%define httpd_name httpd
|
%define httpd_name httpd
|
||||||
# User and Group under which Apache is running
|
# User and Group under which Apache is running
|
||||||
%define httpd_name apache2
|
%define httpd_name apache2
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package: pandorafms-server
|
package: pandorafms-server
|
||||||
Version: 7.0NG.760-220401
|
Version: 7.0NG.760-220404
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: admin
|
Section: admin
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
pandora_version="7.0NG.760-220401"
|
pandora_version="7.0NG.760-220404"
|
||||||
|
|
||||||
package_cpan=0
|
package_cpan=0
|
||||||
package_pandora=1
|
package_pandora=1
|
||||||
|
@ -46,7 +46,7 @@ our @EXPORT = qw(
|
|||||||
|
|
||||||
# version: Defines actual version of Pandora Server for this module only
|
# version: Defines actual version of Pandora Server for this module only
|
||||||
my $pandora_version = "7.0NG.760";
|
my $pandora_version = "7.0NG.760";
|
||||||
my $pandora_build = "220401";
|
my $pandora_build = "220404";
|
||||||
our $VERSION = $pandora_version." ".$pandora_build;
|
our $VERSION = $pandora_version." ".$pandora_build;
|
||||||
|
|
||||||
# Setup hash
|
# Setup hash
|
||||||
|
@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
|
|||||||
|
|
||||||
# version: Defines actual version of Pandora Server for this module only
|
# version: Defines actual version of Pandora Server for this module only
|
||||||
my $pandora_version = "7.0NG.760";
|
my $pandora_version = "7.0NG.760";
|
||||||
my $pandora_build = "220401";
|
my $pandora_build = "220404";
|
||||||
our $VERSION = $pandora_version." ".$pandora_build;
|
our $VERSION = $pandora_version." ".$pandora_build;
|
||||||
|
|
||||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
%define name pandorafms_server
|
%define name pandorafms_server
|
||||||
%define version 7.0NG.760
|
%define version 7.0NG.760
|
||||||
%define release 220401
|
%define release 220404
|
||||||
|
|
||||||
Summary: Pandora FMS Server
|
Summary: Pandora FMS Server
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
%define name pandorafms_server
|
%define name pandorafms_server
|
||||||
%define version 7.0NG.760
|
%define version 7.0NG.760
|
||||||
%define release 220401
|
%define release 220404
|
||||||
|
|
||||||
Summary: Pandora FMS Server
|
Summary: Pandora FMS Server
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
# **********************************************************************
|
# **********************************************************************
|
||||||
|
|
||||||
PI_VERSION="7.0NG.760"
|
PI_VERSION="7.0NG.760"
|
||||||
PI_BUILD="220401"
|
PI_BUILD="220404"
|
||||||
|
|
||||||
MODE=$1
|
MODE=$1
|
||||||
if [ $# -gt 1 ]; then
|
if [ $# -gt 1 ]; then
|
||||||
|
@ -35,7 +35,7 @@ use PandoraFMS::Config;
|
|||||||
use PandoraFMS::DB;
|
use PandoraFMS::DB;
|
||||||
|
|
||||||
# version: define current version
|
# version: define current version
|
||||||
my $version = "7.0NG.760 Build 220401";
|
my $version = "7.0NG.760 Build 220404";
|
||||||
|
|
||||||
# Pandora server configuration
|
# Pandora server configuration
|
||||||
my %conf;
|
my %conf;
|
||||||
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
|||||||
Encode::Locale::decode_argv;
|
Encode::Locale::decode_argv;
|
||||||
|
|
||||||
# version: define current version
|
# version: define current version
|
||||||
my $version = "7.0NG.760 Build 220401";
|
my $version = "7.0NG.760 Build 220404";
|
||||||
|
|
||||||
# save program name for logging
|
# save program name for logging
|
||||||
my $progname = basename($0);
|
my $progname = basename($0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user