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
# Version 7.0NG.758.1, AIX version
# Version 7.0NG.759, AIX version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
# 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,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

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

View File

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

View File

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

View File

@ -19,11 +19,11 @@
<choice id="com.pandorafms.pandorafms_src" visible="false">
<pkg-ref id="com.pandorafms.pandorafms_src"/>
</choice>
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.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">
<pkg-ref id="com.pandorafms.pandorafms_uninstall"/>
</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()" />
<script>
<![CDATA[

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -96,7 +96,6 @@ function agents_modules_load_js()
});
}
else {
var agentes_id = $("#id_agents2").val();
var id_agentes = getQueryParam("full_agents_id");
if (agentes_id === null && id_agentes !== null) {
@ -128,7 +127,6 @@ function agents_modules_load_js()
jQuery.each (data, function (id, value) {
// Remove keys_prefix from the index
id = id.substring(1);
option = $("<option></option>")
.attr ("value", value["id_agente"])
.html (value["alias"]);
@ -155,7 +153,6 @@ function agents_modules_load_js()
jQuery.each (data, function (id, value) {
// Remove keys_prefix from the index
id = id.substring(1);
option = $("<option></option>")
.attr ("value", value["id_agente"])
.html (value["alias"]);
@ -180,8 +177,8 @@ function agents_modules_load_js()
if(data){
jQuery.each (data, function (id, value) {
option = $("<option></option>")
.attr ("value", value["id_agente_modulo"])
.html (value["nombre"]);
.attr ("value", id)
.html (value);
$("#module").append (option);
});
}
@ -207,8 +204,8 @@ function agents_modules_load_js()
if(data){
jQuery.each (data, function (id, value) {
option = $("<option></option>")
.attr ("value", value["id_agente_modulo"])
.html (value["nombre"]);
.attr ("value", id)
.html (value);
$("#module").append (option);
});
}
@ -231,8 +228,8 @@ function agents_modules_load_js()
if(data){
jQuery.each (data, function (id, value) {
option = $("<option></option>")
.attr ("value", value["id_agente_modulo"])
.html (value["nombre"]);
.attr ("value", id)
.html (value);
$("#module").append (option);
});
@ -262,7 +259,6 @@ function agents_modules_load_js()
return results[1];
}
}
</script>
<?php
}

View File

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

View File

@ -1,7 +1,43 @@
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;
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` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL default '',
@ -11,10 +47,43 @@ CREATE TABLE IF NOT EXISTS `talert_calendar` (
UNIQUE (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar');
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 `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 `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` = 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';
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 `tagent_repository` ADD COLUMN `deployment_timeout` INT UNSIGNED DEFAULT 600 AFTER `path`;
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;
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_samples` 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`
@ -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` 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 '',
`name_network` varchar(255) default '',
`description` text NOT NULL,
`location` tinytext NOT NULL,
`location` int(10) unsigned NULL,
`id_recon_task` int(10) unsigned NOT NULL,
`scan_interval` tinyint(2) default 1,
`monitoring` tinyint(2) default 0,
`id_group` mediumint(8) unsigned NULL default 0,
`lightweight_mode` tinyint(2) default 0,
`users_operator` text,
`id_site` bigint unsigned,
`vrf` int(10) unsigned,
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;
CREATE TABLE IF NOT EXISTS `tipam_ip` (
@ -4033,7 +4038,9 @@ CREATE TABLE IF NOT EXISTS `tipam_supernet` (
`address` varchar(250) NOT NULL,
`mask` varchar(250) NOT NULL,
`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;
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
) 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_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.';
@ -4077,6 +4102,7 @@ CREATE TABLE IF NOT EXISTS `tsync_queue` (
`operation` text,
`table` text,
`error` MEDIUMTEXT,
`result` TEXT,
PRIMARY KEY (`id`)
) 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` (
`id` serial,
`name` varchar(255) UNIQUE,
`icon` VARCHAR(255) DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -4173,6 +4200,8 @@ CREATE TABLE IF NOT EXISTS `tncm_agent` (
`id_template` bigint(20) unsigned,
`execute_type` 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,
PRIMARY KEY (`id_agent`),
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
) 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
(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;'),
(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;'),
(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;');
INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5);
(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),(1,6);
-- ----------------------------------------------------------------------
-- 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` 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 {
$commons = array_intersect($out, $oid_snmp);
if ($get_common_modules) {
// Common modules is selected (default)
// Common modules is selected (default).
$out = $commons;
} else {
// All modules is selected
// All modules is selected.
$array1 = array_diff($out, $oid_snmp);
$array2 = array_diff($oid_snmp, $out);
$out = array_merge($commons, $array1, $array2);
@ -135,12 +135,12 @@ if (is_ajax()) {
'agents_update_secondary_groups',
[
$id_agent,
($add_secondary_groups) ? $groups_to_add : [],
($remove_secondary_groups) ? $groups_to_add : [],
(($add_secondary_groups) ? $groups_to_add : []),
(($remove_secondary_groups) ? $groups_to_add : []),
]
);
// 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'],
'critical_inverse' => $row2['critical_inverse'],
'warning_inverse' => $row2['warning_inverse'],
'percentage_warning' => $row2['percentage_warning'],
'percentage_critical' => $row2['percentage_critical'],
'critical_instructions' => $row2['critical_instructions'],
'warning_instructions' => $row2['warning_instructions'],
'unknown_instructions' => $row2['unknown_instructions'],

View File

@ -1544,6 +1544,8 @@ if ($update_module || $create_module) {
$unknown_instructions = (string) get_parameter('unknown_instructions');
$critical_inverse = (int) get_parameter('critical_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');
@ -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');
/*
@ -1697,6 +1708,8 @@ if ($update_module) {
'unknown_instructions' => $unknown_instructions,
'critical_inverse' => $critical_inverse,
'warning_inverse' => $warning_inverse,
'percentage_critical' => $percentage_critical,
'percentage_warning' => $percentage_warning,
'cron_interval' => $cron_interval,
'id_category' => $id_category,
'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'])
);
} else {
if ($prediction_module == 3) {
if ($prediction_module == MODULE_PREDICTION_SYNTHETIC) {
enterprise_hook(
'modules_create_synthetic_operations',
[
@ -1903,6 +1916,8 @@ if ($create_module) {
'unknown_instructions' => $unknown_instructions,
'critical_inverse' => $critical_inverse,
'warning_inverse' => $warning_inverse,
'percentage_critical' => $percentage_critical,
'percentage_warning' => $percentage_warning,
'cron_interval' => $cron_interval,
'id_category' => $id_category,
'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;
} else {
$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'])
);
} else {
if ($prediction_module == 3) {
if ($prediction_module == MODULE_PREDICTION_SYNTHETIC) {
enterprise_hook(
'modules_create_synthetic_operations',
[

View File

@ -253,6 +253,7 @@ $module_action = (string) get_parameter('module_action');
if ($module_action === 'delete') {
$id_agent_modules_delete = (array) get_parameter('id_delete');
$print_result_msg = true;
$count_correct_delete_modules = 0;
foreach ($id_agent_modules_delete as $id_agent_module_del) {
$id_grupo = (int) agents_get_agent_group($id_agente);
@ -268,12 +269,19 @@ if ($module_action === 'delete') {
}
if ($id_agent_module_del < 1) {
db_pandora_audit(
'HACK Attempt',
'Expected variable from form is not correct'
if (count($id_agent_modules_delete) === 1) {
ui_print_error_message(
__('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');
@ -421,6 +429,7 @@ if ($module_action === 'delete') {
}
}
if ($print_result_msg === true) {
$count_modules_to_delete = count($id_agent_modules_delete);
if ($count_correct_delete_modules == 0) {
ui_print_error_message(
@ -442,6 +451,7 @@ if ($module_action === 'delete') {
);
}
}
}
} else if ($module_action === 'disable') {
$id_agent_modules_disable = (array) get_parameter('id_delete');
@ -704,6 +714,8 @@ if ((bool) $checked === true) {
'quiet',
'critical_inverse',
'warning_inverse',
'percentage_critical',
'percentage_warning',
'id_policy_module',
]
);

View File

@ -99,6 +99,9 @@ if (is_ajax()) {
$component['str_critical'] = io_safe_output($component['str_critical']);
$component['warning_inverse'] = (bool) $component['warning_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);
return;
@ -328,6 +331,9 @@ if ($id_agent_module) {
$critical_inverse = $module['critical_inverse'];
$warning_inverse = $module['warning_inverse'];
$percentage_critical = $module['percentage_critical'];
$percentage_warning = $module['percentage_warning'];
$id_category = $module['id_category'];
@ -467,6 +473,8 @@ if ($id_agent_module) {
$critical_inverse = '';
$warning_inverse = '';
$percentage_critical = '';
$percentage_warning = '';
$each_ff = 0;
$ff_event_normal = '';

View File

@ -456,8 +456,16 @@ if (modules_is_string_type($id_module_type) || $edit) {
).'</span>';
}
$table_simple->data[2][1] .= '<br /><em>'.__('Inverse interval').'</em>';
$table_simple->data[2][1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true, $disabledBecauseInPolicy);
$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] .= '</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) {
$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>';
}
$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] .= '</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');
if ($disabledBecauseInPolicy) {
@ -1551,6 +1568,8 @@ $(document).ready (function () {
$('#minmax_critical').show();
$('#minmax_warning').show();
$('#svg_dinamic').show();
$('#percentage_warning').show();
$('#percentage_critical').show();
}
else {
// String types
@ -1559,6 +1578,8 @@ $(document).ready (function () {
$('#minmax_critical').hide();
$('#minmax_warning').hide();
$('#svg_dinamic').hide();
$('#percentage_warning').hide();
$('#percentage_critical').hide();
}
if (type_name_selected.match(/async/) == null) {
@ -1628,11 +1649,64 @@ $(document).ready (function () {
$('#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() {
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() {
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
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_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(max_w == 0 || max_w > min_w){

View File

@ -14,6 +14,7 @@
enterprise_include_once('include/functions_policies.php');
enterprise_include_once('godmode/agentes/module_manager_editor_prediction.php');
require_once 'include/functions_agents.php';
ui_require_jquery_file('validate');
$disabledBecauseInPolicy = false;
$disabledTextBecauseInPolicy = '';
@ -36,9 +37,9 @@ if ($row !== false && is_array($row)) {
// Services are an Enterprise feature.
$custom_integer_1 = $row['custom_integer_1'];
switch ($prediction_module) {
switch ((int) $prediction_module) {
case MODULE_PREDICTION_SERVICE:
$is_service = true;
$selected = 'service_selected';
$custom_integer_2 = 0;
break;
@ -61,20 +62,33 @@ if ($row !== false && is_array($row)) {
if (isset($first_op[1]) && $first_op[1] == 'avg') {
$is_synthetic_avg = true;
$selected = 'synthetic_avg_selected';
} else {
$is_synthetic = true;
$selected = 'synthetic_selected';
}
$custom_integer_1 = 0;
$custom_integer_2 = 0;
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:
$prediction_module = $custom_integer_1;
break;
}
} else {
$selected = 'capacity_planning';
$custom_integer_1 = 0;
}
@ -97,7 +111,7 @@ $data[0] = __('Source module');
$data[0] .= ui_print_help_icon('prediction_source_module', true);
$data[1] = '';
// 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) {
$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/>';
// 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);
$prediction_module_agent = modules_get_agentmodule_agent_name($prediction_module);
$agent_name_clean = $prediction_module_agent;
$agent_alias = agents_get_alias($id_agente_clean);
} else {
$id_agente_clean = $id_agente;
$agent_name_clean = $agent_name;
$id_agente_clean = 0;
$agent_name_clean = '';
$agent_alias = '';
}
$agent_alias = agents_get_alias($id_agente_clean);
$params = [];
$params['return'] = true;
@ -135,7 +150,8 @@ $params['use_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'hidden-id_agente_module_prediction';
$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) {
$sql = 'SELECT id_agente_modulo, nombre
FROM tagente_modulo
@ -143,19 +159,23 @@ if ($id_agente) {
AND history_data = 1
AND id_agente = '.$id_agente_clean.'
AND id_agente_modulo <> '.$id_agente_modulo;
$data[1] .= html_print_select_from_sql(
$sql,
'prediction_module',
$prediction_module,
false,
__('Select Module'),
0,
true
$data[1] .= html_print_input(
[
'type' => 'select_from_sql',
'sql' => $sql,
'name' => 'prediction_module',
'selected' => $prediction_module,
'nothing' => __('Select Module'),
'nothing_value' => 0,
'return' => true,
]
);
} else {
$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/>';
$periods[0] = __('Weekly');
@ -169,6 +189,56 @@ $data[1] .= '</div>';
$table_simple->colspan['prediction_module'][1] = 3;
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.
$selector_form = enterprise_hook('get_selector_form', [$custom_integer_1]);
if ($selector_form !== ENTERPRISE_NOT_HOOK) {
@ -187,10 +257,20 @@ if ($synthetic_module_form !== ENTERPRISE_NOT_HOOK) {
$data[0] = '';
$data[1] = $synthetic_module_form;
$table_simple->colspan['synthetic_module'][1] = 3;
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_module_form = enterprise_hook('get_netflow_module_form', [$custom_integer_1]);
if ($netflow_module_form !== ENTERPRISE_NOT_HOOK) {
@ -214,9 +294,7 @@ unset($table_advanced->data[3]);
enterprise_hook(
'setup_services_synth',
[
$is_service,
$is_synthetic,
$is_synthetic_avg,
$selected,
$is_netflow,
$ops,
]

View File

@ -235,7 +235,7 @@ $search_string = (string) get_parameter('search_string', '');
$group = (int) get_parameter('group', 0);
$group_search = (int) get_parameter('group_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.
$table_filter = new stdClass();

View File

@ -21,8 +21,6 @@ enterprise_include_once('meta/include/functions_alerts_meta.php');
check_login();
enterprise_hook('open_meta_frame');
if (! check_acl($config['id_user'], 0, 'LM')) {
db_pandora_audit(
'ACL Violation',
@ -50,6 +48,8 @@ if (is_ajax()) {
}
}
enterprise_hook('open_meta_frame');
if (defined('METACONSOLE')) {
$sec = 'advanced';
} else {
@ -695,7 +695,9 @@ $(document).ready (function () {
}
else {
$("[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]").trigger('change');
}
}
else {
@ -747,6 +749,7 @@ $(document).ready (function () {
if ($('#field5_value').val() !== '') {
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() {

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);
$user_groups = users_get_groups($config['user'], 'AR', false);
echo '<h3>'.__('Layers').'</h3>';
$table->width = '100%';
@ -562,7 +564,7 @@ $table->data[1][1] = '<div id="form_layer" class="invisible">
</tr>
<tr>
<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>
<td colspan="4"><hr /></td>
@ -883,7 +885,7 @@ function setLayerEditorData (data) {
var $layerFormIdInput = $("input#hidden-current_edit_layer_id");
var $layerFormNameInput = $("input#text-layer_name_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 $layerFormAgentButton = $("input#button-add_agent");
var $layerFormAgentsListItems = $("tr.agents_list_item");
@ -892,7 +894,8 @@ function setLayerEditorData (data) {
$layerFormIdInput.val(data.id);
$layerFormNameInput.val(data.name);
$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("");
$layerFormAgentButton.prop("disabled", true);
$layerFormAgentsListItems.remove();
@ -981,7 +984,7 @@ function unbindLayerEditorEvents () {
$layerFormNameInput.unbind("change");
$layerFormVisibleCheckbox.unbind("click");
$layerFormAgentsFromGroupSelect.unbind("change");
$layerFormAgentsFromGroupSelect.val('-1');
}
function getAgentRow (layerId, agentId, agentAlias) {
@ -990,7 +993,7 @@ function getAgentRow (layerId, agentId, agentAlias) {
var $deleteCol = $("<td />");
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) {
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] .= '</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'][2] = __('Critical status');
@ -682,6 +704,28 @@ $table->data['edit1'][1] = '<table width="100%">';
);
$table->data['edit1'][3] .= '</td>';
$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_1'][0] = '<b>'.__('Description').'</b>';
@ -1571,6 +1615,12 @@ $(document).ready (function () {
else if (this.id == "checkbox-warning_inverse") {
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") {
return; //Do none
}
@ -1830,6 +1880,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()
}
});
});
function changePluginSelect() {
@ -1950,6 +2025,8 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
'history_data',
'critical_inverse',
'warning_inverse',
'percentage_warning',
'percentage_critical',
'critical_instructions',
'warning_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')) {
// Audit //meter en extensiones.
$sub['godmode/admin_access_logs']['text'] = __('System audit log');
$sub['godmode/admin_access_logs']['id'] = 'System audit log';
$sub['godmode/audit_log']['text'] = __('System audit log');
$sub['godmode/audit_log']['id'] = 'System audit log';
$sub['godmode/setup/links']['text'] = __('Links');
$sub['godmode/setup/links']['id'] = 'Links';
$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');
$critical_inverse = (int) get_parameter('critical_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_tag_selected = (array) get_parameter('id_tag_selected');
$pure = get_parameter('pure', 0);
@ -383,6 +386,8 @@ if ($is_management_allowed === true && $create_component) {
'unknown_instructions' => $unknown_instructions,
'critical_inverse' => $critical_inverse,
'warning_inverse' => $warning_inverse,
'percentage_warning' => $percentage_warning,
'percentage_critical' => $percentage_critical,
'id_category' => $id_category,
'tags' => $tags,
'disabled_types_event' => $disabled_types_event,
@ -482,6 +487,8 @@ if ($is_management_allowed === true && $update_component) {
'unknown_instructions' => $unknown_instructions,
'critical_inverse' => $critical_inverse,
'warning_inverse' => $warning_inverse,
'percentage_warning' => $percentage_warning,
'percentage_critical' => $percentage_critical,
'id_category' => $id_category,
'tags' => $tags,
'disabled_types_event' => $disabled_types_event,

View File

@ -93,6 +93,8 @@ if ($create_network_from_module) {
$unknown_instructions = $data_module['unknown_instructions'];
$critical_inverse = $data_module['critical_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'];
$ff_event_normal = $data_module['min_ff_event_normal'];
$ff_event_warning = $data_module['min_ff_event_warning'];
@ -150,7 +152,9 @@ if (isset($id)) {
$warning_instructions = $component['warning_instructions'];
$unknown_instructions = $component['unknown_instructions'];
$critical_inverse = $component['critical_inverse'];
$percentage_critical = $component['percentage_critical'];
$warning_inverse = $component['warning_inverse'];
$percentage_warning = $component['percentage_warning'];
$id_category = $component['id_category'];
$tags = $component['tags'];
$ff_event_normal = $component['min_ff_event_normal'];
@ -233,6 +237,8 @@ if (isset($id)) {
$unknown_instructions = '';
$critical_inverse = 0;
$warning_inverse = 0;
$percentage_critical = 0;
$percentage_warning = 0;
$id_category = 0;
$tags = '';
$ff_event_normal = 0;
@ -823,6 +829,60 @@ $(document).ready (function () {
});
$("#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

View File

@ -13,6 +13,8 @@
// GNU General Public License for more details.
global $config;
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')) {
db_pandora_audit(
@ -185,8 +187,14 @@ $table->data[4][1] .= html_print_input_text(
1024,
true
).'</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] .= '</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->colspan[4][2] = 2;
@ -220,8 +228,15 @@ $table->data[5][1] .= html_print_input_text(
1024,
true
).'</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] .= '</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->colspan[6][1] = 3;
@ -518,6 +533,9 @@ $next_row++;
$('#string_warning').hide();
$('#minmax_critical').show();
$('#minmax_warning').show();
$('#percentage_warning').show();
$('#percentage_critical').show();
}
else {
// String types
@ -525,6 +543,8 @@ $next_row++;
$('#string_warning').show();
$('#minmax_critical').hide();
$('#minmax_warning').hide();
$('#percentage_warning').hide();
$('#percentage_critical').hide();
}
});
@ -566,11 +586,64 @@ $next_row++;
$('#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() {
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() {
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
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_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(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] .= html_print_input_text('str_warning', $str_warning, '', 5, 1024, true).'</span>';
// 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] .= '</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>';
$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] .= html_print_input_text('str_critical', $str_critical, '', 5, 1024, true).'</span>';
// 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] .= '</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');

View File

@ -175,6 +175,8 @@ $agent_max_value = true;
$agent_min_value = true;
$uncompressed_module = true;
$only_data = false;
// Users.
$id_users = [];
$users_groups = [];
@ -185,6 +187,16 @@ $nothing_value = 0;
$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) {
case 'new':
$actionParameter = 'save';
@ -199,7 +211,7 @@ switch ($action) {
$failover_type = REPORT_FAILOVER_TYPE_NORMAL;
$server_name = '';
$server_id = 0;
$dyn_height = 230;
$dyn_height = (empty($config['graph_image_height']) === false) ? $config['graph_image_height'] : REPORT_ITEM_DYNAMIC_HEIGHT;
$landscape = false;
$pagebreak = false;
$summary = 0;
@ -240,7 +252,7 @@ switch ($action) {
$server_name = '';
$server_id = 0;
$get_data_editor = false;
$dyn_height = 230;
$dyn_height = (empty($config['graph_image_height']) === false) ? $config['graph_image_height'] : REPORT_ITEM_DYNAMIC_HEIGHT;
break;
}
@ -733,21 +745,73 @@ switch ($action) {
case 'agent_module':
$description = $item['description'];
$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');
$recursion = $item['recursion'];
if ((count($es['module']) == 1) && ($es['module'][0] == 0)) {
$module = '';
} else {
$module = $es['module'];
}
$group = $item['id_group'];
$modulegroup = $item['id_module_group'];
$idAgentModule = $module;
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':
$description = $item['description'];
$es = json_decode($item['external_source'], true);
@ -829,6 +893,10 @@ switch ($action) {
$select_by_group = $es['select_by_group'];
break;
case 'ncm':
$idAgent = $item['id_agent'];
break;
default:
// It's not possible.
break;
@ -1648,30 +1716,12 @@ $class = 'databox filters';
<td class="bolder"><?php echo __('Agents'); ?></td>
<td>
<?php
$all_agent_log = agents_get_agents(false, ['id_agente', 'alias']);
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;
}
}
}
}
$all_agents = agents_get_agents_selected($group);
html_print_select(
$agents2,
$all_agents,
'id_agents2[]',
$agents_select,
$id_agents,
$script = '',
'',
0,
@ -1680,7 +1730,23 @@ $class = 'databox filters';
true,
'',
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>
@ -1717,48 +1783,146 @@ $class = 'databox filters';
<td class="bolder"><?php echo __('Modules'); ?></td>
<td>
<?php
if (empty($id_agents) || $id_agents == null || $id_agents === 0) {
$all_modules = '';
if (empty($id_agents) === true) {
$all_modules = [];
$idAgentModule = [];
} else {
$all_modules = db_get_all_rows_sql(
'SELECT DISTINCT nombre FROM
tagente_modulo WHERE id_agente IN ('.implode(',', array_values($id_agents)).')'
$all_modules = get_modules_agents(
$modulegroup,
$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(
$all_modules_structured,
$all_modules,
'module[]',
$modules_select,
$idAgentModule,
$script = '',
__('None'),
'',
0,
false,
true,
true,
'',
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>
@ -2552,6 +2716,23 @@ $class = 'databox filters';
</td>
</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">
<td class="bolder"><?php echo __('Severity'); ?></td>
<td>
@ -2920,8 +3101,7 @@ $class = 'databox filters';
echo __('Time lapse intervals');
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,
'',
'',
__('None'),
'0',
10,
'',
@ -3109,6 +3289,58 @@ $class = 'databox filters';
</td>
</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">
<td class="bolder">
<?php
@ -4252,12 +4484,12 @@ $(document).ready (function () {
// Load selected modules by default
$("#id_agents2").trigger('click');
$('#combo_server').change (function (){
$('#combo_server').change(function () {
$("#id_agents").html('');
$("#id_agents2").html('');
$("#module").html('');
$("#inventory_modules").html('');
})
});
$("#text-url").keyup (
function () {
@ -4273,7 +4505,6 @@ $(document).ready (function () {
$("#combo_group").change (
function () {
// Alert report group must show all matches when selecting All group
// ignoring 'recursion' option. #6497.
if ($("#combo_group").val() == 0) {
@ -4284,7 +4515,12 @@ $(document).ready (function () {
}
$("#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);
$("#inventory_modules").html('');
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",
@ -4310,7 +4546,6 @@ $(document).ready (function () {
);
}
);
$("#combo_group").change();
$("#checkbox-recursion").change (
function () {
@ -4324,6 +4559,11 @@ $(document).ready (function () {
},
function (data, status) {
$("#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) {
// Remove keys_prefix from the index
id = id.substring(1);
@ -4347,14 +4587,17 @@ $(document).ready (function () {
"get_modules_group_json" : 1,
"id_module_group" : this.value,
"id_agents" : $("#id_agents2").val(),
"selection" : $("#selection_agent_module").val()
"selection" : $("#selection_agent_module").val(),
"select_mode": 1
},
function (data, status) {
$("#module").html('');
// Check module all.
$("#checkbox-module-check-all").prop('checked', false);
jQuery.each (data, function (id, value) {
option = $("<option></option>")
.attr ("value", value["id_agente_modulo"])
.html (value["nombre"]);
.attr ("value", id)
.html (value);
$("#module").append (option);
});
},
@ -4368,17 +4611,20 @@ $(document).ready (function () {
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",
"get_modules_group_json" : 1,
"selection" : $("#selection_agent_module").val(),
"id_module_group" : $("#combo_modulegroup").val(),
"id_agents" : $("#id_agents2").val(),
"selection" : $("#selection_agent_module").val()
"select_mode": 1
},
function (data, status) {
$("#module").html('');
// Check module all.
$("#checkbox-module-check-all").prop('checked', false);
if(data){
jQuery.each (data, function (id, value) {
option = $("<option></option>")
.attr ("value", value["id_agente_modulo"])
.html (value["nombre"]);
.attr ("value", id)
.html (value);
$("#module").append (option);
});
}
@ -4395,15 +4641,18 @@ $(document).ready (function () {
"get_modules_group_json" : 1,
"id_module_group" : $("#combo_modulegroup").val(),
"id_agents" : $("#id_agents2").val(),
"selection" : $("#selection_agent_module").val()
"selection" : $("#selection_agent_module").val(),
"select_mode": 1
},
function (data, status) {
$("#module").html('');
// Check module all.
$("#checkbox-module-check-all").prop('checked', false);
if(data){
jQuery.each (data, function (id, value) {
option = $("<option></option>")
.attr ("value", value["id_agente_modulo"])
.html (value["nombre"]);
.attr ("value", id)
.html (value);
$("#module").append (option);
});
}
@ -4494,6 +4743,15 @@ $(document).ready (function () {
}
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_agent':
case 'event_report_agent':
@ -4518,12 +4776,6 @@ $(document).ready (function () {
return false;
}
break;
case 'agent_module':
if ($("select#id_agents2>option:selected").val() == undefined) {
dialog_message('#message_no_agent');
return false;
}
break;
case 'inventory':
case 'inventory_changes':
if ($("select#id_agents>option:selected").val() == undefined) {
@ -4568,18 +4820,11 @@ $(document).ready (function () {
case 'sumatory':
case 'historical_data':
case 'increment':
if ($("#id_agent_module").val() == 0) {
dialog_message('#message_no_module');
return false;
}
break;
case 'agent_module':
if ($("select#module>option:selected").val() == undefined) {
dialog_message('#message_no_module');
return false;
}
break;
case 'inventory':
case 'inventory_changes':
if ($("select#inventory_modules>option:selected").val() == 0) {
@ -4632,6 +4877,15 @@ $(document).ready (function () {
return false;
}
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_agent':
case 'event_report_agent':
@ -4656,12 +4910,6 @@ $(document).ready (function () {
return false;
}
break;
case 'agent_module':
if ($("select#id_agents2>option:selected").val() == undefined) {
dialog_message('#message_no_agent');
return false;
}
break;
case 'inventory':
if ($("select#id_agents>option:selected").val() == undefined) {
dialog_message('#message_no_agent');
@ -4701,18 +4949,11 @@ $(document).ready (function () {
case 'sumatory':
case 'historical_data':
case 'increment':
if ($("#id_agent_module").val() == 0) {
dialog_message('#message_no_module');
return false;
}
break;
case 'agent_module':
if ($("select#module>option:selected").val() == undefined) {
dialog_message('#message_no_module');
return false;
}
break;
case 'inventory':
if ($("select#inventory_modules>option:selected").val() == 0) {
dialog_message('#message_no_module');
@ -5485,6 +5726,7 @@ function addGeneralRow() {
}
function chooseType() {
var meta = '<?php echo (is_metaconsole() === true) ? 1 : 0; ?>';
type = $("#type").val();
$("#row_description").hide();
$("#row_label").hide();
@ -5538,6 +5780,8 @@ function chooseType() {
$('#row_hide_notinit_agents').hide();
$('#row_priority_mode').hide();
$("#row_module_group").hide();
$("#row_alert_templates").hide();
$("#row_alert_actions").hide();
$("#row_servers").hide();
$("#row_sort").hide();
$("#row_date").hide();
@ -5562,6 +5806,7 @@ function chooseType() {
$("#select_agent_modules").hide();
$("#modules_row").hide();
$("#row_show_summary_group").hide();
$("#row_show_only_data").hide();
$("#row_event_severity").hide();
$("#row_event_type").hide();
$("#row_event_status").hide();
@ -5586,6 +5831,8 @@ function chooseType() {
$("#row_network_filter").hide();
$("#row_alive_ip").hide();
$("#row_agent_not_assigned_to_ip").hide();
$("#row_show_summary").hide();
$("#row_group_by").hide();
// SLA list default state.
$("#sla_list").hide();
@ -5896,6 +6143,37 @@ function chooseType() {
$("#row_historical_db_check").hide();
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':
$("#row_description").show();
$("#row_period").show();
@ -6319,6 +6597,11 @@ function chooseType() {
} else {
$("#row_profiles_group").hide();
}
break;
case 'ncm':
$("#row_agent").show();
break;
}

View File

@ -1676,22 +1676,77 @@ switch ($action) {
break;
case 'agent_module':
$agents_to_report = get_parameter('id_agents2');
$modules_to_report = get_parameter(
'module',
''
$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(
$es['module'] = get_same_modules_all(
$agents_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);
$good_format = true;
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':
$values['period'] = 0;
$es['date'] = get_parameter('date');
@ -2422,22 +2477,78 @@ switch ($action) {
break;
case 'agent_module':
$agents_to_report = get_parameter('id_agents2');
$modules_to_report = get_parameter(
'module',
''
$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(
$es['module'] = get_same_modules_all(
$agents_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);
$good_format = true;
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':
$values['period'] = get_parameter('period');
$es['id_agents'] = get_parameter('id_agents');

View File

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

View File

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

View File

@ -75,8 +75,8 @@ class RepoDisk extends Repo
$this->files = [];
while ($file_name = readdir($dh)) {
// Files must contain a version number.
if (preg_match('/(\d+)\_x86_64.'.$this->extension.'$/', $file_name, $utimestamp) === 1
|| preg_match('/(\d+)\.'.$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
) {
// Add the file to the repository.
$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);
$delete_event = get_parameter('delete_event', 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_id_source_event = get_parameter('get_id_source_event');
if ($get_comments) {
if ($get_comments === true) {
$event = get_parameter('event', false);
$filter = get_parameter('filter', false);
@ -94,6 +94,8 @@ if ($get_comments) {
return __('Failed to retrieve comments');
}
$eventsGrouped = [];
if ($filter['group_rep'] == 1) {
$events = events_get_all(
['te.*'],
@ -119,14 +121,41 @@ if ($get_comments) {
// True for show comments of validated events.
true
);
if ($events !== false) {
$event = $events[0];
}
} else {
// Consider if the event is grouped.
if (isset($event['event_rep']) === true && $event['event_rep'] > 0) {
// Evaluate if we are in metaconsole or not.
$eventTable = (is_metaconsole() === true) ? 'tmetaconsole_event' : 'tevento';
// 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']);
}
// Get grouped comments.
$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,
$meta,
is_metaconsole(),
$history
);
@ -134,8 +163,10 @@ if ($get_comments) {
$event = $events;
}
}
}
echo events_page_comments($event, true);
// End of get_comments.
echo events_page_comments($event, true, $eventsGrouped);
return;
}
@ -1207,26 +1238,19 @@ if ($dialogue_event_response) {
}
}
if ($add_comment) {
$aviability_comment = true;
$comment = get_parameter('comment');
if ($add_comment === true) {
$comment = (string) get_parameter('comment');
$eventId = (int) get_parameter('event_id');
// Safe comments for hacks.
if (preg_match('/script/i', io_safe_output($comment))) {
$aviability_comment = 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 {
echo 'comment_error';
$return = events_comment($eventId, $comment, 'Added comment', $meta, $history);
}
echo ($return === true) ? 'comment_ok' : 'comment_error';
return;
}
@ -1309,6 +1333,14 @@ if ($get_extended_event) {
&& isset($config['event_replication'])
&& $config['event_replication'] == 1
&& $config['show_events_in_local'] == 1
|| enterprise_hook(
'enterprise_acl',
[
$config['id_user'],
'eventos',
'execute_event_responses',
]
) === false
) {
$readonly = true;
}
@ -1330,6 +1362,10 @@ if ($get_extended_event) {
$timestamp_first = $event['min_timestamp'];
$timestamp_last = $event['max_timestamp'];
$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'];
$event['similar_ids'] = $similar_ids;
@ -1505,7 +1541,7 @@ if ($get_extended_event) {
$console_url = '';
// 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);
} else {
$server = '';
@ -1518,7 +1554,7 @@ if ($get_extended_event) {
}
$connected = true;
if ($meta) {
if ($meta || (is_metaconsole() && !empty($server_id))) {
if (metaconsole_connect($server) === NOERR) {
$connected = true;
} else {

View File

@ -1441,6 +1441,10 @@ class AgentWizard extends HTML
$result[$value]['criticalInv'] = $data[$k];
} else if (empty(preg_match('/module-warning-inv/', $k)) === false) {
$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) {
$result[$value]['moduleType'] = $data[$k];
} else if (empty(preg_match('/module-unit/', $k)) === false) {
@ -1856,6 +1860,8 @@ class AgentWizard extends HTML
$values['max_warning'] = $candidate['warningMax'];
$values['min_critical'] = $candidate['criticalMin'];
$values['max_critical'] = $candidate['criticalMax'];
$values['percentage_warning'] = $candidate['warningPerc'];
$values['percentage_critical'] = $candidate['criticalPerc'];
}
$values['warning_inverse'] = $candidate['warningInv'];
@ -2292,6 +2298,8 @@ class AgentWizard extends HTML
$tmp->max_warning($candidate['warningMax']);
$tmp->min_critical($candidate['criticalMin']);
$tmp->max_critical($candidate['criticalMax']);
$tmp->percentage_warning($candidate['warningPerc']);
$tmp->percentage_critical($candidate['criticalPerc']);
}
$tmp->warning_inverse($candidate['warningInv']);
@ -2457,6 +2465,8 @@ class AgentWizard extends HTML
'min_critical' => $moduleData['module_thresholds']['min_critical'],
'max_critical' => $moduleData['module_thresholds']['max_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'],
'name_oid' => $moduleData['value'],
'value' => $moduleData['value'],
@ -2636,6 +2646,8 @@ class AgentWizard extends HTML
'min_critical' => $moduleData['module_thresholds']['min_critical'],
'max_critical' => $moduleData['module_thresholds']['max_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'],
'current_value' => $currentValue,
'name_oid' => $moduleData['value'],
@ -3280,6 +3292,8 @@ class AgentWizard extends HTML
nc.min_critical,
nc.max_critical,
nc.critical_inverse AS `inv_critical`,
nc.percentage_warning AS `perc_warning`,
nc.percentage_critical AS `perc_critical`,
nc.module_enabled,
%s,
nc.scan_type,
@ -3867,9 +3881,11 @@ class AgentWizard extends HTML
$table->width = '100%';
$table->class = 'info_table';
// Subheaders for Warning and Critical columns.
$subheaders = '<span class=\'font_w300 mrgn_lft_0.8em\'>Min.</span>';
$subheaders .= '<span class=\'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_0.8em\'>Min.</span>';
$subheaders .= '<span class=\'wizard-colum-levels font_w300 mrgn_lft_1.6em\'>Max.</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 = html_print_div(
[
@ -4081,7 +4097,7 @@ class AgentWizard extends HTML
);
$data_warning .= html_print_div(
[
'class' => 'wizard-column-levels',
'class' => 'wizard-column-levels-check',
'style' => 'margin-top: 0.3em;',
'content' => html_print_checkbox(
'module-warning-inv-'.$uniqueId,
@ -4089,7 +4105,24 @@ class AgentWizard extends HTML
$module['inv_warning'],
true,
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,
'form="form-create-modules"'
),
@ -4148,15 +4181,33 @@ class AgentWizard extends HTML
$data[4] .= html_print_div(
[
'class' => 'wizard-column-levels',
'class' => 'wizard-column-levels-check',
'style' => 'margin-top: 0.3em;',
'content' => html_print_checkbox(
'module-critical_inv_'.$uniqueId,
'module-critical-inv-'.$uniqueId,
$module['inv_critical'],
$module['inv_critical'],
true,
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,
'form="form-create-modules"'
),
@ -4534,6 +4585,8 @@ class AgentWizard extends HTML
'min_critical' => $min_critical,
'max_critical' => $max_critical,
'inv_critical' => $inv_critical,
'perc_warning' => false,
'perc_critical' => false,
],
];
@ -4589,6 +4642,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
@ -4641,6 +4696,8 @@ class AgentWizard extends HTML
'min_critical' => $minc,
'max_critical' => $maxc,
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
}
@ -4729,6 +4786,8 @@ class AgentWizard extends HTML
'min_critical' => '85',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
@ -4766,6 +4825,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
@ -4803,6 +4864,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
}
@ -4832,6 +4895,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
// IfInDiscards.
@ -4857,6 +4922,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
// IfOutDiscards.
@ -4882,6 +4949,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
// IfInErrors.
@ -4907,6 +4976,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
// IfOutErrors.
@ -4932,6 +5003,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
@ -5000,6 +5073,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
@ -5026,6 +5101,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
@ -5052,6 +5129,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
// IfOutUcastPkts.
@ -5077,6 +5156,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
// IfInNUcastPkts.
@ -5102,6 +5183,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
// IfOutNUcastPkts.
@ -5127,6 +5210,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
@ -5195,6 +5280,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
@ -5221,6 +5308,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
@ -5247,6 +5336,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
@ -5273,6 +5364,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
// IfHCInNUcastPkts.
@ -5298,6 +5391,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'inv_critical' => false,
'perc_warning' => false,
'perc_critical' => false,
],
];
// IfOutNUcastPkts.
@ -5323,6 +5418,8 @@ class AgentWizard extends HTML
'min_critical' => '0',
'max_critical' => '0',
'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>
<?php
$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(
'include/styles/tooltipster.bundle.min.css'
).'" />'."\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 .= 'class="border_1px_dd" style="';

View File

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

View File

@ -368,12 +368,15 @@ define('MODULE_WUX', 8);
define('MODULE_WIZARD', 9);
// Type of Modules of Prediction.
define('MODULE_PREDICTION_PLANNING', 1);
define('MODULE_PREDICTION_SERVICE', 2);
define('MODULE_PREDICTION_SYNTHETIC', 3);
define('MODULE_PREDICTION_NETFLOW', 4);
define('MODULE_PREDICTION_CLUSTER', 5);
define('MODULE_PREDICTION_CLUSTER_AA', 6);
define('MODULE_PREDICTION_CLUSTER_AP', 7);
define('MODULE_PREDICTION_TRENDING', 8);
// Forced agent OS ID for cluster agents.
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_UNSORT', 0);
define('REPORT_ITEM_DYNAMIC_HEIGHT', 230);
define('REPORT_OLD_TYPE_SIMPLE_GRAPH', 1);
define('REPORT_OLD_TYPE_CUSTOM_GRAPH', 2);
define('REPORT_OLD_TYPE_SLA', 3);

View File

@ -760,9 +760,13 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
if ($field[0] != '`') {
// If the field is as <table>.<field>, don't scape.
if (strstr($field, '.') === false) {
if (preg_match('/(UPPER|LOWER)(.+)/mi', $field)) {
$field = preg_replace('/(UPPER|LOWER])\((.+)\)/mi', '$1(`$2`)', $field);
} else {
$field = '`'.$field.'`';
}
}
}
if ($value === null) {
$not = (($negative === true) ? 'NOT' : '');
@ -774,8 +778,59 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
$not = (($negative === true) ? ' !' : '');
$query .= sprintf('%s %s= %f', $field, $not, $value);
} else if (is_array($value)) {
$values_check = array_keys($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 {
if ($value === '') {
// 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.
*
@ -1386,7 +1390,7 @@ function mysql_db_process_file($path, $handle_error=true)
$query = '';
// Begin the transaction
mysql_db_process_sql_begin();
db_process_sql_begin();
foreach ($file_content as $sql_line) {
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) {
// Error. Rollback the transaction
mysql_db_process_sql_rollback();
db_process_sql_rollback();
if ($config['mysqli']) {
$error_message = mysqli_error($config['dbconnection']);
@ -1438,7 +1442,7 @@ function mysql_db_process_file($path, $handle_error=true)
}
// No errors. Commit the transaction
mysql_db_process_sql_commit();
db_process_sql_commit();
return true;
} else {
return false;
@ -1477,7 +1481,7 @@ function db_run_sql_file($location)
$mysqli->query($config['dbconnection'], 'START TRANSACTION');
} else {
// Run commands
mysql_db_process_sql_begin();
db_process_sql_begin();
// Begin transaction
}
@ -1503,7 +1507,7 @@ function db_run_sql_file($location)
$mysqli->query($config['dbconnection'], 'COMMIT');
$mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
} else {
mysql_db_process_sql_commit();
db_process_sql_commit();
// Save results
}
@ -1513,7 +1517,7 @@ function db_run_sql_file($location)
$mysqli->query($config['dbconnection'], 'ROLLBACK ');
$mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
} else {
mysql_db_process_sql_rollback();
db_process_sql_rollback();
// Undo results
}

View File

@ -1234,6 +1234,7 @@ function get_event_types($id_type=false)
$types['system'] = __('System');
$types['error'] = __('Error');
$types['configuration_change'] = __('Configuration change');
$types['ncm'] = __('Network configuration manager');
// This types are impersonated by the monitor 'x' types
// $types['going_up_normal'] = __('Going Normal');
@ -5965,3 +5966,24 @@ function send_test_email(
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.
*
@ -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).
*

View File

@ -2838,3 +2838,588 @@ function alerts_get_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)
{
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 != '') {
$all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.'');
} 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) {

View File

@ -1377,7 +1377,24 @@ function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache
break;
}
if ($rc !== false) {
db_sync($dbconnection, $sql, $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
@ -1388,7 +1405,7 @@ function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache
// Synchronize changes to nodes if needed.
$sync = new Synchronizer();
if ($sync !== null) {
if ($sync->queue($sql) === false) {
if ($sync->queue($sql, $rc) === false) {
// Launch events per failed query.
$errors = $sync->getLatestErrors();
if ($errors !== null) {
@ -1407,9 +1424,6 @@ function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache
error_log($errors);
}
}
}
return $rc;
}
@ -1808,19 +1822,19 @@ function db_process_sql_delete($table, $where, $where_join='AND')
function db_process_sql_begin()
{
global $config;
$null = null;
switch ($config['dbtype']) {
case 'mysql':
return mysql_db_process_sql_begin();
break;
case 'postgresql':
return postgresql_db_process_sql_begin();
break;
case 'oracle':
return oracle_db_process_sql_begin();
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,19 +1846,19 @@ function db_process_sql_begin()
function db_process_sql_commit()
{
global $config;
$null = null;
switch ($config['dbtype']) {
case 'mysql':
return mysql_db_process_sql_commit();
break;
case 'postgresql':
return postgresql_db_process_sql_commit();
break;
case 'oracle':
return oracle_db_process_sql_commit();
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,19 +1870,19 @@ function db_process_sql_commit()
function db_process_sql_rollback()
{
global $config;
$null = null;
switch ($config['dbtype']) {
case 'mysql':
return mysql_db_process_sql_rollback();
break;
case 'postgresql':
return postgresql_db_process_sql_rollback();
break;
case 'oracle':
return oracle_db_process_sql_rollback();
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>';
$table = new stdClass();
$table->id = 'database_debug';
$table->cellpadding = '0';
$table->width = '95%';
@ -1946,18 +1961,15 @@ function db_get_last_error()
global $config;
switch ($config['dbtype']) {
case 'mysql':
return mysql_db_get_last_error();
break;
case 'postgresql':
return postgresql_db_get_last_error();
break;
case 'oracle':
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;
switch ($config['dbtype']) {
case 'mysql':
return mysql_db_get_type_field_table($table, $field);
break;
case 'postgresql':
return postgresql_db_get_type_field_table($table, $field);
break;
case 'oracle':
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.
* ============================================================================
*/
// Begin.
global $config;
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_agents_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');
}
@ -1619,14 +1621,14 @@ function events_get_events($filter=false, $fields=false)
*/
function events_get_event($id, $fields=false, $meta=false, $history=false)
{
if (empty($id)) {
if (empty($id) === true) {
return false;
}
global $config;
if (is_array($fields)) {
if (! in_array('id_grupo', $fields)) {
if (is_array($fields) === true) {
if (in_array('id_grupo', $fields) === false) {
$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);
$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;
}
@ -2255,7 +2257,7 @@ function events_comment(
// If comments are not stored in json, the format is old.
$event_comments_array = json_decode($event_comments[0]['user_comment']);
if (empty($event_comments_array)) {
if (empty($event_comments_array) === true) {
$comments_format = 'old';
} else {
$comments_format = 'new';
@ -2268,6 +2270,7 @@ function events_comment(
$comment_for_json['action'] = $action;
$comment_for_json['id_user'] = $config['id_user'];
$comment_for_json['utimestamp'] = time();
$comment_for_json['event_id'] = $first_event;
$event_comments_array[] = $comment_for_json;
@ -2282,11 +2285,11 @@ function events_comment(
break;
case 'old':
// Give old ugly format to comment. TODO: Change this method for
// aux table or json.
// Give old ugly format to comment.
// Change this method for aux table or json.
$comment = str_replace(["\r\n", "\r", "\n"], '<br>', $comment);
if ($comment != '') {
if ($comment !== '') {
$commentbox = '<div class="comment_box">'.io_safe_input($comment).'</div>';
} else {
$commentbox = '';
@ -3245,6 +3248,10 @@ function events_get_event_types($type_id)
$type_desc = __('Not normal');
break;
case 'ncm':
$type_desc = __('Network configuration manager');
break;
default:
if (isset($config['text_char_long'])) {
foreach ($diferent_types as $key => $type) {
@ -5103,10 +5110,12 @@ function events_page_general($event)
* Generate 'comments' page for event viewer.
*
* @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.
*/
function events_page_comments($event, $ajax=false)
function events_page_comments($event, $ajax=false, $groupedComments=[])
{
// Comments.
global $config;
@ -5117,23 +5126,53 @@ function events_page_comments($event, $ajax=false)
$table_comments->head = [];
$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->colspan[0][0] = 2;
$data = [];
$data[0] = __('There are no comments');
$table_comments->data[] = $data;
} else {
if (is_array($comments)) {
if (is_array($comments) === true) {
$comments_array = [];
foreach ($comments as $comm) {
if (empty($comm)) {
if (empty($comm) === true) {
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));
}
// 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 {
$comments = str_replace(["\n", '&#x0a;'], '<br>', $comments);
// 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) {
// Show the comments more recent first.
if (is_array($comm)) {
$comm = array_reverse($comm);
}
if (empty($comm)) {
$comments_format = 'old';
} else {
$comments_format = 'new';
}
$comments_format = (empty($comm) === true) ? 'old' : 'new';
switch ($comments_format) {
case 'new':
foreach ($comm as $c) {
$data[0] = '<b>'.$c['action'].' by '.$c['id_user'].'</b>';
$data[0] .= '<br><br><i>'.date($config['date_format'], $c['utimestamp']).'</i>';
$eventIdExplanation = (empty($groupedComments) === false) ? sprintf(' (#%d)', $c['event_id']) : '';
$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>';
$table_comments->data[] = $data;
}
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);
}

View File

@ -729,7 +729,8 @@ function html_print_select(
$required=false,
$truncate_size=false,
$select2_enable=true,
$multiple_select2=false
$select2_multiple_enable=false,
$select2_multiple_enable_all=false
) {
$output = "\n";
@ -791,6 +792,12 @@ function html_print_select(
$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.'>';
if ($nothing !== false) {
@ -890,6 +897,24 @@ function html_print_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()) {
$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>
@ -901,8 +926,7 @@ function html_print_select(
$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_enable === true || $multiple_select2 === true) {
if (($multiple === false || $select2_multiple_enable === true) && $select2_enable === true) {
if (is_ajax()) {
$output .= '<script src="';
$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>';
}
@ -4046,6 +4096,10 @@ function html_print_input_file($name, $return=false, $options=false)
if (isset($options['required'])) {
$output .= ' required';
}
if (isset($options['onchange'])) {
$output .= ' onchange="'.$options['onchange'].'"';
}
}
$output .= ' />';
@ -4438,7 +4492,7 @@ function html_print_switch($attributes=[])
$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.">
<span class='p-slider".$disabled_class."'></span>
</label>";

View File

@ -158,6 +158,56 @@ function integria_api_call($api_hostname=null, $user=null, $user_pass=null, $api
{
global $config;
if (is_metaconsole()) {
$servers = metaconsole_get_connection_names();
foreach ($servers as $key => $server) {
$connection = metaconsole_get_connection($server);
if (metaconsole_connect($connection) != NOERR) {
continue;
}
$integria_enabled = db_get_sql(
'SELECT `value` FROM tconfig WHERE `token` = "integria_enabled"'
);
if (!$integria_enabled) {
metaconsole_restore_db();
continue;
}
// integria_user_level_conf, integria_hostname, integria_api_pass, integria_user, integria_user_level_user, integria_pass, integria_user_level_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'];
}
if ($conf['token'] === 'integria_hostname') {
$api_hostname = $conf['value'];
}
if ($conf['token'] === 'integria_api_pass') {
$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'];
}
@ -189,6 +239,7 @@ function integria_api_call($api_hostname=null, $user=null, $user_pass=null, $api
$user_pass = $user_info['integria_user_level_pass'];
}
}
}
if (is_array($params)) {
$params = implode($token, $params);

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_item_editor']['text'] = __('Graph template items');
$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']) {
$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['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/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['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.
foreach ($menu as $k => $m) {
if (!isset($m['sub'])) {
@ -532,10 +535,12 @@ function menu_add_extras(&$menu)
foreach ($m['sub'] as $kk => $mm) {
if (isset($mm['sec'])) {
if (empty($menu[$mm['sec']]['sub'][$kk]['text']) === true) {
$menu_extra[$mm['sec']]['sub'][$kk]['text'] = $mm['text'];
}
}
}
}
$menu = array_merge_recursive($menu, $menu_extra);

View File

@ -26,6 +26,8 @@
* ============================================================================
*/
use PandoraFMS\Enterprise\Metaconsole\Node;
// Begin.
require_once $config['homedir'].'/include/functions_agents.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.
*
@ -3469,32 +3555,271 @@ function modules_get_agentmodule_mininterval_no_async($id_agent)
}
function get_modules_agents($id_module_group, $id_agents, $selection, $select_mode=true)
{
if ((bool) is_metaconsole() === true) {
if ($select_mode === true) {
$agents = array_reduce(
$id_agents,
function ($carry, $item) {
$explode = explode('|', $item);
$carry[$explode[0]][] = $explode[1];
return $carry;
}
);
} 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
);
}
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)
{
$modules_to_report = [];
if ($modules != '') {
foreach ($modules as $m) {
$module_name = modules_get_agentmodule_name($m);
foreach ($agents as $a) {
$module_in_agent = db_get_value_filter(
'id_agente_modulo',
'tagente_modulo',
[
'id_agente' => $a,
'nombre' => $module_name,
]
);
if ($module_in_agent) {
$modules_to_report[] = $module_in_agent;
}
}
}
if (is_array($agents) === false || empty($agents) === true) {
return [];
}
$modules_to_report = array_merge($modules_to_report, $modules);
$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);
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',
'critical_inverse',
'warning_inverse',
'percentage_warning',
'percentage_critical',
'module_critical_instructions',
'module_warning_instructions',
'module_unknown_instructions',

View File

@ -734,6 +734,13 @@ function reporting_make_reporting_data(
);
break;
case 'alert_report_actions':
$report['contents'][] = reporting_alert_report_actions(
$report,
$content
);
break;
case 'agents_inventory':
$report['contents'][] = reporting_agents_inventory(
$report,
@ -873,6 +880,14 @@ function reporting_make_reporting_data(
);
break;
case 'ncm':
$report['contents'][] = reporting_ncm_config(
$report,
$content,
$pdf
);
break;
default:
// Default.
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)
{
global $config;
$agents_and_modules = json_decode($content['external_source'], true);
$agents = [];
$agents = $agents_and_modules['id_agents'];
$modules = $agents_and_modules['module'];
$id_group = $content['id_group'];
$id_module_group = $content['id_module_group'];
$external_source = json_decode(
$content['external_source'],
true
);
$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';
@ -2700,7 +2819,9 @@ function reporting_agent_module($report, $content)
$cont = 0;
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;
$cont++;
}
@ -9696,19 +9817,21 @@ function reporting_set_conf_charts(
$content,
&$ttl
) {
global $config;
switch ($type) {
case 'dinamic':
default:
$only_image = false;
$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;
break;
case 'static':
$ttl = 2;
$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;
break;

View File

@ -377,6 +377,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
reporting_html_agent_module($table, $item);
break;
case 'alert_report_actions':
reporting_html_alert_report_actions($table, $item);
break;
case 'agents_inventory':
reporting_html_agents_inventory($table, $item);
break;
@ -437,6 +441,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
$mini
);
break;
case 'ncm':
reporting_html_ncm_config($table, $item);
break;
}
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
* 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'),
'name' => __('Agent alert report '),
];
if (!$template) {
$types['alert_report_group'] = [
'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'] = [
'optgroup' => __('Events'),
'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;
}

View File

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

View File

@ -794,7 +794,7 @@ function tags_get_acl_tags(
$acltags = [];
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;
}

View File

@ -329,7 +329,7 @@ function ui_print_message($message, $class='', $attributes='', $return=false, $t
if (!$no_close_bool) {
// Use the no_meta parameter because this image is only in
// 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>
@ -2748,7 +2748,8 @@ function ui_print_module_status(
$output = '<div style="background: '.$color;
$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) {
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 .= '
if (dt_'.$table_id.'.page.info().pages > 1) {
$("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").show()
@ -3489,8 +3495,7 @@ function ui_print_datatable(array $parameters)
order : "current",
page : "All",
search : "applied"
},
columns: [1,'.$columns.']
}'.$export_columns.'
}
}
],

View File

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