Merge remote-tracking branch 'origin/develop' into ent-8208-bug-filtros-en-vista-de-alertas

This commit is contained in:
Calvo 2021-12-27 10:44:25 +01:00
commit 1dec1e468c
581 changed files with 134113 additions and 118788 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent # Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas # (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.758.1 # Version 7.0NG.759
# This program is Free Software, you can redistribute it and/or modify it # 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 # 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 # 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 # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.758.1, AIX version # Version 7.0NG.759, AIX version
# General Parameters # General Parameters
# ================== # ==================

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.758.1-211129 Version: 7.0NG.759-211227
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.758.1 %define version 7.0NG.759
%define release 211129 %define release 211227
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.758.1 %define version 7.0NG.759
%define release 211129 %define release 211227
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

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

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent # Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas # (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.758.1 # Version 7.0NG.759
# This program is Free Software, you can redistribute it and/or modify it # 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 # 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 # Foundation; either version 2 of the Licence or any later version

View File

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

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.758.1 Build 211129") #define PANDORA_VERSION ("7.0NG.759 Build 211227")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.758.1(Build 211129))" VALUE "ProductVersion", "(7.0NG.759(Build 211227))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.758.1-211129 Version: 7.0NG.759-211227
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -89,14 +89,13 @@ function agents_modules_load_js()
var controls = document.getElementById('vc-controls'); var controls = document.getElementById('vc-controls');
autoHideElement(controls, 1000); autoHideElement(controls, 1000);
$('select#refresh').change(function (event) { $('select#refresh').change(function (event) {
refr = Number.parseInt(event.target.value, 10); refr = Number.parseInt(event.target.value, 10);
startCountDown(refr, false); startCountDown(refr, false);
}); });
} }
else { else {
var agentes_id = $("#id_agents2").val(); var agentes_id = $("#id_agents2").val();
var id_agentes = getQueryParam("full_agents_id"); var id_agentes = getQueryParam("full_agents_id");
if (agentes_id === null && id_agentes !== null) { if (agentes_id === null && id_agentes !== null) {
@ -104,15 +103,15 @@ function agents_modules_load_js()
id_agentes.forEach(function(element) { id_agentes.forEach(function(element) {
$("#id_agents2 option[value="+ element +"]").attr("selected",true); $("#id_agents2 option[value="+ element +"]").attr("selected",true);
}); });
selection_agent_module(); selection_agent_module();
} }
$('#refresh').change(function () { $('#refresh').change(function () {
$('#hidden-vc_refr').val($('#refresh option:selected').val()); $('#hidden-vc_refr').val($('#refresh option:selected').val());
}); });
} }
$("#group_id").change (function () { $("#group_id").change (function () {
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente", {"page" : "operation/agentes/ver_agente",
@ -128,7 +127,6 @@ function agents_modules_load_js()
jQuery.each (data, function (id, value) { jQuery.each (data, function (id, value) {
// Remove keys_prefix from the index // Remove keys_prefix from the index
id = id.substring(1); id = id.substring(1);
option = $("<option></option>") option = $("<option></option>")
.attr ("value", value["id_agente"]) .attr ("value", value["id_agente"])
.html (value["alias"]); .html (value["alias"]);
@ -139,7 +137,7 @@ function agents_modules_load_js()
"json" "json"
); );
}); });
$("#checkbox-recursion").change (function () { $("#checkbox-recursion").change (function () {
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente", {"page" : "operation/agentes/ver_agente",
@ -155,7 +153,6 @@ function agents_modules_load_js()
jQuery.each (data, function (id, value) { jQuery.each (data, function (id, value) {
// Remove keys_prefix from the index // Remove keys_prefix from the index
id = id.substring(1); id = id.substring(1);
option = $("<option></option>") option = $("<option></option>")
.attr ("value", value["id_agente"]) .attr ("value", value["id_agente"])
.html (value["alias"]); .html (value["alias"]);
@ -166,7 +163,7 @@ function agents_modules_load_js()
"json" "json"
); );
}); });
$("#modulegroup").change (function () { $("#modulegroup").change (function () {
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente", {"page" : "operation/agentes/ver_agente",
@ -180,8 +177,8 @@ function agents_modules_load_js()
if(data){ if(data){
jQuery.each (data, function (id, value) { jQuery.each (data, function (id, value) {
option = $("<option></option>") option = $("<option></option>")
.attr ("value", value["id_agente_modulo"]) .attr ("value", id)
.html (value["nombre"]); .html (value);
$("#module").append (option); $("#module").append (option);
}); });
} }
@ -207,8 +204,8 @@ function agents_modules_load_js()
if(data){ if(data){
jQuery.each (data, function (id, value) { jQuery.each (data, function (id, value) {
option = $("<option></option>") option = $("<option></option>")
.attr ("value", value["id_agente_modulo"]) .attr ("value", id)
.html (value["nombre"]); .html (value);
$("#module").append (option); $("#module").append (option);
}); });
} }
@ -231,11 +228,11 @@ function agents_modules_load_js()
if(data){ if(data){
jQuery.each (data, function (id, value) { jQuery.each (data, function (id, value) {
option = $("<option></option>") option = $("<option></option>")
.attr ("value", value["id_agente_modulo"]) .attr ("value", id)
.html (value["nombre"]); .html (value);
$("#module").append (option); $("#module").append (option);
}); });
var id_modules = getQueryParam("full_modules_selected"); var id_modules = getQueryParam("full_modules_selected");
if(id_modules !== null) { if(id_modules !== null) {
id_modules = id_modules.split(";"); id_modules = id_modules.split(";");
@ -249,20 +246,19 @@ function agents_modules_load_js()
); );
} }
function getQueryParam (key) { function getQueryParam (key) {
key = key.replace(/[[]/, '['); key = key.replace(/[[]/, '[');
key = key.replace(/[]]/, ']'); key = key.replace(/[]]/, ']');
var pattern = "[?&]" + key + "=([^&#]*)"; var pattern = "[?&]" + key + "=([^&#]*)";
var regex = new RegExp(pattern); var regex = new RegExp(pattern);
var url = unescape(window.location.href); var url = unescape(window.location.href);
var results = regex.exec(url); var results = regex.exec(url);
if (results === null) { if (results === null) {
return null; return null;
} else { } else {
return results[1]; return results[1];
} }
} }
</script> </script>
<?php <?php
} }

View File

@ -114,4 +114,5 @@ enterprise/include/javascript/tooltipster.bundle.min.js
enterprise/include/styles/tooltipster.bundle.min.css enterprise/include/styles/tooltipster.bundle.min.css
mobile/include/javascript/jquery.mobile-1.3.1.js mobile/include/javascript/jquery.mobile-1.3.1.js
mobile/include/style/jquery.mobile-1.3.1.css mobile/include/style/jquery.mobile-1.3.1.css
godmode/alerts/configure_alert_special_days.php godmode/alerts/configure_alert_special_days.php
godmode/admin_access_logs.php

View File

@ -1,20 +1,89 @@
START TRANSACTION; START TRANSACTION;
ALTER TABLE `tagente_modulo` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE `tagente_modulo` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE `tnetwork_component` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE `tnetwork_component` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE `tlocal_component` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE `tlocal_component` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE `tsync_queue` ADD COLUMN `result` TEXT;
ALTER TABLE tagente_modulo MODIFY debug_content TEXT; ALTER TABLE tagente_modulo MODIFY debug_content TEXT;
CREATE TABLE IF NOT EXISTS `tncm_queue` (
`id` SERIAL,
`id_agent` INT(10) UNSIGNED NOT NULL,
`id_script` BIGINT(20) UNSIGNED NOT NULL,
`utimestamp` INT UNSIGNED NOT NULL,
`scheduled` INT UNSIGNED DEFAULT NULL,
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tncm_snippet` (
`id` SERIAL,
`name` TEXT,
`content` TEXT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tncm_firmware` (
`id` SERIAL,
`name` varchar(255),
`shortname` varchar(255) unique,
`vendor` bigint(20) unsigned,
`models` text,
`path` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `talert_calendar` ( CREATE TABLE IF NOT EXISTS `talert_calendar` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL default '', `name` varchar(100) NOT NULL default '',
`id_group` INT(10) NOT NULL DEFAULT 0, `id_group` INT(10) NOT NULL DEFAULT 0,
`description` text, `description` text,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE (`name`) UNIQUE (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tipam_network_location` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL default '',
PRIMARY KEY (`id`),
UNIQUE (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tipam_sites` (
`id` serial,
`name` varchar(100) UNIQUE NOT NULL default '',
`description` text,
`parent` bigint unsigned null,
PRIMARY KEY (`id`),
FOREIGN KEY (`parent`) REFERENCES `tipam_sites`(`id`) ON UPDATE CASCADE ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar');
INSERT IGNORE INTO `tipam_network_location` (`name`) SELECT `location` FROM `tipam_network` WHERE `location` <> '';
UPDATE `tipam_network` INNER JOIN `tipam_network_location` ON tipam_network_location.name=tipam_network.location SET tipam_network.location=tipam_network_location.id;
ALTER TABLE `tipam_network` MODIFY `location` int(10) unsigned NULL;
ALTER TABLE `tipam_network` ADD FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE;
ALTER TABLE `tagent_repository` ADD COLUMN `deployment_timeout` INT UNSIGNED DEFAULT 600 AFTER `path`;
ALTER TABLE `talert_special_days` ADD COLUMN `id_calendar` int(10) unsigned NOT NULL DEFAULT 1; ALTER TABLE `talert_special_days` ADD COLUMN `id_calendar` int(10) unsigned NOT NULL DEFAULT 1;
ALTER TABLE `talert_special_days` ADD COLUMN `day_code` tinyint(2) unsigned NOT NULL DEFAULT 0; ALTER TABLE `talert_special_days` ADD COLUMN `day_code` tinyint(2) unsigned NOT NULL DEFAULT 0;
ALTER TABLE `talert_special_days` ADD FOREIGN KEY (`id_calendar`) REFERENCES `talert_calendar`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `tipam_network` ADD COLUMN `id_site` bigint unsigned;
ALTER TABLE `tipam_network` ADD CONSTRAINT FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE `tipam_supernet` ADD COLUMN `id_site` bigint unsigned;
ALTER TABLE `tipam_supernet` ADD CONSTRAINT FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE `tipam_network` ADD COLUMN `vrf` int(10) unsigned;
ALTER TABLE `tipam_network` ADD CONSTRAINT FOREIGN KEY (`vrf`) REFERENCES `tagente`(`id_agente`) ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE `tncm_agent` ADD COLUMN `cron_interval` varchar(100) default '' AFTER `execute`;
ALTER TABLE `tncm_agent` ADD COLUMN `event_on_change` int unsigned default null AFTER `cron_interval`;
ALTER TABLE `tncm_vendor` ADD COLUMN `icon` VARCHAR(255) DEFAULT '';
ALTER TABLE `tevento` MODIFY COLUMN `event_type` ENUM('going_unknown','unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change', 'ncm') DEFAULT 'unknown';
UPDATE `talert_special_days` set `day_code` = 1 WHERE `same_day` = 'monday'; UPDATE `talert_special_days` set `day_code` = 1 WHERE `same_day` = 'monday';
UPDATE `talert_special_days` set `day_code` = 2 WHERE `same_day` = 'tuesday'; UPDATE `talert_special_days` set `day_code` = 2 WHERE `same_day` = 'tuesday';
@ -25,8 +94,6 @@ UPDATE `talert_special_days` set `day_code` = 6 WHERE `same_day` = 'saturday';
UPDATE `talert_special_days` set `day_code` = 7 WHERE `same_day` = 'sunday'; UPDATE `talert_special_days` set `day_code` = 7 WHERE `same_day` = 'sunday';
ALTER TABLE `talert_special_days` DROP COLUMN `same_day`; ALTER TABLE `talert_special_days` DROP COLUMN `same_day`;
ALTER TABLE `talert_special_days` ADD FOREIGN KEY (`id_calendar`) REFERENCES `talert_calendar`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; UPDATE `tconfig` c1 JOIN (select count(*) as n FROM `tconfig` c2 WHERE (c2.`token` = "node_metaconsole" AND c2.`value` = 1) OR (c2.`token` = "centralized_management" AND c2.`value` = 1) ) v SET c1. `value` = 0 WHERE c1.token = "autocreate_remote_users" AND v.n = 2;
ALTER TABLE `tagent_repository` ADD COLUMN `deployment_timeout` INT UNSIGNED DEFAULT 600 AFTER `path`;
COMMIT; COMMIT;

View File

@ -172,6 +172,8 @@ ALTER TABLE tagente_modulo ADD COLUMN `dynamic_min` bigint(20) default '0';
ALTER TABLE tagente_modulo ADD COLUMN `prediction_sample_window` int(10) default 0; ALTER TABLE tagente_modulo ADD COLUMN `prediction_sample_window` int(10) default 0;
ALTER TABLE tagente_modulo ADD COLUMN `prediction_samples` int(4) default 0; ALTER TABLE tagente_modulo ADD COLUMN `prediction_samples` int(4) default 0;
ALTER TABLE tagente_modulo ADD COLUMN `prediction_threshold` int(4) default 0; ALTER TABLE tagente_modulo ADD COLUMN `prediction_threshold` int(4) default 0;
ALTER TABLE tagente_modulo ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE tagente_modulo ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tagente_estado` -- Table `tagente_estado`
@ -189,3 +191,21 @@ ALTER TABLE tgraph_source ADD COLUMN `id_server` int(11) NOT NULL default 0;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
ALTER TABLE tevent_filter ADD COLUMN `id_agent_module` int(25) DEFAULT 0; ALTER TABLE tevent_filter ADD COLUMN `id_agent_module` int(25) DEFAULT 0;
ALTER TABLE tevent_filter ADD COLUMN `id_agent` int(25) DEFAULT 0; ALTER TABLE tevent_filter ADD COLUMN `id_agent` int(25) DEFAULT 0;
-- ---------------------------------------------------------------------
-- Table `tevent_filter`
-- ---------------------------------------------------------------------
ALTER TABLE `tnetwork_component` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE `tnetwork_component` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0;
-- ---------------------------------------------------------------------
-- Table `tevent_filter`
-- ---------------------------------------------------------------------
ALTER TABLE `tlocal_component` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE `tlocal_component` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0;
-- ---------------------------------------------------------------------
-- Table `tevent_filter`
-- ---------------------------------------------------------------------
ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0;

View File

@ -3970,15 +3970,20 @@ CREATE TABLE IF NOT EXISTS `tipam_network` (
`network` varchar(100) NOT NULL default '', `network` varchar(100) NOT NULL default '',
`name_network` varchar(255) default '', `name_network` varchar(255) default '',
`description` text NOT NULL, `description` text NOT NULL,
`location` tinytext NOT NULL, `location` int(10) unsigned NULL,
`id_recon_task` int(10) unsigned NOT NULL, `id_recon_task` int(10) unsigned NOT NULL,
`scan_interval` tinyint(2) default 1, `scan_interval` tinyint(2) default 1,
`monitoring` tinyint(2) default 0, `monitoring` tinyint(2) default 0,
`id_group` mediumint(8) unsigned NULL default 0, `id_group` mediumint(8) unsigned NULL default 0,
`lightweight_mode` tinyint(2) default 0, `lightweight_mode` tinyint(2) default 0,
`users_operator` text, `users_operator` text,
`id_site` bigint unsigned,
`vrf` int(10) unsigned,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE,
FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE,
FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (`vrf`) REFERENCES `tagente`(`id_agente`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tipam_ip` ( CREATE TABLE IF NOT EXISTS `tipam_ip` (
@ -4033,7 +4038,9 @@ CREATE TABLE IF NOT EXISTS `tipam_supernet` (
`address` varchar(250) NOT NULL, `address` varchar(250) NOT NULL,
`mask` varchar(250) NOT NULL, `mask` varchar(250) NOT NULL,
`subneting_mask` varchar(250) default '', `subneting_mask` varchar(250) default '',
PRIMARY KEY (`id`) `id_site` bigint unsigned,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tipam_supernet_network` ( CREATE TABLE IF NOT EXISTS `tipam_supernet_network` (
@ -4045,6 +4052,24 @@ CREATE TABLE IF NOT EXISTS `tipam_supernet_network` (
FOREIGN KEY (`id_network`) REFERENCES tipam_network(`id`) ON UPDATE CASCADE ON DELETE CASCADE FOREIGN KEY (`id_network`) REFERENCES tipam_network(`id`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tipam_network_location` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL default '',
PRIMARY KEY (`id`),
UNIQUE (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tipam_sites` (
`id` serial,
`name` varchar(100) UNIQUE NOT NULL default '',
`description` text,
`parent` bigint unsigned null,
PRIMARY KEY (`id`),
FOREIGN KEY (`parent`) REFERENCES `tipam_sites`(`id`) ON UPDATE CASCADE ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT IGNORE INTO `tipam_network_location` (`name`) SELECT `location` FROM `tipam_network` WHERE `location` <> '';
SET @insert_type = 3; SET @insert_type = 3;
SET @insert_name = 'IPAM Recon'; SET @insert_name = 'IPAM Recon';
SET @insert_description = 'This script is used to automatically detect network hosts availability and name, used as Recon Custom Script in the recon task. Parameters used are:\n\n* custom_field1 = network. i.e.: 192.168.100.0/24\n* custom_field2 = associated IPAM network id. i.e.: 4. Please do not change this value, it is assigned automatically in IPAM management.\n\nSee documentation for more information.'; SET @insert_description = 'This script is used to automatically detect network hosts availability and name, used as Recon Custom Script in the recon task. Parameters used are:\n\n* custom_field1 = network. i.e.: 192.168.100.0/24\n* custom_field2 = associated IPAM network id. i.e.: 4. Please do not change this value, it is assigned automatically in IPAM management.\n\nSee documentation for more information.';
@ -4077,6 +4102,7 @@ CREATE TABLE IF NOT EXISTS `tsync_queue` (
`operation` text, `operation` text,
`table` text, `table` text,
`error` MEDIUMTEXT, `error` MEDIUMTEXT,
`result` TEXT,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -4109,6 +4135,7 @@ UPDATE `tlanguage` SET `name` = 'Deutsch' WHERE `id_language` = 'de';
CREATE TABLE IF NOT EXISTS `tncm_vendor` ( CREATE TABLE IF NOT EXISTS `tncm_vendor` (
`id` serial, `id` serial,
`name` varchar(255) UNIQUE, `name` varchar(255) UNIQUE,
`icon` VARCHAR(255) DEFAULT '',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -4173,6 +4200,8 @@ CREATE TABLE IF NOT EXISTS `tncm_agent` (
`id_template` bigint(20) unsigned, `id_template` bigint(20) unsigned,
`execute_type` int(2) UNSIGNED NOT NULL default 0, `execute_type` int(2) UNSIGNED NOT NULL default 0,
`execute` int(2) UNSIGNED NOT NULL default 0, `execute` int(2) UNSIGNED NOT NULL default 0,
`cron_interval` varchar(100) default '',
`event_on_change` int unsigned default null,
`last_error` text, `last_error` text,
PRIMARY KEY (`id_agent`), PRIMARY KEY (`id_agent`),
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
@ -4195,6 +4224,41 @@ CREATE TABLE IF NOT EXISTS `tncm_agent_data` (
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------------------------------------------------
-- Table `tncm_queue`
-- ----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tncm_queue` (
`id` SERIAL,
`id_agent` INT(10) UNSIGNED NOT NULL,
`id_script` BIGINT(20) UNSIGNED NOT NULL,
`utimestamp` INT UNSIGNED NOT NULL,
`scheduled` INT UNSIGNED DEFAULT NULL,
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------------------------------------------------
-- Table `tncm_snippet`
-- ----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tncm_snippet` (
`id` SERIAL,
`name` TEXT,
`content` TEXT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------------------------------------------------
-- Table `tncm_firmware`
-- ----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tncm_firmware` (
`id` SERIAL,
`name` varchar(255),
`shortname` varchar(255) unique,
`vendor` bigint(20) unsigned,
`models` text,
`path` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `tncm_vendor` VALUES INSERT INTO `tncm_vendor` VALUES
(1,'Cisco'), (1,'Cisco'),
@ -4221,9 +4285,9 @@ INSERT INTO `tncm_script` VALUES
(2,1,'enable&#x0d;&#x0a;expect:Password:&#92;s*&#x0d;&#x0a;_enablepass_&#x0d;&#x0a;term&#x20;length&#x20;0&#x0d;&#x0a;capture:show&#x20;running-config&#x0d;&#x0a;exit&#x0d;&#x0a;'), (2,1,'enable&#x0d;&#x0a;expect:Password:&#92;s*&#x0d;&#x0a;_enablepass_&#x0d;&#x0a;term&#x20;length&#x20;0&#x0d;&#x0a;capture:show&#x20;running-config&#x0d;&#x0a;exit&#x0d;&#x0a;'),
(3,2,'enable&#x0d;&#x0a;expect:Password:&#92;s*&#x0d;&#x0a;_enablepass_&#x0d;&#x0a;term&#x20;length&#x20;0&#x0d;&#x0a;config&#x20;terminal&#x0d;&#x0a;_applyconfigbackup_&#x0d;&#x0a;exit&#x0d;&#x0a;'), (3,2,'enable&#x0d;&#x0a;expect:Password:&#92;s*&#x0d;&#x0a;_enablepass_&#x0d;&#x0a;term&#x20;length&#x20;0&#x0d;&#x0a;config&#x20;terminal&#x0d;&#x0a;_applyconfigbackup_&#x0d;&#x0a;exit&#x0d;&#x0a;'),
(4,3,'enable&#x0d;&#x0a;expect:Password:&#92;s*&#x0d;&#x0a;_enablepass_&#x0d;&#x0a;term&#x20;length&#x20;0&#x0d;&#x0a;capture:show&#x20;version&#x20;|&#x20;i&#x20;IOS&#x20;Software&#x0d;&#x0a;exit&#x0d;&#x0a;'), (4,3,'enable&#x0d;&#x0a;expect:Password:&#92;s*&#x0d;&#x0a;_enablepass_&#x0d;&#x0a;term&#x20;length&#x20;0&#x0d;&#x0a;capture:show&#x20;version&#x20;|&#x20;i&#x20;IOS&#x20;Software&#x0d;&#x0a;exit&#x0d;&#x0a;'),
(5,5,'enable&#x0d;&#x0a;expect:Password:&#92;s*&#x0d;&#x0a;_enablepass_&#x0d;&#x0a;term&#x20;length&#x20;0&#x0d;&#x0a;config&#x20;term&#x0d;&#x0a;end&#x0d;&#x0a;end&#x0d;&#x0a;exit&#x0d;&#x0a;'); (5,5,'enable&#x0d;&#x0a;expect:Password:&#92;s*&#x0d;&#x0a;_enablepass_&#x0d;&#x0a;term&#x20;length&#x20;0&#x0d;&#x0a;config&#x20;term&#x0d;&#x0a;end&#x0d;&#x0a;end&#x0d;&#x0a;exit&#x0d;&#x0a;'),
(6,4,'copy&#x20;tftp&#x20;flash&#x0d;&#x0a;expect:&#92;]&#92;?&#x0d;&#x0a;_TFTP_SERVER_IP_&#x0d;&#x0a;expect:&#92;]&#92;?&#x0d;&#x0a;_SOURCE_FILE_NAME_&#x0d;&#x0a;expect:&#92;]&#92;?&#x0d;&#x0a;_DESTINATION_FILE_NAME_&#x0d;&#x0a;show&#x20;flash&#x0d;&#x0a;reload&#x0d;&#x0a;expect:confirm&#x0d;&#x0a;y&#x0d;&#x0a;config&#x20;terminal&#x0d;&#x0a;boot&#x20;system&#x20;_DESTINATION_FILE_NAME_');
INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5); INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6);
-- ---------------------------------------------------------------------- -- ----------------------------------------------------------------------
-- Table `talert_calendar` -- Table `talert_calendar`
@ -4252,3 +4316,5 @@ UPDATE `talert_special_days` set `day_code` = 7 WHERE `same_day` = 'sunday';
ALTER TABLE `talert_special_days` DROP COLUMN `same_day`; ALTER TABLE `talert_special_days` DROP COLUMN `same_day`;
ALTER TABLE `talert_special_days` ADD FOREIGN KEY (`id_calendar`) REFERENCES `talert_calendar`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE `talert_special_days` ADD FOREIGN KEY (`id_calendar`) REFERENCES `talert_calendar`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
UPDATE `tconfig` c1 JOIN (select count(*) as n FROM `tconfig` c2 WHERE (c2.`token` = "node_metaconsole" AND c2.`value` = 1) OR (c2.`token` = "centralized_management" AND c2.`value` = 1) ) v SET c1. `value` = 0 WHERE c1.token = "autocreate_remote_users" AND v.n = 2;

View File

@ -1,277 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// 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; 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;
require_once $config['homedir'].'/include/functions_graph.php';
check_login();
$enterprise_include = enterprise_include_once('godmode/admin_access_logs.php');
if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit('ACL Violation', 'Trying to access audit view');
include 'general/noaccess.php';
exit;
}
$offset = (int) get_parameter('offset');
$filter_type = (string) get_parameter('filter_type');
$filter_user = (string) get_parameter('filter_user');
$filter_text = (string) get_parameter('filter_text');
$filter_period = get_parameter('filter_period', null);
$filter_period = ($filter_period !== null) ? (int) $filter_period : 24;
$filter_ip = (string) get_parameter('filter_ip');
$filter_query = '&filter_type='.$filter_type.'&filter_user='.$filter_user.'&filter_text='.$filter_text.'&filter_period='.$filter_period.'&filter_ip='.$filter_ip;
$csv_url = ui_get_full_url(
false,
false,
false,
false
).'index.php?sec=gextensions&sec2=godmode/audit_log_csv'.$filter_query;
$csv_img = html_print_image(
'images/csv.png',
true,
[
'title' => __(
'Export to CSV'
),'class' => 'invert_filter',
]
);
$header_buttons = [
'csv' => [
'active' => false,
'text' => '<a href="'.$csv_url.'">'.$csv_img.'</a>',
],
];
ui_print_page_header(__('%s audit', get_product_name()).' &raquo; '.__('Review Logs'), 'images/gm_log.png', false, '', true, $header_buttons);
$table = new stdClass();
$table->class = 'databox filters';
$table->cellstyle = [];
$table->cellstyle[0] = [];
$table->cellstyle[1] = [];
$table->cellstyle[0][0] = 'text-align: right;';
$table->cellstyle[0][1] = 'text-align: left;';
$table->cellstyle[0][2] = 'text-align: right;';
$table->cellstyle[0][3] = 'text-align: left;';
$table->cellstyle[0][4] = 'text-align: right;';
$table->cellstyle[0][5] = 'text-align: left;';
$table->cellstyle[1][0] = 'text-align: right;';
$table->cellstyle[1][1] = 'text-align: left;';
$table->cellstyle[1][2] = 'text-align: right;';
$table->cellstyle[1][3] = 'text-align: left;';
$table->cellstyle[1][5] = 'text-align: right;';
$table->data = [];
$data = [];
$data[0] = '<b>'.__('Search').'</b>';
$data[1] = html_print_input_text('filter_text', $filter_text, __('Free text for search (*)'), 20, 40, true);
$data[2] = '<b>'.__('Max. hours old').'</b>';
$data[3] = html_print_input_text('filter_period', $filter_period, __('Max. hours old'), 3, 6, true);
$data[4] = '<b>'.__('IP').'</b>';
$data[5] = html_print_input_text('filter_ip', $filter_ip, __('IP'), 15, 15, true);
$table->data[0] = $data;
$data = [];
$actions_sql = 'SELECT DISTINCT(accion), accion AS text FROM tsesion';
$data[0] = '<b>'.__('Action').'</b>';
$data[1] = html_print_select_from_sql($actions_sql, 'filter_type', $filter_type, '', __('All'), '', true);
$users_sql = 'SELECT id_user, id_user AS text FROM tusuario';
$data[2] = '<b>'.__('User').'</b>';
$data[3] = html_print_select_from_sql($users_sql, 'filter_user', $filter_user, '', __('All'), '', true);
$data[4] = '';
$data[5] = html_print_submit_button(__('Filter'), 'filter', false, 'class="sub search"', true);
$table->data[1] = $data;
$form = '<form name="query_sel" method="post" action="index.php?sec=glog&sec2=godmode/admin_access_logs">';
$form .= html_print_table($table, true);
$form .= '</form>';
ui_toggle($form, __('Filter'), '', '', false);
$filter = '1=1';
if (!empty($filter_type)) {
$filter .= sprintf(" AND accion = '%s'", $filter_type);
}
if (!empty($filter_user)) {
$filter .= sprintf(" AND id_usuario = '%s'", $filter_user);
}
if (!empty($filter_text)) {
$filter .= sprintf(" AND (accion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%')", $filter_text, $filter_text);
}
if (!empty($filter_ip)) {
$filter .= sprintf(" AND ip_origen LIKE '%%%s%%'", $filter_ip);
}
if (!empty($filter_period)) {
switch ($config['dbtype']) {
case 'mysql':
$filter .= ' AND fecha >= DATE_ADD(NOW(), INTERVAL -'.$filter_period.' HOUR)';
break;
case 'postgresql':
$filter .= ' AND fecha >= NOW() - INTERVAL \''.$filter_period.' HOUR \'';
break;
case 'oracle':
$filter .= ' AND fecha >= (SYSTIMESTAMP - INTERVAL \''.$filter_period.'\' HOUR)';
break;
}
}
$count_sql = sprintf('SELECT COUNT(*) FROM tsesion WHERE %s', $filter);
$count = (int) db_get_value_sql($count_sql);
$url = 'index.php?sec=godmode&sec2=godmode/admin_access_logs'.$filter_query;
ui_pagination($count, $url);
switch ($config['dbtype']) {
case 'mysql':
$sql = sprintf(
'SELECT *
FROM tsesion
WHERE %s
ORDER BY fecha DESC
LIMIT %d, %d',
$filter,
$offset,
$config['block_size']
);
break;
case 'postgresql':
$sql = sprintf(
'SELECT *
FROM tsesion
WHERE %s
ORDER BY fecha DESC
LIMIT %d OFFSET %d',
$filter,
$config['block_size'],
$offset
);
break;
case 'oracle':
$set = [];
$set['limit'] = $config['block_size'];
$set['offset'] = $offset;
$sql = sprintf(
'SELECT *
FROM tsesion
WHERE %s
ORDER BY fecha DESC',
$filter
);
$result = oracle_recode_query($sql, $set);
break;
}
$result = db_get_all_rows_sql($sql);
if (empty($result)) {
$result = [];
}
$table = new stdClass();
$table->cellpadding = 0;
$table->cellspacing = 0;
$table->width = '100%';
$table->class = 'info_table';
$table->size = [];
$table->data = [];
$table->head = [];
$table->align = [];
$table->rowclass = [];
$table->head[0] = __('User');
$table->head[1] = __('Action');
$table->head[2] = __('Date');
$table->head[3] = __('Source IP');
$table->head[4] = __('Comments');
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
$table->head[5] = enterprise_hook('tableHeadEnterpriseAudit', ['title1']);
$table->head[6] = enterprise_hook('tableHeadEnterpriseAudit', ['title2']);
}
$table->size[0] = 80;
$table->size[2] = 130;
$table->size[3] = 100;
$table->size[4] = 200;
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
$table->size[5] = enterprise_hook('tableHeadEnterpriseAudit', ['size1']);
$table->size[6] = enterprise_hook('tableHeadEnterpriseAudit', ['size2']);
$table->align[5] = enterprise_hook('tableHeadEnterpriseAudit', ['align']);
$table->align[6] = enterprise_hook('tableHeadEnterpriseAudit', ['align2']);
}
$table->colspan = [];
$table->rowstyle = [];
$rowPair = true;
$iterator = 0;
// Get data
foreach ($result as $row) {
$iterator++;
$table->rowclass[] = $rowPair ? 'rowPair' : 'rowOdd';
$rowPair = !$rowPair;
$data = [];
$data[0] = io_safe_output($row['id_usuario']);
$data[1] = ui_print_session_action_icon($row['accion'], true).$row['accion'];
$data[2] = ui_print_help_tip(date($config['date_format'], $row['utimestamp']), true).ui_print_timestamp($row['utimestamp'], true);
$data[3] = io_safe_output($row['ip_origen']);
$data[4] = io_safe_output($row['descripcion']);
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
$data[5] = enterprise_hook('cell1EntepriseAudit', [$row['id_sesion']]);
$data[6] = enterprise_hook('cell2EntepriseAudit', [$row['id_sesion']]);
}
$table->data[] = $data;
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
rowEnterpriseAudit($table, $iterator, $row['id_sesion']);
}
}
foreach ($table->rowclass as $key => $value) {
if (strpos($value, 'limit_scroll') !== false) {
$table->colspan[$key] = [7];
} else {
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
$table->cellclass[$key][6] = 'action_buttons';
}
}
}
html_print_table($table);
ui_pagination($count, $url, 0, 0, false, 'offset', true, 'pagination-bottom');
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
enterprise_hook('enterpriseAuditFooter');
}

View File

@ -103,10 +103,10 @@ if (is_ajax()) {
} else { } else {
$commons = array_intersect($out, $oid_snmp); $commons = array_intersect($out, $oid_snmp);
if ($get_common_modules) { if ($get_common_modules) {
// Common modules is selected (default) // Common modules is selected (default).
$out = $commons; $out = $commons;
} else { } else {
// All modules is selected // All modules is selected.
$array1 = array_diff($out, $oid_snmp); $array1 = array_diff($out, $oid_snmp);
$array2 = array_diff($oid_snmp, $out); $array2 = array_diff($oid_snmp, $out);
$out = array_merge($commons, $array1, $array2); $out = array_merge($commons, $array1, $array2);
@ -135,12 +135,12 @@ if (is_ajax()) {
'agents_update_secondary_groups', 'agents_update_secondary_groups',
[ [
$id_agent, $id_agent,
($add_secondary_groups) ? $groups_to_add : [], (($add_secondary_groups) ? $groups_to_add : []),
($remove_secondary_groups) ? $groups_to_add : [], (($remove_secondary_groups) ? $groups_to_add : []),
] ]
); );
// Echo 0 in case of error. 0 Otherwise. // Echo 0 in case of error. 0 Otherwise.
echo ($ret) ? 1 : 0; echo ((bool) $ret === true) ? 1 : 0;
} }
} }

View File

@ -96,6 +96,8 @@ if (isset($_POST['template_id'])) {
'str_critical' => $row2['str_critical'], 'str_critical' => $row2['str_critical'],
'critical_inverse' => $row2['critical_inverse'], 'critical_inverse' => $row2['critical_inverse'],
'warning_inverse' => $row2['warning_inverse'], 'warning_inverse' => $row2['warning_inverse'],
'percentage_warning' => $row2['percentage_warning'],
'percentage_critical' => $row2['percentage_critical'],
'critical_instructions' => $row2['critical_instructions'], 'critical_instructions' => $row2['critical_instructions'],
'warning_instructions' => $row2['warning_instructions'], 'warning_instructions' => $row2['warning_instructions'],
'unknown_instructions' => $row2['unknown_instructions'], 'unknown_instructions' => $row2['unknown_instructions'],

View File

@ -1544,6 +1544,8 @@ if ($update_module || $create_module) {
$unknown_instructions = (string) get_parameter('unknown_instructions'); $unknown_instructions = (string) get_parameter('unknown_instructions');
$critical_inverse = (int) get_parameter('critical_inverse'); $critical_inverse = (int) get_parameter('critical_inverse');
$warning_inverse = (int) get_parameter('warning_inverse'); $warning_inverse = (int) get_parameter('warning_inverse');
$percentage_critical = (int) get_parameter('percentage_critical');
$percentage_warning = (int) get_parameter('percentage_warning');
$id_category = (int) get_parameter('id_category'); $id_category = (int) get_parameter('id_category');
@ -1605,6 +1607,15 @@ if ($update_module || $create_module) {
); );
} }
if ($prediction_module === MODULE_PREDICTION_PLANNING) {
$custom_string_2 = get_parameter('estimation_type', 'estimation_calculation');
if ($custom_string_2 === 'estimation_calculation') {
$custom_string_1 = get_parameter('estimation_days', -1);
} else {
$custom_string_1 = get_parameter('estimation_interval', '300');
}
}
$active_snmp_v3 = get_parameter('active_snmp_v3'); $active_snmp_v3 = get_parameter('active_snmp_v3');
/* /*
@ -1697,6 +1708,8 @@ if ($update_module) {
'unknown_instructions' => $unknown_instructions, 'unknown_instructions' => $unknown_instructions,
'critical_inverse' => $critical_inverse, 'critical_inverse' => $critical_inverse,
'warning_inverse' => $warning_inverse, 'warning_inverse' => $warning_inverse,
'percentage_critical' => $percentage_critical,
'percentage_warning' => $percentage_warning,
'cron_interval' => $cron_interval, 'cron_interval' => $cron_interval,
'id_category' => $id_category, 'id_category' => $id_category,
'disabled_types_event' => addslashes($disabled_types_event), 'disabled_types_event' => addslashes($disabled_types_event),
@ -1788,7 +1801,7 @@ if ($update_module) {
"Fail to try update module '".io_safe_output($name)."' for agent ".io_safe_output($agent['alias']) "Fail to try update module '".io_safe_output($name)."' for agent ".io_safe_output($agent['alias'])
); );
} else { } else {
if ($prediction_module == 3) { if ($prediction_module == MODULE_PREDICTION_SYNTHETIC) {
enterprise_hook( enterprise_hook(
'modules_create_synthetic_operations', 'modules_create_synthetic_operations',
[ [
@ -1903,6 +1916,8 @@ if ($create_module) {
'unknown_instructions' => $unknown_instructions, 'unknown_instructions' => $unknown_instructions,
'critical_inverse' => $critical_inverse, 'critical_inverse' => $critical_inverse,
'warning_inverse' => $warning_inverse, 'warning_inverse' => $warning_inverse,
'percentage_critical' => $percentage_critical,
'percentage_warning' => $percentage_warning,
'cron_interval' => $cron_interval, 'cron_interval' => $cron_interval,
'id_category' => $id_category, 'id_category' => $id_category,
'disabled_types_event' => addslashes($disabled_types_event), 'disabled_types_event' => addslashes($disabled_types_event),
@ -1931,7 +1946,7 @@ if ($create_module) {
} }
} }
if ($prediction_module == 3 && $serialize_ops == '') { if ($prediction_module == MODULE_PREDICTION_SYNTHETIC && $serialize_ops == '') {
$id_agent_module = false; $id_agent_module = false;
} else { } else {
$id_agent_module = modules_create_agent_module( $id_agent_module = modules_create_agent_module(
@ -1972,7 +1987,7 @@ if ($create_module) {
"Fail to try added module '".io_safe_output($name)."' for agent ".io_safe_output($agent['alias']) "Fail to try added module '".io_safe_output($name)."' for agent ".io_safe_output($agent['alias'])
); );
} else { } else {
if ($prediction_module == 3) { if ($prediction_module == MODULE_PREDICTION_SYNTHETIC) {
enterprise_hook( enterprise_hook(
'modules_create_synthetic_operations', 'modules_create_synthetic_operations',
[ [

View File

@ -253,6 +253,7 @@ $module_action = (string) get_parameter('module_action');
if ($module_action === 'delete') { if ($module_action === 'delete') {
$id_agent_modules_delete = (array) get_parameter('id_delete'); $id_agent_modules_delete = (array) get_parameter('id_delete');
$print_result_msg = true;
$count_correct_delete_modules = 0; $count_correct_delete_modules = 0;
foreach ($id_agent_modules_delete as $id_agent_module_del) { foreach ($id_agent_modules_delete as $id_agent_module_del) {
$id_grupo = (int) agents_get_agent_group($id_agente); $id_grupo = (int) agents_get_agent_group($id_agente);
@ -268,12 +269,19 @@ if ($module_action === 'delete') {
} }
if ($id_agent_module_del < 1) { if ($id_agent_module_del < 1) {
db_pandora_audit( if (count($id_agent_modules_delete) === 1) {
'HACK Attempt', ui_print_error_message(
'Expected variable from form is not correct' __('No modules selected')
); );
die(__('Nice try buddy'));
exit; $print_result_msg = false;
} else {
ui_print_error_message(
__('There was a problem completing the operation')
);
}
continue;
} }
enterprise_include_once('include/functions_config_agents.php'); enterprise_include_once('include/functions_config_agents.php');
@ -421,25 +429,27 @@ if ($module_action === 'delete') {
} }
} }
$count_modules_to_delete = count($id_agent_modules_delete); if ($print_result_msg === true) {
if ($count_correct_delete_modules == 0) { $count_modules_to_delete = count($id_agent_modules_delete);
ui_print_error_message( if ($count_correct_delete_modules == 0) {
sprintf(
__('There was a problem completing the operation. Applied to 0/%d modules.'),
$count_modules_to_delete
)
);
} else {
if ($count_correct_delete_modules == $count_modules_to_delete) {
ui_print_success_message(__('Operation finished successfully.'));
} else {
ui_print_error_message( ui_print_error_message(
sprintf( sprintf(
__('There was a problem completing the operation. Applied to %d/%d modules.'), __('There was a problem completing the operation. Applied to 0/%d modules.'),
$count_correct_delete_modules,
$count_modules_to_delete $count_modules_to_delete
) )
); );
} else {
if ($count_correct_delete_modules == $count_modules_to_delete) {
ui_print_success_message(__('Operation finished successfully.'));
} else {
ui_print_error_message(
sprintf(
__('There was a problem completing the operation. Applied to %d/%d modules.'),
$count_correct_delete_modules,
$count_modules_to_delete
)
);
}
} }
} }
} else if ($module_action === 'disable') { } else if ($module_action === 'disable') {
@ -704,6 +714,8 @@ if ((bool) $checked === true) {
'quiet', 'quiet',
'critical_inverse', 'critical_inverse',
'warning_inverse', 'warning_inverse',
'percentage_critical',
'percentage_warning',
'id_policy_module', 'id_policy_module',
] ]
); );

View File

@ -99,6 +99,9 @@ if (is_ajax()) {
$component['str_critical'] = io_safe_output($component['str_critical']); $component['str_critical'] = io_safe_output($component['str_critical']);
$component['warning_inverse'] = (bool) $component['warning_inverse']; $component['warning_inverse'] = (bool) $component['warning_inverse'];
$component['critical_inverse'] = (bool) $component['critical_inverse']; $component['critical_inverse'] = (bool) $component['critical_inverse'];
$component['percentage_warning'] = (bool) $component['percentage_warning'];
$component['percentage_critical'] = (bool) $component['percentage_critical'];
echo io_json_mb_encode($component); echo io_json_mb_encode($component);
return; return;
@ -328,6 +331,9 @@ if ($id_agent_module) {
$critical_inverse = $module['critical_inverse']; $critical_inverse = $module['critical_inverse'];
$warning_inverse = $module['warning_inverse']; $warning_inverse = $module['warning_inverse'];
$percentage_critical = $module['percentage_critical'];
$percentage_warning = $module['percentage_warning'];
$id_category = $module['id_category']; $id_category = $module['id_category'];
@ -467,6 +473,8 @@ if ($id_agent_module) {
$critical_inverse = ''; $critical_inverse = '';
$warning_inverse = ''; $warning_inverse = '';
$percentage_critical = '';
$percentage_warning = '';
$each_ff = 0; $each_ff = 0;
$ff_event_normal = ''; $ff_event_normal = '';

View File

@ -456,8 +456,16 @@ if (modules_is_string_type($id_module_type) || $edit) {
).'</span>'; ).'</span>';
} }
$table_simple->data[2][1] .= '<br /><em>'.__('Inverse interval').'</em>'; $table_simple->data[2][1] .= '<div id="warning_inverse"><em>'.__('Inverse interval').'</em>';
$table_simple->data[2][1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true, $disabledBecauseInPolicy); $table_simple->data[2][1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true, $disabledBecauseInPolicy);
$table_simple->data[2][1] .= '</div>';
if (modules_is_string_type($id_module_type) === false) {
$table_simple->data[2][1] .= '<div id="percentage_warning"><em>'.__('Percentage').'</em>';
$table_simple->data[2][1] .= html_print_checkbox('percentage_warning', 1, $percentage_warning, true, $disabledBecauseInPolicy);
$table_simple->data[2][1] .= ui_print_help_tip('Defines threshold as a percentage of value decrease/increment', true);
$table_simple->data[2][1] .= '</div>';
}
if (!modules_is_string_type($id_module_type) || $edit) { if (!modules_is_string_type($id_module_type) || $edit) {
$table_simple->data[2][2] = '<svg id="svg_dinamic" width="500" height="300"> </svg>'; $table_simple->data[2][2] = '<svg id="svg_dinamic" width="500" height="300"> </svg>';
@ -509,8 +517,17 @@ if (modules_is_string_type($id_module_type) || $edit) {
).'</span>'; ).'</span>';
} }
$table_simple->data[3][1] .= '<br /><em>'.__('Inverse interval').'</em>'; $table_simple->data[3][1] .= '<div id="critical_inverse"><em>'.__('Inverse interval').'</em>';
$table_simple->data[3][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true, $disabledBecauseInPolicy); $table_simple->data[3][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true, $disabledBecauseInPolicy);
$table_simple->data[3][1] .= '</div>';
if (modules_is_string_type($id_module_type) === false) {
$table_simple->data[3][1] .= '<div id="percentage_critical" /><em>'.__('Percentage').'</em>';
$table_simple->data[3][1] .= ui_print_help_tip('Defines threshold as a percentage of value decrease/increment', true);
$table_simple->data[3][1] .= html_print_checkbox('percentage_critical', 1, $percentage_critical, true, $disabledBecauseInPolicy);
$table_simple->data[3][1] .= '</div>';
}
$table_simple->data[4][0] = __('Historical data'); $table_simple->data[4][0] = __('Historical data');
if ($disabledBecauseInPolicy) { if ($disabledBecauseInPolicy) {
@ -1551,6 +1568,8 @@ $(document).ready (function () {
$('#minmax_critical').show(); $('#minmax_critical').show();
$('#minmax_warning').show(); $('#minmax_warning').show();
$('#svg_dinamic').show(); $('#svg_dinamic').show();
$('#percentage_warning').show();
$('#percentage_critical').show();
} }
else { else {
// String types // String types
@ -1559,6 +1578,8 @@ $(document).ready (function () {
$('#minmax_critical').hide(); $('#minmax_critical').hide();
$('#minmax_warning').hide(); $('#minmax_warning').hide();
$('#svg_dinamic').hide(); $('#svg_dinamic').hide();
$('#percentage_warning').hide();
$('#percentage_critical').hide();
} }
if (type_name_selected.match(/async/) == null) { if (type_name_selected.match(/async/) == null) {
@ -1628,11 +1649,64 @@ $(document).ready (function () {
$('#text-max_critical').val(0); $('#text-max_critical').val(0);
} }
}); });
if ($('#checkbox-warning_inverse').prop('checked') === true) {
$('#percentage_warning').hide();
}
if ($('#checkbox-critical_inverse').prop('checked') === true) {
$('#percentage_critical').hide();
}
if ($('#checkbox-percentage_warning').prop('checked') === true) {
$('#warning_inverse').hide();
}
if ($('#checkbox-percentage_critical').prop('checked') === true) {
$('#critical_inverse').hide();
}
$('#checkbox-warning_inverse').change (function() { $('#checkbox-warning_inverse').change (function() {
paint_graph_values(); paint_graph_values();
}); if ($('#checkbox-warning_inverse').prop('checked') === true){
$('#checkbox-percentage_warning').prop('checked', false);
$('#percentage_warning').hide();
} else {
$('#percentage_warning').show();
}
});
$('#checkbox-critical_inverse').change (function() { $('#checkbox-critical_inverse').change (function() {
paint_graph_values(); paint_graph_values();
if ($('#checkbox-critical_inverse').prop('checked') === true){
$('#checkbox-percentage_critical').prop('checked', false);
$('#percentage_critical').hide();
} else {
$('#percentage_critical').show();
}
});
$('#checkbox-percentage_warning').change (function() {
paint_graph_values();
if ($('#checkbox-percentage_warning').prop('checked') === true){
$('#checkbox-warning_inverse').prop('checked', false);
$('#warning_inverse').hide();
} else {
$('#warning_inverse').show();
}
});
$('#checkbox-percentage_critical').change (function() {
paint_graph_values();
if ($('#checkbox-percentage_critical').prop('checked') === true){
$('#checkbox-critical_inverse').prop('checked', false);
$('#critical_inverse').hide();
}
else {
$('#critical_inverse').show();
}
}); });
}); });
@ -1915,6 +1989,43 @@ function paint_graph_values(){
//messages error //messages error
var message_error_warning = '<?php echo __('Please introduce a maximum warning higher than the minimun warning'); ?>'; var message_error_warning = '<?php echo __('Please introduce a maximum warning higher than the minimun warning'); ?>';
var message_error_critical = '<?php echo __('Please introduce a maximum critical higher than the minimun critical'); ?>'; var message_error_critical = '<?php echo __('Please introduce a maximum critical higher than the minimun critical'); ?>';
var message_error_percentage = '<?php echo __('Please introduce a positive percentage value'); ?>';
//Percentage selector
var percentage_w = $('#checkbox-percentage_warning').prop('checked');
var percentage_c = $('#checkbox-percentage_critical').prop('checked');
if(percentage_w == true || percentage_c == true) {
d3.select("#svg_dinamic rect").remove();
//create svg
var svg = d3.select("#svg_dinamic");
svg.selectAll("g").remove();
if (percentage_w === true) {
if(max_w < 0 || min_w < 0) {
paint_graph_status(0,0,0,0,0,0,1,0,legend_normal,legend_warning,legend_critical,message_error_percentage,message_error_percentage);
} else {
$("#text-max_warning").removeClass("input_error");
$("#text-min_warning").removeClass("input_error");
}
}
if(percentage_c === true) {
if(max_c < 0 || min_c < 0) {
paint_graph_status(0,0,0,0,0,0,0,1,legend_normal,legend_warning,legend_critical,message_error_percentage,message_error_percentage);
} else {
$("#text-min-critical").removeClass("input_error");
$("#text-max_critical").removeClass("input_error");
}
}
return;
} else {
$('#svg_dinamic').show();
}
//if haven't error //if haven't error
if(max_w == 0 || max_w > min_w){ if(max_w == 0 || max_w > min_w){

View File

@ -14,6 +14,7 @@
enterprise_include_once('include/functions_policies.php'); enterprise_include_once('include/functions_policies.php');
enterprise_include_once('godmode/agentes/module_manager_editor_prediction.php'); enterprise_include_once('godmode/agentes/module_manager_editor_prediction.php');
require_once 'include/functions_agents.php'; require_once 'include/functions_agents.php';
ui_require_jquery_file('validate');
$disabledBecauseInPolicy = false; $disabledBecauseInPolicy = false;
$disabledTextBecauseInPolicy = ''; $disabledTextBecauseInPolicy = '';
@ -36,9 +37,9 @@ if ($row !== false && is_array($row)) {
// Services are an Enterprise feature. // Services are an Enterprise feature.
$custom_integer_1 = $row['custom_integer_1']; $custom_integer_1 = $row['custom_integer_1'];
switch ($prediction_module) { switch ((int) $prediction_module) {
case MODULE_PREDICTION_SERVICE: case MODULE_PREDICTION_SERVICE:
$is_service = true; $selected = 'service_selected';
$custom_integer_2 = 0; $custom_integer_2 = 0;
break; break;
@ -61,20 +62,33 @@ if ($row !== false && is_array($row)) {
if (isset($first_op[1]) && $first_op[1] == 'avg') { if (isset($first_op[1]) && $first_op[1] == 'avg') {
$is_synthetic_avg = true; $selected = 'synthetic_avg_selected';
} else { } else {
$is_synthetic = true; $selected = 'synthetic_selected';
} }
$custom_integer_1 = 0; $custom_integer_1 = 0;
$custom_integer_2 = 0; $custom_integer_2 = 0;
break; break;
case MODULE_PREDICTION_TRENDING:
$selected = 'trending_selected';
$prediction_module = $custom_integer_1;
break;
case MODULE_PREDICTION_PLANNING:
$selected = 'capacity_planning';
$prediction_module = $custom_integer_1;
$estimation_interval = $custom_string_1;
$estimation_type = $custom_string_2;
break;
default: default:
$prediction_module = $custom_integer_1; $prediction_module = $custom_integer_1;
break; break;
} }
} else { } else {
$selected = 'capacity_planning';
$custom_integer_1 = 0; $custom_integer_1 = 0;
} }
@ -97,7 +111,7 @@ $data[0] = __('Source module');
$data[0] .= ui_print_help_icon('prediction_source_module', true); $data[0] .= ui_print_help_icon('prediction_source_module', true);
$data[1] = ''; $data[1] = '';
// Services and Synthetic are an Enterprise feature. // Services and Synthetic are an Enterprise feature.
$module_service_synthetic_selector = enterprise_hook('get_module_service_synthetic_selector', [$is_service, $is_synthetic, $is_synthetic_avg]); $module_service_synthetic_selector = enterprise_hook('get_module_service_synthetic_selector', [$selected]);
if ($module_service_synthetic_selector !== ENTERPRISE_NOT_HOOK) { if ($module_service_synthetic_selector !== ENTERPRISE_NOT_HOOK) {
$data[1] = $module_service_synthetic_selector; $data[1] = $module_service_synthetic_selector;
@ -112,16 +126,17 @@ $data[1] = '<div id="module_data" class="w50p float-left top-1em">';
$data[1] .= html_print_label(__('Agent'), 'agent_name', true).'<br/>'; $data[1] .= html_print_label(__('Agent'), 'agent_name', true).'<br/>';
// Get module and agent of the target prediction module // Get module and agent of the target prediction module
if (!empty($prediction_module)) { if (empty($prediction_module) === false) {
$id_agente_clean = modules_get_agentmodule_agent($prediction_module); $id_agente_clean = modules_get_agentmodule_agent($prediction_module);
$prediction_module_agent = modules_get_agentmodule_agent_name($prediction_module); $prediction_module_agent = modules_get_agentmodule_agent_name($prediction_module);
$agent_name_clean = $prediction_module_agent; $agent_name_clean = $prediction_module_agent;
$agent_alias = agents_get_alias($id_agente_clean);
} else { } else {
$id_agente_clean = $id_agente; $id_agente_clean = 0;
$agent_name_clean = $agent_name; $agent_name_clean = '';
$agent_alias = '';
} }
$agent_alias = agents_get_alias($id_agente_clean);
$params = []; $params = [];
$params['return'] = true; $params['return'] = true;
@ -135,7 +150,8 @@ $params['use_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'hidden-id_agente_module_prediction'; $params['hidden_input_idagent_id'] = 'hidden-id_agente_module_prediction';
$data[1] .= ui_print_agent_autocomplete_input($params); $data[1] .= ui_print_agent_autocomplete_input($params);
$data[1] .= html_print_label(__('Module'), 'prediction_module', true); $data[1] .= '<br />';
$data[1] .= html_print_label(__('Module'), 'prediction_module', true).'<br />';
if ($id_agente) { if ($id_agente) {
$sql = 'SELECT id_agente_modulo, nombre $sql = 'SELECT id_agente_modulo, nombre
FROM tagente_modulo FROM tagente_modulo
@ -143,19 +159,23 @@ if ($id_agente) {
AND history_data = 1 AND history_data = 1
AND id_agente = '.$id_agente_clean.' AND id_agente = '.$id_agente_clean.'
AND id_agente_modulo <> '.$id_agente_modulo; AND id_agente_modulo <> '.$id_agente_modulo;
$data[1] .= html_print_select_from_sql(
$sql, $data[1] .= html_print_input(
'prediction_module', [
$prediction_module, 'type' => 'select_from_sql',
false, 'sql' => $sql,
__('Select Module'), 'name' => 'prediction_module',
0, 'selected' => $prediction_module,
true 'nothing' => __('Select Module'),
'nothing_value' => 0,
'return' => true,
]
); );
} else { } else {
$data[1] .= '<select id="prediction_module" name="custom_integer_1" disabled="disabled"><option value="0">Select an Agent first</option></select>'; $data[1] .= '<select id="prediction_module" name="custom_integer_1" disabled="disabled"><option value="0">Select an Agent first</option></select>';
} }
$data[1] .= '<br />';
$data[1] .= html_print_label(__('Period'), 'custom_integer_2', true).'<br/>'; $data[1] .= html_print_label(__('Period'), 'custom_integer_2', true).'<br/>';
$periods[0] = __('Weekly'); $periods[0] = __('Weekly');
@ -169,6 +189,56 @@ $data[1] .= '</div>';
$table_simple->colspan['prediction_module'][1] = 3; $table_simple->colspan['prediction_module'][1] = 3;
push_table_simple($data, 'prediction_module'); push_table_simple($data, 'prediction_module');
$data = [];
$data[0] = '';
$data[1] .= html_print_label(__('Calculation type'), 'estimation_type', true).'<br/>';
$data[1] .= html_print_input(
[
'type' => 'select',
'return' => 'true',
'name' => 'estimation_type',
'class' => 'w250px',
'fields' => [
'estimation_absolute' => __('Estimated absolute value'),
'estimation_calculation' => __('Calculation of days to reach limit'),
],
'selected' => $estimation_type,
],
'div',
false
);
$data[1] .= '<div id="estimation_interval_row">';
$data[1] .= html_print_label(__('Future estimation'), 'estimation_interval', true).'<br/>';
$data[1] .= html_print_input(
[
'type' => 'interval',
'return' => 'true',
'name' => 'estimation_interval',
'value' => $estimation_interval,
],
'div',
false
);
$data[1] .= '</div>';
$data[1] .= '<div id="estimation_days_row">';
$data[1] .= html_print_label(__('Limit value'), 'estimation_days', true).'<br/>';
$data[1] .= html_print_input(
[
'type' => 'number',
'return' => 'true',
'id' => 'estimation_days',
'name' => 'estimation_days',
'value' => $estimation_interval,
]
);
$data[1] .= '</div>';
push_table_simple($data, 'capacity_planning');
// Services are an Enterprise feature. // Services are an Enterprise feature.
$selector_form = enterprise_hook('get_selector_form', [$custom_integer_1]); $selector_form = enterprise_hook('get_selector_form', [$custom_integer_1]);
if ($selector_form !== ENTERPRISE_NOT_HOOK) { if ($selector_form !== ENTERPRISE_NOT_HOOK) {
@ -187,10 +257,20 @@ if ($synthetic_module_form !== ENTERPRISE_NOT_HOOK) {
$data[0] = ''; $data[0] = '';
$data[1] = $synthetic_module_form; $data[1] = $synthetic_module_form;
$table_simple->colspan['synthetic_module'][1] = 3;
push_table_simple($data, 'synthetic_module'); push_table_simple($data, 'synthetic_module');
} }
$trending_module_form = enterprise_hook('get_trending_module_form', [$custom_string_1]);
if ($trending_module_form !== ENTERPRISE_NOT_HOOK) {
$data = [];
$data[0] = '';
$data[1] .= $trending_module_form;
push_table_simple($data, 'trending_module');
}
// Netflow modules are an Enterprise feature. // Netflow modules are an Enterprise feature.
$netflow_module_form = enterprise_hook('get_netflow_module_form', [$custom_integer_1]); $netflow_module_form = enterprise_hook('get_netflow_module_form', [$custom_integer_1]);
if ($netflow_module_form !== ENTERPRISE_NOT_HOOK) { if ($netflow_module_form !== ENTERPRISE_NOT_HOOK) {
@ -214,9 +294,7 @@ unset($table_advanced->data[3]);
enterprise_hook( enterprise_hook(
'setup_services_synth', 'setup_services_synth',
[ [
$is_service, $selected,
$is_synthetic,
$is_synthetic_avg,
$is_netflow, $is_netflow,
$ops, $ops,
] ]

View File

@ -235,7 +235,7 @@ $search_string = (string) get_parameter('search_string', '');
$group = (int) get_parameter('group', 0); $group = (int) get_parameter('group', 0);
$group_search = (int) get_parameter('group_search', 0); $group_search = (int) get_parameter('group_search', 0);
$id_command_search = (int) get_parameter('id_command_search', 0); $id_command_search = (int) get_parameter('id_command_search', 0);
$url = 'index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions'; $url = 'index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions&search_string='.$search_string.'&group_search='.$group_search.'&id_command_search='.$id_command_search;
// Filter table. // Filter table.
$table_filter = new stdClass(); $table_filter = new stdClass();

View File

@ -21,8 +21,6 @@ enterprise_include_once('meta/include/functions_alerts_meta.php');
check_login(); check_login();
enterprise_hook('open_meta_frame');
if (! check_acl($config['id_user'], 0, 'LM')) { if (! check_acl($config['id_user'], 0, 'LM')) {
db_pandora_audit( db_pandora_audit(
'ACL Violation', 'ACL Violation',
@ -50,6 +48,8 @@ if (is_ajax()) {
} }
} }
enterprise_hook('open_meta_frame');
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$sec = 'advanced'; $sec = 'advanced';
} else { } else {
@ -695,7 +695,9 @@ $(document).ready (function () {
} }
else { else {
$("[name=field" + i + "_value]").val(old_value); $("[name=field" + i + "_value]").val(old_value);
$("[name=field" + i + "_value]").trigger('change');
$("[name=field" + i + "_recovery_value]").val(old_recovery_value); $("[name=field" + i + "_recovery_value]").val(old_recovery_value);
$("[name=field" + i + "_recovery_value]").trigger('change');
} }
} }
else { else {
@ -747,6 +749,7 @@ $(document).ready (function () {
if ($('#field5_value').val() !== '') { if ($('#field5_value').val() !== '') {
ajax_get_integria_custom_fields($('#field5_value').val(), integria_custom_fields_values, integria_custom_fields_rvalues); ajax_get_integria_custom_fields($('#field5_value').val(), integria_custom_fields_values, integria_custom_fields_rvalues);
$('#field5_value').trigger('change');
} }
$('#field5_value').on('change', function() { $('#field5_value').on('change', function() {

View File

@ -0,0 +1,71 @@
<?php
/**
* Audit log View.
*
* @category Audit log
* @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.
* ============================================================================
*/
// Begin.
global $config;
require_once $config['homedir'].'/include/class/AuditLog.class.php';
$ajaxPage = 'godmode/audit_log';
// Control call flow.
try {
// User access and validation is being processed on class constructor.
$controller = new AuditLog($ajaxPage);
} catch (Exception $e) {
if ((bool) is_ajax() === true) {
echo json_encode(['error' => '[AuditLog]'.$e->getMessage() ]);
exit;
} else {
echo '[AuditLog]'.$e->getMessage();
}
// Stop this execution, but continue 'globally'.
return;
}
// AJAX controller.
if ((bool) is_ajax() === true) {
$method = get_parameter('method');
if (method_exists($controller, $method) === true) {
if ($controller->ajaxMethod($method) === true) {
$controller->{$method}();
} else {
$controller->error('Unavailable method.');
}
} else {
$controller->error('Method not found. ['.$method.']');
}
// Stop any execution.
exit;
} else {
// Run.
$controller->run();
}

View File

@ -539,6 +539,8 @@ $table->data[9][1] = html_print_input_text('map_default_altitude', $map_default_
html_print_table($table); html_print_table($table);
$user_groups = users_get_groups($config['user'], 'AR', false);
echo '<h3>'.__('Layers').'</h3>'; echo '<h3>'.__('Layers').'</h3>';
$table->width = '100%'; $table->width = '100%';
@ -562,7 +564,7 @@ $table->data[1][1] = '<div id="form_layer" class="invisible">
</tr> </tr>
<tr> <tr>
<td>'.__('Show agents from group').':</td> <td>'.__('Show agents from group').':</td>
<td colspan="3">'.html_print_select_groups(false, $access, $display_all_group, 'layer_group_form', '-1', '', __('None'), '-1', true).'</td> <td colspan="3">'.html_print_select($user_groups, 'layer_group_form', '-1', '', __('none'), '-1', true).'</td>
</tr> </tr>
<tr> <tr>
<td colspan="4"><hr /></td> <td colspan="4"><hr /></td>
@ -883,7 +885,7 @@ function setLayerEditorData (data) {
var $layerFormIdInput = $("input#hidden-current_edit_layer_id"); var $layerFormIdInput = $("input#hidden-current_edit_layer_id");
var $layerFormNameInput = $("input#text-layer_name_form"); var $layerFormNameInput = $("input#text-layer_name_form");
var $layerFormVisibleCheckbox = $("input#checkbox-layer_visible_form"); var $layerFormVisibleCheckbox = $("input#checkbox-layer_visible_form");
var $layerFormAgentsFromGroupSelect = $("select#layer_group_form"); var $layerFormAgentsFromGroupSelect = $("#layer_group_form");
var $layerFormAgentInput = $("input#text-agent_alias"); var $layerFormAgentInput = $("input#text-agent_alias");
var $layerFormAgentButton = $("input#button-add_agent"); var $layerFormAgentButton = $("input#button-add_agent");
var $layerFormAgentsListItems = $("tr.agents_list_item"); var $layerFormAgentsListItems = $("tr.agents_list_item");
@ -892,7 +894,8 @@ function setLayerEditorData (data) {
$layerFormIdInput.val(data.id); $layerFormIdInput.val(data.id);
$layerFormNameInput.val(data.name); $layerFormNameInput.val(data.name);
$layerFormVisibleCheckbox.prop("checked", data.visible); $layerFormVisibleCheckbox.prop("checked", data.visible);
$layerFormAgentsFromGroupSelect.val(data.agentsFromGroup); $(`#layer_group_form option[value=${data.agentsFromGroup}]`).attr('selected', 'selected');
$(`#layer_group_form`).trigger('change');
$layerFormAgentInput.val(""); $layerFormAgentInput.val("");
$layerFormAgentButton.prop("disabled", true); $layerFormAgentButton.prop("disabled", true);
$layerFormAgentsListItems.remove(); $layerFormAgentsListItems.remove();
@ -981,7 +984,7 @@ function unbindLayerEditorEvents () {
$layerFormNameInput.unbind("change"); $layerFormNameInput.unbind("change");
$layerFormVisibleCheckbox.unbind("click"); $layerFormVisibleCheckbox.unbind("click");
$layerFormAgentsFromGroupSelect.unbind("change"); $layerFormAgentsFromGroupSelect.val('-1');
} }
function getAgentRow (layerId, agentId, agentAlias) { function getAgentRow (layerId, agentId, agentAlias) {
@ -990,7 +993,7 @@ function getAgentRow (layerId, agentId, agentAlias) {
var $deleteCol = $("<td />"); var $deleteCol = $("<td />");
var $agentAlias = $("<span class=\"agent_alias\" data-agent-id=\"" + agentId + "\">" + agentAlias + "</span>"); var $agentAlias = $("<span class=\"agent_alias\" data-agent-id=\"" + agentId + "\">" + agentAlias + "</span>");
var $removeBtn = $('<a class="delete_row" href="javascript:" <?php echo html_print_image('images/cross.png', true, ['class' => 'invert_filter']); ?> </a>'); var $removeBtn = $('<a class="delete_row" href="javascript:" <?php echo html_print_image('images/cross.png', false, ['class' => 'invert_filter']); ?> </a>');
$removeBtn.click(function (event) { $removeBtn.click(function (event) {
var $layerRow = $("tr#layer_row_" + layerId); var $layerRow = $("tr#layer_row_" + layerId);

View File

@ -613,6 +613,28 @@ $table->data['edit1'][1] = '<table width="100%">';
); );
$table->data['edit1'][1] .= '</td>'; $table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '</tr>'; $table->data['edit1'][1] .= '</tr>';
$table->data['edit1'][1] .= '<tr>';
$table->data['edit1'][1] .= '<td>';
$table->data['edit1'][1] .= '<em>'.__('Percentage').'</em>';
$table->data['edit1'][1] .= ui_print_help_tip('Defines threshold as a percentage of value decrease/increment', true);
$table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '<td align="right">';
$table->data['edit1'][1] .= html_print_select(
[
'' => __('No change'),
'1' => __('Yes'),
'0' => __('No'),
],
'percentage_warning',
'',
'',
'',
'',
true
);
$table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '</tr>';
$table->data['edit1'][1] .= '</table>'; $table->data['edit1'][1] .= '</table>';
$table->data['edit1'][2] = __('Critical status'); $table->data['edit1'][2] = __('Critical status');
@ -682,6 +704,28 @@ $table->data['edit1'][1] = '<table width="100%">';
); );
$table->data['edit1'][3] .= '</td>'; $table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '</tr>'; $table->data['edit1'][3] .= '</tr>';
$table->data['edit1'][3] .= '<tr>';
$table->data['edit1'][3] .= '<td>';
$table->data['edit1'][3] .= '<em>'.__('Percentage').'</em>';
$table->data['edit1'][3] .= ui_print_help_tip('Defines threshold as a percentage of value decrease/increment', true);
$table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '<td align="right">';
$table->data['edit1'][3] .= html_print_select(
[
'' => __('No change'),
'1' => __('Yes'),
'0' => __('No'),
],
'percentage_critical',
'',
'',
'',
'',
true
);
$table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '</tr>';
$table->data['edit1'][3] .= '</table>'; $table->data['edit1'][3] .= '</table>';
$table->data['edit1_1'][0] = '<b>'.__('Description').'</b>'; $table->data['edit1_1'][0] = '<b>'.__('Description').'</b>';
@ -1571,6 +1615,12 @@ $(document).ready (function () {
else if (this.id == "checkbox-warning_inverse") { else if (this.id == "checkbox-warning_inverse") {
return; //Do none return; //Do none
} }
else if (this.id == "checkbox-percentage_critical") {
return; //Do none
}
else if (this.id == "checkbox-percentage_warning") {
return; //Do none
}
else if (this.id == "checkbox-critical_inverse") { else if (this.id == "checkbox-critical_inverse") {
return; //Do none return; //Do none
} }
@ -1829,6 +1879,31 @@ $(document).ready (function () {
} }
} }
}); });
$('#warning_inverse').change(function() {
if($(this).val() == 1) {
$("#percentage_warning").val('0').change()
}
});
$('#critical_inverse').change(function() {
if($(this).val() == 1) {
$("#percentage_critical").val('0').change();
}
});
$('#percentage_warning').change(function() {
if($(this).val() == 1) {
$("#warning_inverse").val('0').change()
}
});
$('#percentage_critical').change(function() {
if($(this).val() == 1) {
$("#critical_inverse").val('0').change()
}
});
}); });
@ -1950,6 +2025,8 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
'history_data', 'history_data',
'critical_inverse', 'critical_inverse',
'warning_inverse', 'warning_inverse',
'percentage_warning',
'percentage_critical',
'critical_instructions', 'critical_instructions',
'warning_instructions', 'warning_instructions',
'unknown_instructions', 'unknown_instructions',

View File

@ -385,8 +385,8 @@ if (check_acl($config['id_user'], 0, 'PM') || check_acl($config['id_user'], 0, '
if (check_acl($config['id_user'], 0, 'PM')) { if (check_acl($config['id_user'], 0, 'PM')) {
// Audit //meter en extensiones. // Audit //meter en extensiones.
$sub['godmode/admin_access_logs']['text'] = __('System audit log'); $sub['godmode/audit_log']['text'] = __('System audit log');
$sub['godmode/admin_access_logs']['id'] = 'System audit log'; $sub['godmode/audit_log']['id'] = 'System audit log';
$sub['godmode/setup/links']['text'] = __('Links'); $sub['godmode/setup/links']['text'] = __('Links');
$sub['godmode/setup/links']['id'] = 'Links'; $sub['godmode/setup/links']['id'] = 'Links';
$sub['tools/diagnostics']['text'] = __('Diagnostic info'); $sub['tools/diagnostics']['text'] = __('Diagnostic info');

View File

@ -130,6 +130,9 @@ $warning_instructions = (string) get_parameter('warning_instructions');
$unknown_instructions = (string) get_parameter('unknown_instructions'); $unknown_instructions = (string) get_parameter('unknown_instructions');
$critical_inverse = (int) get_parameter('critical_inverse'); $critical_inverse = (int) get_parameter('critical_inverse');
$warning_inverse = (int) get_parameter('warning_inverse'); $warning_inverse = (int) get_parameter('warning_inverse');
$percentage_critical = (int) get_parameter('percentage_critical');
$percentage_warning = (int) get_parameter('percentage_warning');
$id_category = (int) get_parameter('id_category'); $id_category = (int) get_parameter('id_category');
$id_tag_selected = (array) get_parameter('id_tag_selected'); $id_tag_selected = (array) get_parameter('id_tag_selected');
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
@ -383,6 +386,8 @@ if ($is_management_allowed === true && $create_component) {
'unknown_instructions' => $unknown_instructions, 'unknown_instructions' => $unknown_instructions,
'critical_inverse' => $critical_inverse, 'critical_inverse' => $critical_inverse,
'warning_inverse' => $warning_inverse, 'warning_inverse' => $warning_inverse,
'percentage_warning' => $percentage_warning,
'percentage_critical' => $percentage_critical,
'id_category' => $id_category, 'id_category' => $id_category,
'tags' => $tags, 'tags' => $tags,
'disabled_types_event' => $disabled_types_event, 'disabled_types_event' => $disabled_types_event,
@ -482,6 +487,8 @@ if ($is_management_allowed === true && $update_component) {
'unknown_instructions' => $unknown_instructions, 'unknown_instructions' => $unknown_instructions,
'critical_inverse' => $critical_inverse, 'critical_inverse' => $critical_inverse,
'warning_inverse' => $warning_inverse, 'warning_inverse' => $warning_inverse,
'percentage_warning' => $percentage_warning,
'percentage_critical' => $percentage_critical,
'id_category' => $id_category, 'id_category' => $id_category,
'tags' => $tags, 'tags' => $tags,
'disabled_types_event' => $disabled_types_event, 'disabled_types_event' => $disabled_types_event,

View File

@ -93,6 +93,8 @@ if ($create_network_from_module) {
$unknown_instructions = $data_module['unknown_instructions']; $unknown_instructions = $data_module['unknown_instructions'];
$critical_inverse = $data_module['critical_inverse']; $critical_inverse = $data_module['critical_inverse'];
$warning_inverse = $data_module['warning_inverse']; $warning_inverse = $data_module['warning_inverse'];
$percentage_critical = $data_module['percentage_critical'];
$percentage_warning = $data_module['percentage_warning'];
$id_category = $data_module['id_category']; $id_category = $data_module['id_category'];
$ff_event_normal = $data_module['min_ff_event_normal']; $ff_event_normal = $data_module['min_ff_event_normal'];
$ff_event_warning = $data_module['min_ff_event_warning']; $ff_event_warning = $data_module['min_ff_event_warning'];
@ -150,7 +152,9 @@ if (isset($id)) {
$warning_instructions = $component['warning_instructions']; $warning_instructions = $component['warning_instructions'];
$unknown_instructions = $component['unknown_instructions']; $unknown_instructions = $component['unknown_instructions'];
$critical_inverse = $component['critical_inverse']; $critical_inverse = $component['critical_inverse'];
$percentage_critical = $component['percentage_critical'];
$warning_inverse = $component['warning_inverse']; $warning_inverse = $component['warning_inverse'];
$percentage_warning = $component['percentage_warning'];
$id_category = $component['id_category']; $id_category = $component['id_category'];
$tags = $component['tags']; $tags = $component['tags'];
$ff_event_normal = $component['min_ff_event_normal']; $ff_event_normal = $component['min_ff_event_normal'];
@ -233,6 +237,8 @@ if (isset($id)) {
$unknown_instructions = ''; $unknown_instructions = '';
$critical_inverse = 0; $critical_inverse = 0;
$warning_inverse = 0; $warning_inverse = 0;
$percentage_critical = 0;
$percentage_warning = 0;
$id_category = 0; $id_category = 0;
$tags = ''; $tags = '';
$ff_event_normal = 0; $ff_event_normal = 0;
@ -823,6 +829,60 @@ $(document).ready (function () {
}); });
$("#snmp_version" ).trigger("change"); $("#snmp_version" ).trigger("change");
if ($('#checkbox-warning_inverse').prop('checked') === true) {
$('#percentage_warning').hide();
}
if ($('#checkbox-critical_inverse').prop('checked') === true) {
$('#percentage_critical').hide();
}
if ($('#checkbox-percentage_warning').prop('checked') === true) {
$('#warning_inverse').hide();
}
if ($('#checkbox-percentage_critical').prop('checked') === true) {
$('#critical_inverse').hide();
}
$('#checkbox-warning_inverse').change (function() {
if ($('#checkbox-warning_inverse').prop('checked') === true){
$('#checkbox-percentage_warning').prop('checked', false);
$('#percentage_warning').hide();
} else {
$('#percentage_warning').show();
}
});
$('#checkbox-critical_inverse').change (function() {
if ($('#checkbox-critical_inverse').prop('checked') === true){
$('#checkbox-percentage_critical').prop('checked', false);
$('#percentage_critical').hide();
} else {
$('#percentage_critical').show();
}
});
$('#checkbox-percentage_warning').change (function() {
if ($('#checkbox-percentage_warning').prop('checked') === true){
$('#checkbox-warning_inverse').prop('checked', false);
$('#warning_inverse').hide();
} else {
$('#warning_inverse').show();
}
});
$('#checkbox-percentage_critical').change (function() {
if ($('#checkbox-percentage_critical').prop('checked') === true){
$('#checkbox-critical_inverse').prop('checked', false);
$('#critical_inverse').hide();
}
else {
$('#critical_inverse').show();
}
});
}); });
<?php <?php

View File

@ -13,6 +13,8 @@
// GNU General Public License for more details. // GNU General Public License for more details.
global $config; global $config;
require_once $config['homedir'].'/include/graphs/functions_d3.php'; require_once $config['homedir'].'/include/graphs/functions_d3.php';
include_javascript_d3();
if (! check_acl($config['id_user'], 0, 'PM') && ! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'PM') && ! check_acl($config['id_user'], 0, 'AW')) {
db_pandora_audit( db_pandora_audit(
@ -185,8 +187,14 @@ $table->data[4][1] .= html_print_input_text(
1024, 1024,
true true
).'</span>'; ).'</span>';
$table->data[4][1] .= '<br /><em>'.__('Inverse interval').'</em>'; $table->data[4][1] .= '<div id="warning_inverse"><em>'.__('Inverse interval').'</em>';
$table->data[4][1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true); $table->data[4][1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true);
$table->data[4][1] .= '</div>';
$table->data[4][1] .= '<div id="percentage_warning"><em>'.__('Percentage').'</em>';
$table->data[4][1] .= ui_print_help_tip('Defines threshold as a percentage of value decrease/increment', true);
$table->data[4][1] .= html_print_checkbox('percentage_warning', 1, $percentage_warning, true);
$table->data[4][1] .= '</div>';
$table->data[4][2] = '<svg id="svg_dinamic" width="500" height="300"> </svg>'; $table->data[4][2] = '<svg id="svg_dinamic" width="500" height="300"> </svg>';
$table->colspan[4][2] = 2; $table->colspan[4][2] = 2;
@ -220,8 +228,15 @@ $table->data[5][1] .= html_print_input_text(
1024, 1024,
true true
).'</span>'; ).'</span>';
$table->data[5][1] .= '<br /><em>'.__('Inverse interval').'</em>'; $table->data[5][1] .= '<div id="critical_inverse"><em>'.__('Inverse interval').'</em>';
$table->data[5][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true); $table->data[5][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true);
$table->data[5][1] .= '</div>';
$table->data[5][1] .= '<div id="percentage_critical"><em>'.__('Percentage').'</em>';
$table->data[5][1] .= ui_print_help_tip('Defines threshold as a percentage of value decrease/increment', true);
$table->data[5][1] .= html_print_checkbox('percentage_critical', 1, $percentage_critical, true);
$table->data[5][1] .= '</div>';
$table->data[6][0] = __('FF threshold'); $table->data[6][0] = __('FF threshold');
$table->colspan[6][1] = 3; $table->colspan[6][1] = 3;
@ -518,6 +533,9 @@ $next_row++;
$('#string_warning').hide(); $('#string_warning').hide();
$('#minmax_critical').show(); $('#minmax_critical').show();
$('#minmax_warning').show(); $('#minmax_warning').show();
$('#percentage_warning').show();
$('#percentage_critical').show();
} }
else { else {
// String types // String types
@ -525,6 +543,8 @@ $next_row++;
$('#string_warning').show(); $('#string_warning').show();
$('#minmax_critical').hide(); $('#minmax_critical').hide();
$('#minmax_warning').hide(); $('#minmax_warning').hide();
$('#percentage_warning').hide();
$('#percentage_critical').hide();
} }
}); });
@ -566,11 +586,64 @@ $next_row++;
$('#text-max_critical').val(0); $('#text-max_critical').val(0);
} }
}); });
if ($('#checkbox-warning_inverse').prop('checked') === true) {
$('#percentage_warning').hide();
}
if ($('#checkbox-critical_inverse').prop('checked') === true) {
$('#percentage_critical').hide();
}
if ($('#checkbox-percentage_warning').prop('checked') === true) {
$('#warning_inverse').hide();
}
if ($('#checkbox-percentage_critical').prop('checked') === true) {
$('#critical_inverse').hide();
}
$('#checkbox-warning_inverse').change (function() { $('#checkbox-warning_inverse').change (function() {
paint_graph_values(); paint_graph_values();
}); if ($('#checkbox-warning_inverse').prop('checked') === true){
$('#checkbox-percentage_warning').prop('checked', false);
$('#percentage_warning').hide();
} else {
$('#percentage_warning').show();
}
});
$('#checkbox-critical_inverse').change (function() { $('#checkbox-critical_inverse').change (function() {
paint_graph_values(); paint_graph_values();
if ($('#checkbox-critical_inverse').prop('checked') === true){
$('#checkbox-percentage_critical').prop('checked', false);
$('#percentage_critical').hide();
} else {
$('#percentage_critical').show();
}
});
$('#checkbox-percentage_warning').change (function() {
paint_graph_values();
if ($('#checkbox-percentage_warning').prop('checked') === true){
$('#checkbox-warning_inverse').prop('checked', false);
$('#warning_inverse').hide();
} else {
$('#warning_inverse').show();
}
});
$('#checkbox-percentage_critical').change (function() {
paint_graph_values();
if ($('#checkbox-percentage_critical').prop('checked') === true){
$('#checkbox-critical_inverse').prop('checked', false);
$('#critical_inverse').hide();
}
else {
$('#critical_inverse').show();
}
}); });
}); });
@ -634,6 +707,43 @@ $next_row++;
//messages error //messages error
var message_error_warning = '<?php echo __('Please introduce a maximum warning higher than the minimun warning'); ?>'; var message_error_warning = '<?php echo __('Please introduce a maximum warning higher than the minimun warning'); ?>';
var message_error_critical = '<?php echo __('Please introduce a maximum critical higher than the minimun critical'); ?>'; var message_error_critical = '<?php echo __('Please introduce a maximum critical higher than the minimun critical'); ?>';
var message_error_percentage = '<?php echo __('Please introduce a positive percentage value'); ?>';
//Percentage selector
var percentage_w = $('#checkbox-percentage_warning').prop('checked');
var percentage_c = $('#checkbox-percentage_critical').prop('checked');
if(percentage_w == true || percentage_c == true) {
d3.select("#svg_dinamic rect").remove();
//create svg
var svg = d3.select("#svg_dinamic");
svg.selectAll("g").remove();
if (percentage_w === true) {
if(max_w < 0 || min_w < 0) {
paint_graph_status(0,0,0,0,0,0,1,0,legend_normal,legend_warning,legend_critical,message_error_percentage,message_error_percentage);
} else {
$("#text-max_warning").removeClass("input_error");
$("#text-min_warning").removeClass("input_error");
}
}
if(percentage_c === true) {
if(max_c < 0 || min_c < 0) {
paint_graph_status(0,0,0,0,0,0,0,1,legend_normal,legend_warning,legend_critical,message_error_percentage,message_error_percentage);
} else {
$("#text-min-critical").removeClass("input_error");
$("#text-max_critical").removeClass("input_error");
}
}
return;
} else {
$('#svg_dinamic').show();
}
//if haven't error //if haven't error
if(max_w == 0 || max_w > min_w){ if(max_w == 0 || max_w > min_w){

View File

@ -389,8 +389,14 @@ $data[1] .= '</span>';
$data[1] .= '<span class="string_values" id="warning_string_values"><em>'.__('String').' </em>&nbsp;'; $data[1] .= '<span class="string_values" id="warning_string_values"><em>'.__('String').' </em>&nbsp;';
$data[1] .= html_print_input_text('str_warning', $str_warning, '', 5, 1024, true).'</span>'; $data[1] .= html_print_input_text('str_warning', $str_warning, '', 5, 1024, true).'</span>';
// Warning inverse values. // Warning inverse values.
$data[1] .= '<br /><em>'.__('Inverse interval').'</em>&nbsp;'; $data[1] .= '<div id="warning_inverse"><em>'.__('Inverse interval').'</em>&nbsp;';
$data[1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true); $data[1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true);
$data[1] .= '</div>';
$data[1] .= '<div id="percentage_warning"><em>'.__('Percentage').'</em>&nbsp;';
$data[1] .= ui_print_help_tip('Defines threshold as a percentage of value decrease/increment', true);
$data[1] .= html_print_checkbox('percentage_warning', 1, $percentage_warning, true);
$data[1] .= '</div>';
$data[2] = '<svg id="svg_dinamic" width="500" height="300"> </svg>'; $data[2] = '<svg id="svg_dinamic" width="500" height="300"> </svg>';
$table->colspan['warning-svg-row'][2] = 2; $table->colspan['warning-svg-row'][2] = 2;
@ -425,8 +431,15 @@ $data[1] .= '</span>';
$data[1] .= '<span class="string_values" id="critical_string_values"><em>'.__('String').' </em>&nbsp;'; $data[1] .= '<span class="string_values" id="critical_string_values"><em>'.__('String').' </em>&nbsp;';
$data[1] .= html_print_input_text('str_critical', $str_critical, '', 5, 1024, true).'</span>'; $data[1] .= html_print_input_text('str_critical', $str_critical, '', 5, 1024, true).'</span>';
// Critical inverse values. // Critical inverse values.
$data[1] .= '<br /><em>'.__('Inverse interval').'</em>&nbsp;'; $data[1] .= '<div id="critical_inverse"><em>'.__('Inverse interval').'</em>&nbsp;';
$data[1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true); $data[1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true);
$data[1] .= '</div>';
$data[1] .= '<Ddiv id="percentage_critical"><em>'.__('Percentage').'</em>&nbsp;';
$data[1] .= ui_print_help_tip('Defines threshold as a percentage of value decrease/increment', true);
$data[1] .= html_print_checkbox('percentage_critical', 1, $percentage_critical, true);
$data[1] .= '</div>';
push_table_row($data, 'critical-row'); push_table_row($data, 'critical-row');

View File

@ -136,10 +136,10 @@ $percentil = false;
$time_compare_overlapped = false; $time_compare_overlapped = false;
// Added for events items. // Added for events items.
$show_summary_group = false; $show_summary_group = false;
$filter_event_severity = false; $filter_event_severity = false;
$filter_event_type = false; $filter_event_type = false;
$filter_event_status = false; $filter_event_status = false;
$event_graph_by_agent = false; $event_graph_by_agent = false;
$event_graph_by_user_validator = false; $event_graph_by_user_validator = false;
$event_graph_by_criticity = false; $event_graph_by_criticity = false;
@ -175,6 +175,8 @@ $agent_max_value = true;
$agent_min_value = true; $agent_min_value = true;
$uncompressed_module = true; $uncompressed_module = true;
$only_data = false;
// Users. // Users.
$id_users = []; $id_users = [];
$users_groups = []; $users_groups = [];
@ -185,6 +187,16 @@ $nothing_value = 0;
$graph_render = (empty($config['type_mode_graph']) === true) ? 0 : $config['type_mode_graph']; $graph_render = (empty($config['type_mode_graph']) === true) ? 0 : $config['type_mode_graph'];
$valuesGroupBy = [0 => __('None')];
$valuesGroupByDefaultAlertActions = [
'agent' => __('Agent'),
'module' => __('Module'),
'group' => __('Group'),
];
if (is_metaconsole() === false) {
$valuesGroupByDefaultAlertActions['template'] = __('Template');
}
switch ($action) { switch ($action) {
case 'new': case 'new':
$actionParameter = 'save'; $actionParameter = 'save';
@ -199,7 +211,7 @@ switch ($action) {
$failover_type = REPORT_FAILOVER_TYPE_NORMAL; $failover_type = REPORT_FAILOVER_TYPE_NORMAL;
$server_name = ''; $server_name = '';
$server_id = 0; $server_id = 0;
$dyn_height = 230; $dyn_height = (empty($config['graph_image_height']) === false) ? $config['graph_image_height'] : REPORT_ITEM_DYNAMIC_HEIGHT;
$landscape = false; $landscape = false;
$pagebreak = false; $pagebreak = false;
$summary = 0; $summary = 0;
@ -240,7 +252,7 @@ switch ($action) {
$server_name = ''; $server_name = '';
$server_id = 0; $server_id = 0;
$get_data_editor = false; $get_data_editor = false;
$dyn_height = 230; $dyn_height = (empty($config['graph_image_height']) === false) ? $config['graph_image_height'] : REPORT_ITEM_DYNAMIC_HEIGHT;
break; break;
} }
@ -733,21 +745,73 @@ switch ($action) {
case 'agent_module': case 'agent_module':
$description = $item['description']; $description = $item['description'];
$es = json_decode($item['external_source'], true); $es = json_decode($item['external_source'], true);
$id_agents = $es['id_agents'];
// Decode agents and modules.
$id_agents = json_decode(
io_safe_output(base64_decode($es['id_agents'])),
true
);
$module = json_decode(
io_safe_output(base64_decode($es['module'])),
true
);
$selection_a_m = get_parameter('selection'); $selection_a_m = get_parameter('selection');
$recursion = $item['recursion']; $recursion = $item['recursion'];
if ((count($es['module']) == 1) && ($es['module'][0] == 0)) {
$module = '';
} else {
$module = $es['module'];
}
$group = $item['id_group']; $group = $item['id_group'];
$modulegroup = $item['id_module_group']; $modulegroup = $item['id_module_group'];
$idAgentModule = $module; $idAgentModule = $module;
break; break;
case 'alert_report_actions':
$description = $item['description'];
$es = json_decode($item['external_source'], true);
// Decode agents and modules.
$id_agents = json_decode(
io_safe_output(base64_decode($es['id_agents'])),
true
);
$module = json_decode(
io_safe_output(base64_decode($es['module'])),
true
);
$selection_a_m = get_parameter('selection');
$recursion = $item['recursion'];
$group = $item['id_group'];
$modulegroup = $item['id_module_group'];
$idAgentModule = $module;
$alert_templates_selected = $es['templates'];
$alert_actions_selected = $es['actions'];
$show_summary = $es['show_summary'];
$group_by = $es['group_by'];
$only_data = $es['only_data'];
$period = $item['period'];
$lapse = $item['lapse'];
// Set values.
$valuesGroupBy = [
'agent' => __('Agent'),
'module' => __('Module'),
'group' => __('Group'),
];
if (is_metaconsole() === false) {
$valuesGroupBy['template'] = __('Template');
}
$lapse_calc = 1;
break;
case 'agents_inventory': case 'agents_inventory':
$description = $item['description']; $description = $item['description'];
$es = json_decode($item['external_source'], true); $es = json_decode($item['external_source'], true);
@ -829,6 +893,10 @@ switch ($action) {
$select_by_group = $es['select_by_group']; $select_by_group = $es['select_by_group'];
break; break;
case 'ncm':
$idAgent = $item['id_agent'];
break;
default: default:
// It's not possible. // It's not possible.
break; break;
@ -1648,30 +1716,12 @@ $class = 'databox filters';
<td class="bolder"><?php echo __('Agents'); ?></td> <td class="bolder"><?php echo __('Agents'); ?></td>
<td> <td>
<?php <?php
$all_agent_log = agents_get_agents(false, ['id_agente', 'alias']); $all_agents = agents_get_agents_selected($group);
foreach ($all_agent_log as $key => $value) {
$agents2[$value['id_agente']] = $value['alias'];
}
if ((empty($agents2)) || $agents2 == -1) {
$agents = [];
}
$agents_select = [];
if (is_array($id_agents) || is_object($id_agents)) {
foreach ($id_agents as $id) {
foreach ($agents2 as $key => $a) {
if ($key == (int) $id) {
$agents_select[$key] = $key;
}
}
}
}
html_print_select( html_print_select(
$agents2, $all_agents,
'id_agents2[]', 'id_agents2[]',
$agents_select, $id_agents,
$script = '', $script = '',
'', '',
0, 0,
@ -1680,7 +1730,23 @@ $class = 'databox filters';
true, true,
'', '',
false, false,
'min-width: 180px' 'min-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true
);
html_print_input_hidden(
'id_agents2-multiple-text',
json_encode($agents_select)
); );
?> ?>
</td> </td>
@ -1717,48 +1783,146 @@ $class = 'databox filters';
<td class="bolder"><?php echo __('Modules'); ?></td> <td class="bolder"><?php echo __('Modules'); ?></td>
<td> <td>
<?php <?php
if (empty($id_agents) || $id_agents == null || $id_agents === 0) { if (empty($id_agents) === true) {
$all_modules = ''; $all_modules = [];
$idAgentModule = [];
} else { } else {
$all_modules = db_get_all_rows_sql( $all_modules = get_modules_agents(
'SELECT DISTINCT nombre FROM $modulegroup,
tagente_modulo WHERE id_agente IN ('.implode(',', array_values($id_agents)).')' $id_agents,
!$selection_a_m,
true
); );
} }
if ((empty($all_modules)) || $all_modules == -1) {
$all_modules = [];
}
$modules_select = [];
$all_modules_structured = [];
if (is_array($idAgentModule) || is_object($idAgentModule)) {
foreach ($idAgentModule as $id) {
foreach ($all_modules as $key => $a) {
if ($a['id_agente_modulo'] == (int) $id) {
$modules_select[$a['id_agente_modulo']] = $a['id_agente_modulo'];
}
}
}
}
foreach ($all_modules as $a) {
$all_modules_structured[$a['id_agente_modulo']] = $a['nombre'];
}
html_print_select( html_print_select(
$all_modules_structured, $all_modules,
'module[]', 'module[]',
$modules_select, $idAgentModule,
$script = '', $script = '',
__('None'), '',
0, 0,
false, false,
true, true,
true, true,
'', '',
false, false,
'min-width: 180px' 'min-width: 500px; max-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true
);
html_print_input_hidden(
'module-multiple-text',
json_encode($agents_select)
);
?>
</td>
</tr>
<tr id="row_alert_templates" class="datos">
<td class="bolder"><?php echo __('Templates'); ?></td>
<td>
<?php
$alert_templates = [];
$own_info = get_user_info($config['id_user']);
if ($own_info['is_admin']) {
$alert_templates = alerts_get_alert_templates(
false,
[
'id',
'name',
]
);
} else {
$usr_groups = users_get_groups($config['id_user'], 'LW', true);
$filter_groups = '';
$filter_groups = implode(',', array_keys($usr_groups));
$alert_templates = alerts_get_alert_templates(
['id_group IN ('.$filter_groups.')'],
[
'id',
'name',
]
);
}
$alert_templates = array_reduce(
$alert_templates,
function ($carry, $item) {
$carry[$item['id']] = $item['name'];
return $carry;
},
[]
);
html_print_select(
$alert_templates,
'alert_templates[]',
$alert_templates_selected,
'',
'',
0,
false,
true,
true,
'',
false,
'min-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true
);
?>
</td>
</tr>
<tr id="row_alert_actions" class="datos">
<td class="bolder"><?php echo __('Actions'); ?></td>
<td>
<?php
$alert_actions = alerts_get_alert_actions(true);
html_print_select(
$alert_actions,
'alert_actions[]',
$alert_actions_selected,
'',
'',
0,
false,
true,
true,
'',
false,
'min-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true
); );
?> ?>
</td> </td>
@ -2552,6 +2716,23 @@ $class = 'databox filters';
</td> </td>
</tr> </tr>
<tr id="row_show_only_data" class="datos">
<td class="bolder">
<?php
echo __('Only data');
?>
</td>
<td>
<?php
html_print_checkbox_switch(
'only_data',
true,
$only_data
);
?>
</td>
</tr>
<tr id="row_event_severity" class="datos"> <tr id="row_event_severity" class="datos">
<td class="bolder"><?php echo __('Severity'); ?></td> <td class="bolder"><?php echo __('Severity'); ?></td>
<td> <td>
@ -2920,8 +3101,7 @@ $class = 'databox filters';
echo __('Time lapse intervals'); echo __('Time lapse intervals');
ui_print_help_tip( ui_print_help_tip(
__( __(
'Lapses of time in which the period is divided to make more precise calculations 'Lapses of time in which the period is divided to make more precise calculations'
'
) )
); );
?> ?>
@ -2932,7 +3112,7 @@ $class = 'databox filters';
'lapse', 'lapse',
$lapse, $lapse,
'', '',
'', __('None'),
'0', '0',
10, 10,
'', '',
@ -3108,7 +3288,59 @@ $class = 'databox filters';
?> ?>
</td> </td>
</tr> </tr>
<tr id="row_show_summary" class="datos">
<td class="bolder">
<?php
echo __('Show Summary');
?>
</td>
<td>
<?php
html_print_checkbox_switch(
'show_summary',
true,
$show_summary
);
?>
</td>
</tr>
<tr id="row_group_by" class="datos">
<td class="bolder">
<?php
echo __('Group by');
?>
</td>
<td>
<?php
html_print_select(
$valuesGroupBy,
'group_by',
$group_by,
'',
'',
0,
false,
false,
false,
'',
false,
'',
false,
false,
false,
'',
false,
false,
false,
false,
true
);
?>
</td>
</tr>
<tr id="row_landscape" class="datos"> <tr id="row_landscape" class="datos">
<td class="bolder"> <td class="bolder">
<?php <?php
@ -3772,23 +4004,23 @@ function print_SLA_list($width, $action, $idItem=null)
], ],
] ]
); );
if (!empty($services_tmp) if (!empty($services_tmp)
&& $services_tmp != ENTERPRISE_NOT_HOOK && $services_tmp != ENTERPRISE_NOT_HOOK
) {
foreach ($services_tmp as $service) {
$check_module_sla = modules_check_agentmodule_exists(
$service['sla_id_module']
);
$check_module_sla_value = modules_check_agentmodule_exists(
$service['sla_value_id_module']
);
if ($check_module_sla
&& $check_module_sla_value
) { ) {
$services[$service['id']] = $service['name']; foreach ($services_tmp as $service) {
$check_module_sla = modules_check_agentmodule_exists(
$service['sla_id_module']
);
$check_module_sla_value = modules_check_agentmodule_exists(
$service['sla_value_id_module']
);
if ($check_module_sla
&& $check_module_sla_value
) {
$services[$service['id']] = $service['name'];
}
}
} }
}
}
echo '<td class="sla_list_service_col">'; echo '<td class="sla_list_service_col">';
echo html_print_select( echo html_print_select(
@ -4252,12 +4484,12 @@ $(document).ready (function () {
// Load selected modules by default // Load selected modules by default
$("#id_agents2").trigger('click'); $("#id_agents2").trigger('click');
$('#combo_server').change (function (){ $('#combo_server').change(function () {
$("#id_agents").html(''); $("#id_agents").html('');
$("#id_agents2").html(''); $("#id_agents2").html('');
$("#module").html(''); $("#module").html('');
$("#inventory_modules").html(''); $("#inventory_modules").html('');
}) });
$("#text-url").keyup ( $("#text-url").keyup (
function () { function () {
@ -4273,7 +4505,6 @@ $(document).ready (function () {
$("#combo_group").change ( $("#combo_group").change (
function () { function () {
// Alert report group must show all matches when selecting All group // Alert report group must show all matches when selecting All group
// ignoring 'recursion' option. #6497. // ignoring 'recursion' option. #6497.
if ($("#combo_group").val() == 0) { if ($("#combo_group").val() == 0) {
@ -4284,7 +4515,12 @@ $(document).ready (function () {
} }
$("#id_agents2").html(''); $("#id_agents2").html('');
// Check agent all.
$("#checkbox-id_agents2-check-all").prop('checked', false);
$("#module").html(''); $("#module").html('');
// Check module all.
$("#checkbox-module-check-all").prop('checked', false);
$("#inventory_modules").html(''); $("#inventory_modules").html('');
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente", {"page" : "operation/agentes/ver_agente",
@ -4310,7 +4546,6 @@ $(document).ready (function () {
); );
} }
); );
$("#combo_group").change();
$("#checkbox-recursion").change ( $("#checkbox-recursion").change (
function () { function () {
@ -4324,6 +4559,11 @@ $(document).ready (function () {
}, },
function (data, status) { function (data, status) {
$("#id_agents2").html(''); $("#id_agents2").html('');
// Check agent all.
$("#checkbox-id_agents2-check-all").prop('checked', false);
$("#module").html('');
// Check module all.
$("#checkbox-module-check-all").prop('checked', false);
jQuery.each (data, function (id, value) { jQuery.each (data, function (id, value) {
// Remove keys_prefix from the index // Remove keys_prefix from the index
id = id.substring(1); id = id.substring(1);
@ -4347,14 +4587,17 @@ $(document).ready (function () {
"get_modules_group_json" : 1, "get_modules_group_json" : 1,
"id_module_group" : this.value, "id_module_group" : this.value,
"id_agents" : $("#id_agents2").val(), "id_agents" : $("#id_agents2").val(),
"selection" : $("#selection_agent_module").val() "selection" : $("#selection_agent_module").val(),
"select_mode": 1
}, },
function (data, status) { function (data, status) {
$("#module").html(''); $("#module").html('');
// Check module all.
$("#checkbox-module-check-all").prop('checked', false);
jQuery.each (data, function (id, value) { jQuery.each (data, function (id, value) {
option = $("<option></option>") option = $("<option></option>")
.attr ("value", value["id_agente_modulo"]) .attr ("value", id)
.html (value["nombre"]); .html (value);
$("#module").append (option); $("#module").append (option);
}); });
}, },
@ -4368,17 +4611,20 @@ $(document).ready (function () {
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente", {"page" : "operation/agentes/ver_agente",
"get_modules_group_json" : 1, "get_modules_group_json" : 1,
"selection" : $("#selection_agent_module").val(),
"id_module_group" : $("#combo_modulegroup").val(), "id_module_group" : $("#combo_modulegroup").val(),
"id_agents" : $("#id_agents2").val(), "id_agents" : $("#id_agents2").val(),
"selection" : $("#selection_agent_module").val() "select_mode": 1
}, },
function (data, status) { function (data, status) {
$("#module").html(''); $("#module").html('');
// Check module all.
$("#checkbox-module-check-all").prop('checked', false);
if(data){ if(data){
jQuery.each (data, function (id, value) { jQuery.each (data, function (id, value) {
option = $("<option></option>") option = $("<option></option>")
.attr ("value", value["id_agente_modulo"]) .attr ("value", id)
.html (value["nombre"]); .html (value);
$("#module").append (option); $("#module").append (option);
}); });
} }
@ -4395,15 +4641,18 @@ $(document).ready (function () {
"get_modules_group_json" : 1, "get_modules_group_json" : 1,
"id_module_group" : $("#combo_modulegroup").val(), "id_module_group" : $("#combo_modulegroup").val(),
"id_agents" : $("#id_agents2").val(), "id_agents" : $("#id_agents2").val(),
"selection" : $("#selection_agent_module").val() "selection" : $("#selection_agent_module").val(),
"select_mode": 1
}, },
function (data, status) { function (data, status) {
$("#module").html(''); $("#module").html('');
// Check module all.
$("#checkbox-module-check-all").prop('checked', false);
if(data){ if(data){
jQuery.each (data, function (id, value) { jQuery.each (data, function (id, value) {
option = $("<option></option>") option = $("<option></option>")
.attr ("value", value["id_agente_modulo"]) .attr ("value", id)
.html (value["nombre"]); .html (value);
$("#module").append (option); $("#module").append (option);
}); });
} }
@ -4494,6 +4743,15 @@ $(document).ready (function () {
} }
switch (type){ switch (type){
case 'agent_module':
case 'alert_report_actions':
var agents_multiple = $('#id_agents2').val();
var modules_multiple = $('#module').val();
$('#hidden-id_agents2-multiple-text').val(JSON.stringify(agents_multiple));
$('#hidden-module-multiple-text').val(JSON.stringify(modules_multiple));
$('#id_agents2').val('');
$('#module').val('');
break;
case 'alert_report_module': case 'alert_report_module':
case 'alert_report_agent': case 'alert_report_agent':
case 'event_report_agent': case 'event_report_agent':
@ -4518,12 +4776,6 @@ $(document).ready (function () {
return false; return false;
} }
break; break;
case 'agent_module':
if ($("select#id_agents2>option:selected").val() == undefined) {
dialog_message('#message_no_agent');
return false;
}
break;
case 'inventory': case 'inventory':
case 'inventory_changes': case 'inventory_changes':
if ($("select#id_agents>option:selected").val() == undefined) { if ($("select#id_agents>option:selected").val() == undefined) {
@ -4568,18 +4820,11 @@ $(document).ready (function () {
case 'sumatory': case 'sumatory':
case 'historical_data': case 'historical_data':
case 'increment': case 'increment':
if ($("#id_agent_module").val() == 0) { if ($("#id_agent_module").val() == 0) {
dialog_message('#message_no_module'); dialog_message('#message_no_module');
return false; return false;
} }
break; break;
case 'agent_module':
if ($("select#module>option:selected").val() == undefined) {
dialog_message('#message_no_module');
return false;
}
break;
case 'inventory': case 'inventory':
case 'inventory_changes': case 'inventory_changes':
if ($("select#inventory_modules>option:selected").val() == 0) { if ($("select#inventory_modules>option:selected").val() == 0) {
@ -4632,6 +4877,15 @@ $(document).ready (function () {
return false; return false;
} }
switch (type){ switch (type){
case 'agent_module':
case 'alert_report_actions':
var agents_multiple = $('#id_agents2').val();
var modules_multiple = $('#module').val();
$('#hidden-id_agents2-multiple-text').val(JSON.stringify(agents_multiple));
$('#hidden-module-multiple-text').val(JSON.stringify(modules_multiple));
$('#id_agents2').val('');
$('#module').val('');
break;
case 'alert_report_module': case 'alert_report_module':
case 'alert_report_agent': case 'alert_report_agent':
case 'event_report_agent': case 'event_report_agent':
@ -4656,12 +4910,6 @@ $(document).ready (function () {
return false; return false;
} }
break; break;
case 'agent_module':
if ($("select#id_agents2>option:selected").val() == undefined) {
dialog_message('#message_no_agent');
return false;
}
break;
case 'inventory': case 'inventory':
if ($("select#id_agents>option:selected").val() == undefined) { if ($("select#id_agents>option:selected").val() == undefined) {
dialog_message('#message_no_agent'); dialog_message('#message_no_agent');
@ -4701,18 +4949,11 @@ $(document).ready (function () {
case 'sumatory': case 'sumatory':
case 'historical_data': case 'historical_data':
case 'increment': case 'increment':
if ($("#id_agent_module").val() == 0) { if ($("#id_agent_module").val() == 0) {
dialog_message('#message_no_module'); dialog_message('#message_no_module');
return false; return false;
} }
break; break;
case 'agent_module':
if ($("select#module>option:selected").val() == undefined) {
dialog_message('#message_no_module');
return false;
}
break;
case 'inventory': case 'inventory':
if ($("select#inventory_modules>option:selected").val() == 0) { if ($("select#inventory_modules>option:selected").val() == 0) {
dialog_message('#message_no_module'); dialog_message('#message_no_module');
@ -5485,6 +5726,7 @@ function addGeneralRow() {
} }
function chooseType() { function chooseType() {
var meta = '<?php echo (is_metaconsole() === true) ? 1 : 0; ?>';
type = $("#type").val(); type = $("#type").val();
$("#row_description").hide(); $("#row_description").hide();
$("#row_label").hide(); $("#row_label").hide();
@ -5538,6 +5780,8 @@ function chooseType() {
$('#row_hide_notinit_agents').hide(); $('#row_hide_notinit_agents').hide();
$('#row_priority_mode').hide(); $('#row_priority_mode').hide();
$("#row_module_group").hide(); $("#row_module_group").hide();
$("#row_alert_templates").hide();
$("#row_alert_actions").hide();
$("#row_servers").hide(); $("#row_servers").hide();
$("#row_sort").hide(); $("#row_sort").hide();
$("#row_date").hide(); $("#row_date").hide();
@ -5562,6 +5806,7 @@ function chooseType() {
$("#select_agent_modules").hide(); $("#select_agent_modules").hide();
$("#modules_row").hide(); $("#modules_row").hide();
$("#row_show_summary_group").hide(); $("#row_show_summary_group").hide();
$("#row_show_only_data").hide();
$("#row_event_severity").hide(); $("#row_event_severity").hide();
$("#row_event_type").hide(); $("#row_event_type").hide();
$("#row_event_status").hide(); $("#row_event_status").hide();
@ -5586,6 +5831,8 @@ function chooseType() {
$("#row_network_filter").hide(); $("#row_network_filter").hide();
$("#row_alive_ip").hide(); $("#row_alive_ip").hide();
$("#row_agent_not_assigned_to_ip").hide(); $("#row_agent_not_assigned_to_ip").hide();
$("#row_show_summary").hide();
$("#row_group_by").hide();
// SLA list default state. // SLA list default state.
$("#sla_list").hide(); $("#sla_list").hide();
@ -5896,6 +6143,37 @@ function chooseType() {
$("#row_historical_db_check").hide(); $("#row_historical_db_check").hide();
break; break;
case 'alert_report_actions':
$("#row_description").show();
$("#row_group").show();
$("#select_agent_modules").show();
$("#agents_modules_row").show();
$("#modules_row").show();
if(meta == 0){
$("#row_alert_templates").show();
}
$("#row_alert_actions").show();
$("#row_period").show();
$("#row_lapse").show();
$("#row_show_summary").show();
$("#row_show_only_data").show();
$("#row_group_by").show();
if('<?php echo $action; ?>' === 'new'){
$("#group_by").html('');
var dataDefault = '<?php echo json_encode($valuesGroupByDefaultAlertActions); ?>';
Object.entries(JSON.parse(dataDefault)).forEach(function (item) {
option = $("<option></option>")
.attr ("value", item[0])
.html (item[1]);
$("#group_by").append(option);
});
$("#lapse_select").attr('disabled', false);
$("#lapse_select").val('0').trigger('change');
$("#hidden-lapse").val('0');
}
break;
case 'event_report_group': case 'event_report_group':
$("#row_description").show(); $("#row_description").show();
$("#row_period").show(); $("#row_period").show();
@ -6319,6 +6597,11 @@ function chooseType() {
} else { } else {
$("#row_profiles_group").hide(); $("#row_profiles_group").hide();
} }
break;
case 'ncm':
$("#row_agent").show();
break;
} }

View File

@ -1676,22 +1676,77 @@ switch ($action) {
break; break;
case 'agent_module': case 'agent_module':
$agents_to_report = get_parameter('id_agents2'); $agents_to_report_text = get_parameter('id_agents2-multiple-text', '');
$modules_to_report = get_parameter( $modules_to_report_text = get_parameter('module-multiple-text', '');
'module',
'' // Decode json check modules.
$agents_to_report = json_decode(
io_safe_output($agents_to_report_text),
true
);
$modules_to_report = json_decode(
io_safe_output($modules_to_report_text),
true
); );
$es['module'] = get_same_modules( $es['module'] = get_same_modules_all(
$agents_to_report, $agents_to_report,
$modules_to_report $modules_to_report
); );
$es['id_agents'] = $agents_to_report;
// Encode json modules and agents.
$es['module'] = base64_encode(json_encode($es['module']));
$es['id_agents'] = base64_encode(json_encode($agents_to_report));
$values['external_source'] = json_encode($es); $values['external_source'] = json_encode($es);
$good_format = true; $good_format = true;
break; break;
case 'alert_report_actions':
$alert_templates_to_report = get_parameter('alert_templates');
$alert_actions_to_report = get_parameter('alert_actions');
$show_summary = get_parameter('show_summary', 0);
$group_by = get_parameter('group_by');
$only_data = get_parameter('only_data', 0);
$agents_to_report_text = get_parameter('id_agents2-multiple-text');
$modules_to_report_text = get_parameter('module-multiple-text', '');
// Decode json check modules.
$agents_to_report = json_decode(
io_safe_output($agents_to_report_text),
true
);
$modules_to_report = json_decode(
io_safe_output($modules_to_report_text),
true
);
$es['module'] = get_same_modules_all(
$agents_to_report,
$modules_to_report
);
// Encode json modules and agents.
$es['module'] = base64_encode(json_encode($es['module']));
$es['id_agents'] = base64_encode(json_encode($agents_to_report));
$es['templates'] = $alert_templates_to_report;
$es['actions'] = $alert_actions_to_report;
$es['show_summary'] = $show_summary;
$es['group_by'] = $group_by;
$es['only_data'] = $only_data;
$values['external_source'] = json_encode($es);
$values['period'] = get_parameter('period');
$values['lapse_calc'] = get_parameter(
'lapse_calc'
);
$values['lapse'] = get_parameter('lapse');
$good_format = true;
break;
case 'inventory': case 'inventory':
$values['period'] = 0; $values['period'] = 0;
$es['date'] = get_parameter('date'); $es['date'] = get_parameter('date');
@ -2422,22 +2477,78 @@ switch ($action) {
break; break;
case 'agent_module': case 'agent_module':
$agents_to_report = get_parameter('id_agents2'); $agents_to_report_text = get_parameter('id_agents2-multiple-text');
$modules_to_report = get_parameter( $modules_to_report_text = get_parameter('module-multiple-text', '');
'module',
'' // Decode json check modules.
$agents_to_report = json_decode(
io_safe_output($agents_to_report_text),
true
);
$modules_to_report = json_decode(
io_safe_output($modules_to_report_text),
true
); );
$es['module'] = get_same_modules( $es['module'] = get_same_modules_all(
$agents_to_report, $agents_to_report,
$modules_to_report $modules_to_report
); );
$es['id_agents'] = $agents_to_report;
// Encode json modules and agents.
$es['module'] = base64_encode(json_encode($es['module']));
$es['id_agents'] = base64_encode(json_encode($agents_to_report));
$values['external_source'] = json_encode($es); $values['external_source'] = json_encode($es);
$good_format = true; $good_format = true;
break; break;
case 'alert_report_actions':
$alert_templates_to_report = get_parameter('alert_templates');
$alert_actions_to_report = get_parameter('alert_actions');
$show_summary = get_parameter('show_summary', 0);
$group_by = get_parameter('group_by');
$only_data = get_parameter('only_data', 0);
$agents_to_report_text = get_parameter('id_agents2-multiple-text');
$modules_to_report_text = get_parameter('module-multiple-text', '');
// Decode json check modules.
$agents_to_report = json_decode(
io_safe_output($agents_to_report_text),
true
);
$modules_to_report = json_decode(
io_safe_output($modules_to_report_text),
true
);
$es['module'] = get_same_modules_all(
$agents_to_report,
$modules_to_report
);
// Encode json modules and agents.
$es['module'] = base64_encode(json_encode($es['module']));
$es['id_agents'] = base64_encode(json_encode($agents_to_report));
$es['templates'] = $alert_templates_to_report;
$es['actions'] = $alert_actions_to_report;
$es['show_summary'] = $show_summary;
$es['group_by'] = $group_by;
$es['only_data'] = $only_data;
$values['external_source'] = json_encode($es);
$values['period'] = get_parameter('period');
$values['lapse_calc'] = get_parameter(
'lapse_calc'
);
$values['lapse'] = get_parameter('lapse');
$good_format = true;
break;
case 'inventory_changes': case 'inventory_changes':
$values['period'] = get_parameter('period'); $values['period'] = get_parameter('period');
$es['id_agents'] = get_parameter('id_agents'); $es['id_agents'] = get_parameter('id_agents');

View File

@ -60,6 +60,7 @@ if (is_ajax()) {
$table->data['fallback_local_auth'] = $row; $table->data['fallback_local_auth'] = $row;
if (enterprise_installed()) { if (enterprise_installed()) {
$is_management_allowed = is_management_allowed();
// Autocreate remote users. // Autocreate remote users.
$row = []; $row = [];
$row['name'] = __('Autocreate remote users'); $row['name'] = __('Autocreate remote users');
@ -67,7 +68,7 @@ if (is_ajax()) {
'autocreate_remote_users', 'autocreate_remote_users',
1, 1,
$config['autocreate_remote_users'], $config['autocreate_remote_users'],
false, (is_metaconsole() === false) ? !$is_management_allowed : false,
'', '',
'', '',
true true

View File

@ -835,7 +835,7 @@ class Client
function ($carry, $item) { function ($carry, $item) {
$matches = []; $matches = [];
if (is_array($item) !== true if (is_array($item) !== true
&& preg_match('/(\d+)\.tar/', $item, $matches) > 0 && preg_match('/([\d\.\d]+?)\.tar/', $item, $matches) > 0
) { ) {
$carry[] = [ $carry[] = [
'version' => $matches[1], 'version' => $matches[1],

View File

@ -75,8 +75,8 @@ class RepoDisk extends Repo
$this->files = []; $this->files = [];
while ($file_name = readdir($dh)) { while ($file_name = readdir($dh)) {
// Files must contain a version number. // Files must contain a version number.
if (preg_match('/(\d+)\_x86_64.'.$this->extension.'$/', $file_name, $utimestamp) === 1 if (preg_match('/([\d\.]+?)\_x86_64.'.$this->extension.'$/', $file_name, $utimestamp) === 1
|| preg_match('/(\d+)\.'.$this->extension.'$/', $file_name, $utimestamp) === 1 || preg_match('/([\d\.]+?)\.'.$this->extension.'$/', $file_name, $utimestamp) === 1
) { ) {
// Add the file to the repository. // Add the file to the repository.
$this->files[$utimestamp[1]] = $file_name; $this->files[$utimestamp[1]] = $file_name;

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -83,10 +83,10 @@ $in_process_event = get_parameter('in_process_event', 0);
$validate_event = get_parameter('validate_event', 0); $validate_event = get_parameter('validate_event', 0);
$delete_event = get_parameter('delete_event', 0); $delete_event = get_parameter('delete_event', 0);
$get_event_filters = get_parameter('get_event_filters', 0); $get_event_filters = get_parameter('get_event_filters', 0);
$get_comments = get_parameter('get_comments', 0); $get_comments = (bool) get_parameter('get_comments', false);
$get_events_fired = (bool) get_parameter('get_events_fired'); $get_events_fired = (bool) get_parameter('get_events_fired');
$get_id_source_event = get_parameter('get_id_source_event'); $get_id_source_event = get_parameter('get_id_source_event');
if ($get_comments) { if ($get_comments === true) {
$event = get_parameter('event', false); $event = get_parameter('event', false);
$filter = get_parameter('filter', false); $filter = get_parameter('filter', false);
@ -94,6 +94,8 @@ if ($get_comments) {
return __('Failed to retrieve comments'); return __('Failed to retrieve comments');
} }
$eventsGrouped = [];
if ($filter['group_rep'] == 1) { if ($filter['group_rep'] == 1) {
$events = events_get_all( $events = events_get_all(
['te.*'], ['te.*'],
@ -119,23 +121,52 @@ if ($get_comments) {
// True for show comments of validated events. // True for show comments of validated events.
true true
); );
if ($events !== false) { if ($events !== false) {
$event = $events[0]; $event = $events[0];
} }
} else { } else {
$events = events_get_event( // Consider if the event is grouped.
$event['id_evento'], if (isset($event['event_rep']) === true && $event['event_rep'] > 0) {
false, // Evaluate if we are in metaconsole or not.
$meta, $eventTable = (is_metaconsole() === true) ? 'tmetaconsole_event' : 'tevento';
$history // Default grouped message filtering (evento and estado).
); $whereGrouped = sprintf(
'`evento` = "%s" AND `estado` = "%s"',
io_safe_output($event['evento']),
$event['estado']
);
// If id_agente is reported, filter the messages by them as well.
if ((int) $event['id_agente'] > 0) {
$whereGrouped .= sprintf(' AND `id_agente` = "%s"', $event['id_agente']);
}
if ($events !== false) { // Get grouped comments.
$event = $events; $eventsGrouped = db_get_all_rows_sql(
sprintf(
'SELECT `user_comment`
FROM `%s`
WHERE %s',
$eventTable,
$whereGrouped
)
);
} else {
$events = events_get_event(
$event['id_evento'],
false,
is_metaconsole(),
$history
);
if ($events !== false) {
$event = $events;
}
} }
} }
echo events_page_comments($event, true); // End of get_comments.
echo events_page_comments($event, true, $eventsGrouped);
return; return;
} }
@ -1207,26 +1238,19 @@ if ($dialogue_event_response) {
} }
} }
if ($add_comment) { if ($add_comment === true) {
$aviability_comment = true; $comment = (string) get_parameter('comment');
$comment = get_parameter('comment'); $eventId = (int) get_parameter('event_id');
// Safe comments for hacks.
if (preg_match('/script/i', io_safe_output($comment))) { if (preg_match('/script/i', io_safe_output($comment))) {
$aviability_comment = false;
$return = false; $return = false;
}
$event_id = get_parameter('event_id');
if ($aviability_comment !== false) {
$return = events_comment($event_id, $comment, 'Added comment', $meta, $history);
}
if ($return) {
echo 'comment_ok';
} else { } else {
echo 'comment_error'; $return = events_comment($eventId, $comment, 'Added comment', $meta, $history);
} }
echo ($return === true) ? 'comment_ok' : 'comment_error';
return; return;
} }
@ -1309,6 +1333,14 @@ if ($get_extended_event) {
&& isset($config['event_replication']) && isset($config['event_replication'])
&& $config['event_replication'] == 1 && $config['event_replication'] == 1
&& $config['show_events_in_local'] == 1 && $config['show_events_in_local'] == 1
|| enterprise_hook(
'enterprise_acl',
[
$config['id_user'],
'eventos',
'execute_event_responses',
]
) === false
) { ) {
$readonly = true; $readonly = true;
} }
@ -1330,6 +1362,10 @@ if ($get_extended_event) {
$timestamp_first = $event['min_timestamp']; $timestamp_first = $event['min_timestamp'];
$timestamp_last = $event['max_timestamp']; $timestamp_last = $event['max_timestamp'];
$server_id = $event['server_id']; $server_id = $event['server_id'];
if (empty($server_id) && !empty($event['server_name']) && is_metaconsole()) {
$server_id = metaconsole_get_id_server($event['server_name']);
}
$comments = $event['comments']; $comments = $event['comments'];
$event['similar_ids'] = $similar_ids; $event['similar_ids'] = $similar_ids;
@ -1505,7 +1541,7 @@ if ($get_extended_event) {
$console_url = ''; $console_url = '';
// If metaconsole switch to node to get details and custom fields. // If metaconsole switch to node to get details and custom fields.
if ($meta) { if ($meta || (is_metaconsole() && !empty($server_id))) {
$server = metaconsole_get_connection_by_id($server_id); $server = metaconsole_get_connection_by_id($server_id);
} else { } else {
$server = ''; $server = '';
@ -1518,7 +1554,7 @@ if ($get_extended_event) {
} }
$connected = true; $connected = true;
if ($meta) { if ($meta || (is_metaconsole() && !empty($server_id))) {
if (metaconsole_connect($server) === NOERR) { if (metaconsole_connect($server) === NOERR) {
$connected = true; $connected = true;
} else { } else {

View File

@ -1441,6 +1441,10 @@ class AgentWizard extends HTML
$result[$value]['criticalInv'] = $data[$k]; $result[$value]['criticalInv'] = $data[$k];
} else if (empty(preg_match('/module-warning-inv/', $k)) === false) { } else if (empty(preg_match('/module-warning-inv/', $k)) === false) {
$result[$value]['warningInv'] = $data[$k]; $result[$value]['warningInv'] = $data[$k];
} else if (empty(preg_match('/module-warning-perc/', $k)) === false) {
$result[$value]['warningPerc'] = $data[$k.'_sent'];
} else if (empty(preg_match('/module-critical-perc/', $k)) === false) {
$result[$value]['criticalPerc'] = $data[$k.'_sent'];
} else if (empty(preg_match('/module-type/', $k)) === false) { } else if (empty(preg_match('/module-type/', $k)) === false) {
$result[$value]['moduleType'] = $data[$k]; $result[$value]['moduleType'] = $data[$k];
} else if (empty(preg_match('/module-unit/', $k)) === false) { } else if (empty(preg_match('/module-unit/', $k)) === false) {
@ -1856,6 +1860,8 @@ class AgentWizard extends HTML
$values['max_warning'] = $candidate['warningMax']; $values['max_warning'] = $candidate['warningMax'];
$values['min_critical'] = $candidate['criticalMin']; $values['min_critical'] = $candidate['criticalMin'];
$values['max_critical'] = $candidate['criticalMax']; $values['max_critical'] = $candidate['criticalMax'];
$values['percentage_warning'] = $candidate['warningPerc'];
$values['percentage_critical'] = $candidate['criticalPerc'];
} }
$values['warning_inverse'] = $candidate['warningInv']; $values['warning_inverse'] = $candidate['warningInv'];
@ -2292,6 +2298,8 @@ class AgentWizard extends HTML
$tmp->max_warning($candidate['warningMax']); $tmp->max_warning($candidate['warningMax']);
$tmp->min_critical($candidate['criticalMin']); $tmp->min_critical($candidate['criticalMin']);
$tmp->max_critical($candidate['criticalMax']); $tmp->max_critical($candidate['criticalMax']);
$tmp->percentage_warning($candidate['warningPerc']);
$tmp->percentage_critical($candidate['criticalPerc']);
} }
$tmp->warning_inverse($candidate['warningInv']); $tmp->warning_inverse($candidate['warningInv']);
@ -2457,6 +2465,8 @@ class AgentWizard extends HTML
'min_critical' => $moduleData['module_thresholds']['min_critical'], 'min_critical' => $moduleData['module_thresholds']['min_critical'],
'max_critical' => $moduleData['module_thresholds']['max_critical'], 'max_critical' => $moduleData['module_thresholds']['max_critical'],
'inv_critical' => $moduleData['module_thresholds']['inv_critical'], 'inv_critical' => $moduleData['module_thresholds']['inv_critical'],
'perc_warning' => $moduleData['module_thresholds']['perc_warning'],
'perc_critical' => $moduleData['module_thresholds']['perc_critical'],
'module_enabled' => $moduleData['default_enabled'], 'module_enabled' => $moduleData['default_enabled'],
'name_oid' => $moduleData['value'], 'name_oid' => $moduleData['value'],
'value' => $moduleData['value'], 'value' => $moduleData['value'],
@ -2636,6 +2646,8 @@ class AgentWizard extends HTML
'min_critical' => $moduleData['module_thresholds']['min_critical'], 'min_critical' => $moduleData['module_thresholds']['min_critical'],
'max_critical' => $moduleData['module_thresholds']['max_critical'], 'max_critical' => $moduleData['module_thresholds']['max_critical'],
'inv_critical' => $moduleData['module_thresholds']['inv_critical'], 'inv_critical' => $moduleData['module_thresholds']['inv_critical'],
'perc_warning' => $moduleData['module_thresholds']['perc_warning'],
'perc_critical' => $moduleData['module_thresholds']['perc_critical'],
'module_enabled' => $moduleData['module_enabled'], 'module_enabled' => $moduleData['module_enabled'],
'current_value' => $currentValue, 'current_value' => $currentValue,
'name_oid' => $moduleData['value'], 'name_oid' => $moduleData['value'],
@ -3280,6 +3292,8 @@ class AgentWizard extends HTML
nc.min_critical, nc.min_critical,
nc.max_critical, nc.max_critical,
nc.critical_inverse AS `inv_critical`, nc.critical_inverse AS `inv_critical`,
nc.percentage_warning AS `perc_warning`,
nc.percentage_critical AS `perc_critical`,
nc.module_enabled, nc.module_enabled,
%s, %s,
nc.scan_type, nc.scan_type,
@ -3867,9 +3881,11 @@ class AgentWizard extends HTML
$table->width = '100%'; $table->width = '100%';
$table->class = 'info_table'; $table->class = 'info_table';
// Subheaders for Warning and Critical columns. // Subheaders for Warning and Critical columns.
$subheaders = '<span class=\'font_w300 mrgn_lft_0.8em\'>Min.</span>'; $subheaders = '<span class=\'wizard-colum-levels font_w300 mrgn_lft_0.8em\'>Min.</span>';
$subheaders .= '<span class=\'font_w300 mrgn_lft_1.6em\'>Max.</span>'; $subheaders .= '<span class=\'wizard-colum-levels font_w300 mrgn_lft_1.6em\'>Max.</span>';
$subheaders .= '<span class=\'font_w300 mrgn_lft_2em\'>Inv.</span>'; $subheaders .= '<span class=\'wizard-colum-levels font_w300 mrgn_lft_2em\'>Inv.</span>';
$subheaders .= '<span class=\'wizard-colum-levels font_w300 mrgn_lft_2em\'>%.</span>';
// Warning header. // Warning header.
$warning_header = html_print_div( $warning_header = html_print_div(
[ [
@ -4081,7 +4097,7 @@ class AgentWizard extends HTML
); );
$data_warning .= html_print_div( $data_warning .= html_print_div(
[ [
'class' => 'wizard-column-levels', 'class' => 'wizard-column-levels-check',
'style' => 'margin-top: 0.3em;', 'style' => 'margin-top: 0.3em;',
'content' => html_print_checkbox( 'content' => html_print_checkbox(
'module-warning-inv-'.$uniqueId, 'module-warning-inv-'.$uniqueId,
@ -4089,7 +4105,24 @@ class AgentWizard extends HTML
$module['inv_warning'], $module['inv_warning'],
true, true,
false, false,
'', 'change_control(this, \''.$uniqueId.'\')',
false,
'form="form-create-modules"'
),
],
true
);
$data_warning .= html_print_div(
[
'class' => 'wizard-column-levels-check',
'style' => 'margin-top: 0.3em;',
'content' => html_print_checkbox(
'module-warning-perc-'.$uniqueId,
$module['perc_warning'],
$module['perc_warning'],
true,
false,
'change_control(this, \''.$uniqueId.'\')',
false, false,
'form="form-create-modules"' 'form="form-create-modules"'
), ),
@ -4148,15 +4181,33 @@ class AgentWizard extends HTML
$data[4] .= html_print_div( $data[4] .= html_print_div(
[ [
'class' => 'wizard-column-levels', 'class' => 'wizard-column-levels-check',
'style' => 'margin-top: 0.3em;', 'style' => 'margin-top: 0.3em;',
'content' => html_print_checkbox( 'content' => html_print_checkbox(
'module-critical_inv_'.$uniqueId, 'module-critical-inv-'.$uniqueId,
$module['inv_critical'], $module['inv_critical'],
$module['inv_critical'], $module['inv_critical'],
true, true,
false, false,
'', 'change_control(this, \''.$uniqueId.'\')',
false,
'form="form-create-modules"'
),
],
true
);
$data[4] .= html_print_div(
[
'class' => 'wizard-column-levels-check',
'style' => 'margin-top: 0.3em;',
'content' => html_print_checkbox(
'module-critical-perc-'.$uniqueId,
$module['perc_critical'],
$module['perc_critical'],
true,
false,
'change_control(this,\''.$uniqueId.'\')',
false, false,
'form="form-create-modules"' 'form="form-create-modules"'
), ),
@ -4528,12 +4579,14 @@ class AgentWizard extends HTML
'default_enabled' => true, 'default_enabled' => true,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => $min_warning, 'min_warning' => $min_warning,
'max_warning' => $max_warning, 'max_warning' => $max_warning,
'inv_warning' => $inv_warning, 'inv_warning' => $inv_warning,
'min_critical' => $min_critical, 'min_critical' => $min_critical,
'max_critical' => $max_critical, 'max_critical' => $max_critical,
'inv_critical' => $inv_critical, 'inv_critical' => $inv_critical,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
@ -4583,12 +4636,14 @@ class AgentWizard extends HTML
'default_enabled' => true, 'default_enabled' => true,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
@ -4635,12 +4690,14 @@ class AgentWizard extends HTML
'default_enabled' => true, 'default_enabled' => true,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => $minc, 'min_critical' => $minc,
'max_critical' => $maxc, 'max_critical' => $maxc,
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
} }
@ -4723,12 +4780,14 @@ class AgentWizard extends HTML
'module_enabled' => false, 'module_enabled' => false,
'module_unit' => '%', 'module_unit' => '%',
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '85', 'min_critical' => '85',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
@ -4760,12 +4819,14 @@ class AgentWizard extends HTML
'module_enabled' => false, 'module_enabled' => false,
'module_unit' => '%', 'module_unit' => '%',
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
@ -4797,12 +4858,14 @@ class AgentWizard extends HTML
'module_enabled' => false, 'module_enabled' => false,
'module_unit' => '%', 'module_unit' => '%',
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
} }
@ -4826,12 +4889,14 @@ class AgentWizard extends HTML
'default_enabled' => false, 'default_enabled' => false,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
// IfInDiscards. // IfInDiscards.
@ -4851,12 +4916,14 @@ class AgentWizard extends HTML
'default_enabled' => false, 'default_enabled' => false,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
// IfOutDiscards. // IfOutDiscards.
@ -4876,12 +4943,14 @@ class AgentWizard extends HTML
'default_enabled' => false, 'default_enabled' => false,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
// IfInErrors. // IfInErrors.
@ -4901,12 +4970,14 @@ class AgentWizard extends HTML
'default_enabled' => false, 'default_enabled' => false,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
// IfOutErrors. // IfOutErrors.
@ -4926,12 +4997,14 @@ class AgentWizard extends HTML
'default_enabled' => false, 'default_enabled' => false,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
@ -4994,12 +5067,14 @@ class AgentWizard extends HTML
'default_enabled' => true, 'default_enabled' => true,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
@ -5020,12 +5095,14 @@ class AgentWizard extends HTML
'default_enabled' => true, 'default_enabled' => true,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
@ -5046,12 +5123,14 @@ class AgentWizard extends HTML
'default_enabled' => false, 'default_enabled' => false,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
// IfOutUcastPkts. // IfOutUcastPkts.
@ -5071,12 +5150,14 @@ class AgentWizard extends HTML
'default_enabled' => false, 'default_enabled' => false,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
// IfInNUcastPkts. // IfInNUcastPkts.
@ -5096,12 +5177,14 @@ class AgentWizard extends HTML
'default_enabled' => false, 'default_enabled' => false,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
// IfOutNUcastPkts. // IfOutNUcastPkts.
@ -5121,12 +5204,14 @@ class AgentWizard extends HTML
'default_enabled' => false, 'default_enabled' => false,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
@ -5189,12 +5274,14 @@ class AgentWizard extends HTML
'default_enabled' => true, 'default_enabled' => true,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
@ -5215,12 +5302,14 @@ class AgentWizard extends HTML
'default_enabled' => true, 'default_enabled' => true,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
@ -5241,12 +5330,14 @@ class AgentWizard extends HTML
'default_enabled' => false, 'default_enabled' => false,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
@ -5267,12 +5358,14 @@ class AgentWizard extends HTML
'default_enabled' => false, 'default_enabled' => false,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
// IfHCInNUcastPkts. // IfHCInNUcastPkts.
@ -5292,12 +5385,14 @@ class AgentWizard extends HTML
'default_enabled' => false, 'default_enabled' => false,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
// IfOutNUcastPkts. // IfOutNUcastPkts.
@ -5317,12 +5412,14 @@ class AgentWizard extends HTML
'default_enabled' => false, 'default_enabled' => false,
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
'max_warning' => '0', 'max_warning' => '0',
'inv_warning' => false, 'inv_warning' => false,
'min_critical' => '0', 'min_critical' => '0',
'max_critical' => '0', 'max_critical' => '0',
'inv_critical' => false, 'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
], ],
]; ];
@ -5825,6 +5922,29 @@ class AgentWizard extends HTML
}); });
} }
function change_control(checkbox, uniqueId) {
var checkbox_name = $(checkbox).attr('name');
if($(checkbox).prop('checked', true)) {
if(checkbox_name.match(/warning-inv/gm) !== null) {
$('#checkbox-module-warning-perc-'+uniqueId).prop('checked', false);
}
if(checkbox_name.match(/critical-inv/gm) !== null) {
$('#checkbox-module-critical-perc-'+uniqueId).prop('checked', false);
}
if(checkbox_name.match(/warning-perc/gm) !== null) {
$('#checkbox-module-warning-inv-'+uniqueId).prop('checked', false);
}
if(checkbox_name.match(/critical-perc/gm) !== null) {
$('#checkbox-module-critical-inv-'+uniqueId).prop('checked', false);
}
}
}
</script> </script>
<?php <?php
$str = ob_get_clean(); $str = ob_get_clean();

View File

@ -0,0 +1,410 @@
<?php
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
/**
* Controller for Audit Logs
*
* @category Controller
* @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.
* ============================================================================
*/
// Begin.
global $config;
// Necessary classes for extends.
require_once $config['homedir'].'/include/class/HTML.class.php';
enterprise_include_once('godmode/admin_access_logs.php');
/**
* Class AuditLog
*/
class AuditLog extends HTML
{
/**
* Allowed methods to be called using AJAX request.
*
* @var array
*/
public $AJAXMethods = [ 'draw' ];
/**
* Ajax page.
*
* @var string
*/
private $ajaxController;
/**
* Class constructor
*
* @param string $ajaxController Ajax controller.
*/
public function __construct(string $ajaxController)
{
global $config;
check_login();
if (check_acl($config['id_user'], 0, 'PM') === false
&& is_user_admin($config['id_user']) === true
) {
db_pandora_audit(
'ACL Violation',
'Trying to access Audit Logs'
);
include 'general/noaccess.php';
return;
}
// Set the ajax controller.
$this->ajaxController = $ajaxController;
}
/**
* Run view
*
* @return void
*/
public function run()
{
// Javascript.
ui_require_jquery_file('pandora');
// CSS.
ui_require_css_file('wizard');
ui_require_css_file('discovery');
// Datatables list.
try {
$columns = [
'id_usuario',
'accion',
'fecha',
'ip_origen',
'descripcion',
];
$column_names = [
__('User'),
__('Action'),
__('Date'),
__('Source IP'),
__('Comments'),
];
if (enterprise_installed() === true) {
array_push(
$columns,
[
'text' => 'security',
'class' => 'w80px action_buttons show_security_info',
],
[
'text' => 'action',
'class' => 'w80px action_buttons show_extended_info',
]
);
array_push($column_names, __('S.'), __('A.'));
}
$this->tableId = 'audit_logs';
// Header (only in Node).
if (is_metaconsole() === false) {
ui_print_standard_header(
__('%s audit', get_product_name()).' &raquo; '.__('Review Logs'),
'images/gm_log.png',
false,
'',
false,
[],
[
[
'link' => '',
'label' => __('Admin Tools'),
],
[
'link' => '',
'label' => __('System Audit log'),
],
]
);
}
if (is_metaconsole() === true) {
// Only in case of Metaconsole, format the frame.
open_meta_frame();
}
// Load datatables user interface.
ui_print_datatable(
[
'id' => $this->tableId,
'class' => 'info_table',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => $this->ajaxController,
'ajax_data' => ['method' => 'draw'],
'ajax_postprocces' => 'process_datatables_item(item)',
'no_sortable_columns' => [-1],
'order' => [
'field' => 'date',
'direction' => 'asc',
],
'search_button_class' => 'sub filter float-right',
'form' => [
'inputs' => [
[
'label' => __('Search'),
'type' => 'text',
'class' => 'w200px',
'id' => 'filter_text',
'name' => 'filter_text',
],
[
'label' => __('Max. hours old'),
'type' => 'text',
'class' => 'w100px',
'id' => 'filter_period',
'name' => 'filter_period',
],
[
'label' => __('IP'),
'type' => 'text',
'class' => 'w100px',
'id' => 'filter_ip',
'name' => 'filter_ip',
],
[
'label' => __('Action'),
'type' => 'select_from_sql',
'nothing' => __('All'),
'nothing_value' => '-1',
'sql' => 'SELECT DISTINCT(accion), accion AS text FROM tsesion',
'class' => 'mw250px',
'id' => 'filter_type',
'name' => 'filter_type',
],
[
'label' => __('User'),
'type' => 'select_from_sql',
'nothing' => __('All'),
'nothing_value' => '-1',
'sql' => 'SELECT id_user, id_user AS text FROM tusuario',
'class' => 'mw250px',
'id' => 'filter_user',
'name' => 'filter_user',
],
],
],
]
);
} catch (Exception $e) {
echo $e->getMessage();
}
if (is_metaconsole() === true) {
// Close the frame.
close_meta_frame();
}
// Load own javascript file.
echo $this->loadJS();
}
/**
* Get the data for draw the table.
*
* @return void.
*/
public function draw()
{
global $config;
// Initialice filter.
$filter = '1=1';
// Init data.
$data = [];
// Count of total records.
$count = 0;
// Catch post parameters.
$start = get_parameter('start', 0);
$length = get_parameter('length', $config['block_size']);
$order = get_datatable_order();
$filters = get_parameter('filter', []);
$this->filterType = $filters['filter_type'];
$this->filterUser = $filters['filter_user'];
$this->filterText = $filters['filter_text'];
$this->filterPeriod = (empty($filters['filter_period']) === false) ? $filters['filter_period'] : 24;
$this->filterIp = $filters['filter_ip'];
if (empty($this->filterType) === false && $this->filterType !== '-1') {
$filter .= sprintf(" AND accion = '%s'", $this->filterType);
}
if (empty($this->filterUser) === false && $this->filterUser !== '-1') {
$filter .= sprintf(" AND id_usuario = '%s'", $this->filterUser);
}
if (empty($this->filterText) === false) {
$filter .= sprintf(
" AND (accion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%')",
$this->filterText,
$this->filterText
);
}
if (empty($this->filterIp) === false) {
$filter .= sprintf(" AND ip_origen LIKE '%%%s%%'", $this->filterIp);
}
if (empty($this->filterPeriod) === false) {
$filter .= sprintf(' AND fecha >= DATE_ADD(NOW(), INTERVAL -%d HOUR)', $this->filterPeriod);
}
$count = (int) db_get_value_sql(sprintf('SELECT COUNT(*) as "total" FROM tsesion WHERE %s', $filter));
$sql = sprintf(
'SELECT *
FROM tsesion
WHERE %s
ORDER BY %s
LIMIT %d, %d',
$filter,
$order,
$start,
$length
);
$data = db_get_all_rows_sql($sql);
if (empty($data) === false) {
$data = array_reduce(
$data,
function ($carry, $item) {
global $config;
// Transforms array of arrays $data into an array
// of objects, making a post-process of certain fields.
$tmp = (object) $item;
$tmp->id_usuario = io_safe_output($tmp->id_usuario);
$tmp->ip_origen = io_safe_output($tmp->ip_origen);
$tmp->descripcion = io_safe_output($tmp->descripcion);
$tmp->accion = ui_print_session_action_icon($tmp->accion, true).$tmp->accion;
$tmp->utimestamp = ui_print_help_tip(
date(
$config['date_format'],
$tmp->utimestamp
),
true
).ui_print_timestamp($tmp->utimestamp, true);
if (enterprise_installed() === true) {
$tmp->security = enterprise_hook('cell1EntepriseAudit', [$tmp->id_sesion]);
$tmp->action = enterprise_hook('cell2EntepriseAudit', []);
$tmp->extendedInfo = enterprise_hook('rowEnterpriseAudit', [$tmp->id_sesion]);
}
$carry[] = $tmp;
return $carry;
}
);
}
echo json_encode(
[
'data' => $data,
'recordsTotal' => $count,
'recordsFiltered' => $count,
]
);
}
/**
* 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)
{
return in_array($method, $this->AJAXMethods);
}
/**
* Load Javascript code.
*
* @return string.
*/
public function loadJS()
{
// Nothing for this moment.
ob_start();
// Javascript content.
?>
<script type="text/javascript">
function format ( d ) {
var output = '';
if (d.extendedInfo === '') {
output = "<?php echo __('There is no additional information to display'); ?>";
} else {
output = d.extendedInfo;
}
return output;
}
$(document).ready(function() {
// Add event listener for opening and closing details
$('#audit_logs tbody').on('click', 'td.show_extended_info', function () {
var tr = $(this).closest('tr');
var table = <?php echo 'dt_'.$this->tableId; ?>;
var row = table.row( tr );
if ( row.child.isShown() ) {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
}
else {
// Open this row
row.child( format(row.data()) ).show();
tr.addClass('shown');
}
} );
} );
</script>
<?php
// EOF Javascript content.
return ob_get_clean();
}
}

View File

@ -3409,6 +3409,15 @@ class NetworkMap
$output .= '<link rel="stylesheet" type="text/css" href="'.ui_get_full_url( $output .= '<link rel="stylesheet" type="text/css" href="'.ui_get_full_url(
'include/styles/tooltipster.bundle.min.css' 'include/styles/tooltipster.bundle.min.css'
).'" />'."\n"; ).'" />'."\n";
ui_require_css_file('jquery.contextMenu', 'include/styles/js/');
$output .= '<script type="text/javascript" src="';
$output .= ui_get_full_url(
'include/javascript/jquery.contextMenu.js',
false,
false,
false
);
$output .= '" charset="utf-8"></script>';
$output .= '<div id="simple_map" data-id="'.$this->idMap.'" '; $output .= '<div id="simple_map" data-id="'.$this->idMap.'" ';
$output .= 'class="border_1px_dd" style="'; $output .= 'class="border_1px_dd" style="';

View File

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

View File

@ -368,12 +368,15 @@ define('MODULE_WUX', 8);
define('MODULE_WIZARD', 9); define('MODULE_WIZARD', 9);
// Type of Modules of Prediction. // Type of Modules of Prediction.
define('MODULE_PREDICTION_PLANNING', 1);
define('MODULE_PREDICTION_SERVICE', 2); define('MODULE_PREDICTION_SERVICE', 2);
define('MODULE_PREDICTION_SYNTHETIC', 3); define('MODULE_PREDICTION_SYNTHETIC', 3);
define('MODULE_PREDICTION_NETFLOW', 4); define('MODULE_PREDICTION_NETFLOW', 4);
define('MODULE_PREDICTION_CLUSTER', 5); define('MODULE_PREDICTION_CLUSTER', 5);
define('MODULE_PREDICTION_CLUSTER_AA', 6); define('MODULE_PREDICTION_CLUSTER_AA', 6);
define('MODULE_PREDICTION_CLUSTER_AP', 7); define('MODULE_PREDICTION_CLUSTER_AP', 7);
define('MODULE_PREDICTION_TRENDING', 8);
// Forced agent OS ID for cluster agents. // Forced agent OS ID for cluster agents.
define('CLUSTER_OS_ID', 100); define('CLUSTER_OS_ID', 100);
@ -453,6 +456,8 @@ define('REPORT_ITEM_ORDER_BY_ASCENDING', 2);
define('REPORT_ITEM_ORDER_BY_DESCENDING', 1); define('REPORT_ITEM_ORDER_BY_DESCENDING', 1);
define('REPORT_ITEM_ORDER_BY_UNSORT', 0); define('REPORT_ITEM_ORDER_BY_UNSORT', 0);
define('REPORT_ITEM_DYNAMIC_HEIGHT', 230);
define('REPORT_OLD_TYPE_SIMPLE_GRAPH', 1); define('REPORT_OLD_TYPE_SIMPLE_GRAPH', 1);
define('REPORT_OLD_TYPE_CUSTOM_GRAPH', 2); define('REPORT_OLD_TYPE_CUSTOM_GRAPH', 2);
define('REPORT_OLD_TYPE_SLA', 3); define('REPORT_OLD_TYPE_SLA', 3);

View File

@ -760,7 +760,11 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
if ($field[0] != '`') { if ($field[0] != '`') {
// If the field is as <table>.<field>, don't scape. // If the field is as <table>.<field>, don't scape.
if (strstr($field, '.') === false) { if (strstr($field, '.') === false) {
$field = '`'.$field.'`'; if (preg_match('/(UPPER|LOWER)(.+)/mi', $field)) {
$field = preg_replace('/(UPPER|LOWER])\((.+)\)/mi', '$1(`$2`)', $field);
} else {
$field = '`'.$field.'`';
}
} }
} }
@ -774,8 +778,59 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
$not = (($negative === true) ? ' !' : ''); $not = (($negative === true) ? ' !' : '');
$query .= sprintf('%s %s= %f', $field, $not, $value); $query .= sprintf('%s %s= %f', $field, $not, $value);
} else if (is_array($value)) { } else if (is_array($value)) {
$not = (($negative === true) ? 'NOT' : ''); $values_check = array_keys($value);
$query .= sprintf('%s %s IN ("%s")', $field, $not, implode('", "', $value)); $ranges = false;
$initialized = false;
foreach ($values_check as $operation) {
if ($ranges === true && $initialized === true) {
$query .= ' '.$join.' ';
} else {
$initialized = true;
}
if ($operation === '>') {
$query .= sprintf("%s > '%s'", $field, $value[$operation]);
$ranges = true;
} else if ($operation === '>=') {
$query .= sprintf("%s >= '%s'", $field, $value[$operation]);
$ranges = true;
} else if ($operation === '<') {
$query .= sprintf("%s < '%s'", $field, $value[$operation]);
$ranges = true;
} else if ($operation === '<=') {
$query .= sprintf("%s <= '%s'", $field, $value[$operation]);
$ranges = true;
} else if ($operation === '!=') {
$query .= sprintf("%s != '%s'", $field, $value[$operation]);
$ranges = true;
} else if ($operation === '=') {
$query .= sprintf("%s = '%s'", $field, $value[$operation]);
$ranges = true;
} else if ($negative === true && $operation === '>') {
$query .= sprintf("%s <= '%s'", $field, $value[$operation]);
$ranges = true;
} else if ($negative === true && $operation === '>=') {
$query .= sprintf("%s < '%s'", $field, $value[$operation]);
$ranges = true;
} else if ($negative === true && $operation === '<') {
$query .= sprintf("%s >= '%s'", $field, $value[$operation]);
$ranges = true;
} else if ($negative === true && $operation === '<=') {
$query .= sprintf("%s > '%s'", $field, $value[$operation]);
$ranges = true;
} else if ($negative === true && $operation === '!=') {
$query .= sprintf("%s = '%s'", $field, $value[$operation]);
$ranges = true;
} else if ($negative === true && $operation === '=') {
$query .= sprintf("%s != '%s'", $field, $value[$operation]);
$ranges = true;
}
}
if ($ranges !== true) {
$not = (($negative === true) ? 'NOT' : '');
$query .= sprintf('%s %s IN ("%s")', $field, $not, implode('", "', $value));
}
} else { } else {
if ($value === '') { if ($value === '') {
// Search empty string. // Search empty string.
@ -1240,57 +1295,6 @@ function mysql_db_get_all_row_by_steps_sql($new=true, &$result, $sql=null)
} }
/**
* Starts a database transaction.
*/
function mysql_db_process_sql_begin()
{
global $config;
if ($config['mysqli']) {
mysqli_query($config['dbconnection'], 'SET AUTOCOMMIT = 0');
mysqli_query($config['dbconnection'], 'START TRANSACTION');
} else {
mysql_query('SET AUTOCOMMIT = 0');
mysql_query('START TRANSACTION');
}
}
/**
* Commits a database transaction.
*/
function mysql_db_process_sql_commit()
{
global $config;
if ($config['mysqli']) {
mysqli_query($config['dbconnection'], 'COMMIT');
mysqli_query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
} else {
mysql_query('COMMIT');
mysql_query('SET AUTOCOMMIT = 1');
}
}
/**
* Rollbacks a database transaction.
*/
function mysql_db_process_sql_rollback()
{
global $config;
if ($config['mysqli']) {
mysqli_query($config['dbconnection'], 'ROLLBACK ');
mysqli_query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
} else {
mysql_query('ROLLBACK ');
mysql_query('SET AUTOCOMMIT = 1');
}
}
/** /**
* Get last error. * Get last error.
* *
@ -1386,7 +1390,7 @@ function mysql_db_process_file($path, $handle_error=true)
$query = ''; $query = '';
// Begin the transaction // Begin the transaction
mysql_db_process_sql_begin(); db_process_sql_begin();
foreach ($file_content as $sql_line) { foreach ($file_content as $sql_line) {
if (trim($sql_line) != '' && strpos($sql_line, '--') === false) { if (trim($sql_line) != '' && strpos($sql_line, '--') === false) {
@ -1401,7 +1405,7 @@ function mysql_db_process_file($path, $handle_error=true)
if (!$result = $query_result) { if (!$result = $query_result) {
// Error. Rollback the transaction // Error. Rollback the transaction
mysql_db_process_sql_rollback(); db_process_sql_rollback();
if ($config['mysqli']) { if ($config['mysqli']) {
$error_message = mysqli_error($config['dbconnection']); $error_message = mysqli_error($config['dbconnection']);
@ -1438,7 +1442,7 @@ function mysql_db_process_file($path, $handle_error=true)
} }
// No errors. Commit the transaction // No errors. Commit the transaction
mysql_db_process_sql_commit(); db_process_sql_commit();
return true; return true;
} else { } else {
return false; return false;
@ -1477,7 +1481,7 @@ function db_run_sql_file($location)
$mysqli->query($config['dbconnection'], 'START TRANSACTION'); $mysqli->query($config['dbconnection'], 'START TRANSACTION');
} else { } else {
// Run commands // Run commands
mysql_db_process_sql_begin(); db_process_sql_begin();
// Begin transaction // Begin transaction
} }
@ -1503,7 +1507,7 @@ function db_run_sql_file($location)
$mysqli->query($config['dbconnection'], 'COMMIT'); $mysqli->query($config['dbconnection'], 'COMMIT');
$mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 1'); $mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
} else { } else {
mysql_db_process_sql_commit(); db_process_sql_commit();
// Save results // Save results
} }
@ -1513,7 +1517,7 @@ function db_run_sql_file($location)
$mysqli->query($config['dbconnection'], 'ROLLBACK '); $mysqli->query($config['dbconnection'], 'ROLLBACK ');
$mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 1'); $mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
} else { } else {
mysql_db_process_sql_rollback(); db_process_sql_rollback();
// Undo results // Undo results
} }

View File

@ -1234,6 +1234,7 @@ function get_event_types($id_type=false)
$types['system'] = __('System'); $types['system'] = __('System');
$types['error'] = __('Error'); $types['error'] = __('Error');
$types['configuration_change'] = __('Configuration change'); $types['configuration_change'] = __('Configuration change');
$types['ncm'] = __('Network configuration manager');
// This types are impersonated by the monitor 'x' types // This types are impersonated by the monitor 'x' types
// $types['going_up_normal'] = __('Going Normal'); // $types['going_up_normal'] = __('Going Normal');
@ -5965,3 +5966,24 @@ function send_test_email(
return $result; return $result;
} }
if (function_exists('str_contains') === false) {
/**
* Checks if $needle is found in $haystack and returns a boolean value.
* For lower than PHP8 versions.
*
* @param string $haystack The string who can have the needle.
* @param string $needle The needle.
*
* @return boolean True if haystack contains the needle.
*/
function str_contains(string $haystack, string $needle)
{
return $needle !== '' && mb_strpos($haystack, $needle) !== false;
}
}

View File

@ -733,6 +733,63 @@ function agents_get_agents(
} }
function agents_get_agents_selected($group)
{
if (is_metaconsole() === true) {
$all = agents_get_agents(
['id_grupo' => $group],
[
'id_tagente',
'id_tmetaconsole_setup',
'id_agente',
'alias',
],
'AR',
[
'field' => 'alias',
'order' => 'ASC',
],
false,
0,
true
);
$all = array_reduce(
$all,
function ($carry, $item) {
$carry[$item['id_tmetaconsole_setup'].'|'.$item['id_tagente']] = $item['alias'];
return $carry;
},
[]
);
} else {
$all = agents_get_agents(
['id_grupo' => $group],
[
'id_agente',
'alias',
],
'AR',
[
'field' => 'alias',
'order' => 'ASC',
]
);
$all = array_reduce(
$all,
function ($carry, $item) {
$carry[$item['id_agente']] = $item['alias'];
return $carry;
},
[]
);
}
return $all;
}
/** /**
* Get all the alerts of an agent, simple and combined. * Get all the alerts of an agent, simple and combined.
* *
@ -1649,6 +1706,85 @@ function agents_get_name($id_agent, $case='none')
} }
/**
* Get the agents names of an agent.
*
* @param array $array_ids Agents ids.
*
* @return array Id => name.
*/
function agents_get_alias_array($array_ids)
{
if (is_array($array_ids) === false || empty($array_ids) === true) {
return [];
}
if ((bool) is_metaconsole() === true) {
$agents = array_reduce(
$array_ids,
function ($carry, $item) {
$explode = explode('|', $item);
$carry[$explode[0]][] = $explode[1];
return $carry;
}
);
$result = [];
foreach ($agents as $tserver => $id_agents) {
$sql = sprintf(
'SELECT id_tagente as id, alias as `name`
FROM tmetaconsole_agent
WHERE id_tagente IN (%s) AND id_tmetaconsole_setup = %d',
implode(',', $id_agents),
$tserver
);
$data_server = db_get_all_rows_sql($sql);
if ($data_server === false) {
$data_server = [];
}
$data_server = array_reduce(
$data_server,
function ($carry, $item) {
$carry[$item['id']] = $item['name'];
return $carry;
},
[]
);
$result[$tserver] = $data_server;
}
} else {
$sql = sprintf(
'SELECT id_agente as id, alias as `name`
FROM tagente
WHERE id_agente IN (%s)',
implode(',', $array_ids)
);
$result = db_get_all_rows_sql($sql);
if ($result === false) {
$result = [];
}
$result = array_reduce(
$result,
function ($carry, $item) {
$carry[$item['id']] = $item['name'];
return $carry;
},
[]
);
}
return $result;
}
/** /**
* Get alias of an agent (cached function). * Get alias of an agent (cached function).
* *

View File

@ -2838,3 +2838,588 @@ function alerts_get_agent_modules(
return $agent_modules; return $agent_modules;
} }
function alerts_get_actions_names($actions, $reduce=false)
{
$where = '';
if (empty($actions) === false) {
if (is_array($actions) === true) {
$where = sprintf(
'WHERE id IN (%s)',
implode(',', $actions)
);
} else {
$where = sprintf('WHERE id = %d', $actions);
}
}
$sql = sprintf(
'SELECT id, `name`
FROM talert_actions
%s',
$where
);
$result = db_get_all_rows_sql($sql);
if ($result === false) {
$result = [];
}
if ($reduce === true) {
$result = array_reduce(
$result,
function ($carry, $item) {
$carry[$item['id']] = $item['name'];
return $carry;
},
[]
);
}
return $result;
}
/**
* Alert fired.
*
* @param array $filters Filters.
* @param array $groupsBy Groupby and lapse.
*
* @return array Result data.
*/
function alerts_get_alert_fired($filters=[], $groupsBy=[])
{
global $config;
$table = 'tevento';
if (is_metaconsole() === true) {
$table = 'tmetaconsole_event';
}
$filter_date = '';
if (isset($filters['period']) === true
&& empty($filters['period']) === false
) {
$filter_date = sprintf(
'AND %s.utimestamp > %d',
$table,
(time() - $filters['period'])
);
}
$filter_group = '';
if (isset($filters['group']) === true
&& empty($filters['group']) === false
) {
$filter_group = sprintf(
'AND %s.id_grupo = %d',
$table,
$filters['group']
);
}
$filter_agents = '';
if (isset($filters['agents']) === true
&& empty($filters['agents']) === false
) {
if (is_metaconsole() === true) {
$agents = array_reduce(
$filters['agents'],
function ($carry, $item) {
$explode = explode('|', $item);
$carry[$explode[0]][] = $explode[1];
return $carry;
}
);
$filter_agents .= ' AND ( ';
$i = 0;
foreach ($agents as $tserver => $agent) {
if ($i !== 0) {
$filter_agents .= ' OR ';
}
$filter_agents .= sprintf(
'( %s.id_agente IN (%s) AND %s.server_id = %d )',
$table,
implode(',', $agent),
$table,
(int) $tserver
);
$i++;
}
$filter_agents .= ' )';
} else {
$filter_agents = sprintf(
'AND %s.id_agente IN (%s)',
$table,
implode(',', $filters['agents'])
);
}
}
$filter_modules = '';
if (isset($filters['modules']) === true
&& empty($filters['modules']) === false
) {
if (is_metaconsole() === true) {
$modules = array_reduce(
$filters['modules'],
function ($carry, $item) {
$explode = explode('|', $item);
$carry[$explode[0]][] = $explode[1];
return $carry;
}
);
$filter_modules .= ' AND ( ';
$i = 0;
foreach ($modules as $tserver => $module) {
if ($i !== 0) {
$filter_modules .= ' OR ';
}
$filter_modules .= sprintf(
'( %s.id_agentmodule IN (%s) AND %s.server_id = %d )',
$table,
implode(',', $module),
$table,
(int) $tserver
);
$i++;
}
$filter_modules .= ' )';
} else {
$filter_modules = sprintf(
'AND %s.id_agentmodule IN (%s)',
$table,
implode(',', $filters['modules'])
);
}
}
$filter_templates = '';
if (isset($filters['templates']) === true
&& empty($filters['templates']) === false
) {
if (is_metaconsole() === false) {
$filter_templates = sprintf(
'AND talert_template_modules.id_alert_template IN (%s)',
implode(',', $filters['templates'])
);
}
}
$total = (bool) $filters['show_summary'];
$only_data = (bool) $filters['only_data'];
$actions_names = alerts_get_actions_names($filters['actions'], true);
$group_array = [];
$filter_actions = '';
$fields_actions = [];
if (isset($filters['actions']) === true
&& empty($filters['actions']) === false
) {
$filter_actions .= 'AND ( ';
$first = true;
foreach ($actions_names as $name_action) {
if ($first === false) {
$filter_actions .= ' OR ';
}
$filter_actions .= sprintf(
"JSON_CONTAINS(%s.custom_data, '\"%s\"', '\$.actions')",
$table,
io_safe_output($name_action)
);
$fields_actions[$name_action] = sprintf(
"SUM(JSON_CONTAINS(%s.custom_data, '\"%s\"', '\$.actions')) as '%s'",
$table,
io_safe_output($name_action),
io_safe_output($name_action)
);
$first = false;
}
$filter_actions .= ' ) ';
} else {
foreach ($actions_names as $name_action) {
$fields[] = sprintf(
"SUM(JSON_CONTAINS(%s.custom_data, '\"%s\"', '\$.actions')) as '%s'",
$table,
io_safe_output($name_action),
io_safe_output($name_action)
);
}
}
if (is_array($fields_actions) === true
&& empty($fields_actions) === false
) {
foreach ($fields_actions as $name => $field) {
$fields[] = $field;
}
}
$names_search = [];
$names_server = [];
if (isset($groupsBy['group_by']) === true) {
switch ($groupsBy['group_by']) {
case 'module':
$fields[] = $table.'.id_agentmodule as module';
$group_array[] = $table.'.id_agentmodule';
$names_search = modules_get_agentmodule_name_array(
array_values($filters['modules'])
);
if (is_metaconsole() === true) {
$fields[] = $table.'.server_id as server';
$group_array[] = $table.'.server_id';
$names_server = metaconsole_get_names();
}
break;
case 'template':
if (is_metaconsole() === false) {
$fields[] = 'talert_template_modules.id_alert_template as template';
$group_array[] = 'talert_template_modules.id_alert_template';
$names_search = alerts_get_templates_name_array(
array_values($filters['templates'])
);
}
break;
case 'agent':
$fields[] = $table.'.id_agente as agent';
$group_array[] = $table.'.id_agente';
$names_search = agents_get_alias_array(
array_values($filters['agents'])
);
if (is_metaconsole() === true) {
$fields[] = $table.'.server_id as server';
$group_array[] = $table.'.server_id';
$names_server = metaconsole_get_names();
}
break;
case 'group':
$fields[] = $table.'.id_grupo as `group`';
$group_array[] = $table.'.id_grupo';
$names_search = users_get_groups($config['user'], 'AR', false);
break;
default:
// Nothing.
break;
}
}
if (isset($groupsBy['lapse']) === true
&& empty($groupsBy['lapse']) === false
) {
$fields[] = sprintf(
'%s.utimestamp AS Period',
$table
);
$group_array[] = 'period';
}
$group_by = '';
if (is_array($group_array) === true && empty($group_array) === false) {
$group_by = sprintf(' GROUP BY %s', implode(", \n", $group_array));
}
$innerJoin = '';
if (is_metaconsole() === false) {
$innerJoin = sprintf(
'INNER JOIN talert_template_modules
ON talert_template_modules.id = %s.id_alert_am',
$table
);
}
$query = sprintf(
'SELECT
%s
FROM %s
%s
WHERE custom_data != ""
AND %s.event_type="alert_fired"
%s
%s
%s
%s
%s
%s
%s',
implode(", \n", $fields),
$table,
$innerJoin,
$table,
$filter_date,
$filter_group,
$filter_agents,
$filter_modules,
$filter_actions,
$filter_templates,
$group_by
);
$data_query = db_get_all_rows_sql($query);
if ($data_query === false) {
$data_query = [];
}
if (empty($data_query) === false) {
$data = array_reduce(
$data_query,
function ($carry, $item) use ($groupsBy) {
$period = (isset($item['Period']) === true) ? (int) $item['Period'] : 0;
if (is_metaconsole() === true
&& ($groupsBy['group_by'] === 'agent'
|| $groupsBy['group_by'] === 'module')
) {
$grby = $item[$groupsBy['group_by']];
$server = $item['server'];
unset($item['Period']);
unset($item[$groupsBy['group_by']]);
unset($item['server']);
$carry[$period][$server][$grby] = $item;
} else {
$grby = $item[$groupsBy['group_by']];
unset($item['Period']);
unset($item[$groupsBy['group_by']]);
$carry[$period][$grby] = $item;
}
return $carry;
},
[]
);
$intervals = [];
if (isset($groupsBy['lapse']) === true
&& empty($groupsBy['lapse']) === false
) {
$tend = time();
$tstart = ($tend - (int) $filters['period']);
for ($current_time = $tstart; $current_time < $tend; ($current_time += $groupsBy['lapse'])) {
$intervals[] = (int) $current_time;
}
}
$first_element = reset($data);
$first_element = reset($first_element);
if (is_metaconsole() === true
&& ($groupsBy['group_by'] === 'agent'
|| $groupsBy['group_by'] === 'module')
) {
$first_element = reset($first_element);
}
$clone = [];
foreach ($first_element as $key_clone => $value_clone) {
$clone[$key_clone] = 0;
}
$result = [];
if (empty($intervals) === true) {
foreach ($data as $period => $array_data) {
if (is_metaconsole() === true
&& ($groupsBy['group_by'] === 'agent'
|| $groupsBy['group_by'] === 'module')
) {
foreach ($names_search as $server => $names) {
foreach ($names as $id => $name) {
$name = $names_server[$server].' &raquo; '.$name;
if (isset($array_data[$server][$id]) === true) {
$result[$period][$server.'|'.$id] = $array_data[$server][$id];
$result[$period][$server.'|'.$id][$groupsBy['group_by']] = $name;
} else {
if ($only_data === false) {
$clone[$groupsBy['group_by']] = $name;
$result[$period][$server.'|'.$id] = $clone;
}
}
}
}
} else {
foreach ($names_search as $id => $name) {
if (isset($array_data[$id]) === true) {
$result[$period][$id] = $array_data[$id];
$result[$period][$id][$groupsBy['group_by']] = $name;
} else {
if ($only_data === false) {
$clone[$groupsBy['group_by']] = $name;
$result[$period][$id] = $clone;
}
}
}
}
}
} else {
$period_lapse = (int) $groupsBy['lapse'];
foreach ($intervals as $interval) {
$start_interval = $interval;
$end_interval = ($interval + $period_lapse);
if ($only_data === false) {
if (is_metaconsole() === true
&& ($groupsBy['group_by'] === 'agent'
|| $groupsBy['group_by'] === 'module')
) {
foreach ($names_search as $server => $names) {
foreach ($names as $id => $name) {
$result_name = $names_server[$server].' &raquo; '.$name;
$result[$start_interval][$server.'|'.$id] = $clone;
$result[$start_interval][$server.'|'.$id][$groupsBy['group_by']] = $result_name;
}
}
} else {
foreach ($names_search as $id => $name) {
$result[$start_interval][$id] = $clone;
$result[$start_interval][$id][$groupsBy['group_by']] = $name;
}
}
} else {
foreach ($data as $period => $array_data) {
if (is_metaconsole() === true
&& ($groupsBy['group_by'] === 'agent'
|| $groupsBy['group_by'] === 'module')
) {
foreach ($array_data as $server => $datas) {
foreach ($datas as $id_data => $value_data) {
$name = $names_server[$server].' &raquo; '.$names_search[$server][$id_data];
$result[$start_interval][$server.'|'.$id_data] = $clone;
$result[$start_interval][$server.'|'.$id_data][$groupsBy['group_by']] = $name;
}
}
} else {
foreach ($array_data as $id_data => $value_data) {
$name = $names_search[$id_data];
$result[$start_interval][$id_data] = $clone;
$result[$start_interval][$id_data][$groupsBy['group_by']] = $name;
}
}
}
}
foreach ($data as $period => $array_data) {
$period_time = (int) $period;
if ($start_interval < $period_time && $period_time <= $end_interval) {
if (is_metaconsole() === true
&& ($groupsBy['group_by'] === 'agent'
|| $groupsBy['group_by'] === 'module')
) {
foreach ($array_data as $server => $datas) {
foreach ($datas as $id_data => $value_data) {
foreach ($value_data as $key_data => $v) {
if ($key_data !== $groupsBy['group_by']) {
if (isset($result[$start_interval][$server.'|'.$id_data][$key_data])) {
$result[$start_interval][$server.'|'.$id_data][$key_data] += $v;
} else {
$result[$start_interval][$server.'|'.$id_data][$key_data] = $v;
}
}
}
}
}
} else {
foreach ($array_data as $id_data => $value_data) {
foreach ($value_data as $key_data => $v) {
if ($key_data !== $groupsBy['group_by']) {
if (isset($result[$start_interval][$id_data][$key_data])) {
$result[$start_interval][$id_data][$key_data] += $v;
} else {
$result[$start_interval][$id_data][$key_data] = $v;
}
}
}
}
}
unset($data[$period]);
}
}
}
}
}
$result['data'] = $result;
if ($total === true) {
$total_values = [];
foreach ($data_query as $key => $array_data) {
foreach ($array_data as $key_value => $v) {
$total_values[$key_value] = ($total_values[$key_value] + $v);
}
}
if (is_metaconsole() === true
&& ($groupsBy['group_by'] === 'agent'
|| $groupsBy['group_by'] === 'module')
) {
unset($total_values['server']);
}
unset($total_values['Period']);
$result['summary']['total'] = $total_values;
$result['summary']['total'][$groupsBy['group_by']] = __('Total');
}
return $result;
}
/**
* Get the templates names of an agent.
*
* @param array $array_ids Templates ids.
*
* @return array Id => name.
*/
function alerts_get_templates_name_array($array_ids)
{
if (is_array($array_ids) === false || empty($array_ids) === true) {
return [];
}
$sql = sprintf(
'SELECT id, `name`
FROM talert_templates
WHERE id IN (%s)',
implode(',', $array_ids)
);
$result = db_get_all_rows_sql($sql);
if ($result === false) {
$result = [];
}
$result = array_reduce(
$result,
function ($carry, $item) {
$carry[$item['id']] = $item['name'];
return $carry;
},
[]
);
return $result;
}

View File

@ -194,11 +194,11 @@ function custom_graphs_get_user($id_user=0, $only_names=false, $returnAllGroup=t
function custom_graphs_search($id_group, $search) function custom_graphs_search($id_group, $search)
{ {
if ($id_group != '' && $search != '') { if ($id_group != '' && $search != '') {
$all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.' AND name LIKE "%'.$search.'%"'); $all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.' AND (name LIKE "%'.$search.'%" OR description LIKE "'.$search.'")');
} else if ($id_group != '') { } else if ($id_group != '') {
$all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.''); $all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.'');
} else { } else {
$all_graphs = db_get_all_rows_sql('select * from tgraph where name LIKE "%'.$search.'%"'); $all_graphs = db_get_all_rows_sql('select * from tgraph where name LIKE "%'.$search.'%" OR description LIKE "'.$search.'"');
} }
if ($all_graphs === false) { if ($all_graphs === false) {

View File

@ -1377,42 +1377,56 @@ function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache
break; break;
} }
if ($rc !== false) { db_sync($dbconnection, $sql, $rc);
if (enterprise_hook('is_metaconsole') === true
&& isset($config['centralized_management']) === true
&& (bool) $config['centralized_management'] === true
&& $dbconnection === ''
) {
$errors = null;
try {
// Synchronize changes to nodes if needed.
$sync = new Synchronizer();
if ($sync !== null) {
if ($sync->queue($sql) === false) {
// Launch events per failed query.
$errors = $sync->getLatestErrors();
if ($errors !== null) {
$errors = join(', ', $errors);
} else {
$errors = '';
}
}
}
} catch (\Exception $e) {
$errors = $e->getMessage();
}
if ($errors !== null) {
// TODO: Generate pandora event.
error_log($errors);
}
}
}
return $rc; return $rc;
} }
/**
* Propagate to nodes.
*
* @param mixed $dbconnection Dbconnection.
* @param mixed $sql Sql.
* @param mixed $rc Rc.
*
* @return void
*/
function db_sync($dbconnection, $sql, $rc)
{
global $config;
if (enterprise_hook('is_metaconsole') === true
&& isset($config['centralized_management']) === true
&& (bool) $config['centralized_management'] === true
&& $dbconnection === ''
) {
$errors = null;
try {
// Synchronize changes to nodes if needed.
$sync = new Synchronizer();
if ($sync !== null) {
if ($sync->queue($sql, $rc) === false) {
// Launch events per failed query.
$errors = $sync->getLatestErrors();
if ($errors !== null) {
$errors = join(', ', $errors);
} else {
$errors = '';
}
}
}
} catch (\Exception $e) {
$errors = $e->getMessage();
}
if ($errors !== null) {
// TODO: Generate pandora event.
error_log($errors);
}
}
}
/** /**
* Get all the rows in a table of the database. * Get all the rows in a table of the database.
* *
@ -1808,20 +1822,20 @@ function db_process_sql_delete($table, $where, $where_join='AND')
function db_process_sql_begin() function db_process_sql_begin()
{ {
global $config; global $config;
$null = null;
switch ($config['dbtype']) { switch ($config['dbtype']) {
case 'mysql':
return mysql_db_process_sql_begin();
break;
case 'postgresql': case 'postgresql':
return postgresql_db_process_sql_begin(); return postgresql_db_process_sql_begin();
break;
case 'oracle': case 'oracle':
return oracle_db_process_sql_begin(); return oracle_db_process_sql_begin();
break; default:
case 'mysql':
db_process_sql('SET AUTOCOMMIT = 0', 'affected_rows', '', false, $null, false);
db_process_sql('START TRANSACTION', 'affected_rows', '', false, $null, false);
break;
} }
} }
@ -1832,20 +1846,20 @@ function db_process_sql_begin()
function db_process_sql_commit() function db_process_sql_commit()
{ {
global $config; global $config;
$null = null;
switch ($config['dbtype']) { switch ($config['dbtype']) {
case 'mysql':
return mysql_db_process_sql_commit();
break;
case 'postgresql': case 'postgresql':
return postgresql_db_process_sql_commit(); return postgresql_db_process_sql_commit();
break;
case 'oracle': case 'oracle':
return oracle_db_process_sql_commit(); return oracle_db_process_sql_commit();
break; default:
case 'mysql':
db_process_sql('COMMIT', 'affected_rows', '', false, $null, false);
db_process_sql('SET AUTOCOMMIT = 1', 'affected_rows', '', false, $null, false);
break;
} }
} }
@ -1856,20 +1870,20 @@ function db_process_sql_commit()
function db_process_sql_rollback() function db_process_sql_rollback()
{ {
global $config; global $config;
$null = null;
switch ($config['dbtype']) { switch ($config['dbtype']) {
case 'mysql':
return mysql_db_process_sql_rollback();
break;
case 'postgresql': case 'postgresql':
return postgresql_db_process_sql_rollback(); return postgresql_db_process_sql_rollback();
break;
case 'oracle': case 'oracle':
return oracle_db_process_sql_rollback(); return oracle_db_process_sql_rollback();
break; default:
case 'mysql':
db_process_sql('ROLLBACK', 'affected_rows', '', false, $null, false);
db_process_sql('SET AUTOCOMMIT = 1', 'affected_rows', '', false, $null, false);
break;
} }
} }
@ -1889,6 +1903,7 @@ function db_print_database_debug()
echo '<div class="database_debug_title">'.__('Database debug').'</div>'; echo '<div class="database_debug_title">'.__('Database debug').'</div>';
$table = new stdClass();
$table->id = 'database_debug'; $table->id = 'database_debug';
$table->cellpadding = '0'; $table->cellpadding = '0';
$table->width = '95%'; $table->width = '95%';
@ -1946,18 +1961,15 @@ function db_get_last_error()
global $config; global $config;
switch ($config['dbtype']) { switch ($config['dbtype']) {
case 'mysql':
return mysql_db_get_last_error();
break;
case 'postgresql': case 'postgresql':
return postgresql_db_get_last_error(); return postgresql_db_get_last_error();
break;
case 'oracle': case 'oracle':
return oracle_db_get_last_error(); return oracle_db_get_last_error();
break; case 'mysql':
default:
return mysql_db_get_last_error();
} }
} }
@ -1975,18 +1987,15 @@ function db_get_type_field_table($table, $field)
global $config; global $config;
switch ($config['dbtype']) { switch ($config['dbtype']) {
case 'mysql':
return mysql_db_get_type_field_table($table, $field);
break;
case 'postgresql': case 'postgresql':
return postgresql_db_get_type_field_table($table, $field); return postgresql_db_get_type_field_table($table, $field);
break;
case 'oracle': case 'oracle':
return oracle_db_get_type_field_table($table, $field); return oracle_db_get_type_field_table($table, $field);
break; case 'mysql':
default:
return mysql_db_get_type_field_table($table, $field);
} }
} }

View File

@ -25,6 +25,8 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* ============================================================================ * ============================================================================
*/ */
// Begin.
global $config; global $config;
require_once $config['homedir'].'/include/functions_ui.php'; require_once $config['homedir'].'/include/functions_ui.php';
@ -35,7 +37,7 @@ enterprise_include_once('include/functions_metaconsole.php');
enterprise_include_once('meta/include/functions_events_meta.php'); enterprise_include_once('meta/include/functions_events_meta.php');
enterprise_include_once('meta/include/functions_agents_meta.php'); enterprise_include_once('meta/include/functions_agents_meta.php');
enterprise_include_once('meta/include/functions_modules_meta.php'); enterprise_include_once('meta/include/functions_modules_meta.php');
if (is_metaconsole()) { if (is_metaconsole() === true) {
$id_source_event = get_parameter('id_source_event'); $id_source_event = get_parameter('id_source_event');
} }
@ -1619,14 +1621,14 @@ function events_get_events($filter=false, $fields=false)
*/ */
function events_get_event($id, $fields=false, $meta=false, $history=false) function events_get_event($id, $fields=false, $meta=false, $history=false)
{ {
if (empty($id)) { if (empty($id) === true) {
return false; return false;
} }
global $config; global $config;
if (is_array($fields)) { if (is_array($fields) === true) {
if (! in_array('id_grupo', $fields)) { if (in_array('id_grupo', $fields) === false) {
$fields[] = 'id_grupo'; $fields[] = 'id_grupo';
} }
} }
@ -1634,7 +1636,7 @@ function events_get_event($id, $fields=false, $meta=false, $history=false)
$table = events_get_events_table($meta, $history); $table = events_get_events_table($meta, $history);
$event = db_get_row($table, 'id_evento', $id, $fields); $event = db_get_row($table, 'id_evento', $id, $fields);
if (! check_acl($config['id_user'], $event['id_grupo'], 'ER')) { if ((bool) check_acl($config['id_user'], $event['id_grupo'], 'ER') === false) {
return false; return false;
} }
@ -2255,7 +2257,7 @@ function events_comment(
// If comments are not stored in json, the format is old. // If comments are not stored in json, the format is old.
$event_comments_array = json_decode($event_comments[0]['user_comment']); $event_comments_array = json_decode($event_comments[0]['user_comment']);
if (empty($event_comments_array)) { if (empty($event_comments_array) === true) {
$comments_format = 'old'; $comments_format = 'old';
} else { } else {
$comments_format = 'new'; $comments_format = 'new';
@ -2268,6 +2270,7 @@ function events_comment(
$comment_for_json['action'] = $action; $comment_for_json['action'] = $action;
$comment_for_json['id_user'] = $config['id_user']; $comment_for_json['id_user'] = $config['id_user'];
$comment_for_json['utimestamp'] = time(); $comment_for_json['utimestamp'] = time();
$comment_for_json['event_id'] = $first_event;
$event_comments_array[] = $comment_for_json; $event_comments_array[] = $comment_for_json;
@ -2282,11 +2285,11 @@ function events_comment(
break; break;
case 'old': case 'old':
// Give old ugly format to comment. TODO: Change this method for // Give old ugly format to comment.
// aux table or json. // Change this method for aux table or json.
$comment = str_replace(["\r\n", "\r", "\n"], '<br>', $comment); $comment = str_replace(["\r\n", "\r", "\n"], '<br>', $comment);
if ($comment != '') { if ($comment !== '') {
$commentbox = '<div class="comment_box">'.io_safe_input($comment).'</div>'; $commentbox = '<div class="comment_box">'.io_safe_input($comment).'</div>';
} else { } else {
$commentbox = ''; $commentbox = '';
@ -3245,6 +3248,10 @@ function events_get_event_types($type_id)
$type_desc = __('Not normal'); $type_desc = __('Not normal');
break; break;
case 'ncm':
$type_desc = __('Network configuration manager');
break;
default: default:
if (isset($config['text_char_long'])) { if (isset($config['text_char_long'])) {
foreach ($diferent_types as $key => $type) { foreach ($diferent_types as $key => $type) {
@ -5102,11 +5109,13 @@ function events_page_general($event)
/** /**
* Generate 'comments' page for event viewer. * Generate 'comments' page for event viewer.
* *
* @param array $event Event. * @param array $event Event.
* @param boolean $ajax If the query come from AJAX.
* @param boolean $grouped If the event must shown comments grouped.
* *
* @return string HTML. * @return string HTML.
*/ */
function events_page_comments($event, $ajax=false) function events_page_comments($event, $ajax=false, $groupedComments=[])
{ {
// Comments. // Comments.
global $config; global $config;
@ -5117,23 +5126,53 @@ function events_page_comments($event, $ajax=false)
$table_comments->head = []; $table_comments->head = [];
$table_comments->class = 'table_modal_alternate'; $table_comments->class = 'table_modal_alternate';
$comments = ($event['user_comment'] ?? ''); $comments = (empty($groupedComments) === true) ? $event['user_comment'] : $groupedComments;
if (empty($comments)) { if (empty($comments) === true) {
$table_comments->style[0] = 'text-align:center;'; $table_comments->style[0] = 'text-align:center;';
$table_comments->colspan[0][0] = 2; $table_comments->colspan[0][0] = 2;
$data = []; $data = [];
$data[0] = __('There are no comments'); $data[0] = __('There are no comments');
$table_comments->data[] = $data; $table_comments->data[] = $data;
} else { } else {
if (is_array($comments)) { if (is_array($comments) === true) {
$comments_array = [];
foreach ($comments as $comm) { foreach ($comments as $comm) {
if (empty($comm)) { if (empty($comm) === true) {
continue; continue;
} }
// If exists user_comments, come from grouped events and must be handled like this.
if (isset($comm['user_comment']) === true) {
$comm = $comm['user_comment'];
}
$comments_array[] = io_safe_output(json_decode($comm, true)); $comments_array[] = io_safe_output(json_decode($comm, true));
} }
// Plain comments. Can be improved.
$sortedCommentsArray = [];
foreach ($comments_array as $comm) {
foreach ($comm as $subComm) {
$sortedCommentsArray[] = $subComm;
}
}
// Sorting the comments by utimestamp (newer is first).
usort(
$sortedCommentsArray,
function ($a, $b) {
if ($a['utimestamp'] == $b['utimestamp']) {
return 0;
}
return ($a['utimestamp'] > $b['utimestamp']) ? -1 : 1;
}
);
// Clean the unsorted comments and return it to the original array.
$comments_array = [];
$comments_array[] = $sortedCommentsArray;
} else { } else {
$comments = str_replace(["\n", '&#x0a;'], '<br>', $comments); $comments = str_replace(["\n", '&#x0a;'], '<br>', $comments);
// If comments are not stored in json, the format is old. // If comments are not stored in json, the format is old.
@ -5141,23 +5180,28 @@ function events_page_comments($event, $ajax=false)
} }
foreach ($comments_array as $comm) { foreach ($comments_array as $comm) {
// Show the comments more recent first. $comments_format = (empty($comm) === true) ? 'old' : 'new';
if (is_array($comm)) {
$comm = array_reverse($comm);
}
if (empty($comm)) {
$comments_format = 'old';
} else {
$comments_format = 'new';
}
switch ($comments_format) { switch ($comments_format) {
case 'new': case 'new':
foreach ($comm as $c) { foreach ($comm as $c) {
$data[0] = '<b>'.$c['action'].' by '.$c['id_user'].'</b>'; $eventIdExplanation = (empty($groupedComments) === false) ? sprintf(' (#%d)', $c['event_id']) : '';
$data[0] .= '<br><br><i>'.date($config['date_format'], $c['utimestamp']).'</i>';
$data[0] = sprintf(
'<b>%s %s %s%s</b>',
$c['action'],
__('by'),
$c['id_user'],
$eventIdExplanation
);
$data[0] .= sprintf(
'<br><br><i>%s</i>',
date($config['date_format'], $c['utimestamp'])
);
$data[1] = '<p class="break_word">'.stripslashes(str_replace(['\n', '\r'], '<br/>', $c['comment'])).'</p>'; $data[1] = '<p class="break_word">'.stripslashes(str_replace(['\n', '\r'], '<br/>', $c['comment'])).'</p>';
$table_comments->data[] = $data; $table_comments->data[] = $data;
} }
break; break;
@ -5247,7 +5291,7 @@ function events_page_comments($event, $ajax=false)
); );
} }
if ($ajax) { if ($ajax === true) {
return $comments_form.html_print_table($table_comments, true); return $comments_form.html_print_table($table_comments, true);
} }

View File

@ -729,7 +729,8 @@ function html_print_select(
$required=false, $required=false,
$truncate_size=false, $truncate_size=false,
$select2_enable=true, $select2_enable=true,
$multiple_select2=false $select2_multiple_enable=false,
$select2_multiple_enable_all=false
) { ) {
$output = "\n"; $output = "\n";
@ -791,6 +792,12 @@ function html_print_select(
$required = 'required'; $required = 'required';
} }
if ($select2_multiple_enable === true
&& $select2_multiple_enable_all === true
) {
$output .= '<div class="flex-row-center">';
}
$output .= '<select '.$required.' onclick="'.$script.'" id="'.$id.'" name="'.$name.'"'.$attributes.' '.$styleText.'>'; $output .= '<select '.$required.' onclick="'.$script.'" id="'.$id.'" name="'.$name.'"'.$attributes.' '.$styleText.'>';
if ($nothing !== false) { if ($nothing !== false) {
@ -890,6 +897,24 @@ function html_print_select(
} }
$output .= '</select>'; $output .= '</select>';
if ($select2_multiple_enable === true
&& $select2_multiple_enable_all === true
) {
$output .= '<div class="margin-left-2 flex-column">';
$output .= '<span>'.__('All').'</span>';
$output .= html_print_checkbox_switch(
$id.'-check-all',
1,
false,
true,
$disabled,
'checkMultipleAll('.$id.')'
);
$output .= '</div>';
$output .= '</div>';
}
if ($modal && !enterprise_installed()) { if ($modal && !enterprise_installed()) {
$output .= " $output .= "
<div id='".$message."' class='publienterprise publicenterprise_div' title='Community version'><img data-title='".__('Enterprise version not installed')."' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div> <div id='".$message."' class='publienterprise publicenterprise_div' title='Community version'><img data-title='".__('Enterprise version not installed')."' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>
@ -901,8 +926,7 @@ function html_print_select(
$select2 = 'select2_dark.min'; $select2 = 'select2_dark.min';
} }
// Note that multiple_select2 is introduced as a workaround to overcome the pointless limitation of preventing "multiple" select inputs from using select2 library without affecting the existing calls to this function. if (($multiple === false || $select2_multiple_enable === true) && $select2_enable === true) {
if ($multiple === false && $select2_enable === true || $multiple_select2 === true) {
if (is_ajax()) { if (is_ajax()) {
$output .= '<script src="'; $output .= '<script src="';
$output .= ui_get_full_url( $output .= ui_get_full_url(
@ -944,6 +968,32 @@ function html_print_select(
});'; });';
} }
if ($select2_multiple_enable === true
&& $select2_multiple_enable_all === true
) {
$output .= '$("#'.$id.'").on("change", function(e) {
var checked = false;
if(e.target.length !== $("#'.$id.' > option:selected").length) {
checked = false;
} else {
checked = true;
}
$("#checkbox-'.$id.'-check-all").prop("checked", checked);
});';
$output .= '$("#'.$id.'").trigger("change");';
$output .= 'function checkMultipleAll(id){
if ($("#checkbox-"+id.id+"-check-all").is(":checked")) {
$("#"+id.id+" > option").prop("selected", "selected");
$("#"+id.id).trigger("change");
} else {
$("#"+id.id).val(null).trigger("change");
}
}';
}
$output .= '</script>'; $output .= '</script>';
} }
@ -4046,6 +4096,10 @@ function html_print_input_file($name, $return=false, $options=false)
if (isset($options['required'])) { if (isset($options['required'])) {
$output .= ' required'; $output .= ' required';
} }
if (isset($options['onchange'])) {
$output .= ' onchange="'.$options['onchange'].'"';
}
} }
$output .= ' />'; $output .= ' />';
@ -4438,7 +4492,7 @@ function html_print_switch($attributes=[])
$disabled_class = (bool) ($attributes['disabled']) ? ' p-slider-disabled' : ''; $disabled_class = (bool) ($attributes['disabled']) ? ' p-slider-disabled' : '';
return "<label class='p-switch' style='".$attributes['style']."'> return "<label class='p-switch ".$attributes['container-class']."' style='".$attributes['style']."'>
<input type='checkbox' ".$html_expand."> <input type='checkbox' ".$html_expand.">
<span class='p-slider".$disabled_class."'></span> <span class='p-slider".$disabled_class."'></span>
</label>"; </label>";

View File

@ -158,35 +158,86 @@ function integria_api_call($api_hostname=null, $user=null, $user_pass=null, $api
{ {
global $config; global $config;
if ($user_level_conf === null) { if (is_metaconsole()) {
$user_level_conf = (bool) $config['integria_user_level_conf']; $servers = metaconsole_get_connection_names();
} foreach ($servers as $key => $server) {
$connection = metaconsole_get_connection($server);
if (metaconsole_connect($connection) != NOERR) {
continue;
}
$user_info = users_get_user_by_id($config['id_user']); $integria_enabled = db_get_sql(
'SELECT `value` FROM tconfig WHERE `token` = "integria_enabled"'
);
// API access data. if (!$integria_enabled) {
if ($api_hostname === null) { metaconsole_restore_db();
$api_hostname = $config['integria_hostname']; continue;
} }
if ($api_pass === null) { // integria_user_level_conf, integria_hostname, integria_api_pass, integria_user, integria_user_level_user, integria_pass, integria_user_level_pass
$api_pass = $config['integria_api_pass']; $config_aux = db_get_all_rows_sql('SELECT `token`, `value` FROM `tconfig` WHERE `token` IN ("integria_user_level_conf", "integria_hostname", "integria_api_pass", "integria_user", "integria_user_level_user", "integria_pass", "integria_user_level_pass")');
} $user_info = users_get_user_by_id($config['id_user']);
foreach ($config_aux as $key => $conf) {
if ($conf['token'] === 'integria_user_level_conf') {
$user_level_conf = $conf['value'];
}
// Integria user and password. if ($conf['token'] === 'integria_hostname') {
if ($user === null || $user_level_conf === true) { $api_hostname = $conf['value'];
$user = $config['integria_user']; }
if ($user_level_conf === true) { if ($conf['token'] === 'integria_api_pass') {
$user = $user_info['integria_user_level_user']; $api_pass = $conf['value'];
}
if ($conf['token'] === 'integria_user') {
$user = $conf['value'];
}
if ($conf['token'] === 'integria_pass') {
$user_pass = $conf['value'];
}
}
if ($user_level_conf == true) {
$user = $user_info['integria_user_level_user'];
$user_pass = $user_info['integria_user_level_pass'];
}
metaconsole_restore_db();
}
} else {
if ($user_level_conf === null) {
$user_level_conf = (bool) $config['integria_user_level_conf'];
} }
}
if ($user_pass === null || $user_level_conf === true) { $user_info = users_get_user_by_id($config['id_user']);
$user_pass = $config['integria_pass'];
if ($user_level_conf === true) { // API access data.
$user_pass = $user_info['integria_user_level_pass']; if ($api_hostname === null) {
$api_hostname = $config['integria_hostname'];
}
if ($api_pass === null) {
$api_pass = $config['integria_api_pass'];
}
// Integria user and password.
if ($user === null || $user_level_conf === true) {
$user = $config['integria_user'];
if ($user_level_conf === true) {
$user = $user_info['integria_user_level_user'];
}
}
if ($user_pass === null || $user_level_conf === true) {
$user_pass = $config['integria_pass'];
if ($user_level_conf === true) {
$user_pass = $user_info['integria_user_level_pass'];
}
} }
} }

View File

@ -503,14 +503,14 @@ function menu_add_extras(&$menu)
$menu_extra['reporting']['sub']['enterprise/godmode/reporting/graph_template_editor']['text'] = __('Manage graph templates'); $menu_extra['reporting']['sub']['enterprise/godmode/reporting/graph_template_editor']['text'] = __('Manage graph templates');
$menu_extra['reporting']['sub']['enterprise/godmode/reporting/graph_template_item_editor']['text'] = __('Graph template items'); $menu_extra['reporting']['sub']['enterprise/godmode/reporting/graph_template_item_editor']['text'] = __('Graph template items');
$menu_extra['reporting']['sub']['enterprise/godmode/reporting/graph_template_wizard']['text'] = __('Graph template wizard'); $menu_extra['reporting']['sub']['enterprise/godmode/reporting/graph_template_wizard']['text'] = __('Graph template wizard');
$menu_extra['reporting']['sub']['godmode/reporting/reporting_builder&tab=wizard&action=wizard']['text'] = __('Templates wizard');
$menu_extra['reporting']['sub']['godmode/reporting/reporting_builder&tab=template&action=list_template']['text'] = __('Templates');
if ($config['activate_gis']) { if ($config['activate_gis']) {
$menu_extra['godgismaps']['sub']['godmode/gis_maps/configure_gis_map']['text'] = __('Manage GIS Maps'); $menu_extra['godgismaps']['sub']['godmode/gis_maps/configure_gis_map']['text'] = __('Manage GIS Maps');
} }
$menu_extra['workspace']['sub']['operation/messages/message_edit']['text'] = __('Manage messages'); $menu_extra['workspace']['sub']['operation/messages/message_edit']['text'] = __('Manage messages');
$menu_extra['gagente']['sub']['godmode/groups/configure_group']['text'] = __('Manage groups');
$menu_extra['gagente']['sub']['godmode/groups/configure_modu_group']['text'] = __('Manage module groups'); $menu_extra['gagente']['sub']['godmode/groups/configure_modu_group']['text'] = __('Manage module groups');
$menu_extra['gagente']['sub']['godmode/agentes/configure_field']['text'] = __('Manage custom field'); $menu_extra['gagente']['sub']['godmode/agentes/configure_field']['text'] = __('Manage custom field');
@ -524,6 +524,9 @@ function menu_add_extras(&$menu)
$menu_extra['workspace']['sub']['operation/incidents/incident_detail']['text'] = __('Manage incident'); $menu_extra['workspace']['sub']['operation/incidents/incident_detail']['text'] = __('Manage incident');
$menu_extra['gusuarios']['sub']['godmode/groups/configure_group']['text'] = __('Manage groups');
$menu_extra['gusuarios']['sub']['godmode/tag/edit_tag']['text'] = __('Tags management');
// Duplicate extensions as sec=extension to check it from url. // Duplicate extensions as sec=extension to check it from url.
foreach ($menu as $k => $m) { foreach ($menu as $k => $m) {
if (!isset($m['sub'])) { if (!isset($m['sub'])) {
@ -532,7 +535,9 @@ function menu_add_extras(&$menu)
foreach ($m['sub'] as $kk => $mm) { foreach ($m['sub'] as $kk => $mm) {
if (isset($mm['sec'])) { if (isset($mm['sec'])) {
$menu_extra[$mm['sec']]['sub'][$kk]['text'] = $mm['text']; if (empty($menu[$mm['sec']]['sub'][$kk]['text']) === true) {
$menu_extra[$mm['sec']]['sub'][$kk]['text'] = $mm['text'];
}
} }
} }
} }

View File

@ -26,6 +26,8 @@
* ============================================================================ * ============================================================================
*/ */
use PandoraFMS\Enterprise\Metaconsole\Node;
// Begin. // Begin.
require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_users.php';
@ -1435,6 +1437,90 @@ function modules_get_agentmodule_name($id_agente_modulo)
} }
/**
* Get the module names of an agent module.
*
* @param array $array_ids Agents module ids.
*
* @return array Id => name.
*/
function modules_get_agentmodule_name_array($array_ids)
{
if (is_array($array_ids) === false || empty($array_ids) === true) {
return [];
}
if ((bool) is_metaconsole() === true) {
$modules = array_reduce(
$array_ids,
function ($carry, $item) {
$explode = explode('|', $item);
$carry[$explode[0]][] = $explode[1];
return $carry;
}
);
$result = [];
foreach ($modules as $tserver => $id_modules) {
if (metaconsole_connect(null, $tserver) == NOERR) {
$result_modules = modules_get_agentmodule_name_array_data(
$id_modules
);
$result[$tserver] = $result_modules;
metaconsole_restore_db();
}
}
} else {
$result = modules_get_agentmodule_name_array_data(
$array_ids
);
}
return $result;
}
/**
* Data names.
*
* @param array $array_ids Ids.
*
* @return array
*/
function modules_get_agentmodule_name_array_data($array_ids)
{
if (is_array($array_ids) === false || empty($array_ids) === true) {
return [];
}
$sql = sprintf(
'SELECT id_agente_modulo as id, nombre as `name`
FROM tagente_modulo
WHERE id_agente_modulo IN (%s)',
implode(',', $array_ids)
);
$result = db_get_all_rows_sql($sql);
if ($result === false) {
$result = [];
}
$result = array_reduce(
$result,
function ($carry, $item) {
$carry[$item['id']] = $item['name'];
return $carry;
},
[]
);
return $result;
}
/** /**
* Get the module descripcion of an agent module. * Get the module descripcion of an agent module.
* *
@ -3469,32 +3555,271 @@ function modules_get_agentmodule_mininterval_no_async($id_agent)
} }
function get_same_modules($agents, $modules) function get_modules_agents($id_module_group, $id_agents, $selection, $select_mode=true)
{ {
$modules_to_report = []; if ((bool) is_metaconsole() === true) {
if ($modules != '') { if ($select_mode === true) {
foreach ($modules as $m) { $agents = array_reduce(
$module_name = modules_get_agentmodule_name($m); $id_agents,
foreach ($agents as $a) { function ($carry, $item) {
$module_in_agent = db_get_value_filter( $explode = explode('|', $item);
'id_agente_modulo',
'tagente_modulo', $carry[$explode[0]][] = $explode[1];
[ return $carry;
'id_agente' => $a,
'nombre' => $module_name,
]
);
if ($module_in_agent) {
$modules_to_report[] = $module_in_agent;
} }
);
} else {
if (count($id_agents) > 0) {
$rows = db_get_all_rows_sql(
sprintf(
'SELECT `id_agente`, `id_tagente`, `id_tmetaconsole_setup`
FROM `tmetaconsole_agent`
WHERE `id_agente` IN (%s)',
implode(',', $id_agents)
)
);
} else {
$rows = [];
}
$agents = array_reduce(
$rows,
function ($carry, $item) {
if ($carry[$item['id_tmetaconsole_setup']] === null) {
$carry[$item['id_tmetaconsole_setup']] = [];
}
$carry[$item['id_tmetaconsole_setup']][] = $item['id_tagente'];
return $carry;
},
[]
);
}
$modules = [];
foreach ($agents as $tserver => $id_agents) {
if (metaconsole_connect(null, $tserver) == NOERR) {
$modules[$tserver] = select_modules_for_agent_group(
$id_module_group,
$id_agents,
$selection,
false,
false,
true
);
metaconsole_restore_db();
} }
} }
if (!$selection) {
// Common modules.
$final_modules = [];
$nodes_consulted = count($modules);
foreach ($modules as $tserver => $mods) {
foreach ($mods as $module) {
if ($final_modules[$module['nombre']] === null) {
$final_modules[$module['nombre']] = 0;
}
$final_modules[$module['nombre']]++;
}
}
$modules = [];
foreach ($final_modules as $module_name => $occurrences) {
if ($occurrences === $nodes_consulted) {
// Module already present in ALL nodes.
$modules[] = [
'id_agente_modulo' => $module_name,
'nombre' => $module_name,
];
}
}
} else {
// All modules.
$return = [];
$nodes = [];
foreach ($agents as $tserver => $id_agents) {
try {
$nodes[$tserver] = new Node($tserver);
} catch (Exception $e) {
hd($e);
}
$return = array_reduce(
$modules[$tserver],
function ($carry, $item) use ($tserver, $nodes) {
$t = [];
foreach ($item as $k => $v) {
$t[$k] = $v;
}
$t['id_node'] = $tserver;
if ($nodes[$tserver] !== null) {
$t['nombre'] = io_safe_output(
$nodes[$tserver]->server_name().' &raquo; '.$t['nombre']
);
}
$carry[] = $t;
return $carry;
},
$return
);
}
$modules = $return;
}
$modules = array_reduce(
$modules,
function ($carry, $item) {
$carry[$item['id_node'].'|'.$item['id_agente_modulo']] = $item['nombre'];
return $carry;
},
[]
);
} else {
$modules = select_modules_for_agent_group(
$id_module_group,
$id_agents,
$selection,
false
);
} }
$modules_to_report = array_merge($modules_to_report, $modules); return $modules;
}
/**
* List all modules in agents selection.
*
* @param array $agents Agents ids array.
* @param array $modules Modules ids array.
*
* @return array
*/
function get_same_modules($agents, $modules)
{
if (is_array($agents) === false || empty($agents) === true) {
return [];
}
$name_modules = modules_get_agentmodule_name_array_data(
array_values($modules)
);
$sql = sprintf(
'SELECT id_agente_modulo as id,
nombre as `name`
FROM tagente_modulo
WHERE id_agente IN (%s)',
implode(',', array_values($agents))
);
$all = db_get_all_rows_sql($sql);
if ($all === false) {
$all = [];
}
$all = array_reduce(
$all,
function ($carry, $item) use ($name_modules) {
if (array_search($item['name'], $name_modules)) {
$carry[$item['id']] = $item['id'];
}
return $carry;
},
[]
);
$modules_to_report = array_merge($all, $modules);
$modules_to_report = array_unique($modules_to_report); $modules_to_report = array_unique($modules_to_report);
return $modules_to_report; return $all;
}
/**
* List all modules in agents selection to metaconsole or node.
*
* @param array $agents Agents ids array.
* @param array $modules Modules ids array.
*
* @return array List modules [server|id_module, ...].
*/
function get_same_modules_all($agents, $modules, $select_mode=true)
{
if (is_array($agents) === false || empty($agents) === true) {
return [];
}
if (is_metaconsole() === true) {
$modules = array_reduce(
$modules,
function ($carry, $item) {
$explode = explode('|', $item);
$carry[$explode[0]][] = $explode[1];
return $carry;
}
);
if ($select_mode === true) {
$agents = array_reduce(
$agents,
function ($carry, $item) {
$explode = explode('|', $item);
$carry[$explode[0]][] = $explode[1];
return $carry;
}
);
} else {
$rows = db_get_all_rows_sql(
sprintf(
'SELECT `id_agente`, `id_tagente`, `id_tmetaconsole_setup`
FROM `tmetaconsole_agent`
WHERE `id_agente` IN (%s)',
implode(',', $agents)
)
);
$agents = array_reduce(
$rows,
function ($carry, $item) {
if ($carry[$item['id_tmetaconsole_setup']] === null) {
$carry[$item['id_tmetaconsole_setup']] = [];
}
$carry[$item['id_tmetaconsole_setup']][] = $item['id_tagente'];
return $carry;
},
[]
);
}
$result = [];
foreach ($agents as $tserver => $id_agents) {
if (metaconsole_connect(null, $tserver) == NOERR) {
$same_modules = get_same_modules($id_agents, $modules[$tserver]);
foreach ($same_modules as $id_module) {
$result[] = $tserver.'|'.$id_module;
}
metaconsole_restore_db();
}
}
} else {
$result = get_same_modules($agents, $modules);
}
return $result;
} }

View File

@ -532,6 +532,8 @@ function network_components_create_module_from_network_component($id_network_com
'min_ff_event', 'min_ff_event',
'critical_inverse', 'critical_inverse',
'warning_inverse', 'warning_inverse',
'percentage_warning',
'percentage_critical',
'module_critical_instructions', 'module_critical_instructions',
'module_warning_instructions', 'module_warning_instructions',
'module_unknown_instructions', 'module_unknown_instructions',

View File

@ -734,6 +734,13 @@ function reporting_make_reporting_data(
); );
break; break;
case 'alert_report_actions':
$report['contents'][] = reporting_alert_report_actions(
$report,
$content
);
break;
case 'agents_inventory': case 'agents_inventory':
$report['contents'][] = reporting_agents_inventory( $report['contents'][] = reporting_agents_inventory(
$report, $report,
@ -873,6 +880,14 @@ function reporting_make_reporting_data(
); );
break; break;
case 'ncm':
$report['contents'][] = reporting_ncm_config(
$report,
$content,
$pdf
);
break;
default: default:
// Default. // Default.
break; break;
@ -2658,15 +2673,119 @@ function reporting_inventory($report, $content, $type)
} }
/**
* Build data for report alert actions.
*
* @param array $report Report info.
* @param array $content Content.
*
* @return array Result data.
*/
function reporting_alert_report_actions($report, $content)
{
$return = [];
$return['type'] = 'alert_report_actions';
if (empty($content['name']) === true) {
$content['name'] = __('Alert actions');
}
$return['title'] = io_safe_output($content['name']);
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = __('Actions');
$return['description'] = io_safe_output($content['description']);
$return['date'] = reporting_get_date_text($report, $content);
$return['data'] = [];
$es = json_decode($content['external_source'], true);
if (isset($report['id_template']) === true
&& empty($report['id_template']) === false
) {
if (is_metaconsole() === true) {
$server_id = metaconsole_get_id_server($content['server_name']);
$modules = [$server_id.'|'.$content['id_agent_module']];
$agents = [$server_id.'|'.$content['id_agent']];
} else {
$modules = [$content['id_agent_module']];
$agents = [$content['id_agent']];
}
} else {
$modules = json_decode(
io_safe_output(base64_decode($es['module'])),
true
);
$agents = json_decode(
io_safe_output(base64_decode($es['id_agents'])),
true
);
}
$period = $content['period'];
$id_group = $content['id_group'];
$templates = $es['templates'];
$actions = $es['actions'];
$show_summary = $es['show_summary'];
$group_by = $es['group_by'];
$lapse = $content['lapse'];
$only_data = $es['only_data'];
$filters = [
'group' => $id_group,
'agents' => $agents,
'modules' => $modules,
'templates' => $templates,
'actions' => $actions,
'period' => $period,
'show_summary' => (bool) $show_summary,
'only_data' => (bool) $only_data,
];
$groupsBy = [
'group_by' => $group_by,
'lapse' => $lapse,
];
$return['filters'] = $filters;
$return['groupsBy'] = $groupsBy;
$return['data'] = alerts_get_alert_fired($filters, $groupsBy);
return reporting_check_structure_content($return);
}
/**
* Data report agent/module.
*
* @param array $report Report info.
* @param array $content Content info.
*
* @return array Structure Content.
*/
function reporting_agent_module($report, $content) function reporting_agent_module($report, $content)
{ {
global $config; global $config;
$agents_and_modules = json_decode($content['external_source'], true); $external_source = json_decode(
$agents = []; $content['external_source'],
$agents = $agents_and_modules['id_agents']; true
$modules = $agents_and_modules['module']; );
$id_group = $content['id_group'];
$id_module_group = $content['id_module_group']; $agents = json_decode(
io_safe_output(
base64_decode($external_source['id_agents'])
),
true
);
$modules = json_decode(
io_safe_output(
base64_decode($external_source['module'])
),
true
);
$return['type'] = 'agent_module'; $return['type'] = 'agent_module';
@ -2700,7 +2819,9 @@ function reporting_agent_module($report, $content)
$cont = 0; $cont = 0;
foreach ($modules as $modul_id) { foreach ($modules as $modul_id) {
$modules_by_name[$cont]['name'] = io_safe_output(modules_get_agentmodule_name($modul_id)); $modules_by_name[$cont]['name'] = io_safe_output(
modules_get_agentmodule_name($modul_id)
);
$modules_by_name[$cont]['id'] = $modul_id; $modules_by_name[$cont]['id'] = $modul_id;
$cont++; $cont++;
} }
@ -9696,19 +9817,21 @@ function reporting_set_conf_charts(
$content, $content,
&$ttl &$ttl
) { ) {
global $config;
switch ($type) { switch ($type) {
case 'dinamic': case 'dinamic':
default: default:
$only_image = false; $only_image = false;
$width = 900; $width = 900;
$height = isset($content['style']['dyn_height']) ? $content['style']['dyn_height'] : 230; $height = isset($content['style']['dyn_height']) ? $content['style']['dyn_height'] : $config['graph_image_height'];
$ttl = 1; $ttl = 1;
break; break;
case 'static': case 'static':
$ttl = 2; $ttl = 2;
$only_image = true; $only_image = true;
$height = isset($content['style']['dyn_height']) ? $content['style']['dyn_height'] : 230; $height = isset($content['style']['dyn_height']) ? $content['style']['dyn_height'] : $config['graph_image_height'];
$width = 650; $width = 650;
break; break;

View File

@ -377,6 +377,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
reporting_html_agent_module($table, $item); reporting_html_agent_module($table, $item);
break; break;
case 'alert_report_actions':
reporting_html_alert_report_actions($table, $item);
break;
case 'agents_inventory': case 'agents_inventory':
reporting_html_agents_inventory($table, $item); reporting_html_agents_inventory($table, $item);
break; break;
@ -437,6 +441,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
$mini $mini
); );
break; break;
case 'ncm':
reporting_html_ncm_config($table, $item);
break;
} }
if ($item['type'] == 'agent_module') { if ($item['type'] == 'agent_module') {
@ -2729,6 +2737,101 @@ function reporting_html_group_configuration($table, $item, $pdf=0)
} }
/**
* Html output report alert actions
*
* @param object $table Table.
* @param array $item Data for draw report.
* @param integer $pdf PDF output.
*
* @return string Html output.
*/
function reporting_html_alert_report_actions($table, $item, $pdf=0)
{
$data = $item['data'];
$groupsBy = $item['groupsBy'];
$output = '';
if (isset($data['data']) === true
&& empty($data['data']) === false
) {
foreach ($data['data'] as $period => $data_array) {
if (empty($period) === false) {
$output .= '<h1 class="h1-report-alert-actions">';
$output .= __('From').' ';
$output .= date(
'd-m-Y H:i:s',
$period
);
$output .= ' '.__('to').' ';
$output .= date('d-m-Y H:i:s', ($period + (int) $groupsBy['lapse']));
$output .= '</h1>';
}
$output .= get_alert_table($data_array);
}
if (isset($data['summary']) === true
&& empty($data['summary']) === false
) {
$output .= '<h1 class="h1-report-alert-actions">';
$output .= __('Total summary');
$output .= '</h1>';
$output .= get_alert_table($data['summary']);
}
} else {
$output .= ui_print_empty_data(
__('No alerts fired'),
'',
true
);
}
if ($pdf === 0) {
$table->colspan['alert_report_action']['cell'] = 3;
$table->cellstyle['alert_report_action']['cell'] = 'text-align: center;';
$table->data['alert_report_action']['cell'] = $output;
} else {
return $output;
}
}
/**
* Draw alert action table.
*
* @param array $data Data.
*
* @return string Html output.
*/
function get_alert_table($data)
{
$table = new StdCLass();
$table->width = '100%';
$table->data = [];
$table->head = [];
$table->headstyle = [];
$table->cellstyle = [];
$table->headstyle[0] = 'text-align:left;';
$head = reset($data);
foreach (array_reverse(array_keys($head)) as $name) {
$table->head[] = ucfirst($name);
}
foreach ($data as $key => $params) {
$table->cellstyle[$key][0] = 'text-align:left;';
foreach (array_reverse($params) as $name => $value) {
$table->data[$key][] = $value;
}
}
return html_print_table($table, true);
}
/** /**
* This type of report element will generate the interface graphs * This type of report element will generate the interface graphs
* of all those devices that belong to the selected group. * of all those devices that belong to the selected group.
@ -5977,3 +6080,43 @@ function reporting_html_permissions($table, $item, $pdf=0)
); );
} }
} }
/**
* HTML content for ncm configuration diff report.
*
* @param array $item Content generated by reporting_ncm_config.
*
* @return string HTML code.
*/
function reporting_html_ncm_config($table, $item, $pdf=0)
{
$key = uniqid();
if ($pdf === 0) {
ui_require_javascript_file('diff2html-ui.min');
ui_require_css_file('diff2html.min');
$script = "$(document).ready(function() {
const configuration = {
drawFileList: false,
collapsed: true,
matching: 'lines',
outputFormat: 'side-by-side',
};
const diff2htmlUi = new Diff2HtmlUI(
document.getElementById('".$key."'),
atob('".base64_encode($item['data'])."'),
configuration
);
diff2htmlUi.draw();
});";
$content = '<div class="w100p" id="'.$key.'"></div class="w100p">';
$content .= '<script>'.$script.'</script>';
$table->data[1] = $content;
$table->colspan[1][0] = 2;
} else {
$content = '<div style="text-align:left;margin-left: 14px;">';
$content .= str_replace("\n", '<br>', $item['data']);
$content .= '</div>';
return $content;
}
}

View File

@ -834,6 +834,7 @@ function reports_get_report_types($template=false, $not_editor=false)
'optgroup' => __('Alerts'), 'optgroup' => __('Alerts'),
'name' => __('Agent alert report '), 'name' => __('Agent alert report '),
]; ];
if (!$template) { if (!$template) {
$types['alert_report_group'] = [ $types['alert_report_group'] = [
'optgroup' => __('Alerts'), 'optgroup' => __('Alerts'),
@ -841,6 +842,11 @@ function reports_get_report_types($template=false, $not_editor=false)
]; ];
} }
$types['alert_report_actions'] = [
'optgroup' => __('Alerts'),
'name' => __('Actions alert report '),
];
$types['event_report_module'] = [ $types['event_report_module'] = [
'optgroup' => __('Events'), 'optgroup' => __('Events'),
'name' => __('Module event report'), 'name' => __('Module event report'),
@ -911,6 +917,11 @@ function reports_get_report_types($template=false, $not_editor=false)
]; ];
} }
$types['ncm'] = [
'optgroup' => __('NCM'),
'name' => __('Network configuration changes'),
];
return $types; return $types;
} }

View File

@ -1279,6 +1279,8 @@ function snmp_browser_create_modules_snmp(
'unknown_instructions' => '', 'unknown_instructions' => '',
'critical_inverse' => 0, 'critical_inverse' => 0,
'warning_inverse' => 0, 'warning_inverse' => 0,
'percentage_warning' => 0,
'percentage_critical' => 0,
'id_category' => 0, 'id_category' => 0,
'tags' => '', 'tags' => '',
'disabled_types_event' => '{"going_unknown":1}', 'disabled_types_event' => '{"going_unknown":1}',
@ -1336,6 +1338,8 @@ function snmp_browser_create_modules_snmp(
'unknown_instructions' => '', 'unknown_instructions' => '',
'critical_inverse' => 0, 'critical_inverse' => 0,
'warning_inverse' => 0, 'warning_inverse' => 0,
'percentage_warning' => 0,
'percentage_critical' => 0,
'id_category' => 0, 'id_category' => 0,
'disabled_types_event' => '{"going_unknown":1}', 'disabled_types_event' => '{"going_unknown":1}',
'min_ff_event_normal' => 0, 'min_ff_event_normal' => 0,
@ -1394,6 +1398,8 @@ function snmp_browser_create_modules_snmp(
'unknown_instructions' => '', 'unknown_instructions' => '',
'critical_inverse' => 0, 'critical_inverse' => 0,
'warning_inverse' => 0, 'warning_inverse' => 0,
'percentage_warning' => 0,
'percentage_critical' => 0,
'id_category' => 0, 'id_category' => 0,
'disabled_types_event' => '{"going_unknown":1}', 'disabled_types_event' => '{"going_unknown":1}',
'min_ff_event_normal' => 0, 'min_ff_event_normal' => 0,

View File

@ -794,7 +794,7 @@ function tags_get_acl_tags(
$acltags = []; $acltags = [];
foreach ($raw_acltags as $group => $taglist) { foreach ($raw_acltags as $group => $taglist) {
if (!empty($id_group) && !in_array($group, $id_group)) { if (empty($id_group) === false && array_key_exists($group, $id_group) === false) {
continue; continue;
} }

View File

@ -329,7 +329,7 @@ function ui_print_message($message, $class='', $attributes='', $return=false, $t
if (!$no_close_bool) { if (!$no_close_bool) {
// Use the no_meta parameter because this image is only in // Use the no_meta parameter because this image is only in
// the base console. // the base console.
$output .= '<a href="javascript: close_info_box(\''.$id.'\')">'.html_print_image('images/blade.png', true, false, false, true).'</a>'; $output .= '<a href="javascript: close_info_box(\''.$id.'\')">'.html_print_image('images/blade.png', true, false, false, false).'</a>';
} }
$output .= '</td> $output .= '</td>
@ -2748,7 +2748,8 @@ function ui_print_module_status(
$output = '<div style="background: '.$color; $output = '<div style="background: '.$color;
$output .= '" class="'.$class; $output .= '" class="'.$class;
$output .= '" title="'.$title.'"></div>'; $output .= ' forced_title" data-title="'.$title.'" title="';
$output .= $title.'" data-use_title_for_force_title="1"></div>';
if ($return === false) { if ($return === false) {
echo $output; echo $output;
@ -3459,6 +3460,11 @@ function ui_print_datatable(array $parameters)
} }
} }
$export_columns = '';
if ($parameters['csv_exclude_latest'] === true) {
$export_columns = ',columns: \'th:not(:last-child)\'';
}
$js .= ' $js .= '
if (dt_'.$table_id.'.page.info().pages > 1) { if (dt_'.$table_id.'.page.info().pages > 1) {
$("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").show() $("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").show()
@ -3489,8 +3495,7 @@ function ui_print_datatable(array $parameters)
order : "current", order : "current",
page : "All", page : "All",
search : "applied" search : "applied"
}, }'.$export_columns.'
columns: [1,'.$columns.']
} }
} }
], ],

View File

@ -861,7 +861,7 @@ function flot_slicesbar_graph(
$values2 = []; $values2 = [];
foreach ($data as $jsvar => $values) { foreach ($data as $jsvar => $values) {
$values2[] = implode($separator, $values); $values2[] = implode($separator, $values);
$i ++; $i++;
} }
$values = implode($separator2, $values2); $values = implode($separator2, $values2);

View File

@ -381,6 +381,52 @@ SimpleMapController.prototype.paint_nodes = function() {
}); });
} }
}); });
if (
typeof node["type_net"] !== "undefined" &&
node["type_net"] === "supernet"
) {
var items_list = {};
items_list["details"] = {
name: "Show/hide subnets",
icon: "show",
disabled: false,
callback: function(key, options) {
self.nodes.forEach(function(subnode) {
if (
subnode.id != node["id"] &&
subnode.id_parent != null &&
subnode.id_parent == node["id"]
) {
if ($("#node_" + subnode.id).css("display") == "none") {
$("#node_" + subnode.id).show();
} else {
$("#node_" + subnode.id).hide();
}
}
});
self.arrows.forEach(function(arrow) {
if (arrow.source == node["id"] || arrow.target == node["id"]) {
if (
$("#arrow_" + arrow.source + "_" + arrow.target).css(
"display"
) == "none"
) {
$("#arrow_" + arrow.source + "_" + arrow.target).show();
} else {
$("#arrow_" + arrow.source + "_" + arrow.target).hide();
}
}
});
}
};
$.contextMenu({
selector: "#node_" + node["id"],
items: items_list
});
}
} }
}); });
}; };
@ -416,6 +462,9 @@ SimpleMapController.prototype.paint_arrows = function() {
}) })
.attr("y2", function(d) { .attr("y2", function(d) {
return self.center_y + self.getSecondPoint(d["dest"], "y"); return self.center_y + self.getSecondPoint(d["dest"], "y");
})
.attr("id", function(d) {
return "arrow_" + d["source"] + "_" + d["target"];
}); });
} }
}; };

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
!function(n,e){"use strict";function t(){var n=e.createElement("style");n.type="text/css",n.innerHTML=g(".{0}{border-collapse:collapse}.{0} td{padding:0}.{1}:before{content:attr({2})}",[v,L,b]),e.getElementsByTagName("head")[0].appendChild(n)}function r(t){"interactive"===e.readyState||"complete"===e.readyState?i(t):n.addEventListener("DOMContentLoaded",function(){i(t)})}function i(t){try{var r=e.querySelectorAll("code.hljs,code.nohighlight");for(var i in r)r.hasOwnProperty(i)&&l(r[i],t)}catch(o){n.console.error("LineNumbers error: ",o)}}function l(n,e){"object"==typeof n&&f(function(){n.innerHTML=s(n,e)})}function o(n,e){if("string"==typeof n){var t=document.createElement("code");return t.innerHTML=n,s(t,e)}}function s(n,e){e=e||{singleLine:!1};var t=e.singleLine?0:1;return c(n),a(n.innerHTML,t)}function a(n,e){var t=u(n);if(""===t[t.length-1].trim()&&t.pop(),t.length>e){for(var r="",i=0,l=t.length;i<l;i++)r+=g('<tr><td class="{0}"><div class="{1} {2}" {3}="{5}"></div></td><td class="{4}"><div class="{1}">{6}</div></td></tr>',[j,m,L,b,p,i+1,t[i].length>0?t[i]:" "]);return g('<table class="{0}">{1}</table>',[v,r])}return n}function c(n){var e=n.childNodes;for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];h(r.textContent)>0&&(r.childNodes.length>0?c(r):d(r.parentNode))}}function d(n){var e=n.className;if(/hljs-/.test(e)){for(var t=u(n.innerHTML),r=0,i="";r<t.length;r++){var l=t[r].length>0?t[r]:" ";i+=g('<span class="{0}">{1}</span>\n',[e,l])}n.innerHTML=i.trim()}}function u(n){return 0===n.length?[]:n.split(y)}function h(n){return(n.trim().match(y)||[]).length}function f(e){n.setTimeout(e,0)}function g(n,e){return n.replace(/\{(\d+)\}/g,function(n,t){return e[t]?e[t]:n})}var v="hljs-ln",m="hljs-ln-line",p="hljs-ln-code",j="hljs-ln-numbers",L="hljs-ln-n",b="data-line-number",y=/\r\n|\r|\n/g;n.hljs?(n.hljs.initLineNumbersOnLoad=r,n.hljs.lineNumbersBlock=l,n.hljs.lineNumbersValue=o,t()):n.console.error("highlight.js not detected!")}(window,document);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,11 @@
/*! `abnf` grammar compiled for Highlight.js 11.3.1 */
(()=>{var e=(()=>{"use strict";return e=>{const a=e.regex,s=e.COMMENT(/;/,/$/)
;return{name:"Augmented Backus-Naur Form",illegal:/[!@#$^&',?+~`|:]/,
keywords:["ALPHA","BIT","CHAR","CR","CRLF","CTL","DIGIT","DQUOTE","HEXDIG","HTAB","LF","LWSP","OCTET","SP","VCHAR","WSP"],
contains:[{scope:"operator",match:/=\/?/},{scope:"attribute",
match:a.concat(/^[a-zA-Z][a-zA-Z0-9-]*/,/(?=\s*=)/)},s,{scope:"symbol",
match:/%b[0-1]+(-[0-1]+|(\.[0-1]+)+)?/},{scope:"symbol",
match:/%d[0-9]+(-[0-9]+|(\.[0-9]+)+)?/},{scope:"symbol",
match:/%x[0-9A-F]+(-[0-9A-F]+|(\.[0-9A-F]+)+)?/},{scope:"symbol",
match:/%[si](?=".*")/},e.QUOTE_STRING_MODE,e.NUMBER_MODE]}}})()
;hljs.registerLanguage("abnf",e)})();

View File

@ -0,0 +1,13 @@
/*! `accesslog` grammar compiled for Highlight.js 11.3.1 */
(()=>{var e=(()=>{"use strict";return e=>{
const n=e.regex,a=["GET","POST","HEAD","PUT","DELETE","CONNECT","OPTIONS","PATCH","TRACE"]
;return{name:"Apache Access Log",contains:[{className:"number",
begin:/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d{1,5})?\b/,relevance:5},{
className:"number",begin:/\b\d+\b/,relevance:0},{className:"string",
begin:n.concat(/"/,n.either(...a)),end:/"/,keywords:a,illegal:/\n/,relevance:5,
contains:[{begin:/HTTP\/[12]\.\d'/,relevance:5}]},{className:"string",
begin:/\[\d[^\]\n]{8,}\]/,illegal:/\n/,relevance:1},{className:"string",
begin:/\[/,end:/\]/,illegal:/\n/,relevance:0},{className:"string",
begin:/"Mozilla\/\d\.\d \(/,end:/"/,illegal:/\n/,relevance:3},{
className:"string",begin:/"/,end:/"/,illegal:/\n/,relevance:0}]}}})()
;hljs.registerLanguage("accesslog",e)})();

View File

@ -0,0 +1,17 @@
/*! `actionscript` grammar compiled for Highlight.js 11.3.1 */
(()=>{var e=(()=>{"use strict";return e=>{
const a=e.regex,t=/[a-zA-Z_$][a-zA-Z0-9_$]*/,n=a.concat(t,a.concat("(\\.",t,")*")),s={
className:"rest_arg",begin:/[.]{3}/,end:t,relevance:10};return{
name:"ActionScript",aliases:["as"],keywords:{
keyword:["as","break","case","catch","class","const","continue","default","delete","do","dynamic","each","else","extends","final","finally","for","function","get","if","implements","import","in","include","instanceof","interface","internal","is","namespace","native","new","override","package","private","protected","public","return","set","static","super","switch","this","throw","try","typeof","use","var","void","while","with"],
literal:["true","false","null","undefined"]},
contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,{
match:[/\bpackage/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{
match:[/\b(?:class|interface|extends|implements)/,/\s+/,t],className:{
1:"keyword",3:"title.class"}},{className:"meta",beginKeywords:"import include",
end:/;/,keywords:{keyword:"import include"}},{beginKeywords:"function",
end:/[{;]/,excludeEnd:!0,illegal:/\S/,contains:[e.inherit(e.TITLE_MODE,{
className:"title.function"}),{className:"params",begin:/\(/,end:/\)/,
contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s]
},{begin:a.concat(/:\s*/,/([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)/)}]},e.METHOD_GUARD],
illegal:/#/}}})();hljs.registerLanguage("actionscript",e)})();

Some files were not shown because too many files have changed in this diff Show More