Merge remote-tracking branch 'origin/develop' into ent-8731-umc-en-vendor

Conflicts:
	pandora_console/extras/mr/53.sql
This commit is contained in:
fbsanchez 2022-04-07 09:44:12 +02:00
commit 686ba0a5a5
99 changed files with 4730 additions and 998 deletions

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, AIX version
# Version 7.0NG.761, AIX version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, FreeBSD Version
# Version 7.0NG.761, FreeBSD Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, HP-UX Version
# Version 7.0NG.761, HP-UX Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, GNU/Linux
# Version 7.0NG.761, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, GNU/Linux
# Version 7.0NG.761, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, Solaris Version
# Version 7.0NG.761, Solaris Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.760
# Version 7.0NG.761
# This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software
# Foundation; either version 2 of the Licence or any later version

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.760, AIX version
# Version 7.0NG.761, AIX version
# General Parameters
# ==================

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.760
# Version 7.0NG.761
# FreeBSD/IPSO version
# Licenced under GPL licence, 2003-2007 Sancho Lerena

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.760, HPUX Version
# Version 7.0NG.761, HPUX Version
# General Parameters
# ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760
# Version 7.0NG.761
# Licensed under GPL license v2,
# (c) 2003-2021 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760
# Version 7.0NG.761
# Licensed under GPL license v2,
# (c) 2003-2021 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760
# Version 7.0NG.761
# Licensed under GPL license v2,
# please visit http://pandora.sourceforge.net

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.760, Solaris version
# Version 7.0NG.761, Solaris version
# General Parameters
# ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, AIX version
# Version 7.0NG.761, AIX version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.760-220330
Version: 7.0NG.761-220407
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.760-220330"
pandora_version="7.0NG.761-220407"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -31,7 +31,7 @@ fi
if [ "$#" -ge 2 ]; then
VERSION="$2"
else
VERSION="7.0NG.760"
VERSION="7.0NG.761"
fi
# Path for the generated DMG file

View File

@ -19,11 +19,11 @@
<choice id="com.pandorafms.pandorafms_src" visible="false">
<pkg-ref id="com.pandorafms.pandorafms_src"/>
</choice>
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.760" onConclusion="none">pandorafms_src.pdk</pkg-ref>
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.761" onConclusion="none">pandorafms_src.pdk</pkg-ref>
<choice id="com.pandorafms.pandorafms_uninstall" visible="true" customLocation="/Applications">
<pkg-ref id="com.pandorafms.pandorafms_uninstall"/>
</choice>
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.760" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.761" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
<!-- <installation-check script="check()" />
<script>
<![CDATA[

View File

@ -5,9 +5,9 @@
<key>CFBundleIconFile</key> <string>pandorafms.icns</string>
<key>CFBundleIdentifier</key> <string>com.pandorafms.pandorafms_uninstall</string>
<key>CFBundleVersion</key> <string>7.0NG.760</string>
<key>CFBundleGetInfoString</key> <string>7.0NG.760 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
<key>CFBundleShortVersionString</key> <string>7.0NG.760</string>
<key>CFBundleVersion</key> <string>7.0NG.761</string>
<key>CFBundleGetInfoString</key> <string>7.0NG.761 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
<key>CFBundleShortVersionString</key> <string>7.0NG.761</string>
<key>NSPrincipalClass</key><string>NSApplication</string>
<key>NSMainNibFile</key><string>MainMenu</string>

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, GNU/Linux
# Version 7.0NG.761, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, FreeBSD Version
# Version 7.0NG.761, FreeBSD Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, HP-UX Version
# Version 7.0NG.761, HP-UX Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, GNU/Linux
# Version 7.0NG.761, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, GNU/Linux
# Version 7.0NG.761, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, NetBSD Version
# Version 7.0NG.761, NetBSD Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.760, Solaris Version
# Version 7.0NG.761, Solaris Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1014,8 +1014,8 @@ my $Sem = undef;
# Semaphore used to control the number of threads
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.760';
use constant AGENT_BUILD => '220330';
use constant AGENT_VERSION => '7.0NG.761';
use constant AGENT_BUILD => '220407';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.760
%define release 220330
%define version 7.0NG.761
%define release 220407
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.760
%define release 220330
%define version 7.0NG.761
%define release 220407
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -9,8 +9,8 @@
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
# **********************************************************************
PI_VERSION="7.0NG.760"
PI_BUILD="220330"
PI_VERSION="7.0NG.761"
PI_BUILD="220407"
OS_NAME=`uname -s`
FORCE=0

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.760
# Version 7.0NG.761
# This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software
# Foundation; either version 2 of the Licence or any later version

View File

@ -3,7 +3,7 @@ AllowLanguageSelection
{Yes}
AppName
{Pandora FMS Windows Agent v7.0NG.760}
{Pandora FMS Windows Agent v7.0NG.761}
ApplicationID
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{220330}
{220407}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.760 Build 220330")
#define PANDORA_VERSION ("7.0NG.761 Build 220407")
string pandora_path;
string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.760(Build 220330))"
VALUE "ProductVersion", "(7.0NG.761(Build 220407))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.760-220330
Version: 7.0NG.761-220407
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.760-220330"
pandora_version="7.0NG.761-220407"
package_pear=0
package_pandora=1

View File

@ -344,6 +344,7 @@ function mainAgentsModules()
$save_serialize = (int) get_parameter('save_serialize', 0);
$full_modules_selected = explode(';', get_parameter('full_modules_selected', 0));
$full_agents_id = explode(';', get_parameter('full_agents_id', 0));
$show_type = (int) get_parameter('show_type', 0);
// In full screen there is no pagination neither filters.
if (( ($config['pure'] == 0 && $save_serialize) && $update_item == '' ) || ( ($config['pure'] == 1 && $save_serialize == 0) && $update_item == '' )) {
@ -361,11 +362,11 @@ function mainAgentsModules()
unserialize_in_temp($config['id_user'].'_agents', true, 1);
}
if ($modules_selected[0]) {
if (isset($modules_selected[0]) === true && $modules_selected[0]) {
serialize_in_temp($modules_selected, $config['id_user'].'_agent_module', 1);
}
if ($agents_id[0] != -1) {
if (isset($agents_id[0]) === true && $agents_id[0] != -1) {
serialize_in_temp($agents_id, $config['id_user'].'_agents', 1);
}
@ -375,21 +376,30 @@ function mainAgentsModules()
$full_agents = urlencode(implode(';', $agents_id));
$fullscreen['text'] = '<a href="index.php?extension_in_menu=estado&amp;sec=extensions&amp;sec2=extensions/agents_modules&amp;pure=1&amp;
offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&full_modules_selected='.$full_modules.'
offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&full_modules_selected='.$full_modules.'&show_type='.$show_type.'
&full_agents_id='.$full_agents.'&selection_agent_module='.$selection_a_m.'">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>';
} else if ($full_modules_selected[0] && $full_agents_id[0]) {
$full_modules = urlencode(implode(';', $full_modules_selected));
$full_agents = urlencode(implode(';', $full_agents_id));
$fullscreen['text'] = '<a href="index.php?extension_in_menu=estado&amp;sec=extensions&amp;sec2=extensions/agents_modules&amp;pure=1&amp;
offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&full_modules_selected='.$full_modules.'
offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&full_modules_selected='.$full_modules.'&show_type='.$show_type.'
&full_agents_id='.$full_agents.'&selection_agent_module='.$selection_a_m.'">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>';
} else {
$fullscreen['text'] = '<a href="index.php?extension_in_menu=estado&amp;sec=extensions&amp;sec2=extensions/agents_modules&amp;pure=1&amp;
offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>';
offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&show_type='.$show_type.'">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>';
}
}
// Type show.
$show_select = [
0 => __('Show module status'),
1 => __('Show module data'),
];
$filter_type_label = '<b>'.__('Information to be shown').'</b>';
$filter_type = html_print_select($show_select, 'show_type', $show_type, '', '', 0, true, false, false, '', false, 'min-width: 180px;');
// Groups.
$filter_groups_label = '<b>'.__('Group').'</b>';
$filter_groups = html_print_select_groups(false, 'AR', true, 'group_id', $group_id, '', '', '', true, false, true, '', false, 'width: auto;');
@ -480,11 +490,29 @@ function mainAgentsModules()
$full_modules = urlencode(implode(';', $full_modules_selected));
$full_agents = urlencode(implode(';', $full_agents_id));
$url = 'index.php?sec=view&sec2=extensions/agents_modules&amp;pure=0&amp;offset=$offset
&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr&full_modules_selected=$full_modules
&full_agents_id=$full_agents&selection_agent_module=$selection_a_m';
$url = sprintf(
'index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=%s
&group_id=%s&modulegroup=%s&refresh=%s&full_modules_selected=%s
&full_agents_id=%s&selection_agent_module=%s&show_type=%s',
$offset,
$group_id,
$modulegroup,
$refr,
$full_modules,
$full_agents,
$selection_a_m,
$show_type
);
} else {
$url = 'index.php?sec=view&sec2=extensions/agents_modules&amp;pure=0&amp;offset=$offset&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr';
$url = sprintf(
'index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=%s&group_id=%s
&modulegroup=%s&refresh=%s&show_type=%s',
$offset,
$group_id,
$modulegroup,
$refr,
$show_type
);
}
// Floating menu - Start.
@ -546,7 +574,11 @@ function mainAgentsModules()
if ($config['pure'] != 1) {
$show_filters = '<form method="post" action="'.ui_get_url_refresh(['offset' => $offset, 'hor_offset' => $offset, 'group_id' => $group_id, 'modulegroup' => $modulegroup]).'" class="w100p">';
$show_filters .= '<table class="w100p no-border" cellpadding="0" cellspacing="0" border="0">';
$show_filters .= '<table class="w100p no-border" cellpadding="15" cellspacing="0" border="0">';
$show_filters .= '<tr>';
$show_filters .= '<td>'.$filter_type_label.'</td>';
$show_filters .= '<td>'.$filter_type.'</td>';
$show_filters .= '</tr>';
$show_filters .= '<tr>';
$show_filters .= '<td>'.$filter_groups_label.'</td>';
$show_filters .= '<td>'.$filter_groups.'&nbsp;&nbsp;&nbsp;'.$filter_recursion_label.$filter_recursion.'</td>';
@ -574,10 +606,10 @@ function mainAgentsModules()
);
}
if ($agents_id[0] != -1) {
if (isset($agents_id[0]) === true && $agents_id[0] != -1) {
$agents = $agents_id;
} else {
if ($full_agents_id[0]) {
if (isset($full_agents_id[0]) === true && $full_agents_id[0]) {
$agents = $full_agents_id;
} else {
$agents = '';
@ -610,24 +642,34 @@ function mainAgentsModules()
}
$total_pagination = count($agents);
if ($agents_id[0] != -1) {
$all_modules = [];
foreach ($modules_selected as $key => $value) {
$name = modules_get_agentmodule_name($value);
$sql = "SELECT id_agente_modulo
FROM tagente_modulo
WHERE nombre = '".$name."';";
if (isset($agents_id[0]) === true && $agents_id[0] != -1) {
if (isset($modules_selected[0]) === true && $modules_selected[0]) {
$all_modules = [];
foreach ($modules_selected as $key => $value) {
$name = modules_get_agentmodule_name($value);
$sql = "SELECT id_agente_modulo
FROM tagente_modulo
WHERE nombre = '".$name."';";
$result_sql = db_get_all_rows_sql($sql);
$result_sql = db_get_all_rows_sql($sql);
if (is_array($result_sql)) {
foreach ($result_sql as $key => $value) {
$all_modules[$value['id_agente_modulo']] = io_safe_output($name);
if (is_array($result_sql)) {
foreach ($result_sql as $key => $value) {
$all_modules[$value['id_agente_modulo']] = io_safe_output($name);
}
}
}
} else {
$all_modules = agents_get_modules(
$agents,
false,
$filter_module_group,
true,
true
);
}
} else {
if ($full_modules_selected[0]) {
if (isset($full_modules_selected[0]) === true && $full_modules_selected[0]) {
foreach ($full_modules_selected as $key => $value) {
$name = modules_get_agentmodule_name($value);
$sql = "SELECT id_agente_modulo
@ -717,7 +759,7 @@ function mainAgentsModules()
if ($hor_offset > 0) {
$new_hor_offset = ($hor_offset - $block);
echo "<th width='20px' class='vertical_middle center' rowspan='".($nagents + 1)."'><a href='index.php?".'extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&refr=0&save_serialize=1&selection_a_m='.$selection_a_m.'&hor_offset='.$new_hor_offset.'&offset='.$offset."'>".html_print_image(
echo "<th width='20px' class='vertical_middle center' rowspan='".($nagents + 1)."'><a href='index.php?".'extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&refr=0&save_serialize=1&show_type='.$show_type.'&selection_a_m='.$selection_a_m.'&hor_offset='.$new_hor_offset.'&offset='.$offset."'>".html_print_image(
'images/arrow_left_green.png',
true,
['title' => __('Previous modules')]
@ -743,7 +785,7 @@ function mainAgentsModules()
if (($hor_offset + $block) < $nmodules) {
$new_hor_offset = ($hor_offset + $block);
echo "<th width='20px' class='vertical_middle center' rowspan='".($nagents + 1)."'><a href='index.php?".'extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&selection_a_m='.$selection_a_m.'&hor_offset='.$new_hor_offset.'&offset='.$offset."'>".html_print_image(
echo "<th width='20px' class='vertical_middle center' rowspan='".($nagents + 1)."'><a href='index.php?".'extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&show_type='.$show_type.'&selection_a_m='.$selection_a_m.'&hor_offset='.$new_hor_offset.'&offset='.$offset."'>".html_print_image(
'images/arrow_right_green.png',
true,
['title' => __('More modules')]
@ -820,7 +862,6 @@ function mainAgentsModules()
foreach ($module['id'] as $module_id) {
if (!$match && array_key_exists($module_id, $agent_modules)) {
$status = modules_get_agentmodule_status($module_id);
echo "<td class='center'>";
$win_handle = dechex(crc32($module_id.$module['name']));
$graph_type = return_graphtype(modules_get_agentmodule_type($module_id));
@ -833,32 +874,42 @@ function mainAgentsModules()
$module_last_value = htmlspecialchars($module_last_value);
}
switch ($status) {
case AGENT_MODULE_STATUS_NORMAL:
ui_print_status_image('module_ok.png', $module_last_value, false);
break;
if ($show_type === 0) {
$status = modules_get_agentmodule_status($module_id);
switch ($status) {
case AGENT_MODULE_STATUS_NORMAL:
ui_print_status_image('module_ok.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_CRITICAL_BAD:
ui_print_status_image('module_critical.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_CRITICAL_BAD:
ui_print_status_image('module_critical.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_WARNING:
ui_print_status_image('module_warning.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_WARNING:
ui_print_status_image('module_warning.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_UNKNOWN:
ui_print_status_image('module_unknown.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_UNKNOWN:
ui_print_status_image('module_unknown.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
ui_print_status_image('module_alertsfired.png', $module_last_value, false);
break;
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
ui_print_status_image('module_alertsfired.png', $module_last_value, false);
break;
case 4:
ui_print_status_image('module_no_data.png', $module_last_value, false);
break;
case 4:
ui_print_status_image('module_no_data.png', $module_last_value, false);
break;
}
} else {
$module = modules_get_agentmodule($module_id);
$module['datos'] = $module_last_value;
$module_last_value = modules_get_agentmodule_data_for_humans($module);
echo $module_last_value;
}
echo '</a>';
@ -877,22 +928,24 @@ function mainAgentsModules()
echo '</table>';
$show_legend = "<div class='legend_white'>";
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_ALERTFIRED.";'></div></div>".__('Orange cell when the module has fired alerts').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_CRITICAL.";'></div></div>".__('Red cell when the module has a critical status').'
</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_WARNING.";'></div></div>".__('Yellow cell when the module has a warning status').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_NORMAL.";'></div></div>".__('Green cell when the module has a normal status').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_UNKNOWN.";'></div></div>".__('Grey cell when the module has an unknown status').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_NOTINIT.";'></div></div>".__("Cell turns blue when the module is in 'not initialize' status").'</div>';
$show_legend .= '</div>';
ui_toggle($show_legend, __('Legend'));
if ($show_type === 0) {
$show_legend = "<div class='legend_white'>";
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_ALERTFIRED.";'></div></div>".__('Orange cell when the module has fired alerts').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_CRITICAL.";'></div></div>".__('Red cell when the module has a critical status').'
</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_WARNING.";'></div></div>".__('Yellow cell when the module has a warning status').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_NORMAL.";'></div></div>".__('Green cell when the module has a normal status').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_UNKNOWN.";'></div></div>".__('Grey cell when the module has an unknown status').'</div>';
$show_legend .= "<div class='center flex'>
<div class='legend_square_simple'><div style='background-color: ".COL_NOTINIT.";'></div></div>".__("Cell turns blue when the module is in 'not initialize' status").'</div>';
$show_legend .= '</div>';
ui_toggle($show_legend, __('Legend'));
}
$pure_var = $config['pure'];
if ($pure_var) {

View File

@ -114,6 +114,7 @@ function pandora_realtime_graphs()
$canvas .= '</div>';
echo $canvas;
$table = new stdClass();
$table->width = '100%';
$table->id = 'table-form';
$table->class = 'databox filters';

View File

@ -3,6 +3,9 @@ START TRANSACTION;
ALTER TABLE `tipam_vlan` ADD COLUMN `custom_id` bigint(20) unsigned DEFAULT NULL;
ALTER TABLE `tuser_task_scheduled`ADD COLUMN `enabled` TINYINT UNSIGNED NOT NULL DEFAULT 1;
ALTER TABLE `tevent_filter` ADD COLUMN `custom_data` VARCHAR(500) DEFAULT '';
ALTER TABLE `tevent_filter` ADD COLUMN `custom_data_filter_type` TINYINT UNSIGNED DEFAULT 0;
ALTER TABLE tagente MODIFY alias varchar(600) NOT NULL DEFAULT '';
ALTER TABLE tagente MODIFY nombre varchar(600) NOT NULL DEFAULT '';
@ -19,6 +22,11 @@ CREATE TABLE IF NOT EXISTS `tbackup` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
ALTER TABLE `treport_content` ADD COLUMN `macros_definition` TEXT;
ALTER TABLE `treport_content` ADD COLUMN `render_definition` TEXT;
ALTER TABLE `treport_content_template` ADD COLUMN `macros_definition` TEXT;
ALTER TABLE `treport_content_template` ADD COLUMN `render_definition` TEXT;
DROP TABLE `tupdate`;
DROP TABLE `tupdate_package`;
DROP TABLE `tupdate_journal`;

View File

@ -1467,13 +1467,13 @@ ALTER TABLE `ttag` MODIFY COLUMN `name` text NOT NULL default '';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 52);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 53);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png');
UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package', 760);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package', 761);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp');
UPDATE `tconfig` SET `value` = 'mini_severity,evento,id_agente,estado,timestamp' WHERE `token` LIKE 'event_fields';
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_api_password';
@ -1543,6 +1543,8 @@ ALTER TABLE `tevent_filter` MODIFY COLUMN `severity` text NOT NULL;
ALTER TABLE tevent_filter ADD COLUMN `server_id` int(10) NOT NULL default 0;
ALTER TABLE `tevent_filter` ADD COLUMN `time_from` TIME NULL;
ALTER TABLE `tevent_filter` ADD COLUMN `time_to` TIME NULL;
ALTER TABLE `tevent_filter` ADD COLUMN `custom_data` VARCHAR(500) DEFAULT '';
ALTER TABLE `tevent_filter` ADD COLUMN `custom_data_filter_type` TINYINT UNSIGNED DEFAULT 0;
-- ---------------------------------------------------------------------
-- Table `tusuario`

View File

@ -116,6 +116,7 @@ $fields_available['data'] = __('Data');
$fields_available['module_status'] = __('Module Status');
$fields_available['mini_severity'] = __('Severity mini');
$fields_available['module_custom_id'] = __('Module custom ID');
$fields_available['custom_data'] = __('Custom data');
// Remove fields already selected.

View File

@ -89,6 +89,8 @@ if ($id) {
$tag_without_base64 = base64_encode($tag_without_json_clean);
$filter_only_alert = $filter['filter_only_alert'];
$custom_data = $filter['custom_data'];
$custom_data_filter_type = $filter['custom_data_filter_type'];
if ($id_agent_module != 0) {
$text_module = modules_get_agentmodule_name($id_agent_module);
@ -165,30 +167,34 @@ if ($update || $create) {
$tag_without_json = io_safe_input(base64_decode($tag_without_base64));
$filter_only_alert = get_parameter('filter_only_alert', '');
$custom_data = get_parameter('custom_data', '');
$custom_data_filter_type = get_parameter('custom_data_filter_type', '');
$values = [
'id_name' => $id_name,
'id_group_filter' => $id_group_filter,
'id_group' => $id_group,
'event_type' => $event_type,
'severity' => $severity,
'status' => $status,
'search' => $search,
'text_agent' => $text_agent,
'id_agent_module' => $id_agent_module,
'id_agent' => $id_agent,
'pagination' => $pagination,
'event_view_hr' => $event_view_hr,
'id_user_ack' => $id_user_ack,
'group_rep' => $group_rep,
'tag_with' => $tag_with_json,
'tag_without' => $tag_without_json,
'date_from' => $date_from,
'date_to' => $date_to,
'source' => $source,
'id_extra' => $id_extra,
'user_comment' => $user_comment,
'filter_only_alert' => $filter_only_alert,
'id_name' => $id_name,
'id_group_filter' => $id_group_filter,
'id_group' => $id_group,
'event_type' => $event_type,
'severity' => $severity,
'status' => $status,
'search' => $search,
'text_agent' => $text_agent,
'id_agent_module' => $id_agent_module,
'id_agent' => $id_agent,
'pagination' => $pagination,
'event_view_hr' => $event_view_hr,
'id_user_ack' => $id_user_ack,
'group_rep' => $group_rep,
'tag_with' => $tag_with_json,
'tag_without' => $tag_without_json,
'date_from' => $date_from,
'date_to' => $date_to,
'source' => $source,
'id_extra' => $id_extra,
'user_comment' => $user_comment,
'filter_only_alert' => $filter_only_alert,
'custom_data' => $custom_data,
'custom_data_filter_type' => $custom_data_filter_type,
];
$severity = explode(',', $severity);
@ -627,9 +633,26 @@ $table->data[23][1] = html_print_input_text('id_extra', $id_extra, '', 11, 255,
$table->data[24][0] = '<b>'.__('Comment').'</b>';
$table->data[24][1] = html_print_input_text('user_comment', $user_comment, '', 35, 255, true);
$table->data[25][0] = '<b>'.__('Custom data filter type').'</b>';
$table->data[25][1] = html_print_select(
[
'0' => __('Filter custom data by name field'),
'1' => __('Filter custom data by value field'),
],
'custom_data_filter_type',
$custom_data_filter_type,
'',
false,
'',
true
);
$table->data[26][0] = '<b>'.__('Custom data').'</b>';
$table->data[26][1] = html_print_input_text('custom_data', $custom_data, '', 35, 255, true);
if (is_metaconsole()) {
$table->data[25][0] = '<b>'.__('Id souce event').'</b>';
$table->data[25][1] = html_print_input_text(
$table->data[27][0] = '<b>'.__('Id souce event').'</b>';
$table->data[27][1] = html_print_input_text(
'id_source_event',
$id_source_event,
'',

File diff suppressed because it is too large Load Diff

View File

@ -176,6 +176,8 @@ $unknown_checks = true;
$agent_max_value = true;
$agent_min_value = true;
$uncompressed_module = true;
$macros_definition = '';
$render_definition = '';
$only_data = false;
@ -724,6 +726,12 @@ switch ($action) {
$graph_render = $item['graph_render'];
break;
case 'custom_render':
$description = $item['description'];
$macros_definition = $item['macros_definition'];
$render_definition = $item['render_definition'];
break;
case 'top_n':
$description = $item['description'];
$period = $item['period'];
@ -760,6 +768,11 @@ switch ($action) {
);
$selection_a_m = get_parameter('selection');
if (isset($es['show_type']) === true) {
$show_type = $es['show_type'];
}
$recursion = $item['recursion'];
$group = $item['id_group'];
@ -1833,6 +1846,37 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_type_show" class="datos">
<td class="bolder"><?php echo __('Information to be shown'); ?></td>
<td>
<?php
$show_select = [
0 => __('Show module status'),
1 => __('Show module data'),
];
if ($action === 'new' && empty($show_type) === true) {
$show_type = 1;
}
html_print_select(
$show_select,
'show_type',
$show_type,
'',
'',
0,
false,
false,
false,
'',
false,
'min-width: 180px'
);
?>
</td>
</tr>
<tr id="row_alert_templates" class="datos">
<td class="bolder"><?php echo __('Templates'); ?></td>
<td>
@ -2405,6 +2449,38 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_macros_definition" class="datos">
<td class="bolder">
<?php
echo __('Macros definition');
?>
</td>
<td>
<?php echo get_table_custom_macros_report($macros_definition); ?>
</td>
</tr>
<tr id="row_render_definition" class="datos">
<td class="bolder">
<?php
echo __('Render definition').ui_print_help_tip(
__('Be aware because not all CSS inline styles are supported in the pdf library'),
true
);
?>
</td>
<td>
<?php
echo html_print_textarea(
'render_definition',
3,
25,
$render_definition
);
?>
</td>
</tr>
<tr id="row_fullscale" class="datos">
<td class="bolder">
<?php
@ -4557,6 +4633,9 @@ ui_require_javascript_file(
'pandora_inventory',
ENTERPRISE_DIR.'/include/javascript/'
);
ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
ui_require_javascript_file('pandora');
?>
<script type="text/javascript">
@ -4794,6 +4873,14 @@ $(document).ready (function () {
});
});
var added_config = {
"elements": "textarea_render_definition",
"plugins": "preview, print, table, searchreplace, nonbreaking, xhtmlxtras, noneditable",
"theme_advanced_buttons1": "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
"theme_advanced_buttons2": "search,replace,|,bullist,numlist,|,undo,redo,|,link,unlink,image,|,cleanup,code,preview,|,forecolor,backcolor"
}
defineTinyMCE(added_config);
$("#checkbox-select_by_group").change(function () {
var select_by_group = $('#checkbox-select_by_group').prop('checked');
@ -5417,7 +5504,7 @@ function addSLARow() {
var slaMax = $("input[name=sla_max]").val();
var slaLimit = $("input[name=sla_limit]").val();
var serviceId = $("select#id_service>option:selected").val();
if(serviceId != '' && serviceId.split('|').length > 1 ) {
if(serviceId != undefined && serviceId != '' && serviceId.split('|').length > 1 ) {
var ids = serviceId.split('|');
serverId = ids[0];
serviceId = ids[1];
@ -5859,6 +5946,8 @@ function chooseType() {
$("#row_max_min_avg").hide();
$("#row_fullscale").hide();
$("#row_graph_render").hide();
$("#row_macros_definition").hide();
$("#row_render_definition").hide();
$("#row_time_compare_overlapped").hide();
$("#row_quantity").hide();
$("#row_exception_condition_value").hide();
@ -5925,6 +6014,7 @@ function chooseType() {
$("#row_agent_not_assigned_to_ip").hide();
$("#row_show_summary").hide();
$("#row_group_by").hide();
$("#row_type_show").hide();
// SLA list default state.
$("#sla_list").hide();
@ -6404,6 +6494,11 @@ function chooseType() {
}
break;
case 'custom_render':
$("#row_macros_definition").show();
$("#row_render_definition").show();
break;
case 'top_n':
$("#row_description").show();
$("#row_period").show();
@ -6438,6 +6533,7 @@ function chooseType() {
case 'agent_module':
$("#row_module_group").show();
$("#row_type_show").show();
case 'agent_module_status':
$("#row_description").show();
$("#row_group").show();
@ -6729,6 +6825,98 @@ function chooseType() {
}
}
function addCustomFieldRow() {
var array_tr = $("tr.tr-macros-definition");
var last_tr = array_tr[array_tr.length - 1];
var array_id = /(\d)+$/.exec($(last_tr).attr('id'));
var max = (parseInt(array_id[0]) + 1);
var clone = $("#table-macros-definition #table-macros-definition-0")
.clone()
.prop("id", "table-macros-definition-" + max);
clone
.find("#macro_custom_name")
.prop("id", "macro_custom_name_" + max)
.val("");
clone
.find("#macro_custom_key")
.prop("id", "macro_custom_key_" + max)
.val(max);
clone
.find("#macro_custom_type")
.prop("id", "macro_custom_type" + max)
.attr("onchange", "change_custom_fields_macros_report(" + max + ")");
clone
.find("#table-macros-definition-0-value")
.prop("id", "table-macros-definition-"+max+"-value");
clone
.find("#macro_custom_value")
.prop("id", "macro_custom_value_" + max)
.val('');
clone
.find(".icon-clean-custom-macro")
.attr("onclick", "cleanCustomFieldRow(" + max + ")");
clone
.find(".icon-delete-custom-macro")
.attr("onclick", "removeCustomFieldRow(" + max + ")")
.css("display", "inline-block");
clone
.appendTo("#table-macros-definition");
}
function cleanCustomFieldRow(row) {
if(row === 0) {
// Default value.
$("#macro_custom_name").val('');
$("#macro_custom_value").val('');
$("#macro_custom_width").val('');
} else {
$("#macro_custom_name_"+row).val('');
$("#macro_custom_value_"+row).val('');
$("#macro_custom_width_"+row).val('');
}
$("#macro_custom_height_"+row).val('');
$("#macro_custom_period_"+row).val('');
$("#text-macro_custom_value_agent_name_"+row).val('');
$("#macro_custom_value"+row+"id_agent_module")
.val('')
.trigger('change');
}
function removeCustomFieldRow(row) {
if(row !== 0) {
$("tr#table-macros-definition-"+row).remove();
}
}
function change_custom_fields_macros_report(id) {
var new_type = this.event.target.value;
jQuery.post (
"ajax.php",
{
"page" : "include/ajax/reporting.ajax",
"change_custom_fields_macros_report" : 1,
"macro_type": new_type,
"macro_id": id
},
function (data, status) {
console.log(id);
$("td#table-macros-definition-"+id+"-value").empty();
$("td#table-macros-definition-"+id+"-value").append(data);
},
"html"
);
}
function event_change_id_agent_inventory() {
agent_changed_by_multiple_agents_inventory(
{"data" : {

View File

@ -1677,6 +1677,7 @@ switch ($action) {
// Encode json modules and agents.
$es['module'] = base64_encode(json_encode($es['module']));
$es['id_agents'] = base64_encode(json_encode($agents_to_report));
$es['show_type'] = get_parameter('show_type', 0);
$values['external_source'] = json_encode($es);
$good_format = true;
@ -1851,6 +1852,33 @@ switch ($action) {
$good_format = true;
break;
case 'custom_render':
$macro_custom_name = get_parameter('macro_custom_name', []);
$macro_custom_type = get_parameter('macro_custom_type', []);
$macro_custom_value = get_parameter('macro_custom_value', []);
$macro_custom_key = get_parameter('macro_custom_key', []);
$macros_definition = [];
foreach ($macro_custom_name as $key_macro => $value_macro) {
$kl = (empty($macro_custom_key[$key_macro]) === true) ? 0 : $macro_custom_key[$key_macro];
$macros_definition[$key_macro]['name'] = $value_macro;
$macros_definition[$key_macro]['type'] = $macro_custom_type[$key_macro];
if (is_array($macro_custom_value[$kl]) === true) {
foreach ($macro_custom_value[$kl] as $k => $v) {
$macros_definition[$key_macro][$k] = $v;
}
} else {
$macros_definition[$key_macro]['value'] = $macro_custom_value[$key_macro];
}
}
$values['macros_definition'] = json_encode($macros_definition);
$values['render_definition'] = get_parameter('render_definition', '');
$good_format = true;
break;
case 'min_value':
case 'max_value':
case 'avg_value':
@ -2480,6 +2508,7 @@ switch ($action) {
// Encode json modules and agents.
$es['module'] = base64_encode(json_encode($es['module']));
$es['id_agents'] = base64_encode(json_encode($agents_to_report));
$es['show_type'] = get_parameter('show_type', 0);
$values['external_source'] = json_encode($es);
$good_format = true;
@ -2600,6 +2629,33 @@ switch ($action) {
$good_format = true;
break;
case 'custom_render':
$macro_custom_name = get_parameter('macro_custom_name', []);
$macro_custom_type = get_parameter('macro_custom_type', []);
$macro_custom_value = get_parameter('macro_custom_value', []);
$macro_custom_key = get_parameter('macro_custom_key', []);
$macros_definition = [];
foreach ($macro_custom_name as $key_macro => $value_macro) {
$kl = (empty($macro_custom_key[$key_macro]) === true) ? 0 : $macro_custom_key[$key_macro];
$macros_definition[$key_macro]['name'] = $value_macro;
$macros_definition[$key_macro]['type'] = $macro_custom_type[$key_macro];
if (is_array($macro_custom_value[$kl]) === true) {
foreach ($macro_custom_value[$kl] as $k => $v) {
$macros_definition[$key_macro][$k] = $v;
}
} else {
$macros_definition[$key_macro]['value'] = $macro_custom_value[$key_macro];
}
}
$values['macros_definition'] = json_encode($macros_definition);
$values['render_definition'] = get_parameter('render_definition', '');
$good_format = true;
break;
case 'min_value':
case 'max_value':
case 'avg_value':

View File

@ -74,6 +74,12 @@ if ($update_settings) {
);
}
// Update the license file.
$result = file_put_contents($config['remote_config'].'/'.LICENSE_FILE, $_POST['keys']['customer_key']);
if ($result === false) {
ui_print_error_message(__('Failed to Update license file'));
}
ui_print_success_message(__('License updated'));
}
}

View File

@ -1192,7 +1192,7 @@ class DiscoveryTaskList extends HTML
*/
private function progressTaskGraph($task)
{
$result .= '<div class="flex">';
$result = '<div class="flex">';
$result .= '<div class="subtitle">';
$result .= '<span>'._('Overall Progress').'</span>';
@ -1317,6 +1317,9 @@ class DiscoveryTaskList extends HTML
if (is_array($task['stats']) === false) {
$task['stats'] = json_decode($task['summary'], true);
if (json_last_error() !== JSON_ERROR_NONE) {
return $task['summary'];
}
}
if (is_array($task['stats'])) {
@ -1379,31 +1382,35 @@ class DiscoveryTaskList extends HTML
$table->data[$i++][1] .= '</span>';
} else {
// Content.
$table->data[$i][0] = '<b>'.__('Hosts discovered').'</b>';
$table->data[$i][1] = '<span id="discovered">';
$table->data[$i][1] .= $task['stats']['summary']['discovered'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Alive').'</b>';
$table->data[$i][1] = '<span id="alive">';
$table->data[$i][1] .= $task['stats']['summary']['alive'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Not alive').'</b>';
$table->data[$i][1] = '<span id="not_alive">';
$table->data[$i][1] .= $task['stats']['summary']['not_alive'];
$table->data[$i++][1] .= '</span>';
if ($task['type'] == DISCOVERY_HOSTDEVICES) {
$table->data[$i][0] = '<b>'.__('Responding SNMP').'</b>';
$table->data[$i][1] = '<span id="SNMP">';
$table->data[$i][1] .= $task['stats']['summary']['SNMP'];
if (is_array($task['stats']['summary']) === true) {
$table->data[$i][0] = '<b>'.__('Hosts discovered').'</b>';
$table->data[$i][1] = '<span id="discovered">';
$table->data[$i][1] .= $task['stats']['summary']['discovered'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Responding WMI').'</b>';
$table->data[$i][1] = '<span id="WMI">';
$table->data[$i][1] .= $task['stats']['summary']['WMI'];
$table->data[$i][0] = '<b>'.__('Alive').'</b>';
$table->data[$i][1] = '<span id="alive">';
$table->data[$i][1] .= $task['stats']['summary']['alive'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Not alive').'</b>';
$table->data[$i][1] = '<span id="not_alive">';
$table->data[$i][1] .= $task['stats']['summary']['not_alive'];
$table->data[$i++][1] .= '</span>';
if ($task['type'] == DISCOVERY_HOSTDEVICES) {
$table->data[$i][0] = '<b>'.__('Responding SNMP').'</b>';
$table->data[$i][1] = '<span id="SNMP">';
$table->data[$i][1] .= $task['stats']['summary']['SNMP'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Responding WMI').'</b>';
$table->data[$i][1] = '<span id="WMI">';
$table->data[$i][1] .= $task['stats']['summary']['WMI'];
$table->data[$i++][1] .= '</span>';
}
} else {
$table->data[$i][0] = $task['stats']['summary'];
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 775 B

View File

@ -309,6 +309,8 @@ if ($save_event_filter) {
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
$values['id_source_event'] = get_parameter('id_source_event');
$values['custom_data'] = get_parameter('custom_data');
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
if (is_metaconsole()) {
$values['server_id'] = get_parameter('server_id');
@ -363,6 +365,8 @@ if ($update_event_filter) {
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
$values['id_source_event'] = get_parameter('id_source_event');
$values['custom_data'] = get_parameter('custom_data');
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
if (is_metaconsole() === true) {
$values['server_id'] = get_parameter('server_id');
@ -834,7 +838,9 @@ function save_new_filter() {
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val(),
"id_source_event": $("#text-id_source_event").val(),
"server_id": $("#server_id").val()
"server_id": $("#server_id").val(),
"custom_data": $("#text-custom_data").val(),
"custom_data_filter_type": $("#custom_data_filter_type").val()
},
function (data) {
$("#info_box").hide();
@ -907,7 +913,9 @@ function save_update_filter() {
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val(),
"id_source_event": $("#text-id_source_event").val(),
"server_id": $("#server_id").val()
"server_id": $("#server_id").val(),
"custom_data": $("#text-custom_data").val(),
"custom_data_filter_type": $("#custom_data_filter_type").val()
},
function (data) {

View 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;
}

View File

@ -34,6 +34,10 @@ $id = get_parameter('id', 0);
$truncate_text = get_parameter('truncate_text', 0);
$get_metaconsole_hash_data = get_parameter('get_metaconsole_hash_data', 0);
$get_metaconsole_server_url = get_parameter('get_metaconsole_server_url', 0);
$change_custom_fields_macros_report = (bool) get_parameter(
'change_custom_fields_macros_report',
0
);
if ($delete_sla_item) {
$result = db_process_sql_delete('treport_content_sla_combined', ['id' => (int) $id]);
@ -218,3 +222,25 @@ if ($get_metaconsole_server_url) {
echo $server['server_url'];
return;
}
if ($change_custom_fields_macros_report === true) {
include_once $config['homedir'].'/include/functions_reports.php';
$macro_type = get_parameter('macro_type', '');
$macro_id = get_parameter('macro_id', 0);
$macro = [
'name' => '',
'type' => $macro_type,
'value' => '',
];
$custom_fields = custom_fields_macros_report($macro, $macro_id);
$custom_field_draw = '';
if (empty($custom_fields) === false) {
foreach ($custom_fields as $key => $value) {
$custom_field_draw .= $value;
}
}
echo $custom_field_draw;
return;
}

View File

@ -2532,10 +2532,19 @@ class ConsoleSupervisor
global $config;
$message = 'If AllowOverride is disabled, .htaccess will not works.';
$message .= '<pre>Please check /etc/httpd/conf/httpd.conf to resolve this problem.';
if (PHP_OS == 'FreeBSD') {
$message .= '<pre>Please check /usr/local/etc/apache24/httpd.conf to resolve this problem.';
} else {
$message .= '<pre>Please check /etc/httpd/conf/httpd.conf to resolve this problem.';
}
// Get content file.
$file = file_get_contents('/etc/httpd/conf/httpd.conf');
if (PHP_OS == 'FreeBSD') {
$file = file_get_contents('/usr/local/etc/apache24/httpd.conf');
} else {
$file = file_get_contents('/etc/httpd/conf/httpd.conf');
}
$file_lines = preg_split("#\r?\n#", $file, -1, PREG_SPLIT_NO_EMPTY);
$is_none = false;

View File

@ -638,9 +638,9 @@ class HTML
if ($input['arguments']['inline'] != 'true') {
$output .= '<div class="edit_discovery_input">';
} else {
$output .= '<div class="flex mrgn_btn_25px wrap">';
$output .= '<div class="flex-row-center flex-nowrap mrgn_btn_15px">';
if (!isset($input['extra'])) {
$output .= '<div class="w50p">';
$output .= '<div class="w100p">';
}
if (isset($input['extra'])) {
@ -652,7 +652,7 @@ class HTML
$output .= '<div class="mrgn_right_10px">';
}
$output .= '<div class="label_select">';
$output .= '<div class="">';
$output .= $input['label'];
$output .= '</div>';

View 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>';
}
}

View File

@ -20,8 +20,8 @@
/**
* Pandora build version and version
*/
$build_version = 'PC220330';
$pandora_version = 'v7.0NG.760';
$build_version = 'PC220407';
$pandora_version = 'v7.0NG.761';
// Do not overwrite default timezone set if defined.
$script_tz = @date_default_timezone_get();

View File

@ -858,3 +858,6 @@ define(
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
]
);
// Pandora FMS Enterprise license.
define('LICENSE_FILE', 'customer_key');

View File

@ -4194,7 +4194,7 @@ function generator_chart_to_pdf(
) {
$width_img = 650;
$height_img = ($params['height'] + 50);
} else if ($type_graph_pdf === 'hbar') {
} else if ($type_graph_pdf === 'hbar' || $type_graph_pdf === 'pie_chart') {
$width_img = ($params['width'] ?? 550);
$height_img = $params['height'];
} else {

View File

@ -14530,7 +14530,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3)
$id_service_child = 0;
$agent_id = $element['id'];
if (!agents_check_access_agent($agent_id, 'AR')) {
continue;
continue 2;
}
break;
@ -14539,7 +14539,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3)
$id_service_child = 0;
$id_agente_modulo = $element['id'];
if (!agents_check_access_agent(modules_get_agentmodule_agent($id_agente_modulo), 'AR')) {
continue;
continue 2;
}
break;
@ -14554,7 +14554,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3)
$id_service_child
);
if ($service_group === false || !check_acl($config['id_user'], $service_group, 'AD')) {
continue;
continue 2;
}
break;
}
@ -14904,6 +14904,31 @@ function api_set_metaconsole_synch($keys)
}
function api_set_metaconsole_license_file($key)
{
global $config;
if (defined('METACONSOLE')) {
return;
}
if (empty($key) === true) {
returnError('Key cannot be empty.');
return;
}
// Update the license file.
$result = file_put_contents($config['remote_config'].'/'.LICENSE_FILE, $key);
if ($result === false) {
returnError('update-license', 'Failed to Update license file.');
} else {
returnData('string', ['type' => 'string', 'data' => true]);
}
return;
}
function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3)
{
global $config;

View File

@ -210,6 +210,7 @@ function events_get_all_fields()
$columns['data'] = __('Data');
$columns['module_status'] = __('Module status');
$columns['module_custom_id'] = __('Module custom id');
$columns['custom_data'] = __('Custom data');
return $columns;
}
@ -310,6 +311,9 @@ function events_get_column_name($field, $table_alias=false)
case 'direccion':
return __('Agent IP');
case 'custom_data':
return __('Custom data');
default:
return __($field);
}
@ -1122,6 +1126,23 @@ function events_get_all(
);
}
// Custom data.
if (empty($filter['custom_data']) === false) {
if ($filter['custom_data_filter_type'] === '1') {
$sql_filters[] = sprintf(
' AND JSON_VALID(custom_data) = 1
AND (JSON_EXTRACT(custom_data, "$.*") LIKE lower("%%%s%%") COLLATE utf8mb4_0900_ai_ci) ',
io_safe_output($filter['custom_data'])
);
} else {
$sql_filters[] = sprintf(
' AND JSON_VALID(custom_data) = 1
AND (JSON_SEARCH(JSON_KEYS(custom_data), "all", lower("%%%s%%") COLLATE utf8mb4_0900_ai_ci) IS NOT NULL) ',
io_safe_output($filter['custom_data'])
);
}
}
// Validated or in process by.
if (empty($filter['id_user_ack']) === false) {
$sql_filters[] = sprintf(

View File

@ -808,7 +808,7 @@ function html_print_select(
$output .= '<div class="flex-row-center">';
}
$output .= '<select '.$required.' onclick="'.$script.'" id="'.$id.'" name="'.$name.'"'.$attributes.' '.$styleText.'>';
$output .= '<select '.$required.' id="'.$id.'" name="'.$name.'"'.$attributes.' '.$styleText.'>';
if ($nothing !== false) {
if ($nothing != '' || empty($fields)) {
@ -1697,13 +1697,19 @@ function html_print_select_multiple_modules_filtered(array $data):string
$all_modules = [];
}
if (is_array($data['mModules']) === false) {
$result = explode(((is_metaconsole() === true) ? SEPARATOR_META_MODULE : ','), $data['mModules']);
} else {
$result = $data['mModules'];
}
$output .= html_print_input(
[
'label' => __('Modules'),
'type' => 'select',
'fields' => $all_modules,
'name' => 'filtered-module-modules-'.$uniqId,
'selected' => explode((is_metaconsole() === true) ? SEPARATOR_META_MODULE : ',', $data['mModules']),
'selected' => $result,
'return' => true,
'multiple' => true,
'style' => 'min-width: 200px;max-width:200px;',
@ -4765,6 +4771,10 @@ function html_print_input($data, $wrapper='div', $input_only=false)
$style = 'style="color: white"';
}
if (isset($data['label_class']) === false) {
$data['label_class'] = '';
}
$output = '';
if (($data['label'] ?? false) && $input_only === false) {

View File

@ -228,13 +228,26 @@ function messages_process_read(
$utimestamp = time();
}
$already_read = db_get_value_filter(
'utimestamp_read',
'tnotification_user',
[
'id_mensaje' => $message_id,
'id_user' => $config['id_user'],
]
);
if (empty($already_read) === false) {
// Already read.
return true;
}
$ret = db_process_sql_update(
'tnotification_user',
['utimestamp_read' => $utimestamp],
[
'id_mensaje' => $message_id,
'id_user' => $config['id_user'],
'utimestamp_read' => null,
'id_mensaje' => $message_id,
'id_user' => $config['id_user'],
]
);
@ -585,13 +598,6 @@ function messages_get_overview_sent(
'tmensajes',
$filter
);
return db_get_all_rows_field_filter(
'tmensajes',
'id_usuario_origen',
$config['id_user'],
$order
);
}

View File

@ -688,6 +688,15 @@ function reporting_make_reporting_data(
);
break;
case 'custom_render':
$report['contents'][] = reporting_custom_render(
$report,
$content,
$type,
$pdf
);
break;
case 'group_configuration':
$report['contents'][] = reporting_group_configuration(
$report,
@ -2802,6 +2811,12 @@ function reporting_agent_module($report, $content)
true
);
if (isset($external_source['show_type']) === true) {
$show_type = $external_source['show_type'];
} else {
$show_type = 0;
}
$return['type'] = 'agent_module';
if (empty($content['name'])) {
@ -2838,6 +2853,10 @@ function reporting_agent_module($report, $content)
modules_get_agentmodule_name($modul_id)
);
$modules_by_name[$cont]['id'] = $modul_id;
if ($show_type === '1') {
$modules_by_name[$cont]['unit'] = modules_get_unit($modul_id);
}
$cont++;
}
@ -2853,7 +2872,18 @@ function reporting_agent_module($report, $content)
$row['modules'] = [];
foreach ($modules_by_name as $module) {
if (array_key_exists($module['id'], $agent_modules)) {
$row['modules'][$module['name']] = modules_get_agentmodule_status($module['id']);
if ($show_type === '1') {
$module_last_value = modules_get_last_value($module['id']);
if (!is_numeric($module_last_value)) {
$module_last_value = htmlspecialchars($module_last_value);
}
$module['datos'] = $module_last_value;
$row['modules'][$module['name']] = modules_get_agentmodule_data_for_humans($module);
$row['show_type'] = $show_type;
} else {
$row['modules'][$module['name']] = modules_get_agentmodule_status($module['id']);
}
} else {
if (!array_key_exists($module['name'], $row['modules'])) {
$row['modules'][$module['name']] = null;
@ -4654,6 +4684,294 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic',
}
function reporting_custom_render($report, $content, $type='dinamic', $pdf=0)
{
global $config;
$return['type'] = 'custom_render';
if (empty($content['name'])) {
$content['name'] = __('Custom render report');
}
$return['title'] = $content['name'];
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = '';
$return['description'] = $content['description'];
$return['date'] = reporting_get_date_text($report, $content);
$return['failed'] = null;
$macros = [];
$patterns = [];
$substitutions = [];
if (isset($content['macros_definition']) === true
&& empty($content['macros_definition']) === false
) {
$macros = json_decode(
io_safe_output($content['macros_definition']),
true
);
if (empty($macros) === false && is_array($macros) === true) {
foreach ($macros as $key_macro => $data_macro) {
switch ($data_macro['type']) {
case 0:
// Type: String.
$patterns[] = addslashes(
'/_'.$data_macro['name'].'_/'
);
$substitutions[] = $data_macro['value'];
break;
case 1:
// Type Sql value.
$patterns[] = addslashes(
'/_'.$data_macro['name'].'_/'
);
$regex = '/(UPDATE|INSERT INTO|DELETE FROM|TRUNCATE|DROP|ALTER|CREATE|GRANT|REVOKE)\s+(.*?)\s+/i';
if (preg_match($regex, $data_macro['value']) > 0) {
$value_query = __('This query is insecure, it could apply unwanted modiffications on the schema');
} else {
$error_reporting = error_reporting();
error_reporting(0);
$value_query = db_get_value_sql(
trim($data_macro['value'], ';')
);
if ($value_query === false) {
$value_query = __('Error: %s', $config['dbconnection']->error);
}
error_reporting($error_reporting);
}
$substitutions[] = $value_query;
break;
case 2:
// Type: SQL graph.
$patterns[] = addslashes(
'/_'.$data_macro['name'].'_/'
);
$regex = '/(UPDATE|INSERT INTO|DELETE FROM|TRUNCATE|DROP|ALTER|CREATE|GRANT|REVOKE)\s+(.*?)\s+/i';
if (preg_match($regex, $data_macro['value']) > 0) {
$value_query = __('This query is insecure, it could apply unwanted modiffications on the schema');
} else {
$error_reporting = error_reporting();
error_reporting(0);
$data_query = db_get_all_rows_sql(
trim($data_macro['value'], ';')
);
error_reporting($error_reporting);
if ($data_query === false) {
$value_query = __('Error: %s', $config['dbconnection']->error);
} else {
$width = 210;
if (isset($data_macro['width']) === true
&& empty($data_macro['width']) === false
) {
$width = $data_macro['width'];
}
$height = 210;
if (isset($data_macro['height']) === true
&& empty($data_macro['height']) === false
) {
$height = $data_macro['height'];
}
// TODO: Allow to paint horizontal and vertical bar graphs for the moment only pie graphs.
$type = 'sql_graph_pie';
$SQL_GRAPH_MAX_LABEL_SIZE = 5;
$count = 0;
$flagOther = false;
foreach ($data_query as $data_item) {
$count++;
$value = 0;
if (empty($data_item['value']) === false) {
$value = $data_item['value'];
}
if ($count <= 5) {
$label = __('Data');
if (empty($data_item['label']) === false) {
$label = io_safe_output($data_item['label']);
if (strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) {
$first_label = $label;
$label = substr(
$first_label,
0,
floor($SQL_GRAPH_MAX_LABEL_SIZE / 2)
);
$label .= '...<br>';
$label .= substr(
$first_label,
floor(-$SQL_GRAPH_MAX_LABEL_SIZE / 2)
);
}
}
switch ($type) {
case 'sql_graph_vbar':
default:
// Vertical bar.
$data[] = [
'tick' => $label.'_'.$count,
'data' => $value,
];
break;
case 'sql_graph_hbar':
// Horizontal bar.
$data[$label.'_'.$count]['g'] = $value;
break;
case 'sql_graph_pie':
// Pie.
$data[$label.'_'.$count] = $value;
break;
}
} else {
switch ($type) {
case 'sql_graph_vbar':
default:
// Vertical bar.
if ($flagOther === false) {
$data[] = [
'tick' => __('Other'),
'data' => $value,
];
$flagOther = true;
}
$data[(count($data) - 1)]['data'] += $value;
break;
case 'sql_graph_hbar':
// Horizontal bar.
if (isset($data[__('Other')]['g']) === false) {
$data[__('Other')]['g'] = 0;
}
$data[__('Other')]['g'] += $value;
break;
case 'sql_graph_pie':
// Pie.
if (isset($data[__('Other')]) === false) {
$data[__('Other')] = 0;
}
$data[__('Other')] += $value;
break;
}
}
}
$value_query = pie_graph(
$data,
$width,
$height,
__('other'),
ui_get_full_url(false, false, false, false),
'',
$config['fontpath'],
$config['font_size'],
($pdf === true) ? 2 : 1,
'hidden',
'',
true
);
}
}
$substitutions[] = $value_query;
break;
case 3:
// Type: Simple graph.
$patterns[] = addslashes(
'/_'.$data_macro['name'].'_/'
);
$height = $config['graph_image_height'];
if (isset($data_macro['height']) === true
&& empty($data_macro['height']) === false
) {
$height = $data_macro['height'];
}
$period = SECONDS_1DAY;
if (isset($data_macro['period']) === true
&& empty($data_macro['period']) === false
) {
$period = $data_macro['period'];
}
if (is_metaconsole() === true) {
$server = db_get_row(
'tmetaconsole_setup',
'id',
$data_macro['server_id']
);
if (metaconsole_connect($server) != NOERR) {
continue;
}
}
$params = [
'agent_module_id' => $data_macro['id_agent_module'],
'period' => $period,
'title' => '',
'label' => '',
'pure' => false,
'only_image' => true,
'homeurl' => ui_get_full_url(
false,
false,
false,
false
),
'ttl' => ($pdf === true) ? 2 : 1,
'show_unknown' => true,
'height' => $height,
'backgroundColor' => 'transparent',
'return_img_base_64' => true,
'server_id' => (is_metaconsole() === true) ? $data_macro['server_id'] : 0,
];
$substitutions[] = '<img style="max-width:100%;" src="data:image/png;base64,'.grafico_modulo_sparse($params).'" />';
if (is_metaconsole() === true) {
metaconsole_restore_db();
}
break;
default:
// Not possible.
break;
}
}
}
}
$return['data'] = preg_replace(
$patterns,
$substitutions,
$content['render_definition']
);
return reporting_check_structure_content($return);
}
function agents_get_network_interfaces_array(
$network_interfaces_by_agents,
$return,
@ -9940,10 +10258,12 @@ function reporting_get_date_text($report=null, $content=null)
if (!empty($report) && !empty($content)) {
if ($content['period'] == 0) {
$es = json_decode($content['external_source'], true);
if ($es['date'] == 0) {
$return['period'] = 0;
} else {
$return['date'] = $es['date'];
if (empty($es) === false) {
if ($es['date'] == 0) {
$return['period'] = 0;
} else {
$return['date'] = $es['date'];
}
}
} else {
$return['period'] = $content['period'];

View File

@ -350,6 +350,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
reporting_html_network_interfaces_report($table, $item);
break;
case 'custom_render':
reporting_html_custom_render($table, $item);
break;
case 'group_configuration':
reporting_html_group_configuration($table, $item);
break;
@ -1807,9 +1811,9 @@ function reporting_html_agent_module($table, $item)
if (!empty($item['failed'])) {
$table->data['agent_module']['cell'] = $item['failed'];
} else {
$table_data = '<table cellpadding="1" cellspacing="4" cellspacing="0" border="0" class="bg_eee">';
$table_data .= '<th>'.__('Agents').' / '.__('Modules').'</th>';
$table_data = '<table class="border_table" cellpadding="0" cellspacing="0" cellspacing="0">';
$table_data .= '<tr class="border_th">';
$table_data .= '<th class="bg_th">'.__('Agents').' / '.__('Modules').'</th>';
$first = reset($item['data']);
$list_modules = $first['modules'];
@ -1823,11 +1827,14 @@ function reporting_html_agent_module($table, $item)
false,
'...'
);
$table_data .= '<th class="pdd_10px">'.$file_name.'</th>';
$table_data .= '<th class="pdd_10px bg_th">'.$file_name.'</th>';
}
$table_data .= '</tr>';
foreach ($item['data'] as $row) {
$table_data .= "<tr class='height_35px;'>";
$table_data .= "<tr class='height_35px border_tr'>";
switch ($row['agent_status']) {
case AGENT_STATUS_ALERT_FIRED:
$rowcolor = COL_ALERTFIRED;
@ -1865,118 +1872,122 @@ function reporting_html_agent_module($table, $item)
false,
'...'
);
$table_data .= "<td style='background-color: ".$rowcolor.";'>".$file_name.'</td>';
$table_data .= '<td class="pdd_6px left">'.$file_name.'</td>';
foreach ($row['modules'] as $module_name => $module) {
if ($module === null) {
$table_data .= "<td class='bg_dd;'></td>";
$table_data .= '<td></td>';
} else {
$table_data .= "<td class='center bg_ddd'>";
switch ($module) {
default:
case AGENT_STATUS_NORMAL:
$table_data .= ui_print_status_image(
'module_ok.png',
__(
'%s in %s : NORMAL',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
$table_data .= "<td class='center'>";
if (isset($row['show_type']) === true && $row['show_type'] === '1') {
$table_data .= $module;
} else {
switch ($module) {
case AGENT_STATUS_CRITICAL:
$table_data .= ui_print_status_image(
'module_critical.png',
__(
'%s in %s : CRITICAL',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_STATUS_CRITICAL:
$table_data .= ui_print_status_image(
'module_critical.png',
__(
'%s in %s : CRITICAL',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_STATUS_WARNING:
$table_data .= ui_print_status_image(
'module_warning.png',
__(
'%s in %s : WARNING',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_STATUS_WARNING:
$table_data .= ui_print_status_image(
'module_warning.png',
__(
'%s in %s : WARNING',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_STATUS_UNKNOWN:
$table_data .= ui_print_status_image(
'module_unknown.png',
__(
'%s in %s : UNKNOWN',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_STATUS_UNKNOWN:
$table_data .= ui_print_status_image(
'module_unknown.png',
__(
'%s in %s : UNKNOWN',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
$table_data .= ui_print_status_image(
'module_alertsfired.png',
__(
'%s in %s : ALERTS FIRED',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
$table_data .= ui_print_status_image(
'module_alertsfired.png',
__(
'%s in %s : ALERTS FIRED',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case 4:
$table_data .= ui_print_status_image(
'module_no_data.png',
__(
'%s in %s : Not initialize',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
case 4:
$table_data .= ui_print_status_image(
'module_no_data.png',
__(
'%s in %s : Not initialize',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
default:
case AGENT_STATUS_NORMAL:
$table_data .= ui_print_status_image(
'module_ok.png',
__(
'%s in %s : NORMAL',
$module_name,
$row['agent_name']
),
true,
[
'width' => '20px',
'height' => '20px',
],
'images/status_sets/default/'
);
break;
}
}
$table_data .= '</td>';
@ -1986,18 +1997,19 @@ function reporting_html_agent_module($table, $item)
$table_data .= '</table>';
$table_data .= "<div class='legend_basic w96p'>";
$table_data .= '<table>';
$table_data .= "<tr><td colspan='2' class='pdd_b_10px'><b>".__('Legend').'</b></td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_ALERTFIRED.";'></div></td><td>".__('Orange cell when the module has fired alerts').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_CRITICAL.";'></div></td><td>".__('Red cell when the module has a critical status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_WARNING.";'></div></td><td>".__('Yellow cell when the module has a warning status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_NORMAL.";'></div></td><td>".__('Green cell when the module has a normal status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_UNKNOWN.";'></div></td><td>".__('Grey cell when the module has an unknown status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_NOTINIT.";'></div></td><td>".__("Cell turns grey when the module is in 'not initialize' status").'</td></tr>';
$table_data .= '</table>';
$table_data .= '</div>';
if (isset($row['show_type']) === false) {
$table_data .= "<div class='legend_basic w96p'>";
$table_data .= '<table>';
$table_data .= "<tr><td colspan='2' class='pdd_b_10px'><b>".__('Legend').'</b></td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_ALERTFIRED.";'></div></td><td>".__('Orange cell when the module has fired alerts').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_CRITICAL.";'></div></td><td>".__('Red cell when the module has a critical status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_WARNING.";'></div></td><td>".__('Yellow cell when the module has a warning status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_NORMAL.";'></div></td><td>".__('Green cell when the module has a normal status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_UNKNOWN.";'></div></td><td>".__('Grey cell when the module has an unknown status').'</td></tr>';
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: ".COL_NOTINIT.";'></div></td><td>".__("Cell turns grey when the module is in 'not initialize' status").'</td></tr>';
$table_data .= '</table>';
$table_data .= '</div>';
}
$table->data['agent_module']['cell'] = $table_data;
}
@ -3052,6 +3064,47 @@ function reporting_html_network_interfaces_report($table, $item, $pdf=0)
}
/**
* This type of report element will generate the interface graphs
* of all those devices that belong to the selected group.
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param boolean $pdf If it comes from pdf.
*
* @return string HTML code.
*/
function reporting_html_custom_render($table, $item, $pdf=0)
{
$return_pdf = '';
if (empty($item['failed']) === false) {
if ($pdf === 0) {
$table->colspan['interfaces']['cell'] = 3;
$table->cellstyle['interfaces']['cell'] = 'text-align: left;';
$table->data['interfaces']['cell'] = $item['failed'];
} else {
$return_pdf .= $item['failed'];
}
} else {
$output = '<div id="reset-styles">';
$output .= $item['data'];
$output .= '</div>';
if ($pdf === 1) {
$return_pdf .= $output;
} else {
$id = uniqid();
$table->colspan[$id][0] = 3;
$table->data[$id] = $output;
}
}
if ($pdf !== 0) {
return $return_pdf;
}
}
/**
* Unified alert report HTML
*/

View File

@ -818,6 +818,13 @@ function reports_get_report_types($template=false, $not_editor=false)
'optgroup' => __('Grouped'),
'name' => __('Network interfaces'),
];
if (!$template) {
$types['custom_render'] = [
'optgroup' => __('Grouped'),
'name' => __('Custom Render'),
];
}
$types['availability'] = [
'optgroup' => __('Grouped'),
'name' => __('Availability'),
@ -1031,3 +1038,366 @@ function reports_copy_report($id_report)
return true;
}
/**
* Table custom macros.
*
* @param string $data JSON.
*
* @return string Html output.
*/
function get_table_custom_macros_report($data)
{
$table = new StdClass();
$table->data = [];
$table->width = '100%';
$table->class = 'databox data fullwidth';
$table->id = 'table-macros-definition';
$table->rowclass = [];
$table->size = [];
$table->size['name'] = '20%';
$table->size['type'] = '20%';
$table->size['value'] = '50%';
$table->size['op'] = '10%';
$table->head = [];
$table->head['name'] = __('Macro');
$table->head['type'] = __('Type');
$table->head['value'] = __('Value');
$table->head['op'] = html_print_image(
'images/add.png',
true,
[
'class' => 'invert_filter btn_debugModule',
'style' => 'cursor: pointer; filter: invert(100%);',
'onclick' => 'addCustomFieldRow();',
]
);
$list_macro_custom_type = [
0 => __('String'),
1 => __('Sql'),
2 => __('Graph Sql'),
3 => __('Simple graph'),
];
$data = json_decode($data, true);
if (is_array($data) === false || empty($data) === true) {
$data = [];
$data[0] = [
'name' => '',
'type' => 0,
'value' => '',
];
}
$table->data = [];
foreach ($data as $key_macro => $value_data_macro) {
$table->rowclass[$key_macro] = 'tr-macros-definition';
$table->data[$key_macro]['name'] = html_print_input_text_extended(
'macro_custom_name[]',
$value_data_macro['name'],
($key_macro === 0) ? 'macro_custom_name' : 'macro_custom_name_'.$key_macro,
'',
15,
255,
false,
'',
'class="fullwidth"',
true
);
$table->data[$key_macro]['name'] .= html_print_input_hidden(
'macro_custom_key[]',
$key_macro,
true,
false,
false,
($key_macro === 0) ? 'macro_custom_key' : 'macro_custom_key_'.$key_macro
);
$table->data[$key_macro]['type'] = html_print_select(
$list_macro_custom_type,
'macro_custom_type[]',
$value_data_macro['type'],
'change_custom_fields_macros_report('.$key_macro.')',
'',
0,
true,
false,
false,
'fullwidth',
false,
'height: 32px;',
false,
false,
false,
'',
false,
false,
false,
false,
false
);
$custom_fields = custom_fields_macros_report(
$value_data_macro,
$key_macro
);
$custom_field_draw = '';
if (empty($custom_fields) === false) {
foreach ($custom_fields as $key => $value) {
$custom_field_draw .= $value;
}
}
$table->data[$key_macro]['value'] = $custom_field_draw;
$table->data[$key_macro]['op'] = html_print_image(
'images/clean.png',
true,
[
'class' => 'invert_filter icon-clean-custom-macro',
'style' => 'cursor: pointer;',
'onclick' => 'cleanCustomFieldRow('.$key_macro.')',
]
);
$styles_remove = 'cursor: pointer; margin-right:10px;';
if ($key_macro === 0) {
$styles_remove .= 'display:none';
}
$table->data[$key_macro]['op'] .= html_print_image(
'images/delete.png',
true,
[
'class' => 'invert_filter icon-delete-custom-macro',
'style' => $styles_remove,
'onclick' => 'removeCustomFieldRow('.$key_macro.')',
]
);
}
return html_print_table(
$table,
true
);
}
/**
* Custom field macros report
*
* @param array $macro Info macro.
* @param string $key_macro Key.
*
* @return array
*/
function custom_fields_macros_report($macro, $key_macro)
{
$result = [];
switch ($macro['type']) {
case 0:
case 1:
$result['value'] = '<div class="custom-field-macro-report">';
$result['value'] .= '<label>';
$result['value'] .= ($macro['type'] == 0) ? __('String') : __('Sql');
$result['value'] .= '</label>';
$result['value'] .= html_print_input_text_extended(
'macro_custom_value[]',
$macro['value'],
($key_macro === 0) ? 'macro_custom_value' : 'macro_custom_value_'.$key_macro,
'',
15,
255,
false,
'',
'',
true
);
$result['value'] .= '</div>';
break;
case 2:
$result['value'] = '<div class="custom-field-macro-report mb10">';
$result['value'] .= '<label>';
$result['value'] .= __('Sql');
$result['value'] .= '</label>';
$result['value'] .= html_print_input_text_extended(
'macro_custom_value['.$key_macro.'][value]',
$macro['value'],
($key_macro === 0) ? 'macro_custom_value' : 'macro_custom_value_'.$key_macro,
'',
15,
255,
false,
'',
'class="fullwidth"',
true
);
$result['value'] .= '</div>';
$result['size'] = '<div class="custom-field-macro-report">';
$result['size'] .= '<label>';
$result['size'] .= __('Width');
$result['size'] .= '</label>';
$result['size'] .= html_print_input_text_extended(
'macro_custom_value['.$key_macro.'][width]',
$macro['width'],
($key_macro === 0) ? 'macro_custom_width' : 'macro_custom_width_'.$key_macro,
'',
5,
255,
false,
'',
'',
true
);
$result['size'] .= '<label>';
$result['size'] .= __('Height');
$result['size'] .= '</label>';
$result['size'] .= html_print_input_text_extended(
'macro_custom_value['.$key_macro.'][height]',
$macro['height'],
($key_macro === 0) ? 'macro_custom_height' : 'macro_custom_height_'.$key_macro,
'',
5,
255,
false,
'',
'',
true
);
$result['size'] .= '</div>';
break;
case 3:
$params = [];
$params['show_helptip'] = true;
$params['input_name'] = 'macro_custom_value_agent_name_'.$key_macro;
$params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'macro_custom_value_agent_id_'.$key_macro;
$params['hidden_input_idagent_name'] = 'macro_custom_value['.$key_macro.'][agent_id]';
$params['hidden_input_idagent_value'] = $macro['agent_id'];
$params['javascript_is_function_select'] = true;
$params['selectbox_id'] = 'macro_custom_value'.$key_macro.'id_agent_module';
$params['add_none_module'] = false;
$params['return'] = true;
$params['disabled_javascript_on_blur_function'] = true;
if (is_metaconsole() === true) {
$params['print_input_id_server'] = true;
$params['metaconsole_enabled'] = true;
$params['input_id_server_id'] = 'macro_custom_value_id_server_'.$key_macro;
$params['input_id_server_name'] = 'macro_custom_value['.$key_macro.'][server_id]';
$params['input_id_server_value'] = $macro['server_id'];
$params['value'] = agents_meta_get_alias(
$macro['agent_id'],
'none',
$macro['server_id'],
true
);
} else {
$params['value'] = agents_get_alias($macro['agent_id']);
}
$result['size'] = '<div class="custom-field-macro-report mb10">';
$result['size'] .= '<label>';
$result['size'] .= __('Agent');
$result['size'] .= '</label>';
$result['size'] .= ui_print_agent_autocomplete_input($params);
$modules = [];
if (isset($macro['agent_id']) === true
&& empty($macro['agent_id']) === false
) {
if (is_metaconsole() === true) {
$server = db_get_row(
'tmetaconsole_setup',
'id',
$macro['server_id']
);
if (metaconsole_connect($server) != NOERR) {
continue;
}
}
$modules = agents_get_modules(
$macro['agent_id'],
false,
['delete_pending' => 0]
);
if (is_metaconsole() === true) {
metaconsole_restore_db();
}
}
$result['size'] .= '<label>';
$result['size'] .= __('Module');
$result['size'] .= '</label>';
$result['size'] .= html_print_select(
$modules,
'macro_custom_value['.$key_macro.'][id_agent_module]',
$macro['id_agent_module'],
true,
__('Select'),
0,
true,
false,
true,
'',
(empty($macro['agent_id']) === true),
'min-width: 250px;margin-right: 0.5em;'
);
$result['size'] .= '</div>';
$result['size'] .= '<div class="custom-field-macro-report">';
$result['size'] .= '<label>';
$result['size'] .= __('Height');
$result['size'] .= '</label>';
$result['size'] .= html_print_input_text_extended(
'macro_custom_value['.$key_macro.'][height]',
$macro['height'],
($key_macro === 0) ? 'macro_custom_height' : 'macro_custom_height_'.$key_macro,
'',
5,
255,
false,
'',
'',
true
);
$result['size'] .= '<label>';
$result['size'] .= __('Period ');
$result['size'] .= '</label>';
$result['size'] .= html_print_input_text_extended(
'macro_custom_value['.$key_macro.'][period]',
$macro['period'],
($key_macro === 0) ? 'macro_custom_period' : 'macro_custom_period_'.$key_macro,
'',
5,
255,
false,
'',
'',
true
);
$result['size'] .= '</div>';
break;
default:
// Not possible.
break;
}
return $result;
}

View File

@ -862,7 +862,7 @@ function visual_map_print_item(
);
if (metaconsole_load_external_db($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
continue;
break;
}
}
@ -967,7 +967,7 @@ function visual_map_print_item(
);
if (metaconsole_load_external_db($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
continue;
break;
}
}
@ -1113,7 +1113,7 @@ function visual_map_print_item(
['id' => $layoutData['id_metaconsole']]
);
if (metaconsole_load_external_db($connection) != NOERR) {
continue;
break;
}
}
@ -1411,7 +1411,7 @@ function visual_map_print_item(
if (!empty($id_metaconsole)) {
$connection = db_get_row_filter('tmetaconsole_setup', $id_metaconsole);
if (metaconsole_load_external_db($connection) != NOERR) {
continue;
break;
}
}
@ -1719,7 +1719,7 @@ function visual_map_print_item(
['id' => $layoutData['id_metaconsole']]
);
if (metaconsole_load_external_db($connection) != NOERR) {
continue;
break;
}
}
@ -2173,7 +2173,7 @@ function visual_map_print_item(
);
if (metaconsole_load_external_db($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
continue;
break;
}
}
@ -3299,7 +3299,7 @@ function visual_map_get_status_element($layoutData)
);
if (metaconsole_load_external_db($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
continue;
break;
}
}
@ -3385,7 +3385,7 @@ function visual_map_get_status_element($layoutData)
);
if (metaconsole_load_external_db($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
continue;
break;
}
}

View File

@ -104,7 +104,7 @@ function pandoraFlotPie(
'<div style="font-size:' +
font_size +
"pt;" +
'text-align:center;padding:2px;color:white;">' +
'text-align:center;padding:2px;color:#4a4a4a;">' +
label +
"<br/>" +
series.percent.toFixed(2) +

View File

@ -102,7 +102,7 @@ function fullCalendarPandora(calendarEl, options, settings, initialEvents) {
function select_alert_template(info, calendar) {
var nextDay = info.start.getDay() === 6 ? 0 : info.start.getDay() + 1;
if (
info.start.getDay() == info.end.getDay() ||
(info.start.getDay() == info.end.getDay() && info.start < info.end) ||
(nextDay == info.end.getDay() && time_format(info.end) == "00:00:00")
) {
recalculate_events(calendar, {}, info.start, info.end, true);
@ -282,7 +282,6 @@ function eventClick_alert_template(info, calendar, settings) {
onAccept: function() {
var replace_day_from = $("#hidden-day_from").val();
var replace_time_from = $("#text-time_from_event").val();
var array_time_from = replace_time_from.split(":");
var new_date_from = new Date(calendar_days[replace_day_from]);
new_date_from.setHours(
@ -294,8 +293,13 @@ function eventClick_alert_template(info, calendar, settings) {
var replace_day_to = $("#hidden-day_to").val();
var replace_time_to = $("#text-time_to_event").val();
if (replace_time_to === "23:59:59") {
replace_day_to++;
replace_time_to = "00:00:00";
if (replace_day_to == 6) {
replace_day_to = 0;
replace_time_to = "00:00:00";
} else if (replace_day_to != 0) {
replace_day_to++;
replace_time_to = "00:00:00";
}
}
var array_time_to = replace_time_to.split(":");

View File

@ -518,8 +518,8 @@ function confirmDialog(settings) {
hideOkButton +
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
click: function() {
$(this).dialog("close");
if (typeof settings.onAccept == "function") settings.onAccept();
$(this).dialog("close");
$(this).remove();
}
}
@ -547,7 +547,13 @@ function confirmDialog(settings) {
.dialog({
open: settings.open,
title: settings.title,
close: false,
close: function() {
if (typeof settings.notCloseOnDeny == "undefined") {
$(this).dialog("close");
$(this).remove();
}
if (typeof settings.onDeny == "function") settings.onDeny();
},
width: settings.size,
maxHeight: settings.maxHeight,
modal: true,

View File

@ -200,6 +200,10 @@ class AgentModuleWidget extends Widget
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['mTypeShow']) === true) {
$values['mTypeShow'] = $decoder['mTypeShow'];
}
if (isset($decoder['mGroup']) === true) {
$values['mGroup'] = $decoder['mGroup'];
}
@ -246,6 +250,29 @@ class AgentModuleWidget extends Widget
'label' => __('Filter modules'),
];
// Type show.
$show_select = [
0 => __('Show module status'),
1 => __('Show module data'),
];
if (empty($this->values['mModules']) === true && empty($this->values['mTypeShow'])) {
$this->values['mTypeShow'] = 1;
}
$inputs[] = [
'class' => 'flex flex-row',
'label' => __('Information to be shown'),
'arguments' => [
'type' => 'select',
'fields' => $show_select,
'name' => 'filtered-type-show-'.$this->cellId,
'return' => true,
'id' => 'filtered-type-show-'.$this->cellId,
'selected' => ($this->values['mTypeShow'] === null) ? 0 : $this->values['mTypeShow'],
],
];
$return_all_group = false;
if (users_can_manage_group_all('RM') || $this->values['mGroup'] == 0) {
@ -285,6 +312,10 @@ class AgentModuleWidget extends Widget
// Retrieve global - common inputs.
$values = parent::getPost();
$values['mTypeShow'] = \get_parameter(
'filtered-type-show-'.$this->cellId
);
$values['mGroup'] = \get_parameter(
'filtered-module-group-'.$this->cellId
);
@ -409,7 +440,7 @@ class AgentModuleWidget extends Widget
array $visualData,
array $allModules
):string {
$style = 'display:flex; width:100%; margin: 10px;';
$style = 'display:flex; width:96%; margin-top: 10px;';
$table_data = '<div style="'.$style.'">';
$table_data .= '<table class="widget_agent_module transparent mrgn_0px" cellpadding="1" cellspacing="0" border="0">';
@ -478,118 +509,126 @@ class AgentModuleWidget extends Widget
}
foreach ($row['modules'] as $module_name => $module) {
if ($module === null) {
if (in_array($module_name, $allModules) === true) {
$style = 'background-color: transparent;';
$table_data .= "<td style='".$style."'>";
$table_data .= '</td>';
} else {
continue;
}
} else {
if ($this->values['mTypeShow'] === '1') {
$style = 'text-align: center;';
$style .= ' background-color: transparent;';
$table_data .= "<td style='".$style."'>";
switch ($module) {
case AGENT_STATUS_NORMAL:
$table_data .= \ui_print_status_image(
'module_ok.png',
__(
'%s in %s : NORMAL',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_CRITICAL:
$table_data .= \ui_print_status_image(
'module_critical.png',
__(
'%s in %s : CRITICAL',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_WARNING:
$table_data .= \ui_print_status_image(
'module_warning.png',
__(
'%s in %s : WARNING',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_UNKNOWN:
$table_data .= \ui_print_status_image(
'module_unknown.png',
__(
'%s in %s : UNKNOWN',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case 4:
$table_data .= \ui_print_status_image(
'module_no_data.png',
__(
'%s in %s : Not initialize',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_ALERT_FIRED:
default:
$table_data .= \ui_print_status_image(
'module_alertsfired.png',
__(
'%s in %s : ALERTS FIRED',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
}
$table_data .= $module;
$table_data .= '</td>';
} else {
if ($module === null) {
if (in_array($module_name, $allModules) === true) {
$style = 'background-color: transparent;';
$table_data .= "<td style='".$style."'>";
$table_data .= '</td>';
} else {
continue;
}
} else {
$style = 'text-align: center;';
$style .= ' background-color: transparent;';
$table_data .= "<td style='".$style."'>";
switch ($module) {
case AGENT_STATUS_NORMAL:
$table_data .= \ui_print_status_image(
'module_ok.png',
__(
'%s in %s : NORMAL',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_CRITICAL:
$table_data .= \ui_print_status_image(
'module_critical.png',
__(
'%s in %s : CRITICAL',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_WARNING:
$table_data .= \ui_print_status_image(
'module_warning.png',
__(
'%s in %s : WARNING',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_UNKNOWN:
$table_data .= \ui_print_status_image(
'module_unknown.png',
__(
'%s in %s : UNKNOWN',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case 4:
$table_data .= \ui_print_status_image(
'module_no_data.png',
__(
'%s in %s : Not initialize',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_ALERT_FIRED:
default:
$table_data .= \ui_print_status_image(
'module_alertsfired.png',
__(
'%s in %s : ALERTS FIRED',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
}
$table_data .= '</td>';
}
}
}
@ -743,9 +782,11 @@ class AgentModuleWidget extends Widget
}
}
} else {
$modules = $agent->searchModules(
['nombre' => array_keys($reduceAllModules)]
);
if (empty($reduceAllModules) === false) {
$modules = $agent->searchModules(
['nombre' => array_keys($reduceAllModules)]
);
}
}
$visualData[$agent_id]['modules'] = $reduceAllModules;
@ -754,7 +795,14 @@ class AgentModuleWidget extends Widget
continue;
}
$visualData[$agent_id]['modules'][$module->name()] = $module->getStatus()->estado();
if ($this->values['mTypeShow'] === '1') {
$mod = $module->toArray();
$mod['datos'] = $module->lastValue();
$module_last_value = modules_get_agentmodule_data_for_humans($mod);
$visualData[$agent_id]['modules'][$module->name()] = $module_last_value;
} else {
$visualData[$agent_id]['modules'][$module->name()] = $module->getStatus()->estado();
}
}
if ((bool) is_metaconsole() === true) {
@ -765,7 +813,10 @@ class AgentModuleWidget extends Widget
}
}
$allModules = array_keys($reduceAllModules);
if (empty($reduceAllModules) === false) {
$allModules = array_keys($reduceAllModules);
}
if ($allModules === null) {
$allModules = [];
}

View 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;
}

View File

@ -1265,6 +1265,25 @@ input.datos {
.bg_caca {
background-color: #cacaca;
}
.bg_th {
background-color: #efeff0 !important;
color: #000;
font-weight: bold;
}
.border_table {
border-collapse: collapse !important;
}
.border_th {
border-bottom: 2px solid #bfbfbf !important;
}
.border_tr {
border: 1px solid #dbdbdb !important;
}
/* margins */
.mgn-lf-50 {
margin-left: 50px;
@ -8553,3 +8572,446 @@ div#err_msg_centralised {
width: 90%;
margin: 0 auto;
}
.custom-field-macro-report {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
align-content: center;
}
.custom-field-macro-report label {
flex: 0;
margin-right: 10px;
margin-left: 10px;
}
.custom-field-macro-report input {
flex: 2;
}
.mb10 {
margin-bottom: 10px;
}
#reset-styles {
font-size: 9pt;
line-height: 16pt;
padding: 0px;
box-sizing: border-box;
/*page-break-after: always;*/
}
#reset-styles a:link {
text-decoration: underline;
cursor: auto;
}
#reset-styles a:visited {
text-decoration: underline;
cursor: auto;
}
#reset-styles address {
display: block;
font-style: italic;
}
#reset-styles area {
display: none;
}
#reset-styles article {
display: block;
}
#reset-styles aside {
display: block;
}
#reset-styles b {
font-weight: bold;
}
#reset-styles bdo {
unicode-bidi: bidi-override;
}
#reset-styles blockquote {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 40px;
margin-right: 40px;
}
#reset-styles body {
display: block;
margin: 8px;
}
#reset-styles body:focus {
outline: none;
}
#reset-styles caption {
display: table-caption;
text-align: center;
}
#reset-styles cite {
font-style: italic;
}
#reset-styles code {
font-family: monospace;
}
#reset-styles col {
display: table-column;
}
#reset-styles colgroup {
display: table-column-group;
}
#reset-styles datalist {
display: none;
}
#reset-styles dd {
display: block;
margin-left: 40px;
}
#reset-styles del {
text-decoration: line-through;
}
#reset-styles details {
display: block;
}
#reset-styles dfn {
font-style: italic;
}
#reset-styles div {
display: block;
}
#reset-styles dl {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
}
#reset-styles dt {
display: block;
}
#reset-styles em {
font-style: italic;
}
#reset-styles embed:focus {
outline: none;
}
#reset-styles fieldset {
display: block;
margin-left: 2px;
margin-right: 2px;
padding-top: 0.35em;
padding-bottom: 0.625em;
padding-left: 0.75em;
padding-right: 0.75em;
border: 2px groove;
}
#reset-styles figcaption {
display: block;
}
#reset-styles figure {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 40px;
margin-right: 40px;
}
#reset-styles footer {
display: block;
}
#reset-styles form {
display: block;
margin-top: 0em;
}
#reset-styles h1 {
display: inline-block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
margin-block-start: 0.67em;
margin-block-end: 0.67em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;
text-transform: uppercase;
padding: 0;
}
#reset-styles h2 {
display: inline-block;
font-size: 1.5em;
margin-top: 0.83em;
margin-bottom: 0.83em;
margin-left: 0;
margin-right: 0;
margin-block-start: 0.83em;
margin-block-end: 0.83em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;
text-transform: uppercase;
padding: 0;
}
#reset-styles h3 {
display: inline-block;
font-size: 1.17em;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;
text-transform: uppercase;
padding: 0;
}
#reset-styles h4 {
display: inline-block;
margin-top: 1.33em;
margin-bottom: 1.33em;
margin-left: 0;
margin-right: 0;
margin-block-start: 1.33em;
margin-block-end: 1.33em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;
text-transform: uppercase;
padding: 0;
}
#reset-styles h5 {
display: inline-block;
font-size: 0.83em;
margin-top: 1.67em;
margin-bottom: 1.67em;
margin-block-start: 1.67em;
margin-block-end: 1.67em;
margin-inline-start: 0px;
margin-inline-end: 0px;
margin-left: 0;
margin-right: 0;
font-weight: bold;
text-transform: uppercase;
padding: 0;
}
#reset-styles h6 {
display: inline-block;
font-size: 0.67em;
margin-top: 2.33em;
margin-bottom: 2.33em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
text-transform: uppercase;
padding: 0;
}
#reset-styles head {
display: none;
}
#reset-styles header {
display: block;
}
#reset-styles hr {
display: block;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: auto;
margin-right: auto;
border-style: inset;
border-width: 1px;
}
#reset-styles html {
display: block;
}
#reset-styles html:focus {
outline: none;
}
#reset-styles i {
font-style: italic;
}
#reset-styles iframe:focus {
outline: none;
}
#reset-styles iframe[seamless] {
display: block;
}
#reset-styles img {
display: inline-block;
}
#reset-styles ins {
text-decoration: underline;
}
#reset-styles kbd {
font-family: monospace;
}
#reset-styles label {
cursor: default;
}
#reset-styles legend {
display: block;
padding-left: 2px;
padding-right: 2px;
border: none;
}
#reset-styles li {
display: list-item;
}
#reset-styles link {
display: none;
}
#reset-styles map {
display: inline;
}
#reset-styles mark {
background-color: yellow;
color: black;
}
#reset-styles menu {
display: block;
list-style-type: disc;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
padding-left: 40px;
}
#reset-styles nav {
display: block;
}
#reset-styles object:focus {
outline: none;
}
#reset-styles ol {
display: block;
list-style-type: decimal;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
padding-left: 40px;
}
#reset-styles output {
display: inline;
}
#reset-styles p {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
}
#reset-styles param {
display: none;
}
#reset-styles pre {
display: block;
font-family: monospace;
white-space: pre;
margin: 1em 0;
}
#reset-styles q {
display: inline;
}
#reset-styles q::before {
content: open-quote;
}
#reset-styles q::after {
content: close-quote;
}
#reset-styles rt {
line-height: normal;
}
#reset-styles s {
text-decoration: line-through;
}
#reset-styles samp {
font-family: monospace;
}
#reset-styles script {
display: none;
}
#reset-styles section {
display: block;
}
#reset-styles small {
font-size: smaller;
}
#reset-styles strike {
text-decoration: line-through;
}
#reset-styles strong {
font-weight: bold;
}
#reset-styles style {
display: none;
}
#reset-styles sub {
vertical-align: sub;
font-size: smaller;
}
#reset-styles summary {
display: block;
}
#reset-styles sup {
vertical-align: super;
font-size: smaller;
}
#reset-styles table {
display: table;
border-collapse: separate;
border-spacing: 2px;
border-color: gray;
}
#reset-styles tbody {
display: table-row-group;
vertical-align: middle;
border-color: inherit;
}
#reset-styles td {
display: table-cell;
vertical-align: inherit;
text-align: inherit;
}
#reset-styles tfoot {
display: table-footer-group;
vertical-align: middle;
border-color: inherit;
}
#reset-styles thead tr th {
display: table-cell;
vertical-align: inherit;
font-weight: bold;
text-align: center;
background-color: initial;
color: initial;
}
#reset-styles thead {
display: table-header-group;
vertical-align: middle;
border-color: inherit;
}
#reset-styles title {
display: none;
}
#reset-styles tr {
display: table-row;
vertical-align: inherit;
border-color: inherit;
}
#reset-styles u {
text-decoration: underline;
}
#reset-styles ul {
display: block;
list-style-type: disc;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
padding-left: 40px;
}
#reset-styles var {
font-style: italic;
}

View File

@ -128,8 +128,8 @@
</div>
<div style='height: 10px'>
<?php
$version = '7.0NG.760';
$build = '220330';
$version = '7.0NG.761';
$build = '220407';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -134,7 +134,7 @@ if ($group_rep == 2) {
echo '<div class="nf">'.__('No events').'</div>';
}
} else {
// fields that the user has selected to show
// Fields that the user has selected to show.
if ($meta) {
$show_fields = events_meta_get_custom_fields_user();
} else {
@ -345,6 +345,13 @@ if ($group_rep == 2) {
$i++;
}
if ($fields === 'custom_data') {
$table->head[$i] = __('Custom data');
$table->align[$i] = 'left';
$i++;
}
}
if (in_array('estado', $show_fields)) {

View File

@ -226,6 +226,16 @@ $server_id = get_parameter(
$filter['id_server_meta']
);
$custom_data_filter_type = get_parameter(
'filter[custom_data_filter_type]',
$filter['custom_data_filter_type']
);
$custom_data = get_parameter(
'filter[custom_data]',
$filter['custom_data']
);
if (is_metaconsole() === true) {
// Connect to node database.
$id_node = $server_id;
@ -530,6 +540,8 @@ if ($loaded_filter !== false && $from_event_graph != 1 && !isset($fb64)) {
$user_comment = $filter['user_comment'];
$id_source_event = ($filter['id_source_event'] ?? '');
$server_id = $filter['server_id'];
$custom_data = $filter['custom_data'];
$custom_data_filter_type = $filter['custom_data_filter_type'];
}
}
@ -1451,6 +1463,54 @@ $adv_inputs[] = html_print_div(
true
);
// Custom data filter type.
$custom_data_filter_type_input = html_print_select(
[
'0' => __('Filter custom data by field name'),
'1' => __('Filter custom data by field value'),
],
'custom_data_filter_type',
$custom_data_filter_type,
'',
false,
-1,
true
);
$adv_inputs[] = html_print_div(
[
'class' => 'filter_input',
'content' => sprintf(
'<label>%s</label>%s',
__('Custom data filter'),
$custom_data_filter_type_input
),
],
true
);
// Custom data.
$custom_data_input = html_print_input_text(
'custom_data',
$custom_data,
'',
5,
255,
true
);
$adv_inputs[] = html_print_div(
[
'class' => 'filter_input',
'content' => sprintf(
'<label>%s</label>%s',
__('Custom data search'),
$custom_data_input
),
],
true
);
// Tags.
if (is_metaconsole() === true) {
$data = '<fieldset><legend class="pdd_0px">'.__('Events with following tags').'</legend>'.html_print_table($tabletags_with, true).'</fieldset>';
@ -2259,6 +2319,27 @@ function process_datatables_item(item) {
/* Module name */
item.id_agentmodule = item.module_name;
if (item.custom_data !== '') {
var custom_data_str = '';
var item_custom_data_obj = (function(json_str) {
try {
return JSON.parse(json_str);
} catch (err) {
return false;
}
})(item.custom_data);
if (item_custom_data_obj !== false) {
for (const [attr_name, val] of Object.entries(item_custom_data_obj)) {
custom_data_str += attr_name + ' = ' + val + '<br>';
}
item.custom_data = custom_data_str;
} else {
item.custom_data = '';
}
}
}
/* Datatables auxiliary functions ends */

View File

@ -127,6 +127,8 @@ if (is_ajax()) {
$values['source'] = get_parameter('source');
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
$values['custom_data'] = get_parameter('custom_data');
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
if (is_metaconsole()) {
$values['id_source_event'] = get_parameter('id_source_event');
@ -182,6 +184,8 @@ if (is_ajax()) {
$values['source'] = get_parameter('source');
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
$values['custom_data'] = get_parameter('custom_data');
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
if (is_metaconsole()) {
$values['id_source_event'] = get_parameter('id_source_event');
@ -1567,8 +1571,9 @@ $(document).ready( function() {
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val(),
"id_source_event": $("#text-id_source_event").val(),
"server_id" : $("#server_id").val()
"server_id" : $("#server_id").val(),
"custom_data" : $("#text-custom_data").val(),
"custom_data_filter_type" : $("#custom_data_filter_type").val()
},
function (data) {
$(".info_box").hide();
@ -1670,7 +1675,9 @@ $(document).ready( function() {
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val(),
"id_source_event": $("#text-id_source_event").val(),
"server_id" : $("#server_id").val()
"server_id" : $("#server_id").val(),
"custom_data" : $("#text-custom_data").val()
"custom_data_filter_type" : $("#custom_data_filter_type").val()
},
function (data) {
$(".info_box").hide();

View File

@ -226,7 +226,7 @@ try {
if ($custom_data_array !== null) {
array_walk(
$custom_data_array,
function (&$value, $field) {
function (&$value, $field) use ($separator) {
if (is_array($value) === true) {
$value = '['.implode($separator, $value).']';
}

View 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>

View File

@ -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']['refr'] = 0;
$sub2['operation/heatmap']['text'] = __('Heatmap view');
$sub2['operation/heatmap']['refr'] = 0;
$sub['view']['sub2'] = $sub2;
enterprise_hook('inventory_menu');

View File

@ -2,8 +2,8 @@
# Pandora FMS Console
#
%define name pandorafms_console
%define version 7.0NG.760
%define release 220330
%define version 7.0NG.761
%define release 220407
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -2,8 +2,8 @@
# Pandora FMS Console
#
%define name pandorafms_console
%define version 7.0NG.760
%define release 220330
%define version 7.0NG.761
%define release 220407
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -2,8 +2,8 @@
# Pandora FMS Console
#
%define name pandorafms_console
%define version 7.0NG.760
%define release 220330
%define version 7.0NG.761
%define release 220407
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

View File

@ -9,7 +9,7 @@
# This code is licensed under GPL 2.0 license.
# **********************************************************************
PI_VERSION="7.0NG.760"
PI_VERSION="7.0NG.761"
FORCE=0
DESTDIR=""
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`

View File

@ -1251,6 +1251,8 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
`server_id` INT NOT NULL DEFAULT 0,
`time_from` TIME NULL,
`time_to` TIME NULL,
`custom_data` VARCHAR(500) DEFAULT '',
`custom_data_filter_type` TINYINT UNSIGNED DEFAULT 0,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
@ -1608,6 +1610,8 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
`ipam_network_filter` INT UNSIGNED DEFAULT 0,
`ipam_alive_ips` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`ipam_ip_not_assigned_to_agent` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`macros_definition` TEXT,
`render_definition` TEXT,
PRIMARY KEY(`id_rc`),
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
ON UPDATE CASCADE ON DELETE CASCADE
@ -3216,6 +3220,8 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` (
`ipam_network_filter` INT UNSIGNED DEFAULT 0,
`ipam_alive_ips` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`ipam_ip_not_assigned_to_agent` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`macros_definition` TEXT,
`render_definition` TEXT,
PRIMARY KEY(`id_rc`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;

View File

@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
('custom_report_front_header', ''),
('custom_report_front_footer', ''),
('MR', 52),
('MR', 53),
('identification_reminder', 1),
('identification_reminder_timestamp', 0),
('current_package', 760),
('current_package', 761),
('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.00097656250000":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'),
('custom_docs_logo', 'default_docs.png'),
('custom_support_logo', 'default_support.png'),

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.760-220330
Version: 7.0NG.761-220407
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.760-220330"
pandora_version="7.0NG.761-220407"
package_cpan=0
package_pandora=1

View File

@ -1,7 +1,7 @@
#############################################################################
# Pandora FMS Server Parameters
# Pandora FMS, the Flexible Monitoring System.
# Version 7.0NG.760
# Version 7.0NG.761
# Licensed under GPL license v2,
# (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -45,8 +45,8 @@ our @EXPORT = qw(
);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.760";
my $pandora_build = "220330";
my $pandora_version = "7.0NG.761";
my $pandora_build = "220407";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -1848,18 +1848,7 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
my @user_list = map {clean_blank($_)} split /,/, $field1;
my @group_list = map {clean_blank($_)} split /,/, $field2;
my $notification = {};
$notification->{'subject'} = safe_input($field3);
$notification->{'mensaje'} = safe_input($field4);
$notification->{'id_source'} = get_db_value($dbh, 'SELECT id FROM tnotification_source WHERE description = ?', safe_input('System status'));
# Create message
my $notification_id = db_process_insert($dbh,'id_mensaje','tmensajes',$notification);
if (!$notification_id) {
logger($pa_config, "Failed action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined($agent) ? $agent->{'alias'} : 'N/A') . "'.", 3);
} else {
notification_set_targets($pa_config, $dbh, $notification_id, \@user_list, \@group_list);
}
send_console_notification($pa_config, $dbh, $field3, $field4, \@user_list, \@group_list);
} else {
logger($pa_config, "Failed action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined($agent) ? $agent->{'alias'} : 'N/A') . "' Empty targets. Ignored.", 3);
}
@ -1876,6 +1865,40 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
}
}
##########################################################################
=head2 C<< send_console_notification (I<$pa_config>, I<$dbh>, I<$subject>, I<$message>, I<$user_list>, I<$group_list>) >>
Send message (with subject) to given userlist and/ or group list.
=cut
##########################################################################
sub send_console_notification {
my ($pa_config, $dbh, $subject, $message, $user_list, $group_list) = @_;
my $notification = {};
$notification->{'subject'} = safe_input($subject);
$notification->{'mensaje'} = safe_input($message);
$notification->{'id_source'} = get_db_value($dbh,
'SELECT id FROM tnotification_source WHERE description = ?',
safe_input('System status')
);
# Create message
my $notification_id = db_process_insert($dbh, 'id_mensaje', 'tmensajes', $notification);
if (!$notification_id) {
logger($pa_config, "Cannot send notification '" . $subject . "'", 3);
} else {
notification_set_targets(
$pa_config,
$dbh,
$notification_id,
$user_list,
$group_list
);
}
}
##########################################################################
=head2 C<< pandora_access_update (I<$pa_config>, I<$agent_id>, I<$dbh>) >>

View File

@ -251,6 +251,7 @@ sub data_consumer ($$) {
}
my $recon = new PandoraFMS::Recon::Base(
parent => $self,
communities => \@communities,
dbh => $dbh,
group_id => $task->{'id_group'},
@ -1727,6 +1728,23 @@ sub PandoraFMS::Recon::Base::delete_connections($) {
sub PandoraFMS::Recon::Base::message($$$) {
my ($self, $message, $verbosity) = @_;
if ($verbosity <= 1) {
my $label = "[Discovery task " . $self->{'task_id'} . "]";
if (ref($self->{'task_data'}) eq 'HASH' && defined($self->{'task_data'}{'name'})) {
$label = "[Discovery task " . $self->{'task_data'}{'name'} . "]";
}
PandoraFMS::Core::send_console_notification(
$self->{'pa_config'},
$self->{'parent'}->getDBH(),
$label,
$message,
['admin']
);
$self->{'summary'} = $message;
}
logger($self->{'pa_config'}, "[Recon task " . $self->{'task_id'} . "] $message", $verbosity);
}

View File

@ -33,8 +33,8 @@ use base 'Exporter';
our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.760";
my $pandora_build = "220330";
my $pandora_version = "7.0NG.761";
my $pandora_build = "220407";
our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -1037,6 +1037,7 @@ sub limpia_cadena {
################################################################################
sub clean_blank {
my $input = $_[0];
return $input unless defined($input);
$input =~ s/^\s+//g;
$input =~ s/\s+$//g;
return $input;

View File

@ -2,8 +2,8 @@
# Pandora FMS Server
#
%define name pandorafms_server
%define version 7.0NG.760
%define release 220330
%define version 7.0NG.761
%define release 220407
Summary: Pandora FMS Server
Name: %{name}

View File

@ -2,8 +2,8 @@
# Pandora FMS Server
#
%define name pandorafms_server
%define version 7.0NG.760
%define release 220330
%define version 7.0NG.761
%define release 220407
Summary: Pandora FMS Server
Name: %{name}

View File

@ -8,8 +8,8 @@
# This code is licensed under GPL 2.0 license.
# **********************************************************************
PI_VERSION="7.0NG.760"
PI_BUILD="220330"
PI_VERSION="7.0NG.761"
PI_BUILD="220407"
MODE=$1
if [ $# -gt 1 ]; then

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
my $version = "7.0NG.760 Build 220330";
my $version = "7.0NG.761 Build 220407";
# Pandora server configuration
my %conf;

View File

@ -82,24 +82,26 @@ sub ha_daemonize($) {
# Fork!
defined(my $pid = fork) or die "Can't fork: $!";
if ($pid) {
# Store PID of this process in file presented by config token
if ($PID_FILE ne "") {
if ( -e $PID_FILE && open (FILE, $PID_FILE)) {
$pid = <FILE> + 0;
close FILE;
# Check if pandora_ha is running.
die "[ERROR] pandora_ha is already running with pid: $pid." if (kill (0, $pid));
}
umask 0022;
open (FILE, '>', $PID_FILE) or die "[FATAL] $!";
print FILE $pid;
close (FILE);
}
exit;
}
exit if ($pid);
# Child inherits execution.
setsid or die "Can't start a new session: $!";
# Store PID of this process in file presented by config token
if ($PID_FILE ne "") {
if ( -e $PID_FILE && open (FILE, $PID_FILE)) {
$pid = <FILE> + 0;
close FILE;
# Check if pandora_ha is running.
die "[ERROR] pandora_ha is already running with pid: $pid.\n" if (kill (0, $pid));
}
umask 0022;
open (FILE, '>', $PID_FILE) or die "[FATAL] $!";
print FILE $$;
close (FILE);
}
}
########################################################################
@ -315,10 +317,10 @@ sub ha_main($) {
# Log to a separate file if needed.
$conf->{'log_file'} = $conf->{'ha_log_file'} if defined ($conf->{'ha_log_file'});
ha_daemonize($conf) if ($DAEMON == 1);
$Running = 1;
ha_daemonize($conf) if ($DAEMON == 1);
while ($Running) {
eval {
eval {

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "7.0NG.760 Build 220330";
my $version = "7.0NG.761 Build 220407";
# save program name for logging
my $progname = basename($0);