Merge branch 'develop' into 'ent-8607-12764-Agregar-columna-IDs-personalizadas-a-VLANs-en-IPAM'

# Conflicts:
#   pandora_console/extras/mr/53.sql
This commit is contained in:
Alejandro Campos 2022-03-16 14:07:23 +00:00
commit 0c41459b83
137 changed files with 3365 additions and 1608 deletions

View File

@ -1,11 +1,12 @@
FROM pandorafms/pandorafms-base FROM pandorafms/pandorafms-base:centos7
# Build variables. # Build variables.
ARG BRANCH=develop ARG BRANCH=develop
ARG DB_PASS=pandora ARG DB_PASS=pandora
# Clone the Pandora FMS repo. # Clone the Pandora FMS repo.
RUN git clone --depth 1 -b "$BRANCH" https://github.com/pandorafms/pandorafms.git /tmp/pandorafms RUN git clone --depth 1 -b "$BRANCH" https://github.com/pandorafms/pandorafms.git /tmp/pandorafms || \
git clone --depth 1 -b develop https://github.com/pandorafms/pandorafms.git /tmp/pandorafms
# Install the Pandora FMS Server. # Install the Pandora FMS Server.
RUN cd /tmp/pandorafms/pandora_server && \ RUN cd /tmp/pandorafms/pandora_server && \
@ -21,21 +22,27 @@ RUN cd /tmp/pandorafms/pandora_agents/unix && \
RUN sed -i "s/#ServerName.*/ServerName localhost:80/" /etc/httpd/conf/httpd.conf RUN sed -i "s/#ServerName.*/ServerName localhost:80/" /etc/httpd/conf/httpd.conf
# Install the Pandora FMS Console. # Install the Pandora FMS Console.
RUN service mysqld start && \ RUN rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql && \
/usr/bin/mysqladmin -u root password "$DB_PASS" && \ mkdir -p /var/log/mysql/ && chown mysql. /var/log/mysql && \
service httpd start && \ chown mysql. -R /var/lib/mysql && \
cp -r /tmp/pandorafms/pandora_console /var/www/html && \ sudo -u mysql mysqld --initialize --explicit_defaults_for_timestamp && \
chown -R apache.apache /var/www/html/pandora_console/ && \ sudo -u mysql mysqld --daemonize & \
python /tmp/pandorafms/tests/install_console.py sleep 50 && \
mysql_default_pass=$(cat /var/log/mysqld.log | grep "temporary password" | awk '{print $NF}') && \
mysqladmin -u root -p"$mysql_default_pass" --user=root password 'pandora' && \
httpd -k start && \
cp -r /tmp/pandorafms/pandora_console /var/www/html && \
chown -R apache.apache /var/www/html/pandora_console/ && \
python /tmp/pandorafms/tests/install_console.py
# Redirect HTTP requests to / to the Pandora FMS Console. # Redirect HTTP requests to / to the Pandora FMS Console.
RUN echo '<meta http-equiv="refresh" content="0;url=/pandora_console">' > /var/www/html/index.html RUN echo '<meta http-equiv="refresh" content="0;url=/pandora_console">' > /var/www/html/index.html
# Create the entrypoint script. # Create the entrypoint script.
RUN echo -e '#/bin/bash\n \ RUN echo -e '#/bin/bash\n \
service mysqld start &&\n \ sudo -u mysql mysqld --daemonize &&\n \
service httpd start &&\n \ httpd -k start &&\n \
service crond start &&\n \ /usr/sbin/crond &&\n \
/etc/init.d/pandora_agent_daemon start && \ /etc/init.d/pandora_agent_daemon start && \
/etc/init.d/pandora_server start && \ /etc/init.d/pandora_server start && \
tail -f /var/log/pandora/pandora_server.log' \ tail -f /var/log/pandora/pandora_server.log' \

View File

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

View File

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

View File

@ -39,7 +39,7 @@ BEGIN {
use File::Copy; use File::Copy;
use Scalar::Util qw(looks_like_number); use Scalar::Util qw(looks_like_number);
use lib '/usr/lib/perl5'; BEGIN { push @INC, '/usr/lib/perl5'; }
################################################################################ ################################################################################
# Erase blank spaces before and after the string # Erase blank spaces before and after the string
@ -312,7 +312,7 @@ BEGIN {
$YAML = 1; $YAML = 1;
} }
use lib '/usr/lib/perl5'; BEGIN { push @INC, '/usr/lib/perl5'; }
our @ISA = ("Exporter"); our @ISA = ("Exporter");
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
@ -1003,7 +1003,7 @@ use IO::Socket;
use Sys::Syslog; use Sys::Syslog;
use Time::Local; use Time::Local;
use lib '/usr/lib/perl5'; BEGIN { push @INC, '/usr/lib/perl5'; }
# Agent XML data # Agent XML data
my $Xml; my $Xml;
@ -1015,7 +1015,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.760'; use constant AGENT_VERSION => '7.0NG.760';
use constant AGENT_BUILD => '220222'; use constant AGENT_BUILD => '220316';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.760 %define version 7.0NG.760
%define release 220222 %define release 220316
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}
@ -24,7 +24,7 @@ Requires(preun): chkconfig /bin/rm /usr/sbin/userdel
Requires: coreutils unzip Requires: coreutils unzip
Requires: util-linux procps grep Requires: util-linux procps grep
Requires: /sbin/ip /bin/awk Requires: /sbin/ip /bin/awk
Requires: perl perl(Sys::Syslog) perl(IO::Compress::Zip) Requires: perl(Sys::Syslog) perl(IO::Compress::Zip)
# Required by plugins # Required by plugins
#Requires: sh-utils sed passwd net-tools rpm #Requires: sh-utils sed passwd net-tools rpm
AutoReq: 0 AutoReq: 0

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.760 %define version 7.0NG.760
%define release 220222 %define release 220316
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -42,6 +42,8 @@ pidof_pandora () {
elif [ "$OS_NAME" = "SunOS" ] elif [ "$OS_NAME" = "SunOS" ]
then then
ZONENAME_CMD="/bin/zonename" ZONENAME_CMD="/bin/zonename"
# Has to be run from sources. The binary version inserts blanks between
# $DAEMON and $PANDORA_PATH.
TRUNCATED_DAEMON=`echo "$DAEMON $PANDORA_PATH" | cut -c1-20` TRUNCATED_DAEMON=`echo "$DAEMON $PANDORA_PATH" | cut -c1-20`
if [ -x $ZONENAME_CMD ] if [ -x $ZONENAME_CMD ]
then then
@ -59,7 +61,7 @@ pidof_pandora () {
then then
# Virtuozzo/OpenVZ # Virtuozzo/OpenVZ
local _pid _ctid _pids local _pid _ctid _pids
_pids=`ps -Af | grep "$DAEMON $PANDORA_PATH" | grep -v grep | awk '{ print $2 }'` _pids=`ps -Af | grep "$DAEMON" | grep "$PANDORA_PATH" | grep -v grep | awk '{ print $2 }'`
[ "$_pids" ] && for _pid in $_pids [ "$_pids" ] && for _pid in $_pids
do do
_ctid=`/usr/sbin/vzpid $_pid | awk '$1 == '$_pid' { print $2 }'` _ctid=`/usr/sbin/vzpid $_pid | awk '$1 == '$_pid' { print $2 }'`
@ -71,9 +73,9 @@ pidof_pandora () {
done done
elif [ "$OS_NAME" = "AIX" ]; then elif [ "$OS_NAME" = "AIX" ]; then
# AIX # AIX
PANDORA_PID=`ps -ef | grep "$DAEMON $PANDORA_PATH" | grep -v grep | awk '{ print $2 }'` PANDORA_PID=`ps -ef | grep "$DAEMON" | grep "$PANDORA_PATH" | grep -v grep | awk '{ print $2 }'`
else else
PANDORA_PID=`ps -Afw | grep "$DAEMON $PANDORA_PATH" | grep -v grep | awk '{ print $2 }'` PANDORA_PID=`ps -Afw | grep "$DAEMON" | grep "$PANDORA_PATH" | grep -v grep | awk '{ print $2 }'`
fi fi
echo $PANDORA_PID echo $PANDORA_PID

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.760" PI_VERSION="7.0NG.760"
PI_BUILD="220222" PI_BUILD="220316"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -14,7 +14,7 @@ use strict;
use LWP::Simple; use LWP::Simple;
use LWP::UserAgent; use LWP::UserAgent;
use MIME::Base64; use MIME::Base64;
use lib '/usr/lib/perl5'; BEGIN { push @INC, '/usr/lib/perl5'; }
use PandoraFMS::Tools; use PandoraFMS::Tools;
# Init # Init

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{220222} {220316}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -11,7 +11,7 @@ use strict;
use warnings; use warnings;
use File::Basename; use File::Basename;
use lib '/usr/lib/perl5'; BEGIN { push @INC, '/usr/lib/perl5'; }
use PandoraFMS::PluginTools; use PandoraFMS::PluginTools;
use PandoraFMS::Omnishell; use PandoraFMS::Omnishell;

View File

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

View File

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

View File

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

View File

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

View File

@ -11,6 +11,9 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
use PandoraFMS\Enterprise\Metaconsole\Node;
function dbmanager_query($sql, &$error, $dbconnection) function dbmanager_query($sql, &$error, $dbconnection)
{ {
global $config; global $config;
@ -88,6 +91,10 @@ function dbmgr_extension_main()
global $config; global $config;
if (is_metaconsole() === true) {
open_meta_frame();
}
if (!is_user_admin($config['id_user'])) { if (!is_user_admin($config['id_user'])) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,
@ -98,11 +105,59 @@ function dbmgr_extension_main()
} }
$sql = (string) get_parameter('sql'); $sql = (string) get_parameter('sql');
$node_id = (int) get_parameter('node_id', -1);
ui_print_page_header(__('Database interface'), 'images/gm_db.png', false, false, true); ui_print_page_header(__('Database interface'), 'images/gm_db.png', false, false, true);
echo '<div class="notify">'; if (is_metaconsole() === true) {
echo __( $img = '../../images/warning_modern.png';
} else {
$img = 'images/warning_modern.png';
}
$msg = '<div id="err_msg_centralised">'.html_print_image(
$img,
true
);
$msg .= '<div>'.__(
'Warning, you are accessing the database directly. You can leave the system inoperative if you run an inappropriate SQL statement'
).'</div></div>';
$warning_message = '<script type="text/javascript">
$(document).ready(function () {
infoMessage({
title: \''.__('Warning').'\',
text: \''.$msg.'\' ,
simple: true,
})
})
</script>';
if (empty($sql) === true) {
echo $warning_message;
}
echo "<form method='post' action=''>";
$table = new stdClass();
$table->id = 'db_interface';
$table->class = 'databox';
$table->width = '100%';
$table->data = [];
$table->head = [];
$table->colspan = [];
$table->rowstyle = [];
$table->colspan[0][0] = 2;
$table->colspan[1][0] = 2;
$table->rowspan[2][0] = 3;
$table->rowclass[0] = 'notify';
$table->rowclass[3] = 'pdd_5px';
$table->rowclass[3] = 'flex-content-right';
$table->rowclass[4] = 'flex-content-right';
$data[0][0] = __(
"This is an advanced extension to interface with %s database directly from WEB console "This is an advanced extension to interface with %s database directly from WEB console
using native SQL sentences. Please note that <b>you can damage</b> your %s installation using native SQL sentences. Please note that <b>you can damage</b> your %s installation
if you don't know </b>exactly</b> what are you are doing, if you don't know </b>exactly</b> what are you are doing,
@ -113,19 +168,59 @@ function dbmgr_extension_main()
get_product_name(), get_product_name(),
get_product_name() get_product_name()
); );
echo '</div>';
echo '<br />'; $data[1][0] = "Some samples of usage: <blockquote><em>SHOW STATUS;<br />DESCRIBE tagente<br />SELECT * FROM tserver<br />UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'</em></blockquote>";
echo "Some samples of usage: <blockquote><em>SHOW STATUS;<br />DESCRIBE tagente<br />SELECT * FROM tserver<br />UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'</em></blockquote>";
echo '<br /><br />'; \enterprise_include_once('include/functions_metaconsole.php');
echo "<form method='post' action=''>"; $servers = \metaconsole_get_servers();
html_print_textarea('sql', 5, 50, html_entity_decode($sql, ENT_QUOTES)); if (is_array($servers) === true) {
echo '<br />'; $servers = array_reduce(
echo '<div class="action-buttons w100p">'; $servers,
echo '<br />'; function ($carry, $item) {
html_print_submit_button(__('Execute SQL'), '', false, 'class="sub next"'); $carry[$item['id']] = $item['server_name'];
echo '</div>'; return $carry;
}
);
} else {
$servers = [];
}
$data[2][0] = html_print_textarea(
'sql',
5,
50,
html_entity_decode($sql, ENT_QUOTES),
'',
true
);
if (is_metaconsole() === true) {
$data[3][2] = html_print_input(
[
'name' => 'node_id',
'type' => 'select',
'fields' => $servers,
'selected' => $node_id,
'nothing' => __('This metaconsole'),
'nothing_value' => -1,
'return' => true,
'label' => _('Select query target'),
]
);
}
$data[4][2] = '<div class="action-buttons w100p">';
$data[4][2] .= html_print_submit_button(
__('Execute SQL'),
'',
false,
'class="sub next"',
true
);
$data[4][2] .= '</div>';
$table->data = $data;
html_print_table($table);
echo '</form>'; echo '</form>';
// Processing SQL Code // Processing SQL Code
@ -137,10 +232,29 @@ function dbmgr_extension_main()
echo '<hr />'; echo '<hr />';
echo '<br />'; echo '<br />';
$dbconnection = $config['dbconnection']; try {
$error = ''; if (\is_metaconsole() === true && $node_id !== -1) {
$node = new Node($node_id);
$result = dbmanager_query($sql, $error, $dbconnection); $dbconnection = @get_dbconnection(
[
'dbhost' => $node->dbhost(),
'dbport' => $node->dbport(),
'dbname' => $node->dbname(),
'dbuser' => $node->dbuser(),
'dbpass' => $node->dbpass(),
]
);
$error = '';
$result = dbmanager_query($sql, $error, $dbconnection);
} else {
$dbconnection = $config['dbconnection'];
$error = '';
$result = dbmanager_query($sql, $error, $dbconnection);
}
} catch (\Exception $e) {
$error = __('Error querying database node');
$result = false;
}
if ($result === false) { if ($result === false) {
echo '<strong>An error has occured when querying the database.</strong><br />'; echo '<strong>An error has occured when querying the database.</strong><br />';
@ -181,9 +295,29 @@ function dbmgr_extension_main()
html_print_table($table); html_print_table($table);
echo '</div>'; echo '</div>';
if (is_metaconsole()) {
close_meta_frame();
}
} }
if (is_metaconsole() === true) {
// This adds a option in the operation menu.
extensions_add_meta_menu_option(
'DB interface',
'PM',
'gextensions',
'database.png',
'v1r1',
'gdbman'
);
extensions_add_meta_function('dbmgr_extension_main');
} else {
}
// This adds a option in the operation menu // This adds a option in the operation menu
extensions_add_godmode_menu_option(__('DB interface'), 'PM', 'gextensions', 'dbmanager/icon.png', 'v1r1', 'gdbman'); extensions_add_godmode_menu_option(__('DB interface'), 'PM', 'gextensions', 'dbmanager/icon.png', 'v1r1', 'gdbman');

View File

@ -119,4 +119,8 @@ godmode/admin_access_logs.php
enterprise/extensions/backup/main.php enterprise/extensions/backup/main.php
enterprise/extensions/backup.php enterprise/extensions/backup.php
mobile/include/javascript/jquery.mobile-1.4.5.js mobile/include/javascript/jquery.mobile-1.4.5.js
mobile/include/style/jquery.mobile-1.4.5.css mobile/include/style/jquery.mobile-1.4.5.css
enterprise/extensions/backup/backup.js
enterprise/extensions/backup/sql/backup.sql
enterprise/extensions/backup/sql/backup.oracle.sql
enterprise/extensions/backup/sql/backup.postgreSQL.sql

View File

@ -5,17 +5,28 @@ CREATE INDEX `IDX_tservice_element` ON `tservice_element`(`id_service`,`id_agent
ALTER TABLE `tusuario` ADD COLUMN `local_user` tinyint(1) unsigned NOT NULL DEFAULT 0; ALTER TABLE `tusuario` ADD COLUMN `local_user` tinyint(1) unsigned NOT NULL DEFAULT 0;
ALTER TABLE tevent_response ADD COLUMN display_command tinyint(1) default 0; ALTER TABLE tevent_response ADD COLUMN display_command tinyint(1) default 0;
ALTER TABLE `talert_execution_queue`
DROP COLUMN `id_alert_template_module`,
DROP COLUMN `alert_mode`,
DROP COLUMN `extra_macros`,
MODIFY COLUMN `data` LONGTEXT;
ALTER TABLE `talert_templates` ADD COLUMN `schedule` TEXT; ALTER TABLE `talert_templates` ADD COLUMN `schedule` TEXT;
ALTER TABLE `tevent_alert` ADD COLUMN `schedule` TEXT; ALTER TABLE `tevent_alert` ADD COLUMN `schedule` TEXT;
SOURCE procedures/alertTemplates.sql;
CALL `migrateRanges`();
DROP PROCEDURE `migrateRanges`;
SOURCE procedures/alertEvents.sql;
CALL `migrateEventRanges`();
DROP PROCEDURE `migrateEventRanges`;
ALTER TABLE `tautoconfig` ADD COLUMN `disabled` TINYINT DEFAULT 0; ALTER TABLE `tautoconfig` ADD COLUMN `disabled` TINYINT DEFAULT 0;
UPDATE `tpolicy_groups` SET `policy_applied`=0;
CREATE TABLE IF NOT EXISTS `tpolicy_group_agents` (
`id` SERIAL,
`id_policy` INT UNSIGNED,
`id_agent` INT UNSIGNED,
`direct` TINYINT UNSIGNED DEFAULT 0,
FOREIGN KEY (`id_policy`) REFERENCES `tpolicies`(`id`)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
COMMIT; COMMIT;

View File

@ -2,4 +2,18 @@ START TRANSACTION;
ALTER TABLE `tipam_vlan` ADD COLUMN `custom_id` bigint(20) unsigned DEFAULT NULL; ALTER TABLE `tipam_vlan` ADD COLUMN `custom_id` bigint(20) unsigned DEFAULT NULL;
UPDATE `tuser_task` SET `parameters` = 'a:3:{i:0;a:2:{s:11:"description";s:11:"Description";s:4:"type";s:4:"text";}i:1;a:3:{s:11:"description";s:20:"Save to disk in path";s:4:"type";s:6:"string";s:13:"default_value";s:21:"_%_ATTACHMENT_PATH_%_";}i:2;a:3:{s:11:"description";s:14:"Active backups";s:4:"type";s:6:"number";s:13:"default_value";i:3;}}' WHERE `function_name` = 'cron_task_do_backup';
CREATE TABLE IF NOT EXISTS `tbackup` (
`id` SERIAL,
`utimestamp` BIGINT DEFAULT 0,
`filename` VARCHAR(512) DEFAULT '',
`id_user` VARCHAR(60) DEFAULT '',
`description` MEDIUMTEXT,
`pid` INT UNSIGNED DEFAULT 0,
`filepath` VARCHAR(512) DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
COMMIT; COMMIT;

View File

@ -1,40 +0,0 @@
CREATE PROCEDURE migrateEventRanges()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE i INT;
DECLARE r TEXT;
DECLARE cur1 CURSOR FOR SELECT `id` FROM `tevent_alert`;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
UPDATE `tevent_alert` SET `schedule` = '{"monday":_1_,"tuesday":_2_,"wednesday":_3_,"thursday":_4_,"friday":_5_,"saturday":_6_,"sunday":_7_}';
UPDATE `tevent_alert` SET `time_from` = "00:00:00", `time_to` = "00:00:00" WHERE `time_from` = `time_to`;
OPEN cur1;
read_loop: LOOP
FETCH cur1 INTO i;
IF done THEN
LEAVE read_loop;
END IF;
SELECT concat('[{"start":"', `time_from`, '","end":"', `time_to`, '"}]') into r FROM `tevent_alert` WHERE `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_1_", r) WHERE `monday` > 0 AND `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_2_", r) WHERE `tuesday` > 0 AND `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_3_", r) WHERE `wednesday` > 0 AND `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_4_", r) WHERE `thursday` > 0 AND `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_5_", r) WHERE `friday` > 0 AND `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_6_", r) WHERE `saturday` > 0 AND `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_7_", r) WHERE `sunday` > 0 AND `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_1_", '""') WHERE `monday` = 0 AND `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_2_", '""') WHERE `tuesday` = 0 AND `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_3_", '""') WHERE `wednesday` = 0 AND `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_4_", '""') WHERE `thursday` = 0 AND `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_5_", '""') WHERE `friday` = 0 AND `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_6_", '""') WHERE `saturday` = 0 AND `id` = i;
UPDATE `tevent_alert` SET `schedule` = REPLACE(`schedule`, "_7_", '""') WHERE `sunday` = 0 AND `id` = i;
END LOOP;
CLOSE cur1;
END ;

View File

@ -1,40 +0,0 @@
CREATE PROCEDURE migrateRanges()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE i INT;
DECLARE r TEXT;
DECLARE cur1 CURSOR FOR SELECT `id` FROM `talert_templates`;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
UPDATE `talert_templates` SET `schedule` = '{"monday":_1_,"tuesday":_2_,"wednesday":_3_,"thursday":_4_,"friday":_5_,"saturday":_6_,"sunday":_7_}';
UPDATE `talert_templates` SET `time_from` = "00:00:00", `time_to` = "00:00:00" WHERE `time_from` = `time_to`;
OPEN cur1;
read_loop: LOOP
FETCH cur1 INTO i;
IF done THEN
LEAVE read_loop;
END IF;
SELECT concat('[{"start":"', `time_from`, '","end":"', `time_to`, '"}]') into r FROM `talert_templates` WHERE `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_1_", r) WHERE `monday` > 0 AND `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_2_", r) WHERE `tuesday` > 0 AND `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_3_", r) WHERE `wednesday` > 0 AND `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_4_", r) WHERE `thursday` > 0 AND `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_5_", r) WHERE `friday` > 0 AND `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_6_", r) WHERE `saturday` > 0 AND `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_7_", r) WHERE `sunday` > 0 AND `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_1_", '""') WHERE `monday` = 0 AND `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_2_", '""') WHERE `tuesday` = 0 AND `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_3_", '""') WHERE `wednesday` = 0 AND `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_4_", '""') WHERE `thursday` = 0 AND `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_5_", '""') WHERE `friday` = 0 AND `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_6_", '""') WHERE `saturday` = 0 AND `id` = i;
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_7_", '""') WHERE `sunday` = 0 AND `id` = i;
END LOOP;
CLOSE cur1;
END ;

View File

@ -213,6 +213,20 @@ CREATE TABLE IF NOT EXISTS `tpolicy_groups` (
UNIQUE (`id_policy`, `id_group`) UNIQUE (`id_policy`, `id_group`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tpolicy_group_agents`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tpolicy_group_agents` (
`id` SERIAL,
`id_policy` INT UNSIGNED,
`id_agent` INT UNSIGNED,
`direct` TINYINT UNSIGNED DEFAULT 0,
FOREIGN KEY (`id_policy`) REFERENCES `tpolicies`(`id`)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tdashboard` -- Table `tdashboard`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
@ -4124,14 +4138,11 @@ ALTER TABLE `tperfil` ADD COLUMN `network_config_management`tinyint(1) NOT NULL
-- Table `talert_execution_queue` -- Table `talert_execution_queue`
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_execution_queue` ( CREATE TABLE IF NOT EXISTS `talert_execution_queue` (
`id` int(10) unsigned NOT NULL auto_increment, `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_alert_template_module` int(10) unsigned NOT NULL, `data` LONGTEXT,
`alert_mode` tinyint(1) NOT NULL, `utimestamp` BIGINT NOT NULL DEFAULT 0,
`data` mediumtext NOT NULL, PRIMARY KEY (`id`)
`extra_macros` text, ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
`utimestamp` bigint(20) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
UPDATE `tlanguage` SET `name` = 'Deutsch' WHERE `id_language` = 'de'; UPDATE `tlanguage` SET `name` = 'Deutsch' WHERE `id_language` = 'de';

View File

@ -36,30 +36,32 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
).'</div>'; ).'</div>';
// ======= Servers List =============================================== // ======= Servers List ===============================================
$servers_list = '<div id="servers_list">'; if ((bool) check_acl($config['id_user'], 0, 'AW') !== false) {
$servers = []; $servers_list = '<div id="servers_list">';
$servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver'); $servers = [];
if ($servers['all'] != 0) { $servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver');
$servers['up'] = (int) servers_check_status(); if ($servers['all'] != 0) {
$servers['down'] = ($servers['all'] - $servers['up']); $servers['up'] = (int) servers_check_status();
if ($servers['up'] == 0) { $servers['down'] = ($servers['all'] - $servers['up']);
// All Servers down or no servers at all. if ($servers['up'] == 0) {
$servers_check_img = html_print_image('images/header_down_gray.png', true, ['alt' => 'cross', 'class' => 'bot', 'title' => __('All systems').': '.__('Down')]); // All Servers down or no servers at all.
} else if ($servers['down'] != 0) { $servers_check_img = html_print_image('images/header_down_gray.png', true, ['alt' => 'cross', 'class' => 'bot', 'title' => __('All systems').': '.__('Down')]);
// Some servers down. } else if ($servers['down'] != 0) {
$servers_check_img = html_print_image('images/header_warning_gray.png', true, ['alt' => 'error', 'class' => 'bot', 'title' => $servers['down'].' '.__('servers down')]); // Some servers down.
} else { $servers_check_img = html_print_image('images/header_warning_gray.png', true, ['alt' => 'error', 'class' => 'bot', 'title' => $servers['down'].' '.__('servers down')]);
// All servers up. } else {
$servers_check_img = html_print_image('images/header_ready_gray.png', true, ['alt' => 'ok', 'class' => 'bot', 'title' => __('All systems').': '.__('Ready')]); // All servers up.
} $servers_check_img = html_print_image('images/header_ready_gray.png', true, ['alt' => 'ok', 'class' => 'bot', 'title' => __('All systems').': '.__('Ready')]);
}
unset($servers); unset($servers);
// Since this is the header, we don't like to trickle down variables. // Since this is the header, we don't like to trickle down variables.
$servers_check_img_link = '<a class="white" href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60">'; $servers_check_img_link = '<a class="white" href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60">';
$servers_check_img_link .= $servers_check_img; $servers_check_img_link .= $servers_check_img;
$servers_check_img_link .= '</a>'; $servers_check_img_link .= '</a>';
}; };
$servers_list .= $servers_check_img_link.'</div>'; $servers_list .= $servers_check_img_link.'</div>';
}

View File

@ -39,7 +39,7 @@ $(document).ready(function(){
var menuType_value = "<?php echo ($_SESSION['menu_type'] ?? ''); ?>"; var menuType_value = "<?php echo ($_SESSION['menu_type'] ?? ''); ?>";
if (menuType_value === '' || menuType_value === 'classic') { if (menuType_value === '' || menuType_value === 'classic') {
$('ul.submenu').css('left', '214px'); $('ul.submenu').css('left', '214px');
} }
else{ else{
$('ul.submenu').css('left', '59px'); $('ul.submenu').css('left', '59px');
@ -107,7 +107,12 @@ echo '</a></div>';
require 'operation/menu.php'; require 'operation/menu.php';
require 'godmode/menu.php'; require 'godmode/menu.php';
echo sprintf('<div id="button_collapse" class="button_%s button_collapse"></div>', $menuTypeClass); html_print_div(
[
'id' => 'button_collapse',
'class' => sprintf('button_collapse button_%s', $menuTypeClass),
]
);
echo '</div>'; echo '</div>';
// Menu_container. // Menu_container.
@ -122,7 +127,7 @@ if (isset($config['fixed_header']) === true) {
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
/* <![CDATA[ */ /* <![CDATA[ */
$('#button_collapse').on('click', function() { $('#button_collapse').on('click', function() {
if($('#menu_full').hasClass('menu_full_classic')){ if($('#menu_full').hasClass('menu_full_classic')){
localStorage.setItem("menuType", "collapsed"); localStorage.setItem("menuType", "collapsed");
@ -155,7 +160,7 @@ $('#button_collapse').on('click', function() {
$('.logo_full').toggle(); $('.logo_full').toggle();
$('.logo_icon').toggle(); $('.logo_icon').toggle();
$('#menu_full').toggleClass('menu_full_classic menu_full_collapsed'); $('#menu_full').toggleClass('menu_full_classic menu_full_collapsed');
$('#button_collapse').toggleClass('button_classic button_collapsed'); $('#button_collapse').toggleClass('button_classic button_collapsed');
$('div#title_menu').toggleClass('title_menu_classic title_menu_collapsed'); $('div#title_menu').toggleClass('title_menu_classic title_menu_collapsed');
$('div#page').toggleClass('page_classic page_collapsed'); $('div#page').toggleClass('page_classic page_collapsed');
@ -389,9 +394,9 @@ $(document).ready(function() {
if( typeof(table_hover) != 'undefined') if( typeof(table_hover) != 'undefined')
$("ul#sub"+table_hover[0].id).hide(); $("ul#sub"+table_hover[0].id).hide();
if( typeof(table_hover2) != 'undefined') if( typeof(table_hover2) != 'undefined')
$("ul#sub"+table_hover2[0].id).hide(); $("ul#sub"+table_hover2[0].id).hide();
}); });
$('div.menu>ul>li>ul>li>ul>li>a').click(function() { $('div.menu>ul>li>ul>li>ul>li>a').click(function() {
openTime = 4000; openTime = 4000;
if( typeof(table_hover) != 'undefined') if( typeof(table_hover) != 'undefined')
@ -399,7 +404,7 @@ $(document).ready(function() {
if( typeof(table_hover2) != 'undefined') if( typeof(table_hover2) != 'undefined')
$("ul#sub"+table_hover2[0].id).hide(); $("ul#sub"+table_hover2[0].id).hide();
}); });
}); });
</script> </script>

View File

@ -191,7 +191,7 @@ if ($disk_conf_delete) {
@unlink($filename['conf']); @unlink($filename['conf']);
} }
echo '<form autocomplete="new-password" name="conf_agent" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente">'; echo '<form autocomplete="new-password" name="conf_agent" id="form_agent" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente">';
// Custom ID. // Custom ID.
$custom_id_div = '<div class="label_select">'; $custom_id_div = '<div class="label_select">';
@ -452,123 +452,14 @@ if (!$new_agent && $alias != '') {
echo '</div>'; echo '</div>';
if (enterprise_installed()) { if (enterprise_installed()) {
$secondary_groups_selected = enterprise_hook('agents_get_secondary_groups', [$id_agente]); $adv_secondary_groups_label = '<div class="label_select">';
$adv_secondary_groups_label = '<div class="label_select"><p class="input_label">'.__('Secondary groups').'</p></div>'; $adv_secondary_groups_label .= '<p class="input_label">';
$adv_secondary_groups_left = html_print_select_groups( $adv_secondary_groups_label .= __('Secondary groups');
// Id_user. $adv_secondary_groups_label .= '</p>';
// Use the current user to select the groups. $adv_secondary_groups_label .= '</div>';
false, $select_agent_secondary = html_print_select_agent_secondary(
// Privilege. $agent,
// ACL permission. $id_agente
'AR',
// ReturnAllGroup.
// Not all group.
false,
// Name.
// HTML id.
'secondary_groups',
// Selected.
// No select any by default.
'',
// Script.
// Javascript onChange code.
'',
// Nothing.
// Do not user no selected value.
false,
// Nothing_value.
// Do not use no selected value.
0,
// Return.
// Return HTML (not echo).
true,
// Multiple.
// Multiple selection.
true,
// Sort.
// Sorting by default.
true,
// Class.
// CSS classnames (default).
'',
// Disabled.
// Not disabled (default).
false,
// Style.
// Inline styles (default).
'min-width:170px;',
// Option_style.
// Option style select (default).
false,
// Id_group.
// Do not truncate the users tree (default).
false,
// Keys_field.
// Key to get as value (default).
'id_grupo',
// Strict_user.
// Not strict user (default).
false,
// Delete_groups.
// Do not show the primary group in this selection.
array_merge(
(empty($secondary_groups_selected['plain']) === false) ? $secondary_groups_selected['plain'] : [],
[$agent['id_grupo']]
)
// Include_groups.
// Size.
// Simple_multiple_options.
);
$adv_secondary_groups_arrows = html_print_input_image(
'add_secondary',
'images/darrowright_green.png',
1,
'',
true,
[
'id' => 'right_autorefreshlist',
'title' => __('Add secondary groups'),
'onclick' => 'agent_manager_add_secondary_groups(event, '.$id_agente.');',
]
).html_print_input_image(
'remove_secondary',
'images/darrowleft_green.png',
1,
'',
true,
[
'id' => 'left_autorefreshlist',
'title' => __('Remove secondary groups'),
'onclick' => 'agent_manager_remove_secondary_groups(event, '.$id_agente.');',
]
);
$adv_secondary_groups_right .= html_print_select(
// Values.
$secondary_groups_selected['for_select'],
// HTML id.
'secondary_groups_selected',
// Selected.
'',
// Javascript onChange code.
'',
// Nothing selected.
false,
// Nothing selected.
0,
// Return HTML (not echo).
true,
// Multiple selection.
true,
// Sort.
true,
// Class.
'',
// Disabled.
false,
// Style.
'min-width:170px;'
); );
// Safe operation mode. // Safe operation mode.
@ -824,19 +715,15 @@ if (enterprise_installed()) {
} }
// General display distribution. // General display distribution.
$table_adv_options = $advanced_div.$adv_secondary_groups_label.' $table_adv_options = $advanced_div;
<div class="sg_source"> $table_adv_options .= $adv_secondary_groups_label;
'.$adv_secondary_groups_left.' $table_adv_options .= $select_agent_secondary;
</div> $table_adv_options .= '</div>';
<div class="secondary_group_arrows">
'.$adv_secondary_groups_arrows.' $table_adv_options .= '<div class="agent_av_opt_right" >';
</div> $table_adv_options .= $table_adv_parent;
<div class="sg_target"> $table_adv_options .= $table_adv_module_mode;
'.$adv_secondary_groups_right.' $table_adv_options .= $table_adv_cascade;
</div>
</div>
<div class="agent_av_opt_right" >
'.$table_adv_parent.$table_adv_module_mode.$table_adv_cascade;
if ($new_agent) { if ($new_agent) {
// If agent is new, show custom id as old style format. // If agent is new, show custom id as old style format.
@ -1113,133 +1000,6 @@ ui_require_jquery_file('bgiframe');
} }
} }
function agent_manager_add_secondary_groups (event, id_agent) {
event.preventDefault();
var primary_value = $("#grupo").val()
// The selected primary value cannot be selected like secondary
if ($("#secondary_groups option:selected[value=" + primary_value + "]").length > 0) {
alert("<?php echo __('Primary group cannot be secondary too.'); ?>")
return
}
// On agent creation PHP will update the secondary groups table (not via AJAX)
if (id_agent == 0) {
agent_manager_add_secondary_groups_ui();
agent_manager_update_hidden_input_secondary();
return;
}
var selected_items = new Array();
$("#secondary_groups option:selected").each(function(){
selected_items.push($(this).val())
})
var data = {
page: "godmode/agentes/agent_manager",
id_agent: id_agent,
groups: selected_items,
add_secondary_groups: 1,
}
// Make the AJAX call to update the secondary groups
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "html",
data: data,
success: function (data) {
if (data == 1) {
agent_manager_add_secondary_groups_ui();
} else {
console.error("Error in AJAX call to add secondary groups")
}
},
error: function (data) {
console.error("Fatal error in AJAX call to add secondary groups")
}
});
}
function agent_manager_remove_secondary_groups (event, id_agent) {
event.preventDefault();
// On agent creation PHP will update the secondary groups table (not via AJAX)
if (id_agent == 0) {
agent_manager_remove_secondary_groups_ui();
agent_manager_update_hidden_input_secondary();
return;
}
var selected_items = new Array();
$("#secondary_groups_selected option:selected").each(function(){
selected_items.push($(this).val())
})
var data = {
page: "godmode/agentes/agent_manager",
id_agent: id_agent,
groups: selected_items,
remove_secondary_groups: 1,
}
// Make the AJAX call to update the secondary groups
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "html",
data: data,
success: function (data) {
if (data == 1) {
agent_manager_remove_secondary_groups_ui();
} else {
console.error("Error in AJAX call to add secondary groups")
}
},
error: function (data) {
console.error("Fatal error in AJAX call to add secondary groups")
}
});
}
// Move from left input to right input
function agent_manager_add_secondary_groups_ui () {
$("#secondary_groups_selected option[value=0]").remove()
$("#secondary_groups option:selected").each(function() {
$(this).remove().appendTo("#secondary_groups_selected")
})
}
// Move from right input to left input
function agent_manager_remove_secondary_groups_ui () {
// Remove the groups selected if success
$("#secondary_groups_selected option:selected").each(function(){
$(this).remove().appendTo("#secondary_groups")
})
// Add none if empty select
if ($("#secondary_groups_selected option").length == 0) {
$("#secondary_groups_selected").append($('<option>',{
value: 0,
text: "<?php echo __('None'); ?>"
}))
}
}
function agent_manager_update_hidden_input_secondary () {
var groups = [];
if(!$('form[name="conf_agent"] #secondary_hidden').length) {
$('form[name="conf_agent"]').append(
'<input name="secondary_hidden" type="hidden" id="secondary_hidden">'
);
}
var groups = new Array();
$("#secondary_groups_selected option").each(function() {
groups.push($(this).val())
})
$("#secondary_hidden").val(groups.join(','));
}
$(document).ready (function() { $(document).ready (function() {

View File

@ -30,8 +30,9 @@
global $config; global $config;
enterprise_include('godmode/agentes/configurar_agente.php'); enterprise_include('godmode/agentes/configurar_agente.php');
enterprise_include('include/functions_policies.php');
enterprise_include_once('include/functions_modules.php'); enterprise_include_once('include/functions_modules.php');
enterprise_include_once('include/functions_config_agents.php');
enterprise_include('include/functions_policies.php');
require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_cron.php'; require_once $config['homedir'].'/include/functions_cron.php';
ui_require_javascript_file('encode_decode_base64'); ui_require_javascript_file('encode_decode_base64');
@ -307,23 +308,6 @@ if ($create_agent) {
$agent_created_ok = true; $agent_created_ok = true;
$tpolicy_group_old = db_get_all_rows_sql(
'SELECT id_policy FROM tpolicy_groups
WHERE id_group = '.$grupo
);
if ($tpolicy_group_old) {
foreach ($tpolicy_group_old as $key => $old_group) {
db_process_sql_insert(
'tpolicy_agents',
[
'id_policy' => $old_group['id_policy'],
'id_agent' => $id_agente,
]
);
}
}
$info = '{"Name":"'.$nombre_agente.'", $info = '{"Name":"'.$nombre_agente.'",
"IP":"'.$direccion_agente.'", "IP":"'.$direccion_agente.'",
"Group":"'.$grupo.'", "Group":"'.$grupo.'",
@ -1002,7 +986,6 @@ if ($update_agent) {
$fields = db_get_all_fields_in_table('tagent_custom_fields'); $fields = db_get_all_fields_in_table('tagent_custom_fields');
$secondary_groups = (string) get_parameter('secondary_hidden', ''); $secondary_groups = (string) get_parameter('secondary_hidden', '');
if ($fields === false) { if ($fields === false) {
$fields = []; $fields = [];
} }
@ -1117,12 +1100,6 @@ if ($update_agent) {
// Force an update of the agent cache. // Force an update of the agent cache.
} }
$group_old = db_get_sql('SELECT id_grupo FROM tagente WHERE id_agente ='.$id_agente);
$tpolicy_group_old = db_get_all_rows_sql(
'SELECT id_policy FROM tpolicy_groups
WHERE id_group = '.$group_old
);
$result = db_process_sql_update('tagente', $values, ['id_agente' => $id_agente]); $result = db_process_sql_update('tagente', $values, ['id_agente' => $id_agente]);
if ($result === false && $update_custom_result == false) { if ($result === false && $update_custom_result == false) {
@ -1161,59 +1138,6 @@ if ($update_agent) {
} }
} }
if ($tpolicy_group_old) {
foreach ($tpolicy_group_old as $key => $value) {
$tpolicy_agents_old = db_get_sql(
'SELECT * FROM tpolicy_agents
WHERE id_policy = '.$value['id_policy'].' AND id_agent = '.$id_agente
);
if ($tpolicy_agents_old) {
$result2 = db_process_sql_update(
'tpolicy_agents',
['pending_delete' => 1],
[
'id_agent' => $id_agente,
'id_policy' => $value['id_policy'],
]
);
}
}
}
$tpolicy_group = db_get_all_rows_sql(
'SELECT id_policy FROM tpolicy_groups
WHERE id_group = '.$grupo
);
if ($tpolicy_group) {
foreach ($tpolicy_group as $key => $value) {
$tpolicy_agents = db_get_sql(
'SELECT * FROM tpolicy_agents
WHERE id_policy = '.$value['id_policy'].' AND id_agent ='.$id_agente
);
if (!$tpolicy_agents) {
db_process_sql_insert(
'tpolicy_agents',
[
'id_policy' => $value['id_policy'],
'id_agent' => $id_agente,
]
);
} else {
$result3 = db_process_sql_update(
'tpolicy_agents',
['pending_delete' => 0],
[
'id_agent' => $id_agente,
'id_policy' => $value['id_policy'],
]
);
}
}
}
$info = '{ $info = '{
"id_agente":"'.$id_agente.'", "id_agente":"'.$id_agente.'",
"alias":"'.$alias.'", "alias":"'.$alias.'",
@ -2078,6 +2002,7 @@ if ($disable_module) {
io_safe_output($module_name), io_safe_output($module_name),
] ]
); );
// Force disable. // Force disable.
$disabled = 1; $disabled = 1;

View File

@ -533,10 +533,10 @@ if ($search != '') {
$search_sql .= ')'; $search_sql .= ')';
} else { } else {
$search_sql = sprintf( $search_sql = sprintf(
' AND ( nombre ' AND ( nombre
LIKE "%%%s%%" OR alias LIKE "%%%s%%" OR alias
LIKE "%%%s%%" OR comentarios LIKE "%%%s%%" LIKE "%%%s%%" OR comentarios LIKE "%%%s%%"
OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND description LIKE "%%%s%%")', OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND description LIKE "%%%s%%"))',
$search, $search,
$search, $search,
$search, $search,

View File

@ -639,20 +639,20 @@ $table->data[5][1] = "
<tr><td>".ui_get_using_system_timezone_warning().'</td></tr> <tr><td>".ui_get_using_system_timezone_warning().'</td></tr>
<tr> <tr>
<td>'.__('Type Periodicity:').'&nbsp;'.html_print_select( <td>'.__('Type Periodicity:').'&nbsp;'.html_print_select(
[ [
'weekly' => __('Weekly'), 'weekly' => __('Weekly'),
'monthly' => __('Monthly'), 'monthly' => __('Monthly'),
], ],
'type_periodicity', 'type_periodicity',
$type_periodicity, $type_periodicity,
'change_type_periodicity();', 'change_type_periodicity();',
'', '',
0, 0,
true, true,
false, false,
true, true,
'', '',
$disabled_in_execution $disabled_in_execution
)."</td> )."</td>
</tr> </tr>
<tr> <tr>
@ -672,31 +672,31 @@ $table->data[5][1] = "
<tr> <tr>
<td>".__('From day:').'</td> <td>".__('From day:').'</td>
<td>'.html_print_select( <td>'.html_print_select(
$days, $days,
'periodically_day_from', 'periodically_day_from',
$periodically_day_from, $periodically_day_from,
'', '',
'', '',
0, 0,
true, true,
false, false,
true, true,
'', '',
$disabled_in_execution $disabled_in_execution
).'</td> ).'</td>
<td>'.__('To day:').'</td> <td>'.__('To day:').'</td>
<td>'.html_print_select( <td>'.html_print_select(
$days, $days,
'periodically_day_to', 'periodically_day_to',
$periodically_day_to, $periodically_day_to,
'', '',
'', '',
0, 0,
true, true,
false, false,
true, true,
'', '',
$disabled_in_execution $disabled_in_execution
).'</td> ).'</td>
<td>'.ui_print_help_tip(__('The end day must be higher than the start day'), true).'</td> <td>'.ui_print_help_tip(__('The end day must be higher than the start day'), true).'</td>
</tr> </tr>
@ -705,26 +705,26 @@ $table->data[5][1] = "
<tr> <tr>
<td>'.__('From hour:').'</td> <td>'.__('From hour:').'</td>
<td>'.html_print_input_text( <td>'.html_print_input_text(
'periodically_time_from', 'periodically_time_from',
$periodically_time_from, $periodically_time_from,
'', '',
7, 7,
7, 7,
true, true,
$disabled_in_execution $disabled_in_execution
).ui_print_help_tip( ).ui_print_help_tip(
__('The end time must be higher than the start time'), __('The end time must be higher than the start time'),
true true
).'</td> ).'</td>
<td>'.__('To hour:').'</td> <td>'.__('To hour:').'</td>
<td>'.html_print_input_text( <td>'.html_print_input_text(
'periodically_time_to', 'periodically_time_to',
$periodically_time_to, $periodically_time_to,
'', '',
7, 7,
7, 7,
true, true,
$disabled_in_execution $disabled_in_execution
).ui_print_help_tip( ).ui_print_help_tip(
__('The end time must be higher than the start time'), __('The end time must be higher than the start time'),
true true
@ -1008,13 +1008,13 @@ $table->data['module'][1] = "
<td class='cell_delete_button' style='text-align: right; width:10%;' id=''>".'<a class="link_delete" <td class='cell_delete_button' style='text-align: right; width:10%;' id=''>".'<a class="link_delete"
onclick="if(!confirm(\''.__('Are you sure?').'\')) return false;" onclick="if(!confirm(\''.__('Are you sure?').'\')) return false;"
href="">'.html_print_image( href="">'.html_print_image(
'images/cross.png', 'images/cross.png',
true, true,
[ [
'border' => '0', 'border' => '0',
'alt' => __('Delete'), 'alt' => __('Delete'),
'class' => 'invert_filter', 'class' => 'invert_filter',
] ]
).'</a>'."</td> ).'</a>'."</td>
</tr> </tr>
<tr class='datos2' id='add_modules_row'> <tr class='datos2' id='add_modules_row'>

View File

@ -1,27 +1,53 @@
<?php <?php
/**
* Planned downtimes list.
*
* @category Planned downtimes
* @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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Load global vars.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
global $config; global $config;
check_login(); check_login();
$read_permisson = check_acl($config['id_user'], 0, 'AR'); $read_permisson = (bool) check_acl($config['id_user'], 0, 'AR');
$write_permisson = check_acl($config['id_user'], 0, 'AD'); $write_permisson = (bool) check_acl($config['id_user'], 0, 'AD');
$manage_permisson = check_acl($config['id_user'], 0, 'AW'); $manage_permisson = (bool) check_acl($config['id_user'], 0, 'AW');
$access = ($read_permisson == true) ? 'AR' : (($write_permisson == true) ? 'AD' : (($manage_permisson == true) ? 'AW' : 'AR')); $access = null;
if ($read_permisson === true) {
$access = 'AR';
}
if (! $read_permisson && !$manage_permisson) { if ($write_permisson === true) {
$access = 'AD';
}
if ($manage_permisson === true) {
$access = 'AW';
}
if ($read_permisson === false && $manage_permisson === false) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,
'Trying to access downtime scheduler' 'Trying to access downtime scheduler'
@ -35,16 +61,109 @@ require_once 'include/functions_events.php';
require_once 'include/functions_planned_downtimes.php'; require_once 'include/functions_planned_downtimes.php';
require_once 'include/functions_reporting.php'; require_once 'include/functions_reporting.php';
$malformed_downtimes = planned_downtimes_get_malformed(); if (is_ajax() === true) {
$malformed_downtimes_exist = !empty($malformed_downtimes) ? true : false; $show_info_agents_modules_affected = (bool) get_parameter(
'show_info_agents_modules_affected',
false
);
$get_info_agents_modules_affected = (bool) get_parameter(
'get_info_agents_modules_affected',
false
);
if ($show_info_agents_modules_affected === true) {
$id = (int) get_parameter('id', 0);
$columns = [
'agent_name',
'module_name',
];
$column_names = [
__('Agents'),
__('Modules'),
];
ui_print_datatable(
[
'id' => 'agent_modules_affected_planned_downtime',
'class' => 'info_table',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => 'godmode/agentes/planned_downtime.list',
'ajax_data' => [
'get_info_agents_modules_affected' => 1,
'id' => $id,
],
'order' => [
'field' => 'agent_name',
'direction' => 'asc',
],
'search_button_class' => 'sub filter float-right',
'form' => [
'inputs' => [
[
'label' => __('Agents'),
'type' => 'text',
'class' => 'w200px',
'id' => 'filter_agents',
'name' => 'filter_agents',
],
[
'label' => __('Modules'),
'type' => 'text',
'class' => 'w200px',
'id' => 'filter_modules',
'name' => 'filter_modules',
],
],
],
]
);
return;
}
if ($get_info_agents_modules_affected === true) {
$id = (int) get_parameter('id', 0);
// Catch post parameters.
$options = [
'limit' => get_parameter('start', 0),
'offset' => get_parameter('length', $config['block_size']),
'order' => get_datatable_order(),
'filters' => get_parameter('filter', []),
];
$modules = get_agents_modules_planned_dowtime($id, $options);
$count = get_agents_modules_planned_dowtime($id, $options, $count);
echo json_encode(
[
'data' => $modules,
'recordsTotal' => $count[0]['total'],
'recordsFiltered' => $count[0]['total'],
]
);
return;
}
return;
}
$malformed_downtimes = planned_downtimes_get_malformed();
$malformed_downtimes_exist = (empty($malformed_downtimes) === false) ? true : false;
$migrate_malformed = (bool) get_parameter('migrate_malformed'); $migrate_malformed = (bool) get_parameter('migrate_malformed');
if ($migrate_malformed) { if ($migrate_malformed === true) {
$migration_result = planned_downtimes_migrate_malformed_downtimes(); $migration_result = planned_downtimes_migrate_malformed_downtimes();
if ($migration_result['status'] == false) { $str = 'An error occurred while migrating the malformed scheduled downtimes';
$str2 = 'Please run the migration again or contact with the administrator';
if ((bool) $migration_result['status'] === false) {
ui_print_error_message( ui_print_error_message(
__('An error occurred while migrating the malformed scheduled downtimes').'. '.__('Please run the migration again or contact with the administrator') __($str).'. '.__($str2)
); );
echo '<br>'; echo '<br>';
} }
@ -63,12 +182,15 @@ ui_print_page_header(
$id_downtime = (int) get_parameter('id_downtime', 0); $id_downtime = (int) get_parameter('id_downtime', 0);
$stop_downtime = (bool) get_parameter('stop_downtime'); $stop_downtime = (bool) get_parameter('stop_downtime');
// STOP DOWNTIME // STOP DOWNTIME.
if ($stop_downtime) { if ($stop_downtime === true) {
$downtime = db_get_row('tplanned_downtime', 'id', $id_downtime); $downtime = db_get_row('tplanned_downtime', 'id', $id_downtime);
// Check AD permission on the downtime // Check AD permission on the downtime.
if (empty($downtime) || (! check_acl($config['id_user'], $downtime['id_group'], 'AD') && ! check_acl($config['id_user'], $downtime['id_group'], 'AW'))) { if (empty($downtime) === true
|| ((bool) check_acl($config['id_user'], $downtime['id_group'], 'AD') === false
&& (bool) check_acl($config['id_user'], $downtime['id_group'], 'AW') === false)
) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,
'Trying to access downtime scheduler' 'Trying to access downtime scheduler'
@ -80,7 +202,9 @@ if ($stop_downtime) {
$result = planned_downtimes_stop($downtime); $result = planned_downtimes_stop($downtime);
if ($result === false) { if ($result === false) {
ui_print_error_message(__('An error occurred stopping the scheduled downtime')); ui_print_error_message(
__('An error occurred stopping the scheduled downtime')
);
} else { } else {
echo $result['message']; echo $result['message'];
} }
@ -88,11 +212,14 @@ if ($stop_downtime) {
$delete_downtime = (int) get_parameter('delete_downtime'); $delete_downtime = (int) get_parameter('delete_downtime');
// DELETE WHOLE DOWNTIME! // DELETE WHOLE DOWNTIME!
if ($delete_downtime) { if (empty($delete_downtime) === false) {
$downtime = db_get_row('tplanned_downtime', 'id', $id_downtime); $downtime = db_get_row('tplanned_downtime', 'id', $id_downtime);
// Check AD permission on the downtime // Check AD permission on the downtime.
if (empty($downtime) || (! check_acl($config['id_user'], $downtime['id_group'], 'AD') && ! check_acl($config['id_user'], $downtime['id_group'], 'AW'))) { if (empty($downtime) === true
|| ((bool) check_acl($config['id_user'], $downtime['id_group'], 'AD') === false
&& (bool) check_acl($config['id_user'], $downtime['id_group'], 'AW') === false)
) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,
'Trying to access downtime scheduler' 'Trying to access downtime scheduler'
@ -102,10 +229,13 @@ if ($delete_downtime) {
} }
// The downtime shouldn't be running!! // The downtime shouldn't be running!!
if ($downtime['executed']) { if ((bool) $downtime['executed'] === true) {
ui_print_error_message(__('This scheduled downtime is running')); ui_print_error_message(__('This scheduled downtime is running'));
} else { } else {
$result = db_process_sql_delete('tplanned_downtime', ['id' => $id_downtime]); $result = db_process_sql_delete(
'tplanned_downtime',
['id' => $id_downtime]
);
ui_print_result_message( ui_print_result_message(
$result, $result,
@ -119,15 +249,25 @@ if ($delete_downtime) {
$offset = (int) get_parameter('offset'); $offset = (int) get_parameter('offset');
$filter_params = []; $filter_params = [];
$search_text = $filter_params['search_text'] = (string) get_parameter('search_text'); $search_text = (string) get_parameter('search_text');
$date_from = $filter_params['date_from'] = (string) get_parameter('date_from'); $date_from = (string) get_parameter('date_from');
$date_to = $filter_params['date_to'] = (string) get_parameter('date_to'); $date_to = (string) get_parameter('date_to');
$execution_type = $filter_params['execution_type'] = (string) get_parameter('execution_type'); $execution_type = (string) get_parameter('execution_type');
$show_archived = $filter_params['archived'] = (bool) get_parameter('archived'); $show_archived = (bool) get_parameter('archived');
$agent_id = $filter_params['agent_id'] = (int) get_parameter('agent_id'); $agent_id = (int) get_parameter('agent_id');
$agent_name = $filter_params['agent_name'] = (string) (!empty($agent_id) ? get_parameter('agent_name') : ''); $agent_name = (string) ((empty($agent_id) === false) ? get_parameter('agent_name') : '');
$module_id = $filter_params['module_id'] = (int) get_parameter('module_name_hidden'); $module_id = (int) get_parameter('module_name_hidden');
$module_name = $filter_params['module_name'] = (string) (!empty($module_id) ? get_parameter('module_name') : ''); $module_name = (string) ((empty($module_id) === false) ? get_parameter('module_name') : '');
$filter_params['search_text'] = $search_text;
$filter_params['date_from'] = $date_from;
$filter_params['date_to'] = $date_to;
$filter_params['execution_type'] = $execution_type;
$filter_params['archived'] = $show_archived;
$filter_params['agent_id'] = $agent_id;
$filter_params['agent_name'] = $agent_name;
$filter_params['module_id'] = $module_id;
$filter_params['module_name'] = $module_name;
$filter_params_str = http_build_query($filter_params); $filter_params_str = http_build_query($filter_params);
@ -141,11 +281,32 @@ $table_form->data = [];
$row = []; $row = [];
// Search text. // Search text.
$row[] = __('Search').'&nbsp;'.html_print_input_text('search_text', $search_text, '', 50, 250, true); $row[] = __('Search').'&nbsp;'.html_print_input_text(
'search_text',
$search_text,
'',
50,
250,
true
);
// Dates. // Dates.
$date_inputs = __('From').'&nbsp;'.html_print_input_text('date_from', $date_from, '', 10, 10, true); $date_inputs = __('From').'&nbsp;'.html_print_input_text(
'date_from',
$date_from,
'',
10,
10,
true
);
$date_inputs .= '&nbsp;&nbsp;'; $date_inputs .= '&nbsp;&nbsp;';
$date_inputs .= __('To').'&nbsp;'.html_print_input_text('date_to', $date_to, '', 10, 10, true); $date_inputs .= __('To').'&nbsp;'.html_print_input_text(
'date_to',
$date_to,
'',
10,
10,
true
);
$row[] = $date_inputs; $row[] = $date_inputs;
$table_form->data[] = $row; $table_form->data[] = $row;
@ -157,9 +318,24 @@ $execution_type_fields = [
'once' => __('Once'), 'once' => __('Once'),
'periodically' => __('Periodically'), 'periodically' => __('Periodically'),
]; ];
$row[] = __('Execution type').'&nbsp;'.html_print_select($execution_type_fields, 'execution_type', $execution_type, '', __('Any'), '', true, false, false); $row[] = __('Execution type').'&nbsp;'.html_print_select(
$execution_type_fields,
'execution_type',
$execution_type,
'',
__('Any'),
'',
true,
false,
false
);
// Show past downtimes. // Show past downtimes.
$row[] = __('Show past downtimes').'&nbsp;'.html_print_checkbox('archived', 1, $show_archived, true); $row[] = __('Show past downtimes').'&nbsp;'.html_print_checkbox(
'archived',
1,
$show_archived,
true
);
$table_form->data[] = $row; $table_form->data[] = $row;
@ -178,48 +354,84 @@ $agent_input = __('Agent').'&nbsp;'.ui_print_agent_autocomplete_input($params);
$row[] = $agent_input; $row[] = $agent_input;
// Module. // Module.
$row[] = __('Module').'&nbsp;'.html_print_autocomplete_modules('module_name', $module_name, false, true, '', [], true); $row[] = __('Module').'&nbsp;'.html_print_autocomplete_modules(
'module_name',
$module_name,
false,
true,
'',
[],
true
);
$row[] = html_print_submit_button(__('Search'), 'search', false, 'class="sub search"', true); $row[] = html_print_submit_button(
__('Search'),
'search',
false,
'class="sub search"',
true
);
$table_form->data[] = $row; $table_form->data[] = $row;
// End of table filter. // End of table filter.
// Useful to know if the user has done a form filtering. // Useful to know if the user has done a form filtering.
$filter_performed = false; $filter_performed = false;
$downtimes = [];
$groups = users_get_groups(false, $access); $groups = users_get_groups(false, $access);
if (!empty($groups)) { if (empty($groups) === false) {
$where_values = '1=1'; $where_values = '1=1';
$groups_string = implode(',', array_keys($groups)); $groups_string = implode(',', array_keys($groups));
$where_values .= " AND id_group IN ($groups_string)"; $where_values .= sprintf(' AND id_group IN (%s)', $groups_string);
// WARNING: add $filter_performed = true; to any future filter. // WARNING: add $filter_performed = true; to any future filter.
if (!empty($search_text)) { if (empty($search_text) === false) {
$filter_performed = true; $filter_performed = true;
$where_values .= sprintf(
$where_values .= " AND (name LIKE '%$search_text%' OR description LIKE '%$search_text%')"; ' AND (name LIKE "%%%s%%" OR description LIKE "%%%s%%")',
$search_text,
$search_text
);
} }
if (!empty($execution_type)) { if (empty($execution_type) === false) {
$filter_performed = true; $filter_performed = true;
$where_values .= sprintf(' AND type_execution = "%s"', $execution_type);
$where_values .= " AND type_execution = '$execution_type'";
} }
if (!empty($date_from)) { if (empty($date_from) === false) {
$filter_performed = true; $filter_performed = true;
$where_values .= sprintf(
$where_values .= " AND (type_execution = 'periodically' OR (type_execution = 'once' AND date_from >= '".strtotime("$date_from 00:00:00")."'))"; ' AND (type_execution = "periodically"
OR (type_execution = "once"
AND date_from >= "%s")
)',
strtotime($date_from.' 00:00:00')
);
} }
if (!empty($date_to)) { if (empty($date_to) === false) {
$filter_performed = true; $filter_performed = true;
$periodically_monthly_w = sprintf(
$periodically_monthly_w = "type_periodicity = 'monthly' 'type_periodicity = "monthly" AND (
AND ((periodically_day_from <= '".date('d', strtotime($date_from))."' AND periodically_day_to >= '".date('d', strtotime($date_to))."') (
OR (periodically_day_from > periodically_day_to periodically_day_from <= "%s"
AND (periodically_day_from <= '".date('d', strtotime($date_from))."' OR periodically_day_to >= '".date('d', strtotime($date_to))."')))"; AND periodically_day_to >= "%s"
)
OR (
periodically_day_from > periodically_day_to
AND (
periodically_day_from <= "%s"
OR periodically_day_to >= "%s"
)
)
)',
date('d', strtotime($date_from)),
date('d', strtotime($date_to)),
date('d', strtotime($date_from)),
date('d', strtotime($date_to))
);
$periodically_weekly_days = []; $periodically_weekly_days = [];
$date_from_aux = strtotime($date_from); $date_from_aux = strtotime($date_from);
@ -229,7 +441,7 @@ if (!empty($groups)) {
while ($date_from_aux <= $date_end && $days_number < 7) { while ($date_from_aux <= $date_end && $days_number < 7) {
$weekday_actual = strtolower(date('l', $date_from_aux)); $weekday_actual = strtolower(date('l', $date_from_aux));
$periodically_weekly_days[] = "$weekday_actual = 1"; $periodically_weekly_days[] = $weekday_actual.' = 1';
$date_from_aux = ($date_from_aux + SECONDS_1DAY); $date_from_aux = ($date_from_aux + SECONDS_1DAY);
$days_number++; $days_number++;
@ -237,36 +449,60 @@ if (!empty($groups)) {
$periodically_weekly_w = "type_periodicity = 'weekly' AND (".implode(' OR ', $periodically_weekly_days).')'; $periodically_weekly_w = "type_periodicity = 'weekly' AND (".implode(' OR ', $periodically_weekly_days).')';
$periodically_w = "type_execution = 'periodically' AND (($periodically_monthly_w) OR ($periodically_weekly_w))"; $periodically_w = sprintf(
'type_execution = "periodically" AND ((%s) OR (%s))',
$periodically_monthly_w,
$periodically_weekly_w
);
$once_w = "type_execution = 'once' AND date_to <= '".strtotime("$date_to 23:59:59")."'"; $once_w = sprintf(
'type_execution = "once" AND date_to <= "%s"',
strtotime($date_to.' 23:59:59')
);
$where_values .= " AND (($periodically_w) OR ($once_w))"; $where_values .= sprintf(
' AND ((%s) OR (%s))',
$periodically_w,
$once_w
);
} }
if (!$show_archived) { if ($show_archived === false) {
$filter_performed = true; $filter_performed = true;
$where_values .= sprintf(
$where_values .= " AND (type_execution = 'periodically' OR (type_execution = 'once' AND date_to >= '".time()."'))"; ' AND (type_execution = "periodically"
OR (type_execution = "once"
AND date_to >= "%s"))',
time()
);
} }
if (!empty($agent_id)) { if (empty($agent_id) === false) {
$filter_performed = true; $filter_performed = true;
$where_values .= sprintf(
$where_values .= " AND id IN (SELECT id_downtime FROM tplanned_downtime_agents WHERE id_agent = $agent_id)"; ' AND id IN (SELECT id_downtime FROM tplanned_downtime_agents WHERE id_agent = %d)',
$agent_id
);
} }
if (!empty($module_id)) { if (empty($module_id) === false) {
$filter_performed = true; $filter_performed = true;
$where_values .= sprintf(
$where_values .= " AND (id IN (SELECT id_downtime ' AND (id IN (
FROM tplanned_downtime_modules SELECT id_downtime
WHERE id_agent_module = $module_id) FROM tplanned_downtime_modules
OR id IN (SELECT id_downtime WHERE id_agent_module = %d)
FROM tplanned_downtime_agents tpda, tagente_modulo tam OR id IN (
WHERE tpda.id_agent = tam.id_agente SELECT id_downtime
AND tam.id_agente_modulo = $module_id FROM tplanned_downtime_agents tpda, tagente_modulo tam
AND tpda.all_modules = 1))"; WHERE tpda.id_agent = tam.id_agente
AND tam.id_agente_modulo = %d
AND tpda.all_modules = 1
)
)',
$module_id,
$module_id
);
} }
// Columns of the table tplanned_downtime. // Columns of the table tplanned_downtime.
@ -296,68 +532,41 @@ if (!empty($groups)) {
'id_user', 'id_user',
]; ];
switch ($config['dbtype']) { $columns_str = implode(',', $columns);
case 'mysql': $sql = sprintf(
case 'postgresql': 'SELECT %s
$columns_str = implode(',', $columns); FROM tplanned_downtime
$sql = "SELECT $columns_str WHERE %s
FROM tplanned_downtime ORDER BY type_execution DESC, date_from DESC
WHERE $where_values LIMIT %d
ORDER BY type_execution DESC, date_from DESC OFFSET %d',
LIMIT ".$config['block_size']." $columns_str,
OFFSET $offset"; $where_values,
break; $config['block_size'],
$offset
);
case 'oracle': $sql_count = sprintf(
// Oracle doesn't have TIME type, so we should transform the DATE value 'SELECT COUNT(id) AS num
$new_time_from = "TO_CHAR(periodically_time_from, 'HH24:MI:SS') AS periodically_time_from"; FROM tplanned_downtime
$new_time_to = "TO_CHAR(periodically_time_to, 'HH24:MI:SS') AS periodically_time_to"; WHERE %s',
$where_values
$time_from_key = array_search('periodically_time_from', $columns); );
$time_to_key = array_search('periodically_time_to', $columns);
if ($time_from_key !== false) {
$columns[$time_from_key] = $new_time_from;
}
if ($time_to_key !== false) {
$columns[$time_to_key] = $new_time_to;
}
$columns_str = implode(',', $columns);
$set = [];
$set['limit'] = $config['block_size'];
$set['offset'] = $offset;
$sql = "SELECT $columns_str
FROM tplanned_downtime
WHERE $where_values
ORDER BY type_execution DESC, date_from DESC";
$sql = oracle_recode_query($sql, $set);
break;
}
$sql_count = "SELECT COUNT(id) AS num
FROM tplanned_downtime
WHERE $where_values";
$downtimes = db_get_all_rows_sql($sql); $downtimes = db_get_all_rows_sql($sql);
$downtimes_number_res = db_get_all_rows_sql($sql_count); $downtimes_number_res = db_get_all_rows_sql($sql_count);
$downtimes_number = $downtimes_number_res != false ? $downtimes_number_res[0]['num'] : 0; $downtimes_number = ($downtimes_number_res !== false) ? $downtimes_number_res[0]['num'] : 0;
} else {
$downtimes = [];
} }
$url_list = 'index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list';
$url_editor = 'index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor';
// No downtimes cause the user has not anyone. // No downtimes cause the user has not anyone.
if (!$downtimes && !$filter_performed) { if ($downtimes === false && $filter_performed === false) {
include_once $config['homedir'].'/general/first_task/planned_downtime.php'; include_once $config['homedir'].'/general/first_task/planned_downtime.php';
} } else if ($downtimes === false) {
// No downtimes cause the user performed a search. // No downtimes cause the user performed a search.
else if (!$downtimes) {
// Filter form. // Filter form.
echo "<form method='post' action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'>"; echo '<form method="post" action="'.$url_list.'">';
html_print_table($table_form); html_print_table($table_form);
echo '</form>'; echo '</form>';
@ -367,22 +576,25 @@ else if (!$downtimes) {
echo '<div class="action-buttons w100p" >'; echo '<div class="action-buttons w100p" >';
// Create button. // Create button.
if ($write_permisson) { if ($write_permisson === true) {
echo '&nbsp;'; echo '&nbsp;';
echo '<form method="post" class="display_in" action="index.php?sec=extensions&amp;sec2=godmode/agentes/planned_downtime.editor">'; echo '<form method="post" class="display_in" action="'.$url_editor.'">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
echo '</form>'; echo '</form>';
} }
echo '</div>'; echo '</div>';
} } else {
// Has downtimes. // Has downtimes.
else { echo '<form method="post" action="'.$url_list.'">';
echo "<form method='post' action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'>";
html_print_table($table_form); html_print_table($table_form);
echo '</form>'; echo '</form>';
ui_pagination($downtimes_number, "index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list&$filter_params_str", $offset); ui_pagination(
$downtimes_number,
$url_list.'&'.$filter_params_str,
$offset
);
// User groups with AR, AD or AW permission. // User groups with AR, AD or AW permission.
$groupsAD = users_get_groups($config['id_user'], $access); $groupsAD = users_get_groups($config['id_user'], $access);
@ -402,8 +614,11 @@ else {
$table->head['execution'] = __('Execution'); $table->head['execution'] = __('Execution');
$table->head['configuration'] = __('Configuration'); $table->head['configuration'] = __('Configuration');
$table->head['running'] = __('Running'); $table->head['running'] = __('Running');
$table->head['agents_modules'] = __('Affected');
if ($write_permisson || $manage_permisson) { if ($write_permisson === true
|| $manage_permisson === true
) {
$table->head['stop'] = __('Stop downtime'); $table->head['stop'] = __('Stop downtime');
$table->head['copy'] = __('Copy'); $table->head['copy'] = __('Copy');
$table->head['edit'] = __('Edit'); $table->head['edit'] = __('Edit');
@ -414,7 +629,9 @@ else {
$table->align['group'] = 'center'; $table->align['group'] = 'center';
$table->align['running'] = 'center'; $table->align['running'] = 'center';
if ($write_permisson || $manage_permisson) { if ($write_permisson === true
|| $manage_permisson === true
) {
$table->align['stop'] = 'center'; $table->align['stop'] = 'center';
$table->align['edit'] = 'center'; $table->align['edit'] = 'center';
$table->align['delete'] = 'center'; $table->align['delete'] = 'center';
@ -430,7 +647,7 @@ else {
WHERE id_downtime = '.$downtime['id'] WHERE id_downtime = '.$downtime['id']
); );
$data['name'] = $downtime['name']." ($total)"; $data['name'] = $downtime['name'].' ('.$total.')';
$data['description'] = $downtime['description']; $data['description'] = $downtime['description'];
$data['group'] = ui_print_group_icon($downtime['id_group'], true); $data['group'] = ui_print_group_icon($downtime['id_group'], true);
@ -451,7 +668,7 @@ else {
$data['configuration'] = reporting_format_planned_downtime_dates($downtime); $data['configuration'] = reporting_format_planned_downtime_dates($downtime);
if ($downtime['executed'] == 0) { if ((int) $downtime['executed'] === 0) {
$data['running'] = html_print_image( $data['running'] = html_print_image(
'images/pixel_red.png', 'images/pixel_red.png',
true, true,
@ -473,44 +690,124 @@ else {
); );
} }
$settings = [
'url' => ui_get_full_url('ajax.php', false, false, false),
'loadingText' => __('Loading, this operation might take several minutes...'),
'title' => __('Agents / Modules affected'),
'id' => $downtime['id'],
];
$data['agents_modules'] = '<a href="#" onclick=\'dialogAgentModulesAffected('.json_encode($settings).')\'>';
$data['agents_modules'] .= html_print_image(
'images/search_big.png',
true,
[
'title' => __('Agents and modules affected'),
'style' => 'width:22px; height: 22px;',
]
);
$data['agents_modules'] .= '</a>';
// If user have writting permissions. // If user have writting permissions.
if (in_array($downtime['id_group'], $groupsAD)) { if (in_array($downtime['id_group'], $groupsAD) === true) {
// Stop button // Stop button.
if ($downtime['type_execution'] == 'once' && $downtime['executed'] == 1) { if ($downtime['type_execution'] === 'once'
if (check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') && (int) $downtime['executed'] === 1
|| check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD') ) {
if ((bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') === true
|| (bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD') === true
) { ) {
$data['stop'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'.'&stop_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str.'">'.html_print_image('images/cancel.png', true, ['title' => __('Stop downtime')]); $url_list_params = $url_list.'&stop_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str;
$data['stop'] = '<a href="'.$url_list_params.'">';
$data['stop'] .= html_print_image(
'images/cancel.png',
true,
['title' => __('Stop downtime')]
);
} else { } else {
$data['stop'] = html_print_image('images/cancel.png', true, ['title' => __('Stop downtime')]); $data['stop'] = html_print_image(
'images/cancel.png',
true,
['title' => __('Stop downtime')]
);
} }
} else { } else {
$data['stop'] = ''; $data['stop'] = '';
} }
// Edit & delete buttons. // Edit & delete buttons.
if ($downtime['executed'] == 0) { if ((int) $downtime['executed'] === 0) {
if (check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') if ((bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') === true
|| check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD') || (bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD') === true
) { ) {
// Copy. // Copy.
$data['copy'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&downtime_copy=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/copy.png', true, ['title' => __('Copy'), 'class' => 'invert_filter']).'</a>'; $data['copy'] = '<a href="'.$url_editor.'&downtime_copy=1&id_downtime='.$downtime['id'].'">';
$data['copy'] .= html_print_image(
'images/copy.png',
true,
[
'title' => __('Copy'),
'class' => 'invert_filter',
]
);
$data['copy'] .= '</a>';
// Edit. // Edit.
$data['edit'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update'), 'class' => 'invert_filter']).'</a>'; $data['edit'] = '<a href="'.$url_editor.'&edit_downtime=1&id_downtime='.$downtime['id'].'">';
$data['edit'] .= html_print_image(
'images/config.png',
true,
[
'title' => __('Update'),
'class' => 'invert_filter',
]
);
$data['edit'] .= '</a>';
// Delete. // Delete.
$data['delete'] = '<a id="delete_downtime" href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'.'&delete_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str.'">'.html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']); $url_delete = $url_list.'&delete_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str;
$data['delete'] = '<a id="delete_downtime" href="'.$url_delete.'">';
$data['delete'] .= html_print_image(
'images/cross.png',
true,
[
'title' => __('Delete'),
'class' => 'invert_filter',
]
);
$data['delete'] .= '</a>';
} else { } else {
$data['edit'] = ''; $data['edit'] = '';
$data['delete'] = ''; $data['delete'] = '';
} }
} else if ($downtime['executed'] == 1 && $downtime['type_execution'] == 'once') { } else if ((int) $downtime['executed'] === 1
if (check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') && $downtime['type_execution'] === 'once'
|| check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD') ) {
if ((bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') === true
|| (bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD') === true
) { ) {
// Copy. // Copy.
$data['copy'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&downtime_copy=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/copy.png', true, ['title' => __('Copy'), 'class' => 'invert_filter']).'</a>'; $data['copy'] = '<a href="'.$url_editor.'&downtime_copy=1&id_downtime='.$downtime['id'].'">';
$data['copy'] .= html_print_image(
'images/copy.png',
true,
[
'title' => __('Copy'),
'class' => 'invert_filter',
]
);
$data['copy'] .= '</a>';
// Edit. // Edit.
$data['edit'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update'), 'class' => 'invert_filter']).'</a>'; $data['edit'] = '<a href="'.$url_editor.'&edit_downtime=1&id_downtime='.$downtime['id'].'">';
$data['edit'] .= html_print_image(
'images/config.png',
true,
[
'title' => __('Update'),
'class' => 'invert_filter',
]
);
$data['edit'] .= '</a>';
// Delete. // Delete.
$data['delete'] = __('N/A'); $data['delete'] = __('N/A');
} else { } else {
@ -529,7 +826,9 @@ else {
$data['delete'] = ''; $data['delete'] = '';
} }
if (!empty($malformed_downtimes_exist) && isset($malformed_downtimes[$downtime['id']])) { if (empty($malformed_downtimes_exist) === false
&& isset($malformed_downtimes[$downtime['id']]) === true
) {
$next_row_num = count($table->data); $next_row_num = count($table->data);
$table->cellstyle[$next_row_num][0] = 'color: red'; $table->cellstyle[$next_row_num][0] = 'color: red';
$table->cellstyle[$next_row_num][1] = 'color: red'; $table->cellstyle[$next_row_num][1] = 'color: red';
@ -542,7 +841,17 @@ else {
} }
html_print_table($table); html_print_table($table);
ui_pagination($downtimes_number, "index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list&$filter_params_str", $offset, 0, false, 'offset', true, 'pagination-bottom'); ui_pagination(
$downtimes_number,
$url_list.'&'.$filter_params_str,
$offset,
0,
false,
'offset',
true,
'pagination-bottom'
);
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
// CSV export button. // CSV export button.
@ -551,32 +860,44 @@ else {
__('Export to CSV'), __('Export to CSV'),
'csv_export', 'csv_export',
false, false,
"location.href='godmode/agentes/planned_downtime.export_csv.php?$filter_params_str'", 'location.href="godmode/agentes/planned_downtime.export_csv.php?'.$filter_params_str.'"',
'class="sub next"' 'class="sub next"'
); );
echo '</div>'; echo '</div>';
// Create button. // Create button.
if ($write_permisson) { if ($write_permisson === true) {
echo '&nbsp;'; echo '&nbsp;';
echo '<form method="post" action="index.php?sec=extensions&amp;sec2=godmode/agentes/planned_downtime.editor" class="display_in" >'; echo '<form method="post" action="'.$url_editor.'" class="display_in" >';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); html_print_submit_button(
__('Create'),
'create',
false,
'class="sub next"'
);
echo '</form>'; echo '</form>';
} }
echo '</div>'; echo '</div>';
} }
ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/'); ui_require_jquery_file(
'ui.datepicker-'.get_user_language(),
'include/javascript/i18n/'
);
ui_require_javascript_file('pandora_planned_downtimes');
?> ?>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
$("input[name=module_name_hidden]").val(<?php echo (int) $module_id; ?>); $("input[name=module_name_hidden]").val(<?php echo (int) $module_id; ?>);
$(document).ready (function () { $(document).ready (function () {
$("#text-date_from, #text-date_to").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"}); $("#text-date_from, #text-date_to")
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]); .datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
$.datepicker
.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
$("a#delete_downtime").click(function (e) { $("a#delete_downtime").click(function (e) {
if (!confirm("<?php echo __('WARNING: If you delete this scheduled downtime, it will not be taken into account in future SLA reports'); ?>")) { if (!confirm("<?php echo __('WARNING: If you delete this scheduled downtime, it will not be taken into account in future SLA reports'); ?>")) {

View File

@ -61,50 +61,7 @@ if (defined('LAST_STEP') === false) {
} }
// Default events calendar. // Default events calendar.
$default_events_calendar = [ $default_events_calendar = default_events_calendar($id, 'talert_templates');
'monday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
'tuesday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
'wednesday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
'thursday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
'friday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
'saturday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
'sunday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
];
if ($duplicate_template === true) { if ($duplicate_template === true) {
$source_id = (int) get_parameter('source_id'); $source_id = (int) get_parameter('source_id');
@ -370,7 +327,12 @@ function update_template($step)
$result = alerts_update_alert_template($id, $values); $result = alerts_update_alert_template($id, $values);
} else if ($step == 2) { } else if ($step == 2) {
$schedule = get_parameter('schedule'); $schedule = io_safe_output(get_parameter('schedule', []));
json_decode($schedule, true);
if (json_last_error() !== JSON_ERROR_NONE) {
return false;
}
$special_day = (int) get_parameter('special_day'); $special_day = (int) get_parameter('special_day');
$threshold = (int) get_parameter('threshold'); $threshold = (int) get_parameter('threshold');
$max_alerts = (int) get_parameter('max_alerts'); $max_alerts = (int) get_parameter('max_alerts');
@ -389,12 +351,7 @@ function update_template($step)
} }
$values = [ $values = [
'schedule' => json_encode( 'schedule' => $schedule,
json_decode(
io_safe_output($schedule),
true
)
),
'special_day' => $special_day, 'special_day' => $special_day,
'time_threshold' => $threshold, 'time_threshold' => $threshold,
'id_alert_action' => $default_action, 'id_alert_action' => $default_action,
@ -485,7 +442,6 @@ $type = '';
$value = ''; $value = '';
$max = ''; $max = '';
$min = ''; $min = '';
$schedule = json_encode( $schedule = json_encode(
$default_events_calendar $default_events_calendar
); );
@ -614,7 +570,9 @@ if ($id && ! $create_template) {
$min = $template['min_value']; $min = $template['min_value'];
$matches = $template['matches_value']; $matches = $template['matches_value'];
$schedule = $template['schedule']; $schedule = json_encode(
$default_events_calendar
);
$special_day = (int) $template['special_day']; $special_day = (int) $template['special_day'];
$max_alerts = $template['max_alerts']; $max_alerts = $template['max_alerts'];
$min_alerts = $template['min_alerts']; $min_alerts = $template['min_alerts'];

View File

@ -90,6 +90,8 @@ $data[1] = html_print_input_text(
'', '',
50, 50,
255, 255,
true,
false,
true true
); );
$data[1] .= html_print_input_hidden('id_response', $event_response['id'], true); $data[1] .= html_print_input_hidden('id_response', $event_response['id'], true);

View File

@ -64,6 +64,40 @@ require_once $config['homedir'].'/include/functions_users.php';
$create_profiles = (int) get_parameter('create_profiles'); $create_profiles = (int) get_parameter('create_profiles');
// Get users and groups user can manage to check and for selectors.
$group_um = users_get_groups_UM($config['id_user']);
$users_profiles = '';
$users_order = [
'field' => 'id_user',
'order' => 'ASC',
];
$info_users = [];
// Is admin.
if (users_is_admin()) {
$info_users = users_get_info($users_order, 'id_user');
// has PM permission.
} else if (check_acl($config['id_user'], 0, 'PM')) {
$info_users = users_get_info($users_order, 'id_user');
foreach ($info_users as $id_user => $value) {
if (users_is_admin($id_user)) {
unset($info_users[$value]);
}
}
} else {
$info = [];
foreach ($group_um as $group => $value) {
$info = array_merge($info, users_get_users_by_group($group, $value));
}
foreach ($info as $key => $value) {
if (!$value['is_admin']) {
$info_users[$key] = $value['id_user'];
}
}
}
if ($create_profiles) { if ($create_profiles) {
$profiles_id = get_parameter('profiles_id', -1); $profiles_id = get_parameter('profiles_id', -1);
$groups_id = get_parameter('groups_id', -1); $groups_id = get_parameter('groups_id', -1);
@ -74,8 +108,42 @@ if ($create_profiles) {
$result = false; $result = false;
} else { } else {
foreach ($profiles_id as $profile) { foreach ($profiles_id as $profile) {
// Check profiles permissions for non admin user.
if (is_user_admin($config['user_id']) === false) {
$user_profiles = profile_get_profiles(
[
'pandora_management' => '<> 1',
'db_management' => '<> 1',
]
);
if (array_search((int) $profile, array_keys($user_profiles)) === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to add administrator profile whith standar user for user '.io_safe_input($user)
);
exit;
}
}
foreach ($groups_id as $group) { foreach ($groups_id as $group) {
if (check_acl($config['id_user'], $group, 'UM') === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to add profile group without permission for user '.io_safe_input($user)
);
exit;
}
foreach ($users_id as $user) { foreach ($users_id as $user) {
if (array_search($user, $info_users) === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to edit user without permission for user '.io_safe_input($user)
);
exit;
}
$profile_data = db_get_row_filter('tusuario_perfil', ['id_usuario' => $user, 'id_perfil' => $profile, 'id_grupo' => $group]); $profile_data = db_get_row_filter('tusuario_perfil', ['id_usuario' => $user, 'id_perfil' => $profile, 'id_grupo' => $group]);
// If the profile doesnt exist, we create it // If the profile doesnt exist, we create it
if ($profile_data === false) { if ($profile_data === false) {
@ -142,7 +210,6 @@ $table->size[2] = '33%';
$data = []; $data = [];
$data[0] = '<form method="post" id="form_profiles" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users&option=add_profiles">'; $data[0] = '<form method="post" id="form_profiles" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users&option=add_profiles">';
$group_um = users_get_groups_UM($config['id_user']);
$display_all_group = true; $display_all_group = true;
if (check_acl($config['id_user'], 0, 'PM')) { if (check_acl($config['id_user'], 0, 'PM')) {
@ -205,36 +272,6 @@ $data[1] = html_print_select_groups(
$data[2] = '<span id="alerts_loading" class="invisible">'; $data[2] = '<span id="alerts_loading" class="invisible">';
$data[2] .= html_print_image('images/spinner.png', true); $data[2] .= html_print_image('images/spinner.png', true);
$data[2] .= '</span>'; $data[2] .= '</span>';
$users_profiles = '';
$users_order = [
'field' => 'id_user',
'order' => 'ASC',
];
$info_users = [];
// Is admin.
if (users_is_admin()) {
$info_users = users_get_info($users_order, 'id_user');
// has PM permission.
} else if (check_acl($config['id_user'], 0, 'PM')) {
$info_users = users_get_info($users_order, 'id_user');
foreach ($info_users as $id_user => $value) {
if (users_is_admin($id_user)) {
unset($info_users[$value]);
}
}
} else {
$info = [];
foreach ($group_um as $group => $value) {
$info = array_merge($info, users_get_users_by_group($group, $value));
}
foreach ($info as $key => $value) {
if (!$value['is_admin']) {
$info_users[$key] = $value['id_user'];
}
}
}
$data[2] .= html_print_select( $data[2] .= html_print_select(
$info_users, $info_users,

View File

@ -14,7 +14,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
* *
* ============================================================================ * ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list * Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -47,15 +47,17 @@ require_once $config['homedir'].'/include/functions_gis.php';
require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_users.php';
enterprise_include_once('include/functions_config_agents.php'); enterprise_include_once('include/functions_config_agents.php');
if (is_ajax()) { if (is_ajax() === true) {
$get_n_conf_files = (bool) get_parameter('get_n_conf_files'); $get_n_conf_files = (bool) get_parameter('get_n_conf_files', false);
if ($get_n_conf_files) { $groups_secondary_selected = (bool) get_parameter('groups_secondary_selected', false);
if ($get_n_conf_files === true) {
$id_agents = get_parameter('id_agents'); $id_agents = get_parameter('id_agents');
$cont = 0; $cont = 0;
foreach ($id_agents as $id_agent) { foreach ($id_agents as $id_agent) {
$name = agents_get_name($id_agent); $name = agents_get_name($id_agent);
$agent_md5 = md5($name); $agent_md5 = md5($name);
if (file_exists($config['remote_config'].'/md5/'.$agent_md5.'.md5')) { if (file_exists($config['remote_config'].'/md5/'.$agent_md5.'.md5') === true) {
$cont++; $cont++;
} }
} }
@ -63,6 +65,24 @@ if (is_ajax()) {
echo $cont; echo $cont;
return; return;
} }
if ($groups_secondary_selected === true) {
$groups = get_parameter('groups', []);
$groups_selected = get_parameter('groups_selected', []);
hd($groups, true);
hd($groups_selected, true);
$user_groups = users_get_groups($config['user'], 'AR', false);
$ret = [];
foreach ($user_groups as $id_gr => $name_group) {
if (in_array($id_gr, $groups) === false) {
$ret[$id_gr] = $name_group;
}
}
echo json_encode($ret);
return;
}
} }
$update_agents = get_parameter('update_agents', 0); $update_agents = get_parameter('update_agents', 0);
@ -140,6 +160,9 @@ if ($update_agents) {
$values['safe_mode_module'] = '0'; $values['safe_mode_module'] = '0';
} }
$secondary_groups_added = (array) get_parameter('secondary_groups_added', []);
$secondary_groups_removed = (array) get_parameter('secondary_groups_removed', []);
$fields = db_get_all_fields_in_table('tagent_custom_fields'); $fields = db_get_all_fields_in_table('tagent_custom_fields');
if ($fields === false) { if ($fields === false) {
@ -213,19 +236,14 @@ if ($update_agents) {
} }
$n_edited = 0; $n_edited = 0;
$result = false; $result = [];
foreach ($id_agents as $id_agent) { foreach ($id_agents as $id_agent) {
$old_interval_value = db_get_value_filter('intervalo', 'tagente', ['id_agente' => $id_agent]); $old_interval_value = db_get_value_filter('intervalo', 'tagente', ['id_agente' => $id_agent]);
if (!empty($values)) { if (!empty($values)) {
$group_old = false;
$disabled_old = false; $disabled_old = false;
if ($values['id_grupo'] || isset($values['disabled'])) { if ($values['id_grupo'] || isset($values['disabled'])) {
$values_old = db_get_row_filter('tagente', ['id_agente' => $id_agent], ['id_grupo', 'disabled']); $values_old = db_get_row_filter('tagente', ['id_agente' => $id_agent], ['id_grupo', 'disabled']);
if ($values_old['id_grupo']) {
$group_old = $values_old['id_grupo'];
}
if (isset($values['disabled'])) { if (isset($values['disabled'])) {
$disabled_old = $values_old['disabled']; $disabled_old = $values_old['disabled'];
} }
@ -236,20 +254,20 @@ if ($update_agents) {
$values['safe_mode_module'] = $id_module_safe[$id_agent]; $values['safe_mode_module'] = $id_module_safe[$id_agent];
} }
$result = db_process_sql_update( $result[$id_agent]['db'] = db_process_sql_update(
'tagente', 'tagente',
$values, $values,
['id_agente' => $id_agent] ['id_agente' => $id_agent]
); );
if ($result && $config['metaconsole_agent_cache'] == 1) { if ($result[$id_agent]['db'] && $config['metaconsole_agent_cache'] == 1) {
$server_name['server_name'] = db_get_sql('SELECT server_name FROM tagente WHERE id_agente ='.$id_agent); $server_name['server_name'] = db_get_sql('SELECT server_name FROM tagente WHERE id_agente ='.$id_agent);
// Force an update of the agent cache. // Force an update of the agent cache.
$result_metaconsole = agent_update_from_cache($id_agent, $values, $server_name); $result_metaconsole = agent_update_from_cache($id_agent, $values, $server_name);
} }
// Update the configuration files. // Update the configuration files.
if ($result && ($old_interval_value != $values['intervalo']) && !empty($values['intervalo'])) { if ($result[$id_agent]['db'] && ($old_interval_value != $values['intervalo']) && !empty($values['intervalo'])) {
enterprise_hook( enterprise_hook(
'config_agents_update_config_token', 'config_agents_update_config_token',
[ [
@ -274,74 +292,6 @@ if ($update_agents) {
alerts_validate_alert_agent($id_agent); alerts_validate_alert_agent($id_agent);
} }
} }
if ($group_old || $result) {
if ($group_old && $group_old != null) {
$tpolicy_group_old = db_get_all_rows_sql(
'SELECT id_policy FROM tpolicy_groups
WHERE id_group = '.$group_old
);
} else {
$tpolicy_group_old = db_get_all_rows_sql('SELECT id_policy FROM tpolicy_groups');
}
if ($tpolicy_group_old) {
foreach ($tpolicy_group_old as $key => $value) {
$tpolicy_agents_old = db_get_sql(
'SELECT * FROM tpolicy_agents
WHERE id_policy = '.$value['id_policy'].' AND id_agent = '.$id_agent
);
if ($tpolicy_agents_old) {
$result2 = db_process_sql_update(
'tpolicy_agents',
['pending_delete' => 1],
[
'id_agent' => $id_agent,
'id_policy' => $value['id_policy'],
]
);
}
}
}
if ($values['id_grupo'] && $values['id_grupo'] != null) {
$tpolicy_group_new = db_get_all_rows_sql(
'SELECT id_policy FROM tpolicy_groups
WHERE id_group = '.$values['id_grupo']
);
} else {
$tpolicy_group_new = db_get_all_rows_sql('SELECT id_policy FROM tpolicy_groups');
}
if ($tpolicy_group_new) {
foreach ($tpolicy_group_new as $key => $value) {
$tpolicy_agents_new = db_get_sql(
'SELECT * FROM tpolicy_agents
WHERE id_policy = '.$value['id_policy'].' AND id_agent ='.$id_agent
);
if (!$tpolicy_agents_new) {
db_process_sql_insert(
'tpolicy_agents',
[
'id_policy' => $value['id_policy'],
'id_agent' => $id_agent,
]
);
} else {
$result3 = db_process_sql_update(
'tpolicy_agents',
['pending_delete' => 0],
[
'id_agent' => $id_agent,
'id_policy' => $value['id_policy'],
]
);
}
}
}
}
} }
$info = []; $info = [];
@ -361,7 +311,7 @@ if ($update_agents) {
if ($old_value === false) { if ($old_value === false) {
// Create custom field if not exist. // Create custom field if not exist.
$result = db_process_sql_insert( $result[$id_agent]['fields'][$field['id_field']] = db_process_sql_insert(
'tagent_custom_data', 'tagent_custom_data',
[ [
'id_field' => $key, 'id_field' => $key,
@ -371,7 +321,7 @@ if ($update_agents) {
); );
} else { } else {
if ($old_value[0]['description'] !== $value) { if ($old_value[0]['description'] !== $value) {
$result = db_process_sql_update( $result[$id_agent]['fields'][$field['id_field']] = db_process_sql_update(
'tagent_custom_data', 'tagent_custom_data',
['description' => $value], ['description' => $value],
[ [
@ -384,36 +334,160 @@ if ($update_agents) {
} }
} }
$n_edited += (int) $result; // Create or Remove the secondary groups.
} if (empty($secondary_groups_added) === false
|| empty($secondary_groups_removed) === false
) {
$result[$id_agent]['secondary'] = enterprise_hook(
'agents_update_secondary_groups',
[
$id_agent,
$secondary_groups_added,
$secondary_groups_removed,
true,
]
);
}
if ($result['db'] !== false) {
if ($result !== false) {
db_pandora_audit(
AUDIT_LOG_MASSIVE_MANAGEMENT,
'Update agent '.$id_agent,
false,
false,
json_encode($info)
);
} else {
if (isset($id_agent)) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_MASSIVE_MANAGEMENT, AUDIT_LOG_MASSIVE_MANAGEMENT,
'Try to update agent '.$id_agent, 'Update agent '.$id_agent,
false, false,
false, false,
json_encode($info) json_encode($info)
); );
} else {
if (isset($id_agent) === true) {
db_pandora_audit(
AUDIT_LOG_MASSIVE_MANAGEMENT,
'Try to update agent '.$id_agent,
false,
false,
json_encode($info)
);
}
} }
} }
$ret = [];
foreach ($result as $id_agent => $item) {
if ($item['db'] !== false) {
$ret['db']['edited'] += 1;
$ret['db']['edited_agent'][] = $id_agent;
} else {
$ret['db']['failed'] += 1;
$ret['db']['failed_agent'][] = $id_agent;
}
ui_print_result_message( if (isset($item['fields']) === true
$result !== false, && empty($item['fields']) === false
__('Agents updated successfully (%d)', $n_edited), ) {
__('Agents cannot be updated (maybe there was no field to update)') foreach ($item['fields'] as $kfield => $vfield) {
); if ($vfield !== false) {
$ret['fields'][$id_agent]['edited'] += 1;
$ret['fields'][$id_agent]['edited_field'][] = $kfield;
} else {
$ret['fields'][$id_agent]['failed'] += 1;
$ret['fields'][$id_agent]['failed_field'][] = $kfield;
}
}
}
if (isset($item['secondary']) === true
&& empty($item['secondary']) === false
) {
foreach ($item['secondary'] as $type_action => $values_secondary) {
foreach ($values_secondary as $kgr => $vgr) {
if ($vgr !== false) {
$ret['secondary'][$type_action][$id_agent]['edited'] += 1;
$ret['secondary'][$type_action][$id_agent]['edited_gr'][] = $kgr;
} else {
$ret['secondary'][$type_action][$id_agent]['failed'] += 1;
$ret['secondary'][$type_action][$id_agent]['failed_gr'][] = $kgr;
}
}
}
}
}
foreach ($ret as $type => $ret_val) {
switch ($type) {
case 'db':
if (isset($ret_val['edited']) === true
&& $ret_val['edited'] > 0
) {
ui_print_success_message(
__(
'Agents updated successfully (%d)',
$ret_val['edited'],
implode(
',',
$ret_val['edited_agent']
)
)
);
}
if (isset($ret_val['failed']) === true
&& $ret_val['failed'] > 0
) {
ui_print_error_message(
__(
'Agents cannot be updated (%d), ids (%s)',
$ret_val['failed'],
implode(',', $ret_val['failed_agent'])
)
);
}
break;
case 'fields':
$str = '';
foreach ($ret_val as $kag => $vag) {
if (isset($vag['failed']) === true
&& $vag['failed'] > 0
) {
$str .= __(
'Agent ID: %s cannot be updated custom fields (%s)',
$kag,
implode(',', $vag['failed_field'])
).'<br>';
}
}
if (empty($str) === false) {
ui_print_error_message($str);
}
break;
case 'secondary':
$str = '';
foreach ($ret_val as $type => $values_secondary) {
foreach ($values_secondary as $kag => $vag) {
if (isset($vag['failed']) === true
&& $vag['failed'] > 0
) {
$str .= __(
'Agent ID: %s cannot be updated %s secondary groups (%s)',
$kag,
$type,
implode(',', $vag['failed_gr'])
).'<br>';
}
}
}
if (empty($str) === false) {
ui_print_error_message($str);
}
break;
default:
// Not posible.
break;
}
}
} }
$id_group = 0; $id_group = 0;
@ -599,7 +673,16 @@ $table->data[0][1] .= '<b>'.__('Cascade protection').'</b>'.html_print_select(
true true
); );
$table->data[0][1] .= '&nbsp;&nbsp;'.__('Module').'&nbsp;'.html_print_select($modules, 'cascade_protection_module', $cascade_protection_module, '', '', 0, true); $table->data[0][1] .= '&nbsp;&nbsp;'.__('Module').'&nbsp;';
$table->data[0][1] .= html_print_select(
$modules,
'cascade_protection_module',
$cascade_protection_module,
'',
'',
0,
true
);
$table->data[1][0] = __('Group'); $table->data[1][0] = __('Group');
$table->data[1][1] = '<div class="w290px inline">'; $table->data[1][1] = '<div class="w290px inline">';
@ -623,7 +706,17 @@ $table->data[1][1] .= '</div>';
$table->data[2][0] = __('Interval'); $table->data[2][0] = __('Interval');
$table->data[2][1] = html_print_extended_select_for_time('interval', 0, '', __('No change'), '0', 10, true, 'width: 150px', false); $table->data[2][1] = html_print_extended_select_for_time(
'interval',
0,
'',
__('No change'),
'0',
10,
true,
'width: 150px',
false
);
$table->data[3][0] = __('OS'); $table->data[3][0] = __('OS');
$table->data[3][1] = html_print_select_from_sql( $table->data[3][1] = html_print_select_from_sql(
@ -667,7 +760,14 @@ $table->data[4][1] = html_print_select(
// Description. // Description.
$table->data[5][0] = __('Description'); $table->data[5][0] = __('Description');
$table->data[5][1] = html_print_input_text('description', $description, '', 45, 255, true); $table->data[5][1] = html_print_input_text(
'description',
$description,
'',
45,
255,
true
);
html_print_table($table); html_print_table($table);
unset($table); unset($table);
@ -700,18 +800,148 @@ $table->data = [];
$table->data[0][0] = __('Custom ID'); $table->data[0][0] = __('Custom ID');
$table->data[0][1] = html_print_input_text('custom_id', $custom_id, '', 16, 255, true); $table->data[0][1] = html_print_input_text('custom_id', $custom_id, '', 16, 255, true);
// Secondary Groups.
if (enterprise_installed() === true) {
$groups = users_get_groups($config['id_user'], 'AW', false);
$table->data['secondary_groups_added'][0] = __('Add secondary groups');
$table->data['secondary_groups_added'][1] = html_print_select(
$groups,
'secondary_groups_added[]',
0,
false,
'',
'',
true,
true,
true,
'',
false,
'min-width: 500px; max-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true
);
$table->data['secondary_groups_removed'][0] = __('Remove secondary groups');
$table->data['secondary_groups_removed'][1] = html_print_select(
$groups,
'secondary_groups_removed[]',
0,
false,
'',
'',
true,
true,
true,
'',
false,
'min-width: 500px; max-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true
);
}
// Learn mode / Normal mode. // Learn mode / Normal mode.
$table->data[1][0] = __('Module definition'); $table->data[1][0] = __('Module definition');
$table->data[1][1] = __('No change').' '.html_print_radio_button_extended('mode', -1, '', $mode, false, '', 'class="mrgn_right_40px"', true); $table->data[1][1] = __('No change').' ';
$table->data[1][1] .= __('Learning mode').' '.html_print_radio_button_extended('mode', 1, '', $mode, false, '', 'class="mrgn_right_40px"', true); $table->data[1][1] .= html_print_radio_button_extended(
$table->data[1][1] .= __('Normal mode').' '.html_print_radio_button_extended('mode', 0, '', $mode, false, '', 'class="mrgn_right_40px"', true); 'mode',
$table->data[1][1] .= __('Autodisable mode').' '.html_print_radio_button_extended('mode', 2, '', $mode, false, '', 'class="mrgn_right_40px"', true); -1,
'',
$mode,
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[1][1] .= __('Learning mode').' ';
$table->data[1][1] .= html_print_radio_button_extended(
'mode',
1,
'',
$mode,
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[1][1] .= __('Normal mode').' ';
$table->data[1][1] .= html_print_radio_button_extended(
'mode',
0,
'',
$mode,
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[1][1] .= __('Autodisable mode').' ';
$table->data[1][1] .= html_print_radio_button_extended(
'mode',
2,
'',
$mode,
false,
'',
'class="mrgn_right_40px"',
true
);
// Status (Disabled / Enabled). // Status (Disabled / Enabled).
$table->data[2][0] = __('Status'); $table->data[2][0] = __('Status');
$table->data[2][1] = __('No change').' '.html_print_radio_button_extended('disabled', -1, '', $disabled, false, '', 'class="mrgn_right_40px"', true); $table->data[2][1] = __('No change').' ';
$table->data[2][1] .= __('Disabled').' '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).' '.html_print_radio_button_extended('disabled', 1, '', $disabled, false, '', 'class="mrgn_right_40px"', true); $table->data[1][1] .= html_print_radio_button_extended(
$table->data[2][1] .= __('Active').' '.html_print_radio_button_extended('disabled', 0, '', $disabled, false, '', 'class="mrgn_right_40px"', true); 'disabled',
-1,
'',
$disabled,
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[2][1] .= __('Disabled').' ';
$table->data[1][1] .= ui_print_help_tip(
__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'),
true
).' ';
$table->data[1][1] .= html_print_radio_button_extended(
'disabled',
1,
'',
$disabled,
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[2][1] .= __('Active').' ';
$table->data[1][1] .= html_print_radio_button_extended(
'disabled',
0,
'',
$disabled,
false,
'',
'class="mrgn_right_40px"',
true
);
// Remote configuration. // Remote configuration.
$table->data[3][0] = __('Remote configuration'); $table->data[3][0] = __('Remote configuration');
@ -886,7 +1116,6 @@ attachActionButton('update_agents', 'update', $table->width);
echo '</div></form>'; echo '</div></form>';
ui_require_jquery_file('form'); ui_require_jquery_file('form');
ui_require_jquery_file('pandora.controls'); ui_require_jquery_file('pandora.controls');
ui_require_jquery_file('ajaxqueue'); ui_require_jquery_file('ajaxqueue');
ui_require_jquery_file('bgiframe'); ui_require_jquery_file('bgiframe');
@ -985,25 +1214,26 @@ $(document).ready (function () {
jQuery.each ($("#id_agents option:selected"), function (i, val) { jQuery.each ($("#id_agents option:selected"), function (i, val) {
idAgents.push($(val).val()); idAgents.push($(val).val());
}); });
jQuery.post ("ajax.php", jQuery.post (
{"page" : "godmode/massive/massive_edit_agents", "ajax.php",
{
"page" : "godmode/massive/massive_edit_agents",
"get_n_conf_files" : 1, "get_n_conf_files" : 1,
"id_agents[]" : idAgents "id_agents[]" : idAgents
}, },
function (data, status) { function (data, status) {
if (data == 0) { if (data == 0) {
$("#delete_configurations").attr("style", "display: none"); $("#delete_configurations").attr("style", "display: none");
$("#not_available_configurations").attr("style", ""); $("#not_available_configurations").attr("style", "");
} }
else { else {
$("#n_configurations").text(data); $("#n_configurations").text(data);
$("#not_available_configurations").attr("style", "display: none"); $("#not_available_configurations").attr("style", "display: none");
$("#delete_configurations").attr("style", ""); $("#delete_configurations").attr("style", "");
} }
}, },
"json" "json"
); );
$("#form_agents").attr("style", ""); $("#form_agents").attr("style", "");
if($("#safe_mode_change").val() == 1) { if($("#safe_mode_change").val() == 1) {
@ -1043,8 +1273,41 @@ $(document).ready (function () {
disabled = 2; disabled = 2;
//$("#id_group").trigger("change"); $("#status_agents").change(function() {
$("#id_group").trigger("change");
});
$("#secondary_groups_added").change(
function() {
var groups = $("#secondary_groups_added").val();
var groups_selected = $("#secondary_groups_removed").val();
jQuery.post (
"ajax.php",
{
"page" : "godmode/massive/massive_edit_agents",
"groups_secondary_selected" : 1,
"groups" : groups
},
function (data, status) {
$('#secondary_groups_removed').empty();
$('#secondary_groups_removed').val(null).trigger("change");
if($.type(data) === "object"){
jQuery.each (data, function (id, value) {
option = $("<option></option>").attr("value", id).html(value);
if (inArray(id, groups_selected) === true) {
option.attr("selected", true);
}
$("#secondary_groups_removed").append(option).trigger("change");
});
} else {
option = $("<option></option>").attr("value", '').html('None');
$("#secondary_groups_removed").append(option).trigger("change");
}
},
"json"
);
}
);
}); });
function changeIcons() { function changeIcons() {

View File

@ -743,6 +743,7 @@ switch ($action) {
break; break;
case 'agent_module': case 'agent_module':
case 'agent_module_status':
$description = $item['description']; $description = $item['description'];
$es = json_decode($item['external_source'], true); $es = json_decode($item['external_source'], true);
@ -4004,23 +4005,23 @@ function print_SLA_list($width, $action, $idItem=null)
], ],
] ]
); );
if (!empty($services_tmp) if (!empty($services_tmp)
&& $services_tmp != ENTERPRISE_NOT_HOOK && $services_tmp != ENTERPRISE_NOT_HOOK
) {
foreach ($services_tmp as $service) {
$check_module_sla = modules_check_agentmodule_exists(
$service['sla_id_module']
);
$check_module_sla_value = modules_check_agentmodule_exists(
$service['sla_value_id_module']
);
if ($check_module_sla
&& $check_module_sla_value
) { ) {
$services[$service['id']] = $service['name']; foreach ($services_tmp as $service) {
$check_module_sla = modules_check_agentmodule_exists(
$service['sla_id_module']
);
$check_module_sla_value = modules_check_agentmodule_exists(
$service['sla_value_id_module']
);
if ($check_module_sla
&& $check_module_sla_value
) {
$services[$service['id']] = $service['name'];
}
}
} }
}
}
echo '<td class="sla_list_service_col">'; echo '<td class="sla_list_service_col">';
echo html_print_select( echo html_print_select(
@ -4744,6 +4745,7 @@ $(document).ready (function () {
switch (type){ switch (type){
case 'agent_module': case 'agent_module':
case 'agent_module_status':
case 'alert_report_actions': case 'alert_report_actions':
var agents_multiple = $('#id_agents2').val(); var agents_multiple = $('#id_agents2').val();
var modules_multiple = $('#module').val(); var modules_multiple = $('#module').val();
@ -4878,6 +4880,7 @@ $(document).ready (function () {
} }
switch (type){ switch (type){
case 'agent_module': case 'agent_module':
case 'agent_module_status':
case 'alert_report_actions': case 'alert_report_actions':
var agents_multiple = $('#id_agents2').val(); var agents_multiple = $('#id_agents2').val();
var modules_multiple = $('#module').val(); var modules_multiple = $('#module').val();
@ -6345,9 +6348,10 @@ function chooseType() {
break; break;
case 'agent_module': case 'agent_module':
$("#row_module_group").show();
case 'agent_module_status':
$("#row_description").show(); $("#row_description").show();
$("#row_group").show(); $("#row_group").show();
$("#row_module_group").show();
$("#select_agent_modules").show(); $("#select_agent_modules").show();
$("#agents_modules_row").show(); $("#agents_modules_row").show();
$("#modules_row").show(); $("#modules_row").show();

View File

@ -938,7 +938,7 @@ switch ($action) {
$table->head[$next] = __('Private'); $table->head[$next] = __('Private');
$table->headstyle[$next] = 'min-width: 40px;text-align: left;'; $table->headstyle[$next] = 'min-width: 40px;text-align: left;';
$table->size[$next] = '2%'; $table->size[$next] = '2%';
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
$table->align[$next] = ''; $table->align[$next] = '';
} else { } else {
$table->align[$next] = 'left'; $table->align[$next] = 'left';
@ -952,7 +952,7 @@ switch ($action) {
$next++; $next++;
$op_column = false; $op_column = false;
if (!defined('METACONSOLE')) { if (is_metaconsole() === false) {
$op_column = true; $op_column = true;
$table->head[$next] = '<span title="Operations">'.__('Op.').'</span>'.html_print_checkbox( $table->head[$next] = '<span title="Operations">'.__('Op.').'</span>'.html_print_checkbox(
'all_delete', 'all_delete',
@ -967,6 +967,8 @@ switch ($action) {
// $table->size = array (); // $table->size = array ();
$table->size[$next] = '10%'; $table->size[$next] = '10%';
$table->align[$next] = 'right'; $table->align[$next] = 'right';
} else {
$table->size[1] = '40%';
} }
$columnview = false; $columnview = false;
@ -1266,7 +1268,7 @@ switch ($action) {
|| check_acl($config['id_user'], 0, 'RM') || check_acl($config['id_user'], 0, 'RM')
) { ) {
echo '<form method="post" action="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=main&action=new&pure='.$pure.'">'; echo '<form method="post" action="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=main&action=new&pure='.$pure.'">';
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
echo '<div class="action-buttons w100p">'; echo '<div class="action-buttons w100p">';
} else { } else {
echo '<div class="action-buttons w100p">'; echo '<div class="action-buttons w100p">';
@ -1653,6 +1655,7 @@ switch ($action) {
break; break;
case 'agent_module': case 'agent_module':
case 'agent_module_status':
$agents_to_report_text = get_parameter('id_agents2-multiple-text', ''); $agents_to_report_text = get_parameter('id_agents2-multiple-text', '');
$modules_to_report_text = get_parameter('module-multiple-text', ''); $modules_to_report_text = get_parameter('module-multiple-text', '');
@ -2454,6 +2457,7 @@ switch ($action) {
break; break;
case 'agent_module': case 'agent_module':
case 'agent_module_status':
$agents_to_report_text = get_parameter('id_agents2-multiple-text'); $agents_to_report_text = get_parameter('id_agents2-multiple-text');
$modules_to_report_text = get_parameter('module-multiple-text', ''); $modules_to_report_text = get_parameter('module-multiple-text', '');
@ -3552,25 +3556,6 @@ if ($enterpriseEnable && defined('METACONSOLE')) {
} }
if ($resultOperationDB !== null) { if ($resultOperationDB !== null) {
$err = '';
switch ($_POST['type']) {
case 'custom_graph':
$err .= 'You must enter custom graph';
break;
case 'SLA':
$err .= 'You must enter some character in SLA limit field';
default:
$err .= '';
break;
}
ui_print_result_message(
$resultOperationDB,
__('Successfull action'),
__('Unsuccessful action<br><br>'.$err)
);
if ($action == 'update') { if ($action == 'update') {
$buttons[$activeTab]['active'] = false; $buttons[$activeTab]['active'] = false;
$activeTab = 'list_items'; $activeTab = 'list_items';
@ -3598,6 +3583,25 @@ if ($resultOperationDB !== null) {
); );
} }
} }
$err = '';
switch ($_POST['type']) {
case 'custom_graph':
$err .= 'You must enter custom graph';
break;
case 'SLA':
$err .= 'You must enter some character in SLA limit field';
default:
$err .= '';
break;
}
ui_print_result_message(
$resultOperationDB,
__('Successfull action'),
__('Unsuccessful action<br><br>'.$err)
);
} }
switch ($activeTab) { switch ($activeTab) {

View File

@ -47,6 +47,8 @@ if (isset($_GET['server'])) {
$exec_server_enable = __('Yes'); $exec_server_enable = __('Yes');
} }
$table = new stdClass();
$table->cellpadding = 4; $table->cellpadding = 4;
$table->cellspacing = 4; $table->cellspacing = 4;
$table->width = '100%'; $table->width = '100%';

View File

@ -262,7 +262,8 @@ if ($filemanager) {
'index.php?sec=gservers&sec2=godmode/servers/plugin'.$chunck_url.'&plugin_command=[FILE_FULLPATH]&id_plugin='.$id_plugin, 'index.php?sec=gservers&sec2=godmode/servers/plugin'.$chunck_url.'&plugin_command=[FILE_FULLPATH]&id_plugin='.$id_plugin,
true, true,
0775, 0775,
false false,
['all' => true]
); );
} }

View File

@ -65,13 +65,22 @@ $real_directory = realpath($config['homedir'].'/'.$directory);
echo '<h4>'.__('Index of %s', $directory).'</h4>'; echo '<h4>'.__('Index of %s', $directory).'</h4>';
$upload_file_or_zip = (bool) get_parameter('upload_file_or_zip'); $upload_file = (bool) get_parameter('upload_file');
$create_text_file = (bool) get_parameter('create_text_file'); $create_text_file = (bool) get_parameter('create_text_file');
$default_real_directory = realpath($config['homedir'].'/'); $default_real_directory = realpath($config['homedir'].'/');
if ($upload_file_or_zip === true) { if ($upload_file === true) {
upload_file($upload_file_or_zip, $default_real_directory, $real_directory); upload_file(
$upload_file,
$default_real_directory,
$real_directory,
[
MIME_TYPES['jpg'],
MIME_TYPES['png'],
MIME_TYPES['gif'],
]
);
} }
if ($create_text_file === true) { if ($create_text_file === true) {
@ -89,5 +98,6 @@ filemanager_file_explorer(
false, false,
'', '',
false, false,
false false,
[]
); );

View File

@ -289,11 +289,16 @@ if (is_array($config) === true
&& (bool) $config['history_db_enabled'] === true && (bool) $config['history_db_enabled'] === true
) { ) {
ob_start(); ob_start();
$password = $config['history_db_pass'];
if (function_exists('io_output_password') === true) {
$password = io_output_password($config['history_db_pass']);
}
$dbhHistory = db_connect( $dbhHistory = db_connect(
$config['history_db_host'], $config['history_db_host'],
$config['history_db_name'], $config['history_db_name'],
$config['history_db_user'], $config['history_db_user'],
io_output_password($config['history_db_pass']), $password,
$config['history_db_port'] $config['history_db_port']
); );
ob_get_clean(); ob_get_clean();
@ -312,6 +317,11 @@ $insecure = false;
$pandora_url = ui_get_full_url('godmode/um_client', false, false, false); $pandora_url = ui_get_full_url('godmode/um_client', false, false, false);
if (is_array($config) === true) { if (is_array($config) === true) {
$allowOfflinePatches = false;
if (isset($config['allow_offline_patches']) === true) {
$allowOfflinePatches = (bool) $config['allow_offline_patches'];
}
if (isset($config['secure_update_manager']) === false) { if (isset($config['secure_update_manager']) === false) {
$config['secure_update_manager'] = null; $config['secure_update_manager'] = null;
} }
@ -425,6 +435,7 @@ $ui = new Manager(
'remote_config' => $remote_config, 'remote_config' => $remote_config,
'propagate_updates' => $is_metaconsole, 'propagate_updates' => $is_metaconsole,
'proxy' => $proxy, 'proxy' => $proxy,
'allowOfflinePatches' => $allowOfflinePatches,
'set_maintenance_mode' => function () { 'set_maintenance_mode' => function () {
if (function_exists('config_update_value') === true) { if (function_exists('config_update_value') === true) {
config_update_value('maintenance_mode', 1); config_update_value('maintenance_mode', 1);

View File

@ -84,6 +84,13 @@ class Manager
*/ */
private $authCode; private $authCode;
/**
* Allow install offline packages not following current version.
*
* @var boolean
*/
private $allowOfflinePatches = false;
/** /**
* Undocumented function * Undocumented function
@ -144,6 +151,10 @@ class Manager
$settings['offline'] = true; $settings['offline'] = true;
} }
if (isset($settings['allowOfflinePatches']) === true) {
$this->allowOfflinePatches = (bool) $settings['allowOfflinePatches'];
}
$this->umc = new Client($settings); $this->umc = new Client($settings);
} }
@ -228,18 +239,19 @@ class Manager
View::render( View::render(
'offline', 'offline',
[ [
'version' => $this->umc->getVersion(), 'version' => $this->umc->getVersion(),
'mr' => $this->umc->getMR(), 'mr' => $this->umc->getMR(),
'error' => $this->umc->getLastError(), 'error' => $this->umc->getLastError(),
'asset' => function ($rp) { 'asset' => function ($rp) {
echo $this->getUrl($rp); echo $this->getUrl($rp);
}, },
'authCode' => $this->authCode, 'authCode' => $this->authCode,
'ajax' => $this->ajaxUrl, 'ajax' => $this->ajaxUrl,
'ajaxPage' => $this->ajaxPage, 'ajaxPage' => $this->ajaxPage,
'progress' => $this->umc->getUpdateProgress(), 'progress' => $this->umc->getUpdateProgress(),
'running' => $this->umc->isRunning(), 'running' => $this->umc->isRunning(),
'insecure' => $this->umc->isInsecure(), 'insecure' => $this->umc->isInsecure(),
'allowOfflinePatches' => $this->allowOfflinePatches,
] ]
); );
} }

View File

@ -1,6 +1,7 @@
/* exported form_upload */ /* exported form_upload */
/* global $,ajax,cleanExit,preventExit,umConfirm,umErrorMsg */ /* global $,ajax,cleanExit,preventExit,umConfirm,umErrorMsg */
/* global texts,ajaxPage,insecureMode */ /* global texts,ajaxPage,insecureMode */
/* global ImSureWhatImDoing */
/** /**
* *
@ -204,7 +205,9 @@ function form_upload(url, auth, current_package) {
let number_update = res.version; let number_update = res.version;
let server_update = res.server_update; let server_update = res.server_update;
let current_version = parseFloat(current_package);
let target_version = Math.round(parseFloat(current_package)) + 1; let target_version = Math.round(parseFloat(current_package)) + 1;
let target_patch = parseFloat(current_package) + 0.1;
if (number_update === null) { if (number_update === null) {
umConfirm({ umConfirm({
@ -221,7 +224,31 @@ function form_upload(url, auth, current_package) {
cancelUpdate(); cancelUpdate();
} }
}); });
} else if (Math.round(parseFloat(number_update)) != target_version) { } else if (
parseFloat(number_update) != target_version &&
parseFloat(number_update) != target_patch &&
parseFloat(number_update) != current_version
) {
if (ImSureWhatImDoing == undefined || ImSureWhatImDoing == false) {
umConfirm({
message:
'<span class="warning"></span><p>' +
(server_update
? texts.notGoingToInstallUnoficialServerWarning
: texts.notGoingToInstallUnoficialWarning) +
"</p>",
title: texts.warning,
size: 535,
onAccept: function() {
location.reload();
},
onDeny: function() {
cancelUpdate();
}
});
return;
}
umConfirm({ umConfirm({
message: message:
'<span class="warning"></span><p>' + '<span class="warning"></span><p>' +

View File

@ -181,7 +181,7 @@ class ClientTest extends \PHPUnit\Framework\TestCase
{ {
// Load the conf. // Load the conf.
try { try {
$this->conf = new \Config('client/conf/test.ini'); $this->conf = new \Config(__DIR__.'/../conf/test.ini');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->fail($e->getMessage()); $this->fail($e->getMessage());
} }

View File

@ -83,7 +83,9 @@
'fileList': "<?php echo __('Files included in this package'); ?>", 'fileList': "<?php echo __('Files included in this package'); ?>",
'ignoresign': "<?php echo __('Ignore'); ?>", 'ignoresign': "<?php echo __('Ignore'); ?>",
'verifysigntitle': "<?php echo __('Verify package signature'); ?>", 'verifysigntitle': "<?php echo __('Verify package signature'); ?>",
'verifysigns': "<?php echo __('Copy into the textarea the signature validation token you can retrieve from %s and press OK to verify the package, press ignore to avoid signature verification', 'https://support.pandorafms.com'); ?>" 'verifysigns': "<?php echo __('Copy into the textarea the signature validation token you can retrieve from %s and press OK to verify the package, press ignore to avoid signature verification', 'https://support.pandorafms.com'); ?>",
'notGoingToInstallUnoficialServerWarning': "<?php echo __('This server update does not correspond with current console version and is not going to be installed unless patches are allowed. Please enable patches in update manager settings.'); ?>",
'notGoingToInstallUnoficialWarning': "<?php echo __('This update does not correspond with next version of %s and is not going to be installed unless patches are allowed. Please enable patches in update manager settings.', get_product_name()); ?>",
} }
var insecureMode = <?php echo ($insecure === true) ? 'true' : 'false'; ?>; var insecureMode = <?php echo ($insecure === true) ? 'true' : 'false'; ?>;
@ -96,4 +98,6 @@
); );
} }
var ImSureWhatImDoing = <?php echo (false === $allowOfflinePatches) ? 'false' : 'true'; ?>;
</script> </script>

View File

@ -93,6 +93,10 @@ if (!$action_update_url_update_manager) {
'update_manager_proxy_password', 'update_manager_proxy_password',
$config['update_manager_proxy_password'] $config['update_manager_proxy_password']
); );
$allow_offline_patches = get_parameter_switch(
'allow_offline_patches',
$config['allow_offline_patches']
);
if ($action_update_url_update_manager) { if ($action_update_url_update_manager) {
$result = config_update_value( $result = config_update_value(
@ -134,6 +138,13 @@ if (!$action_update_url_update_manager) {
); );
} }
if ($result) {
$result = config_update_value(
'allow_offline_patches',
$allow_offline_patches
);
}
if ($result && license_free()) { if ($result && license_free()) {
$result = config_update_value( $result = config_update_value(
'identification_reminder', 'identification_reminder',
@ -154,6 +165,7 @@ if (!$action_update_url_update_manager) {
$update_manager_proxy_port = get_parameter('update_manager_proxy_port', ''); $update_manager_proxy_port = get_parameter('update_manager_proxy_port', '');
$update_manager_proxy_user = get_parameter('update_manager_proxy_user', ''); $update_manager_proxy_user = get_parameter('update_manager_proxy_user', '');
$update_manager_proxy_password = get_parameter('update_manager_proxy_password', ''); $update_manager_proxy_password = get_parameter('update_manager_proxy_password', '');
$allow_offline_patches = get_parameter_switch('allow_offline_patches', false);
if ($action_update_url_update_manager) { if ($action_update_url_update_manager) {
@ -196,6 +208,13 @@ if (!$action_update_url_update_manager) {
); );
} }
if ($result) {
$result = config_update_value(
'allow_offline_patches',
$allow_offline_patches
);
}
if ($result && license_free()) { if ($result && license_free()) {
$result = config_update_value('identification_reminder', $identification_reminder); $result = config_update_value('identification_reminder', $identification_reminder);
} }
@ -288,33 +307,39 @@ $table->data[5][1] = html_print_input_password(
true true
); );
$table->data[6][0] = __('Allow no-consecutive patches:');
$table->data[6][1] = html_print_switch(
[
'name' => 'allow_offline_patches',
'value' => $allow_offline_patches,
'return' => true,
]
);
$table->data[6][0] = __('Registration ID:'); $table->data[7][0] = __('Registration ID:');
$table->data[6][1] = '<i>'.$config['pandora_uid'].'</i>'; $table->data[7][1] = '<i>'.$config['pandora_uid'].'</i>';
if (update_manager_verify_registration() === true && users_is_admin()) { if (update_manager_verify_registration() === true && users_is_admin()) {
$table->data[7][0] = __('Cancel registration:'); $table->data[8][0] = __('Cancel registration:');
$table->data[7][1] = '<a href="'; $table->data[8][1] = '<a href="';
if ((bool) is_metaconsole() === true) { if ((bool) is_metaconsole() === true) {
$table->data[7][1] .= ui_get_full_url( $table->data[8][1] .= ui_get_full_url(
'index.php?sec=advanced&sec2=advanced/metasetup&pure=0&tab=update_manager_setup&um_disconnect_console=1' 'index.php?sec=advanced&sec2=advanced/metasetup&pure=0&tab=update_manager_setup&um_disconnect_console=1'
); );
} else { } else {
$table->data[7][1] .= ui_get_full_url( $table->data[8][1] .= ui_get_full_url(
'index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=setup&um_disconnect_console=1' 'index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=setup&um_disconnect_console=1'
); );
} }
$table->data[7][1] .= '" onclick="if(confirm(\'Are you sure?\')) {return true;} else { return false; }">'.__('Unregister').'</a>'; $table->data[8][1] .= '" onclick="if(confirm(\'Are you sure?\')) {return true;} else { return false; }">'.__('Unregister').'</a>';
} }
if (license_free()) { if (license_free()) {
$config['identification_reminder'] = isset($config['identification_reminder']) ? $config['identification_reminder'] : 1; $config['identification_reminder'] = isset($config['identification_reminder']) ? $config['identification_reminder'] : 1;
$table->data[8][0] = __('Pandora FMS community reminder').ui_print_help_tip(__('Every 8 days, a message is displayed to admin users to remember to register this Pandora instance'), true); $table->data[9][0] = __('Pandora FMS community reminder').ui_print_help_tip(__('Every 8 days, a message is displayed to admin users to remember to register this Pandora instance'), true);
$table->data[8][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('identification_reminder', 1, '', $config['identification_reminder'], true).'&nbsp;&nbsp;'; $table->data[9][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('identification_reminder', 1, '', $config['identification_reminder'], true).'&nbsp;&nbsp;';
$table->data[8][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('identification_reminder', 0, '', $config['identification_reminder'], true); $table->data[9][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('identification_reminder', 0, '', $config['identification_reminder'], true);
} }
html_print_input_hidden('action_update_url_update_manager', 1); html_print_input_hidden('action_update_url_update_manager', 1);

View File

@ -324,6 +324,16 @@ if ($create_user) {
$user_is_admin = (int) get_parameter('is_admin', 0); $user_is_admin = (int) get_parameter('is_admin', 0);
if (users_is_admin() === false && $user_is_admin !== 0) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to create with administrator privileges to user by non administrator user '.$config['id_user']
);
include 'general/noaccess.php';
exit;
}
$values = []; $values = [];
$values['id_user'] = (string) get_parameter('id_user'); $values['id_user'] = (string) get_parameter('id_user');
$values['fullname'] = (string) get_parameter('fullname'); $values['fullname'] = (string) get_parameter('fullname');
@ -538,6 +548,16 @@ if ($update_user) {
$values['default_event_filter'] = (int) get_parameter('default_event_filter'); $values['default_event_filter'] = (int) get_parameter('default_event_filter');
$values['default_custom_view'] = (int) get_parameter('default_custom_view'); $values['default_custom_view'] = (int) get_parameter('default_custom_view');
if (users_is_admin() === false && (bool) $values['is_admin'] !== false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to add administrator privileges to user by non administrator user '.$config['id_user']
);
include 'general/noaccess.php';
exit;
}
// eHorus user level conf. // eHorus user level conf.
$values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false); $values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false);
$values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user'); $values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user');
@ -1247,11 +1267,16 @@ $session_time .= html_print_input_text(
$user_groups = implode(',', array_keys((users_get_groups($id, 'AR', $display_all_group)))); $user_groups = implode(',', array_keys((users_get_groups($id, 'AR', $display_all_group))));
$event_filter_data = db_get_all_rows_sql('SELECT id_name, id_filter FROM tevent_filter WHERE id_group_filter IN ('.$user_groups.')'); if (empty($user_groups) === false) {
if ($event_filter_data === false) { $event_filter_data = db_get_all_rows_sql('SELECT id_name, id_filter FROM tevent_filter WHERE id_group_filter IN ('.$user_groups.')');
if ($event_filter_data === false) {
$event_filter_data = [];
}
} else {
$event_filter_data = []; $event_filter_data = [];
} }
$event_filter = []; $event_filter = [];
$event_filter[0] = __('None'); $event_filter[0] = __('None');
foreach ($event_filter_data as $filter) { foreach ($event_filter_data as $filter) {

View File

@ -260,9 +260,21 @@ if (is_metaconsole() === true) {
$disable_user = get_parameter('disable_user', false); $disable_user = get_parameter('disable_user', false);
if ((bool) get_parameter('user_del', false) === true) { $delete_user = (bool) get_parameter('user_del', false);
if ($delete_user === true) {
// Delete user. // Delete user.
$id_user = get_parameter('delete_user', 0); $id_user = get_parameter('delete_user', 0);
if (users_is_admin($id_user) === true && users_is_admin() === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to delete admininstrator user by non administrator user '.$config['id_user']
);
include 'general/noaccess.php';
exit;
}
// Only allow delete user if is not the actual user. // Only allow delete user if is not the actual user.
if ($id_user != $config['id_user']) { if ($id_user != $config['id_user']) {
$user_row = users_get_user_by_id($id_user); $user_row = users_get_user_by_id($id_user);
@ -332,6 +344,16 @@ if ((bool) get_parameter('user_del', false) === true) {
// Disable_user. // Disable_user.
$id_user = get_parameter('id', 0); $id_user = get_parameter('id', 0);
if (users_is_admin($id_user) === true && users_is_admin() === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to disable admininstrator user by non administrator user '.$config['id_user']
);
include 'general/noaccess.php';
exit;
}
if ($id_user !== 0) { if ($id_user !== 0) {
$result = users_disable($id_user, $disable_user); $result = users_disable($id_user, $disable_user);
} else { } else {
@ -353,9 +375,9 @@ if ((bool) get_parameter('user_del', false) === true) {
} }
} }
$filter_group = (int) get_parameter('filter_group', 0); $filter_group = (int) get_parameter('filter_group', 0);
$filter_search = get_parameter('filter_search', ''); $filter_search = get_parameter('filter_search', '');
$search = (bool) get_parameter('search', false); $search = (bool) get_parameter('search', false);
if (($filter_group == 0) && ($filter_search == '')) { if (($filter_group == 0) && ($filter_search == '')) {
$search = false; $search = false;
@ -545,6 +567,13 @@ if ($search) {
} }
} }
foreach ($info1 as $user_id => $user_info) {
// If user is not admin then don't display admin users.
if ($user_is_admin === false && (bool) $user_info['is_admin'] === true) {
unset($info1[$user_id]);
}
}
$info = $info1; $info = $info1;
// Prepare pagination. // Prepare pagination.
@ -557,11 +586,6 @@ $rowPair = true;
$iterator = 0; $iterator = 0;
$cont = 0; $cont = 0;
foreach ($info as $user_id => $user_info) { foreach ($info as $user_id => $user_info) {
if (!$user_is_admin && $user_info['is_admin']) {
// If user is not admin then don't display admin users.
continue;
}
// User profiles. // User profiles.
if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) { if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) {
$user_profiles = db_get_all_rows_field_filter( $user_profiles = db_get_all_rows_field_filter(
@ -662,7 +686,7 @@ foreach ($info as $user_id => $user_info) {
if ($total_profile == 0 && count($user_profiles) >= 5) { if ($total_profile == 0 && count($user_profiles) >= 5) {
$data[4] .= '<span onclick="showGroups()" class="pdd_l_15px"> $data[4] .= '<span onclick="showGroups()" class="pdd_l_15px">
'.html_print_image( '.html_print_image(
'images/zoom.png', 'images/zoom.png',
true, true,
[ [
@ -853,20 +877,21 @@ if ($is_management_allowed === true) {
} }
} }
echo '</div>'; echo '</div>';
enterprise_hook('close_meta_frame'); enterprise_hook('close_meta_frame');
echo '<script type="text/javascript"> echo '<script type="text/javascript">
function showGroups(){ function showGroups(){
var groups_list = document.getElementById("groups_list"); var groups_list = document.getElementById("groups_list");
if(groups_list.style.display == "none"){ if(groups_list.style.display == "none"){
document.querySelectorAll("[id=groups_list]").forEach(element=> document.querySelectorAll("[id=groups_list]").forEach(element=>
element.style.display = "block"); element.style.display = "block");
}else{ }else{
document.querySelectorAll("[id=groups_list]").forEach(element=> document.querySelectorAll("[id=groups_list]").forEach(element=>
element.style.display = "none"); element.style.display = "none");
}; };
} }
</script>'; </script>';

View File

@ -544,11 +544,6 @@ class AgentWizard extends HTML
// Get the servers. // Get the servers.
$rows = get_proxy_servers(); $rows = get_proxy_servers();
// Check if satellite server has remote configuration enabled.
$satellite_remote = config_agents_has_remote_configuration(
$this->idAgent
);
// Generate a list with allowed servers. // Generate a list with allowed servers.
if (isset($rows) === true && is_array($rows) === true) { if (isset($rows) === true && is_array($rows) === true) {
foreach ($rows as $row) { foreach ($rows as $row) {

View File

@ -158,7 +158,9 @@ class CredentialStore extends Wizard
// Check access. // Check access.
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AR')) { if ((bool) check_acl($config['id_user'], 0, 'PM') === false
|| (bool) check_acl($config['id_user'], 0, 'UM') === false
) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,
'Trying to access credential store' 'Trying to access credential store'

View File

@ -167,8 +167,10 @@ class Tree
*/ */
protected function getDisabledFilter() protected function getDisabledFilter()
{ {
$only_disabled = (is_metaconsole() === true) ? (int) $this->filter['show_disabled'] : 0;
if (empty($this->filter['showDisabled'])) { if (empty($this->filter['showDisabled'])) {
return ' tam.disabled = 0 AND ta.disabled = 0'; return ' tam.disabled = 0 AND ta.disabled = '.$only_disabled;
} }
return ' 1 = 1'; return ' 1 = 1';

View File

@ -311,13 +311,14 @@ class TreeGroup extends Tree
$table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente'; $table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente';
$table_sec = is_metaconsole() ? 'tmetaconsole_agent_secondary_group' : 'tagent_secondary_group'; $table_sec = is_metaconsole() ? 'tmetaconsole_agent_secondary_group' : 'tagent_secondary_group';
$only_disabled = (is_metaconsole() === true) ? (int) $this->filter['show_disabled'] : 0;
$sql_model = "SELECT %s FROM $sql_model = "SELECT %s FROM
( (
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_grupo AS g SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_grupo AS g
FROM $table ta FROM $table ta
$module_search_inner $module_search_inner
WHERE ta.disabled = 0 WHERE ta.disabled = $only_disabled
%s %s
$agent_search_filter $agent_search_filter
$agent_status_filter $agent_status_filter
@ -330,7 +331,7 @@ class TreeGroup extends Tree
FROM $table ta INNER JOIN $table_sec tasg FROM $table ta INNER JOIN $table_sec tasg
ON ta.id_agente = tasg.id_agent ON ta.id_agente = tasg.id_agent
$module_search_inner $module_search_inner
WHERE ta.disabled = 0 WHERE ta.disabled = $only_disabled
%s %s
$agent_search_filter $agent_search_filter
$agent_status_filter $agent_status_filter
@ -390,37 +391,29 @@ class TreeGroup extends Tree
$groups[$group['id']] = $group; $groups[$group['id']] = $group;
} }
// Build the module hierarchy // Build the module hierarchy.
foreach ($groups as $id => $group) { foreach ($groups as $id => $group) {
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { if (isset($groups[$id]['parent']) === true && ($groups[$id]['parent'] != 0)) {
$parent = $groups[$id]['parent']; $parent = $groups[$id]['parent'];
// Parent exists // Parent exists.
if (!isset($groups[$parent]['children'])) { if (isset($groups[$parent]['children']) === true) {
$groups[$parent]['children'] = []; $groups[$parent]['children'] = [];
} }
// Store a reference to the group into the parent // Store a reference to the group into the parent.
$groups[$parent]['children'][] = &$groups[$id]; $groups[$parent]['children'][] = &$groups[$id];
// This group was introduced into a parent // This group was introduced into a parent.
$groups[$id]['have_parent'] = true; $groups[$id]['have_parent'] = true;
} }
} }
// Sort the children groups // Sort the children groups.
foreach ($groups as $id => $group) { foreach ($groups as $id => $group) {
if (isset($groups[$id]['children'])) { if (isset($groups[$id]['children']) === true) {
usort($groups[$id]['children'], ['Tree', 'cmpSortNames']); usort($groups[$id]['children'], ['Tree', 'cmpSortNames']);
} }
} }
// Filter groups and eliminates the reference to children groups out of her parent
$groups = array_filter(
$groups,
function ($group) {
return !($group['have_parent'] ?? false);
}
);
return array_values($groups); return array_values($groups);
} }

View File

@ -20,7 +20,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC220222'; $build_version = 'PC220316';
$pandora_version = 'v7.0NG.760'; $pandora_version = 'v7.0NG.760';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -788,6 +788,7 @@ define('AUDIT_LOG_MASSIVE_MANAGEMENT', 'Massive operation management');
define('AUDIT_LOG_POLICY_MANAGEMENT', 'Policy management'); define('AUDIT_LOG_POLICY_MANAGEMENT', 'Policy management');
define('AUDIT_LOG_AGENT_REMOTE_MANAGEMENT', 'Agent remote configuration'); define('AUDIT_LOG_AGENT_REMOTE_MANAGEMENT', 'Agent remote configuration');
define('AUDIT_LOG_FILE_COLLECTION', 'File collection'); define('AUDIT_LOG_FILE_COLLECTION', 'File collection');
define('AUDIT_LOG_FILE_MANAGER', 'File manager');
define('AUDIT_LOG_ALERT_MANAGEMENT', 'Alert management'); define('AUDIT_LOG_ALERT_MANAGEMENT', 'Alert management');
define('AUDIT_LOG_ALERT_CORRELATION_MANAGEMENT', 'Alert correlation management'); define('AUDIT_LOG_ALERT_CORRELATION_MANAGEMENT', 'Alert correlation management');
define('AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT', 'Visual Console Management'); define('AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT', 'Visual Console Management');
@ -796,3 +797,58 @@ define('AUDIT_LOG_SNMP_MANAGEMENT', 'SNMP management');
define('AUDIT_LOG_DASHBOARD_MANAGEMENT', 'Dashboard management'); define('AUDIT_LOG_DASHBOARD_MANAGEMENT', 'Dashboard management');
define('AUDIT_LOG_SERVICE_MANAGEMENT', 'Service management'); define('AUDIT_LOG_SERVICE_MANAGEMENT', 'Service management');
define('AUDIT_LOG_INCIDENT_MANAGEMENT', 'Incident management'); define('AUDIT_LOG_INCIDENT_MANAGEMENT', 'Incident management');
// MIMEs.
define(
'MIME_TYPES',
[
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',
// Images.
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',
// Archives.
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'exe' => 'application/x-msdownload',
'msi' => 'application/x-msdownload',
'cab' => 'application/vnd.ms-cab-compressed',
'gz' => 'application/x-gzip',
'gz' => 'application/x-bzip2',
// Audio/Video.
'mp3' => 'audio/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
// Adobe.
'pdf' => 'application/pdf',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
// MS Office.
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
// Open Source Office files.
'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
]
);

View File

@ -750,6 +750,7 @@ function agents_get_agents_selected($group)
'id_tmetaconsole_setup', 'id_tmetaconsole_setup',
'id_agente', 'id_agente',
'alias', 'alias',
'server_name',
], ],
'AR', 'AR',
[ [
@ -764,7 +765,7 @@ function agents_get_agents_selected($group)
$all = array_reduce( $all = array_reduce(
$all, $all,
function ($carry, $item) { function ($carry, $item) {
$carry[$item['id_tmetaconsole_setup'].'|'.$item['id_tagente']] = $item['alias']; $carry[$item['id_tmetaconsole_setup'].'|'.$item['id_tagente']] = $item['server_name'].' &raquo; '.$item['alias'];
return $carry; return $carry;
}, },
[] []
@ -1243,6 +1244,11 @@ function agents_get_group_agents(
unset($search['string']); unset($search['string']);
} }
if (isset($search['matchIds']) === true && is_array($search['matchIds']) === true) {
$filter[] = sprintf('id_agente IN (%s)', implode(', ', $search['matchIds']));
unset($search['matchIds']);
}
if (isset($search['name']) === true) { if (isset($search['name']) === true) {
$name = io_safe_input($search['name']); $name = io_safe_input($search['name']);
$filter[] = "nombre LIKE '$name'"; $filter[] = "nombre LIKE '$name'";
@ -3223,8 +3229,8 @@ function agents_get_network_interfaces($agents=false, $agents_filter=false)
$ni_by_agents = []; $ni_by_agents = [];
foreach ($agents as $agent) { foreach ($agents as $agent) {
$agent_id = (isset($agent['id_agente'])) ? $agent['id_agente'] : $agent; $agent_id = (isset($agent['id_agente'])) ? $agent['id_agente'] : $agent;
$agent_group_id = $agent['id_grupo']; $agent_group_id = (isset($agent['id_grupo']) === true) ? $agent['id_grupo'] : '';
$agent_name = $agent['alias']; $agent_name = (isset($agent['alias']) === true) ? $agent['alias'] : '';
$agent_interfaces = []; $agent_interfaces = [];
$accepted_module_types = []; $accepted_module_types = [];
@ -4180,3 +4186,78 @@ function get_planned_downtime_agents_list($id_downtime, $filter_cond, $id_groups
return $agents; return $agents;
} }
/**
* Agent Module status and data
*
* @param integer $id_group Group
* @param array $agents Agents filter.
* @param array $modules Modules filter.
*
* @return array Result.
*/
function get_status_data_agent_modules($id_group, $agents=[], $modules=[])
{
$slq_filter_group = '';
if (empty($id_group) === false) {
$slq_filter_group = sprintf(
' AND tagente.id_grupo = %d',
$id_group
);
}
$slq_filter_agent = '';
if (empty($agents) === false) {
$slq_filter_agent = sprintf(
' AND tagente_modulo.id_agente IN (%s)',
implode(',', $agents)
);
}
$slq_filter_module = '';
if (empty($modules) === false) {
$slq_filter_module = sprintf(
' AND tagente_modulo.id_agente_modulo IN (%s)',
implode(',', $modules)
);
}
$sql = sprintf(
'SELECT tagente_modulo.id_agente_modulo as id_agent_module,
tagente_modulo.nombre as name_module,
tagente_modulo.unit as unit_module,
tagente_modulo.id_agente as id_agent,
tagente_estado.datos as data_module,
tagente_estado.timestamp as data_time_module,
tagente_estado.estado as status_module,
tagente.alias as name_agent,
tagente.id_grupo as id_group,
tgrupo.nombre as name_group
FROM tagente_modulo
INNER JOIN tagente_estado
ON tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
INNER JOIN tagente
ON tagente_modulo.id_agente = tagente.id_agente
LEFT JOIN tagent_secondary_group
ON tagente.id_agente = tagent_secondary_group.id_agent
INNER JOIN tgrupo
ON tagente.id_grupo = tgrupo.id_grupo
WHERE 1=1
%s
%s
%s
',
$slq_filter_group,
$slq_filter_agent,
$slq_filter_module
);
$res = db_get_all_rows_sql($sql);
if ($res === false) {
$res = [];
}
return $res;
}

View File

@ -3395,3 +3395,120 @@ function alerts_get_templates_name_array($array_ids)
return $result; return $result;
} }
/**
* Default values events calendar templates.
*
* @param integer $id ID.
* @param string $table Name table.
*
* @return array Data Events.
*/
function default_events_calendar($id, $table)
{
$result = [
'monday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
'tuesday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
'wednesday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
'thursday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
'friday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
'saturday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
'sunday' => [
[
'start' => '00:00:00',
'end' => '00:00:00',
],
],
];
$days = [
'monday',
'tuesday',
'wednesday',
'thursday',
'friday',
'saturday',
'sunday',
];
// Check Exists.
if (empty($id) === false) {
$sql_default_alert = sprintf(
'SELECT `id`,
`name`,
`time_from`,
`time_to`,
`monday`,
`tuesday`,
`wednesday`,
`thursday`,
`friday`,
`saturday`,
`sunday`,
`schedule`
FROM %s
WHERE id = %d',
$table,
$id
);
$r = db_get_row_sql($sql_default_alert);
if ($r != false) {
// Check Exist schedule.
if (empty($r['schedule']) === false) {
$result = json_decode(io_safe_output($r['schedule']), true);
} else {
// Compatibility mode old.
$result = [];
foreach ($days as $day) {
if ((int) $r[$day] === 1) {
$start = $r['time_from'];
$to = $r['time_to'];
if ($r['time_from'] === $r['time_to']) {
$start = '00:00:00';
$to = '00:00:00';
}
$result[$day][0] = [
'start' => $start,
'end' => $to,
];
}
}
}
}
}
return $result;
}

View File

@ -1535,10 +1535,6 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3)
'disabled', 'disabled',
] ]
); );
$tpolicy_group_old = db_get_all_rows_sql(
'SELECT id_policy FROM tpolicy_groups
WHERE id_group = '.$values_old['id_grupo']
);
$return = db_process_sql_update( $return = db_process_sql_update(
'tagente', 'tagente',
@ -1577,59 +1573,6 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3)
] ]
); );
} }
if ($tpolicy_group_old) {
foreach ($tpolicy_group_old as $key => $value) {
$tpolicy_agents_old = db_get_sql(
'SELECT * FROM tpolicy_agents
WHERE id_policy = '.$value['id_policy'].' AND id_agent = '.$id_agent
);
if ($tpolicy_agents_old) {
$result2 = db_process_sql_update(
'tpolicy_agents',
['pending_delete' => 1],
[
'id_agent' => $id_agent,
'id_policy' => $value['id_policy'],
]
);
}
}
}
$tpolicy_group = db_get_all_rows_sql(
'SELECT id_policy FROM tpolicy_groups
WHERE id_group = '.$idGroup
);
if ($tpolicy_group) {
foreach ($tpolicy_group as $key => $value) {
$tpolicy_agents = db_get_sql(
'SELECT * FROM tpolicy_agents
WHERE id_policy = '.$value['id_policy'].' AND id_agent ='.$id_agent
);
if (!$tpolicy_agents) {
db_process_sql_insert(
'tpolicy_agents',
[
'id_policy' => $value['id_policy'],
'id_agent' => $id_agent,
]
);
} else {
$result3 = db_process_sql_update(
'tpolicy_agents',
['pending_delete' => 0],
[
'id_agent' => $id_agent,
'id_policy' => $value['id_policy'],
]
);
}
}
}
} }
returnData( returnData(
@ -1829,11 +1772,6 @@ function api_set_update_agent_field($id_agent, $use_agent_alias, $params)
] ]
); );
$tpolicy_group_old = db_get_all_rows_sql(
'SELECT id_policy FROM tpolicy_groups
WHERE id_group = '.$values_old['id_grupo']
);
$return = db_process_sql_update( $return = db_process_sql_update(
'tagente', 'tagente',
$fields, $fields,
@ -1861,59 +1799,6 @@ function api_set_update_agent_field($id_agent, $use_agent_alias, $params)
] ]
); );
} }
if ($tpolicy_group_old) {
foreach ($tpolicy_group_old as $key => $value) {
$tpolicy_agents_old = db_get_sql(
'SELECT * FROM tpolicy_agents
WHERE id_policy = '.$value['id_policy'].' AND id_agent = '.$agent
);
if ($tpolicy_agents_old) {
$result2 = db_process_sql_update(
'tpolicy_agents',
['pending_delete' => 1],
[
'id_agent' => $agent,
'id_policy' => $value['id_policy'],
]
);
}
}
}
$tpolicy_group = db_get_all_rows_sql(
'SELECT id_policy FROM tpolicy_groups
WHERE id_group = '.$field['id_grupo']
);
if ($tpolicy_group) {
foreach ($tpolicy_group as $key => $value) {
$tpolicy_agents = db_get_sql(
'SELECT * FROM tpolicy_agents
WHERE id_policy = '.$value['id_policy'].' AND id_agent ='.$agent
);
if (!$tpolicy_agents) {
db_process_sql_insert(
'tpolicy_agents',
[
'id_policy' => $value['id_policy'],
'id_agent' => $agent,
]
);
} else {
$result3 = db_process_sql_update(
'tpolicy_agents',
['pending_delete' => 0],
[
'id_agent' => $agent,
'id_policy' => $value['id_policy'],
]
);
}
}
}
} }
} }
@ -2066,23 +1951,6 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3)
agents_add_address($id_agente, $direccion_agente); agents_add_address($id_agente, $direccion_agente);
} }
$tpolicy_group_old = db_get_all_rows_sql(
'SELECT id_policy FROM tpolicy_groups
WHERE id_group = '.$grupo
);
if ($tpolicy_group_old) {
foreach ($tpolicy_group_old as $key => $old_group) {
db_process_sql_insert(
'tpolicy_agents',
[
'id_policy' => $old_group['id_policy'],
'id_agent' => $id_agente,
]
);
}
}
$info = '{"Name":"'.$nombre_agente.'", $info = '{"Name":"'.$nombre_agente.'",
"IP":"'.$direccion_agente.'", "IP":"'.$direccion_agente.'",
"Group":"'.$grupo.'", "Group":"'.$grupo.'",

View File

@ -4187,6 +4187,28 @@ function events_get_response_target(
); );
} }
if (strpos($target, '_owner_username_') !== false) {
if (empty($event['owner_user']) === false) {
$fullname = users_get_user_by_id($event['owner_user']);
$target = str_replace(
'_owner_username_',
io_safe_output($fullname['fullname']),
$target
);
} else {
$target = str_replace('_owner_username_', __('N/A'), $target);
}
}
if (strpos($target, '_current_username_') !== false) {
$fullname = users_get_user_by_id($config['id_user']);
$target = str_replace(
'_current_username_',
io_safe_output($fullname['fullname']),
$target
);
}
return $target; return $target;
} }
@ -7588,6 +7610,28 @@ function events_get_field_value_by_event_id(
$value = str_replace('_current_user_', $config['id_user'], $value); $value = str_replace('_current_user_', $config['id_user'], $value);
} }
if (strpos($value, '_owner_username_') !== false) {
if (empty($event['owner_user']) === false) {
$fullname = users_get_user_by_id($event['owner_user']);
$value = str_replace(
'_owner_username_',
io_safe_output($fullname['fullname']),
$value
);
} else {
$value = str_replace('_owner_username_', __('N/A'), $value);
}
}
if (strpos($value, '_current_username_') !== false) {
$fullname = users_get_user_by_id($config['id_user']);
$value = str_replace(
'_current_username_',
io_safe_output($fullname['fullname']),
$value
);
}
return $value; return $value;
} }

View File

@ -14,7 +14,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
* *
* ============================================================================ * ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list * Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -48,69 +48,22 @@ if (function_exists('mime_content_type') === false) {
*/ */
function mime_content_type(string $filename) function mime_content_type(string $filename)
{ {
$mime_types = [
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',
// Images.
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',
// Archives.
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'exe' => 'application/x-msdownload',
'msi' => 'application/x-msdownload',
'cab' => 'application/vnd.ms-cab-compressed',
'gz' => 'application/x-gzip',
'gz' => 'application/x-bzip2',
// Audio/Video.
'mp3' => 'audio/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
// Adobe.
'pdf' => 'application/pdf',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
// MS Office.
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
// Open Source Office files.
'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
];
$ext_fields = explode('.', $filename); $ext_fields = explode('.', $filename);
$ext = array_pop($ext_fields); $ext = array_pop($ext_fields);
$ext = strtolower($ext); $ext = strtolower($ext);
if (array_key_exists($ext, $mime_types) === true) { if (array_key_exists($ext, MIME_TYPES) === true) {
return $mime_types[$ext]; return MIME_TYPES[$ext];
} else if (function_exists('finfo_open') === true) { } else if (function_exists('finfo_open') === true) {
$finfo = finfo_open(FILEINFO_MIME); $finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_file($finfo, $filename); $mimetype = finfo_file($finfo, $filename);
finfo_close($finfo); finfo_close($finfo);
return $mimetype; return $mimetype;
} else { } else {
error_log('Warning: Cannot find finfo_open function. Fileinfo extension is not enabled. Please add "extension=fileinfo.so" or "extension=fileinfo.dll" in your php.ini'); db_pandora_audit(
AUDIT_LOG_FILE_MANAGER,
'Warning: Cannot find finfo_open function. Fileinfo extension is not enabled. Please add "extension=fileinfo.so" or "extension=fileinfo.dll" in your php.ini'
);
return 'unknown'; return 'unknown';
} }
} }
@ -129,10 +82,12 @@ require_once $config['homedir'].'/vendor/autoload.php';
* @param boolean $upload_file_or_zip Upload file or zip. * @param boolean $upload_file_or_zip Upload file or zip.
* @param string $default_real_directory String with default directory. * @param string $default_real_directory String with default directory.
* @param string $destination_directory String with destination directory. * @param string $destination_directory String with destination directory.
* @param array $filterFilesType If come filled, filter uploaded files with this extensions.
* *
* @throws Exception Exception.
* @return void * @return void
*/ */
function upload_file($upload_file_or_zip, $default_real_directory, $destination_directory) function upload_file($upload_file_or_zip, $default_real_directory, $destination_directory, $filterFilesType=[])
{ {
global $config; global $config;
$config['filemanager'] = []; $config['filemanager'] = [];
@ -179,13 +134,24 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_
// controlled by corresponding .htaccess). // controlled by corresponding .htaccess).
$config['filemanager']['message'] = ui_print_error_message(__('Security error')); $config['filemanager']['message'] = ui_print_error_message(__('Security error'));
} else { } else {
$result = false;
// Copy file to directory and change name. // Copy file to directory and change name.
$nombre_archivo = sprintf('%s/%s', $real_directory, $filename); $nombre_archivo = sprintf('%s/%s', $real_directory, $filename);
try { try {
$result = copy($_FILES['file']['tmp_name'], $nombre_archivo); $mimeContentType = mime_content_type($_FILES['file']['tmp_name']);
if (empty($filterFilesType) === true || in_array($mimeContentType, $filterFilesType) === true) {
$result = copy($_FILES['file']['tmp_name'], $nombre_archivo);
} else {
$error_message = 'The uploaded file is not allowed. Only gif, png or jpg files can be uploaded.';
throw new Exception(__($error_message));
}
} catch (Exception $ex) { } catch (Exception $ex) {
$result = false; db_pandora_audit(
AUDIT_LOG_FILE_MANAGER,
'Error Uploading files: '.$ex->getMessage()
);
$config['filemanager']['message'] = ui_print_error_message(__('Upload error').': '.$ex->getMessage());
} }
if ($result === true) { if ($result === true) {
@ -203,8 +169,6 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_
$config['filemanager']['correct_upload_file'] = 1; $config['filemanager']['correct_upload_file'] = 1;
// Delete temporal file. // Delete temporal file.
unlink($_FILES['file']['tmp_name']); unlink($_FILES['file']['tmp_name']);
} else {
$config['filemanager']['message'] = ui_print_error_message(__('Upload error'));
} }
} }
} }
@ -496,7 +460,7 @@ function filemanager_read_recursive_dir($dir, $relative_path='', $add_empty_dirs
* @param boolean $download_button The flag to show download button, by default false. * @param boolean $download_button The flag to show download button, by default false.
* @param string $umask The umask as hex values to set the new files or updload. * @param string $umask The umask as hex values to set the new files or updload.
* @param boolean $homedir_filemanager Homedir filemanager. * @param boolean $homedir_filemanager Homedir filemanager.
* @param boolean $allowCreateText If true, 'Create Text' button will be shown. * @param array $options Associative array. ['all' => true] will show all options. Check function for valid options.
*/ */
function filemanager_file_explorer( function filemanager_file_explorer(
$real_directory, $real_directory,
@ -509,7 +473,7 @@ function filemanager_file_explorer(
$download_button=false, $download_button=false,
$umask='', $umask='',
$homedir_filemanager=false, $homedir_filemanager=false,
$allowCreateText=true $options=[]
) { ) {
global $config; global $config;
@ -517,6 +481,9 @@ function filemanager_file_explorer(
$real_directory = str_replace('\\', '/', $real_directory); $real_directory = str_replace('\\', '/', $real_directory);
$relative_directory = str_replace('\\', '/', $relative_directory); $relative_directory = str_replace('\\', '/', $relative_directory);
$father = str_replace('\\', '/', $father); $father = str_replace('\\', '/', $father);
// Options.
$allowZipFiles = (isset($options['all']) === true) || ((isset($options['allowZipFiles']) === true) && ($options['allowZipFiles'] === true));
$allowCreateText = (isset($options['all']) === true) || ((isset($options['allowCreateText']) === true) && ($options['allowCreateText'] === true));
if ($homedir_filemanager === false) { if ($homedir_filemanager === false) {
$homedir_filemanager = $config['homedir']; $homedir_filemanager = $config['homedir'];
@ -530,7 +497,7 @@ function filemanager_file_explorer(
actions_dialog('create_folder'); actions_dialog('create_folder');
$("#create_folder").css("display", "block"); $("#create_folder").css("display", "block");
check_opened_dialog('create_folder'); check_opened_dialog('create_folder');
} }
<?php if ($allowCreateText === true) : ?> <?php if ($allowCreateText === true) : ?>
function show_create_text_file() { function show_create_text_file() {
actions_dialog('create_text_file'); actions_dialog('create_text_file');
@ -542,7 +509,7 @@ function filemanager_file_explorer(
actions_dialog('upload_file'); actions_dialog('upload_file');
$("#upload_file").css("display", "block"); $("#upload_file").css("display", "block");
check_opened_dialog('upload_file'); check_opened_dialog('upload_file');
} }
function check_opened_dialog(check_opened){ function check_opened_dialog(check_opened){
if(check_opened !== 'create_folder'){ if(check_opened !== 'create_folder'){
@ -579,11 +546,11 @@ function filemanager_file_explorer(
case 'upload_file': case 'upload_file':
title_action = "<?php echo __('Upload Files'); ?>"; title_action = "<?php echo __('Upload Files'); ?>";
break; break;
default: default:
break; break;
} }
$('#'+action) $('#'+action)
.dialog({ .dialog({
title: title_action, title: title_action,
@ -839,15 +806,86 @@ function filemanager_file_explorer(
$tabs_dialog .= '</ul>'; $tabs_dialog .= '</ul>';
echo '<div id="create_folder" class="invisible">'.$tabs_dialog.' // Create folder section.
<form method="post" action="'.$url.'">'.html_print_input_text('dirname', '', '', 30, 255, true).html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"', true).html_print_input_hidden('directory', $relative_directory, true).html_print_input_hidden('create_dir', 1, true).html_print_input_hidden('hash', md5($relative_directory.$config['server_unique_identifier']), true).html_print_input_hidden('hash2', md5($relative_directory.$config['server_unique_identifier']), true).'</form></div>'; $createFolderElements = $tabs_dialog;
$createFolderElements .= sprintf('<form method="POST" action="%s">', $url);
$createFolderElements .= html_print_input_text('dirname', '', '', 30, 255, true);
$createFolderElements .= html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"', true);
$createFolderElements .= html_print_input_hidden('directory', $relative_directory, true);
$createFolderElements .= html_print_input_hidden('create_dir', 1, true);
$createFolderElements .= html_print_input_hidden('hash', md5($relative_directory.$config['server_unique_identifier']), true);
$createFolderElements .= html_print_input_hidden('hash2', md5($relative_directory.$config['server_unique_identifier']), true);
$createFolderElements .= '</form>';
echo '<div id="upload_file" class="invisible"> '.$tabs_dialog.' html_print_div(
<form method="post" action="'.$url.'" enctype="multipart/form-data">'.ui_print_help_tip(__('The zip upload in this dir, easy to upload multiple files.'), true).html_print_input_file('file', true, false).html_print_input_hidden('umask', $umask, true).html_print_checkbox('decompress', 1, false, true).__('Decompress').html_print_submit_button(__('Go'), 'go', false, 'class="sub next"', true).html_print_input_hidden('real_directory', $real_directory, true).html_print_input_hidden('directory', $relative_directory, true).html_print_input_hidden('hash', md5($real_directory.$relative_directory.$config['server_unique_identifier']), true).html_print_input_hidden('hash2', md5($relative_directory.$config['server_unique_identifier']), true).html_print_input_hidden('upload_file_or_zip', 1, true).'</form></div>'; [
'id' => 'create_folder',
'class' => 'invisible',
'content' => $createFolderElements,
]
);
// Upload file section.
$uploadFileElements = $tabs_dialog;
$uploadFileElements .= sprintf('<form method="POST" action="%s" enctype="multipart/form-data">', $url);
$uploadFileElements .= html_print_input_hidden('umask', $umask, true);
if ($allowZipFiles === true) {
$uploadFileElements .= ui_print_help_tip(__('The zip upload in this dir, easy to upload multiple files.'), true);
$uploadFileElements .= html_print_input_file('file', true, false);
$uploadFileElements .= html_print_checkbox('decompress', 1, false, true).__('Decompress');
$uploadFileElements .= html_print_input_hidden('upload_file_or_zip', 1, true);
} else {
$uploadFileElements .= html_print_div(
[
'id' => 'upload_file_input_full',
'content' => html_print_input_file(
'file',
true,
[ 'style' => 'border:0; padding:0; width:100%' ]
),
],
true
);
$uploadFileElements .= html_print_input_hidden('upload_file', 1, true);
}
$uploadFileElements .= html_print_submit_button(__('Go'), 'go', false, 'class="sub next"', true);
$uploadFileElements .= html_print_input_hidden('real_directory', $real_directory, true);
$uploadFileElements .= html_print_input_hidden('directory', $relative_directory, true);
$uploadFileElements .= html_print_input_hidden('hash', md5($real_directory.$relative_directory.$config['server_unique_identifier']), true);
$uploadFileElements .= html_print_input_hidden('hash2', md5($relative_directory.$config['server_unique_identifier']), true);
$uploadFileElements .= '</form>';
html_print_div(
[
'id' => 'upload_file',
'class' => 'invisible',
'content' => $uploadFileElements,
]
);
// Create text section.
if ($allowCreateText === true) { if ($allowCreateText === true) {
echo ' <div id="create_text_file" class="invisible">'.$tabs_dialog.' $createTextElements = $tabs_dialog;
<form method="post" action="'.$url.'">'.html_print_input_text('name_file', '', '', 30, 50, true).html_print_submit_button(__('Create'), 'create', false, 'class="sub next"', true).html_print_input_hidden('real_directory', $real_directory, true).html_print_input_hidden('directory', $relative_directory, true).html_print_input_hidden('hash', md5($real_directory.$relative_directory.$config['server_unique_identifier']), true).html_print_input_hidden('umask', $umask, true).html_print_input_hidden('create_text_file', 1, true).'</form></div>'; $createTextElements .= '<form method="post" action="'.$url.'">';
$createTextElements .= html_print_input_text('name_file', '', '', 30, 50, true);
$createTextElements .= html_print_submit_button(__('Create'), 'create', false, 'class="sub next"', true);
$createTextElements .= html_print_input_hidden('real_directory', $real_directory, true);
$createTextElements .= html_print_input_hidden('directory', $relative_directory, true);
$createTextElements .= html_print_input_hidden('hash', md5($real_directory.$relative_directory.$config['server_unique_identifier']), true);
$createTextElements .= html_print_input_hidden('umask', $umask, true);
$createTextElements .= html_print_input_hidden('create_text_file', 1, true);
$createTextElements .= '</form>';
html_print_div(
[
'id' => 'create_text_file',
'class' => 'invisible',
'content' => $createTextElements,
]
);
} }
echo "<div style='width: ".$table->width.";' class='file_table_buttons'>"; echo "<div style='width: ".$table->width.";' class='file_table_buttons'>";

View File

@ -567,7 +567,7 @@ function groups_get_groups_tree_recursive($groups, $trash=0, $trash2=0)
$tree = $groups; $tree = $groups;
foreach ($groups as $key => $group) { foreach ($groups as $key => $group) {
if ($group['id_grupo'] == 0) { if (is_array($group) === false || (int) $group['id_grupo'] === 0) {
continue; continue;
} }

View File

@ -4267,6 +4267,10 @@ function html_print_input_file($name, $return=false, $options=false)
if (isset($options['onchange'])) { if (isset($options['onchange'])) {
$output .= ' onchange="'.$options['onchange'].'"'; $output .= ' onchange="'.$options['onchange'].'"';
} }
if (isset($options['style']) === true) {
$output .= ' style="'.$options['style'].'"';
}
} }
$output .= ' />'; $output .= ' />';
@ -4936,7 +4940,13 @@ function html_print_input($data, $wrapper='div', $input_only=false)
((isset($data['size']) === true) ? $data['size'] : false), ((isset($data['size']) === true) ? $data['size'] : false),
((isset($data['modal']) === true) ? $data['modal'] : false), ((isset($data['modal']) === true) ? $data['modal'] : false),
((isset($data['message']) === true) ? $data['message'] : ''), ((isset($data['message']) === true) ? $data['message'] : ''),
((isset($data['select_all']) === true) ? $data['select_all'] : false) ((isset($data['select_all']) === true) ? $data['select_all'] : false),
((isset($data['simple_multiple_options']) === true) ? $data['simple_multiple_options'] : false),
((isset($data['required']) === true) ? $data['required'] : false),
((isset($data['truncate_size']) === true) ? $data['truncate_size'] : false),
((isset($data['select2_enable']) === true) ? $data['select2_enable'] : true),
((isset($data['select2_multiple_enable']) === true) ? $data['select2_multiple_enable'] : false),
((isset($data['select2_multiple_enable_all']) === true) ? $data['select2_multiple_enable_all'] : false)
); );
break; break;
@ -5728,3 +5738,198 @@ function html_print_select_search(
echo $output; echo $output;
} }
} }
/**
* Print html select for agents secondary.
*
* @param integer $agent Agent.
* @param integer $id_agente Id Agent.
* @param array $options Array options.
*
* @return string Html output.
*/
function html_print_select_agent_secondary($agent, $id_agente, $options=[])
{
ui_require_css_file('agent_manager');
ui_require_javascript_file('pandora_agents');
if (empty($options) === '' || isset($options['id_form']) === false) {
$options['id_form'] = 'form_agent';
}
if (empty($options) === '' || isset($options['extra_id']) === false) {
$options['extra_id'] = '';
}
if (empty($options) === '' || isset($options['only_select']) === false) {
$options['only_select'] = false;
}
$secondary_groups_selected = enterprise_hook(
'agents_get_secondary_groups',
[$id_agente]
);
$name = 'secondary_groups'.$options['extra_id'];
if ($options['only_select'] === true) {
$name = 'secondary_groups'.$options['extra_id'].'[]';
}
$adv_secondary_groups_left = html_print_select_groups(
// Id_user.
// Use the current user to select the groups.
false,
// Privilege.
// ACL permission.
'AR',
// ReturnAllGroup.
// Not all group.
false,
// Name.
// HTML id.
$name,
// Selected.
// No select any by default.
'',
// Script.
// Javascript onChange code.
'',
// Nothing.
// Do not user no selected value.
false,
// Nothing_value.
// Do not use no selected value.
0,
// Return.
// Return HTML (not echo).
true,
// Multiple.
// Multiple selection.
true,
// Sort.
// Sorting by default.
true,
// Class.
// CSS classnames (default).
'',
// Disabled.
// Not disabled (default).
false,
// Style.
// Inline styles (default).
'min-width:170px;',
// Option_style.
// Option style select (default).
false,
// Id_group.
// Do not truncate the users tree (default).
false,
// Keys_field.
// Key to get as value (default).
'id_grupo',
// Strict_user.
// Not strict user (default).
false,
// Delete_groups.
// Do not show the primary group in this selection.
array_merge(
(empty($secondary_groups_selected['plain']) === false) ? $secondary_groups_selected['plain'] : [],
[$agent['id_grupo']]
)
// Include_groups.
// Size.
// Simple_multiple_options.
);
if ($options['only_select'] === false) {
$dictionary = base64_encode(
json_encode(
[
'primary_group' => __('Primary group cannot be secondary too.'),
'strNone' => __('None'),
]
)
);
$adv_secondary_groups_arrows = html_print_input_image(
'add_secondary',
'images/darrowright_green.png',
1,
'',
true,
[
'id' => 'right_autorefreshlist'.$options['extra_id'],
'title' => __('Add secondary groups'),
'onclick' => 'agent_manager_add_secondary_groups(event, '.$id_agente.',\''.$options['extra_id'].'\', \''.$options['id_form'].'\', \''.$dictionary.'\');',
]
);
$adv_secondary_groups_arrows .= html_print_input_image(
'remove_secondary',
'images/darrowleft_green.png',
1,
'',
true,
[
'id' => 'left_autorefreshlist'.$options['extra_id'],
'title' => __('Remove secondary groups'),
'onclick' => 'agent_manager_remove_secondary_groups(event, '.$id_agente.',\''.$options['extra_id'].'\', \''.$options['id_form'].'\', \''.$dictionary.'\');',
]
);
$adv_secondary_groups_right .= html_print_select(
// Values.
$secondary_groups_selected['for_select'],
// HTML id.
'secondary_groups_selected'.$options['extra_id'],
// Selected.
'',
// Javascript onChange code.
'',
// Nothing selected.
false,
// Nothing selected.
0,
// Return HTML (not echo).
true,
// Multiple selection.
true,
// Sort.
true,
// Class.
'',
// Disabled.
false,
// Style.
'min-width:170px;'
);
$output = '';
if (isset($options['container']) === true
&& $options['container'] === true
) {
$output = '<div class="secondary_groups_list">';
}
$output .= '<div class="sg_source">';
$output .= $adv_secondary_groups_left;
$output .= '</div>';
$output .= '<div class="secondary_group_arrows">';
$output .= $adv_secondary_groups_arrows;
$output .= '</div>';
$output .= '<div class="sg_target">';
$output .= $adv_secondary_groups_right;
$output .= '</div>';
if (isset($options['container']) === true
&& $options['container'] === true
) {
$output .= '</div>';
}
} else {
$output .= $adv_secondary_groups_left;
}
return $output;
}

View File

@ -989,7 +989,7 @@ function planned_downtimes_copy($id_downtime)
foreach ($planned_modules as $planned_module) { foreach ($planned_modules as $planned_module) {
// Unset id. // Unset id.
unset($planned_module['id']); unset($planned_module['id']);
// Set id_planned downtime // Set id_planned downtime.
$planned_module['id_downtime'] = $result['id_downtime']; $planned_module['id_downtime'] = $result['id_downtime'];
$result['id_modules'][] = db_process_sql_insert( $result['id_modules'][] = db_process_sql_insert(
'tplanned_downtime_moduless', 'tplanned_downtime_moduless',
@ -1004,3 +1004,82 @@ function planned_downtimes_copy($id_downtime)
return $result; return $result;
} }
/**
* Get agentts and modules for planned_downtime.
*
* @param [type] $id Id planned.
*
* @return array Result array data.
*/
function get_agents_modules_planned_dowtime($id, $options, $count=false)
{
$result = [];
$filters_agent = '';
if (isset($options['filters']['filter_agents']) === true
&& empty($options['filters']['filter_agents']) === false
) {
$filters_agent = sprintf(
' AND (tagente.alias LIKE "%%%s%%")',
$options['filters']['filter_agents']
);
}
$filters_module = '';
if (isset($options['filters']['filter_modules']) === true
&& empty($options['filters']['filter_modules']) === false
) {
$filters_module = sprintf(
' AND (tagente_modulo.nombre LIKE "%%%s%%")',
$options['filters']['filter_modules']
);
}
if ($count === false) {
$query = sprintf(
'SELECT tplanned_downtime_modules.*,
tagente.alias as agent_name,
tagente_modulo.nombre as module_name
FROM tplanned_downtime_modules
INNER JOIN tagente
ON tplanned_downtime_modules.id_agent = tagente.id_agente
INNER JOIN tagente_modulo
ON tplanned_downtime_modules.id_agent_module = tagente_modulo.id_agente_modulo
WHERE id_downtime = %d
%s
%s
ORDER BY %s
LIMIT %d, %d',
$id,
$filters_agent,
$filters_module,
$options['order'],
$options['limit'],
$options['offset']
);
} else {
$query = sprintf(
'SELECT count(tplanned_downtime_modules.id) as total
FROM tplanned_downtime_modules
INNER JOIN tagente
ON tplanned_downtime_modules.id_agent = tagente.id_agente
INNER JOIN tagente_modulo
ON tplanned_downtime_modules.id_agent_module = tagente_modulo.id_agente_modulo
WHERE id_downtime = %d
%s
%s',
$id,
$filters_agent,
$filters_module
);
}
$result = db_get_all_rows_sql($query);
if ($result === false) {
$result = [];
}
return $result;
}

View File

@ -730,6 +730,13 @@ function reporting_make_reporting_data(
); );
break; break;
case 'agent_module_status':
$report['contents'][] = reporting_agent_module_status(
$report,
$content
);
break;
case 'alert_report_actions': case 'alert_report_actions':
$report['contents'][] = reporting_alert_report_actions( $report['contents'][] = reporting_alert_report_actions(
$report, $report,
@ -2854,6 +2861,136 @@ function reporting_agent_module($report, $content)
} }
/**
* Agents module status
*
* @param array $report Info Report.
* @param array $content Info content.
*
* @return array
*/
function reporting_agent_module_status($report, $content)
{
global $config;
$return['type'] = 'agent_module_status';
if (empty($content['name'])) {
$content['name'] = __('Agent/Modules Status');
}
$return['title'] = io_safe_output($content['name']);
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$group_name = groups_get_name($content['id_group'], true);
if ($content['id_module_group'] == 0) {
$module_group_name = __('All');
} else {
$module_group_name = db_get_value(
'name',
'tmodule_group',
'id_mg',
$content['id_module_group']
);
}
$return['subtitle'] = $group_name.' - '.$module_group_name;
$return['description'] = io_safe_output($content['description']);
$return['date'] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
$return['data'] = [];
$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
);
if (is_metaconsole() === true) {
$agents_per_node = [];
$modules_per_node = [];
if (empty($agents) === false) {
foreach ($agents as $value) {
$agent_array = explode('|', $value);
$agents_per_node[$agent_array[0]][] = $agent_array[1];
}
}
if (empty($modules) === false) {
foreach ($modules as $value) {
$module_array = explode('|', $value);
$modules_per_node[$module_array[0]][] = $module_array[1];
}
}
if (empty($agents_per_node) === false) {
foreach ($agents_per_node as $server => $agents) {
$connection = metaconsole_get_connection_by_id($server);
if (metaconsole_connect($connection) != NOERR) {
continue;
}
$res[$connection['server_name']] = get_status_data_agent_modules(
$content['id_group'],
$agents,
$modules_per_node[$server]
);
metaconsole_restore_db();
}
} else {
$metaconsole_connections = metaconsole_get_connection_names();
// For all nodes.
if (isset($metaconsole_connections) === true
&& is_array($metaconsole_connections) === true
) {
foreach ($metaconsole_connections as $metaconsole) {
// Get server connection data.
$server_data = metaconsole_get_connection($metaconsole);
// Establishes connection.
if (metaconsole_load_external_db($server_data) !== NOERR) {
continue;
}
$res[$server_data['server_name']] = get_status_data_agent_modules(
$content['id_group'],
$agents,
$modules
);
metaconsole_restore_db();
}
}
}
} else {
$res['node'] = get_status_data_agent_modules(
$content['id_group'],
$agents,
$modules
);
}
$return['data'] = $res;
return reporting_check_structure_content($return);
}
function reporting_exception( function reporting_exception(
$report, $report,
$content, $content,
@ -11049,11 +11186,29 @@ function reporting_get_stats_users($data)
$tdata = []; $tdata = [];
$tdata[0] = html_print_image('images/user.png', true, ['title' => __('Defined users'), 'class' => 'invert_filter']); $tdata[0] = html_print_image('images/user.png', true, ['title' => __('Defined users'), 'class' => 'invert_filter']);
$user_groups = users_get_strict_mode_groups($config['id_user'], false); $user_is_admin = users_is_admin();
if (array_key_exists(0, $user_groups)) {
$users = users_get_user_users($config['id_user'], 'AR', true); $users = [];
if ($user_is_admin) {
$users = get_users('', ['disabled' => 0], ['id_user', 'is_admin']);
} else { } else {
$users = users_get_user_users($config['id_user'], 'AR', false); $group_um = users_get_groups_UM($config['id_user']);
// 0 is the group 'all'.
if (isset($group_um[0])) {
$users = get_users('', ['disabled' => 0], ['id_user', 'is_admin']);
} else {
foreach ($group_um as $group => $value) {
$users = array_merge($users, users_get_users_by_group($group, $value, false));
}
}
}
foreach ($users as $user_id => $user_info) {
// If user is not admin then don't display admin users.
if ($user_is_admin === false && (bool) $user_info['is_admin'] === true) {
unset($users[$user_id]);
}
} }
$tdata[1] = count($users); $tdata[1] = count($users);

View File

@ -377,6 +377,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
reporting_html_agent_module($table, $item); reporting_html_agent_module($table, $item);
break; break;
case 'agent_module_status':
reporting_html_agent_module_status($table, $item);
break;
case 'alert_report_actions': case 'alert_report_actions':
reporting_html_alert_report_actions($table, $item); reporting_html_alert_report_actions($table, $item);
break; break;
@ -1999,6 +2003,125 @@ function reporting_html_agent_module($table, $item)
} }
/**
* Html report agent modules status.
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param integer $pdf Pdf output.
*
* @return mixed
*/
function reporting_html_agent_module_status($table, $item, $pdf=0)
{
global $config;
$return_pdf = '';
if (empty($item['data']) === true) {
if ($pdf !== 0) {
$return_pdf .= __('No items');
} else {
$table->colspan['group_report']['cell'] = 3;
$table->cellstyle['group_report']['cell'] = 'text-align: center;';
$table->data['group_report']['cell'] = __('No items');
}
} else {
$table_info = new stdClass();
$table_info->width = '99%';
$table_info->align = [];
if (is_metaconsole() === true) {
$table_info->align['server'] = 'left';
}
$table_info->align['name_group'] = 'left';
$table_info->align['name_agent'] = 'left';
$table_info->align['name_module'] = 'left';
$table_info->align['status_module'] = 'left';
$table_info->align['data_module'] = 'left';
$table_info->align['data_time_module'] = 'left';
$table_info->headstyle = [];
if (is_metaconsole() === true) {
$table_info->headstyle['server'] = 'text-align: left';
}
$table_info->headstyle['name_group'] = 'text-align: left';
$table_info->headstyle['name_agent'] = 'text-align: left';
$table_info->headstyle['name_module'] = 'text-align: left';
$table_info->headstyle['status_module'] = 'text-align: left';
$table_info->headstyle['data_module'] = 'text-align: left';
$table_info->headstyle['data_time_module'] = 'text-align: left';
$table_info->head = [];
if (is_metaconsole() === true) {
$table_info->head['server'] = __('Server');
}
$table_info->head['name_agent'] = __('Agent');
$table_info->head['name_module'] = __('Module');
$table_info->head['name_group'] = __('Group');
$table_info->head['status_module'] = __('Status');
$table_info->head['data_module'] = __('Data');
$table_info->head['data_time_module'] = __('Last time');
$table_info->data = [];
foreach ($item['data'] as $server => $info) {
foreach ($info as $data) {
$row = [];
if (is_metaconsole() === true) {
$row['server'] = $server;
}
$row['name_agent'] = $data['name_agent'];
$row['name_module'] = $data['name_module'];
$row['name_group'] = $data['name_group'];
$row['status_module'] = ui_print_module_status(
$data['status_module'],
true,
'status_rounded_rectangles',
null,
($pdf === 1) ? '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' : ''
);
if (is_numeric($data['data_module']) === true) {
$row['data_module'] = remove_right_zeros(
number_format(
$data['data_module'],
$config['graph_precision']
)
);
} else {
$row['data_module'] = (empty($data['data_module']) === true) ? '--' : $data['data_module'];
}
$row['data_module'] .= $data['unit_module'];
$row['data_time_module'] = $data['data_time_module'];
$table_info->data[] = $row;
}
}
if ($pdf !== 0) {
$table_info->title = $item['title'];
$table_info->titleclass = 'title_table_pdf';
$table_info->titlestyle = 'text-align:left;';
$return_pdf .= html_print_table($table_info, true);
} else {
$table->colspan['data']['cell'] = 3;
$table->cellstyle['data']['cell'] = 'text-align: center;';
$table->data['data']['cell'] = html_print_table($table_info, true);
}
}
if ($pdf !== 0) {
return $return_pdf;
}
}
/** /**
* Function to print to HTML Exception report. * Function to print to HTML Exception report.
* *

View File

@ -796,6 +796,11 @@ function reports_get_report_types($template=false, $not_editor=false)
} }
} }
$types['agent_module_status'] = [
'optgroup' => __('Grouped'),
'name' => __('Agents/Modules status'),
];
// Only pandora managers have access to the whole database. // Only pandora managers have access to the whole database.
if (check_acl($config['id_user'], 0, 'PM')) { if (check_acl($config['id_user'], 0, 'PM')) {
$types['sql'] = [ $types['sql'] = [

View File

@ -2713,16 +2713,15 @@ function ui_print_status_image(
$imagepath = $path; $imagepath = $path;
} }
if ($imagepath == 'images/status_sets/default') { if ($imagepath === 'images/status_sets/default') {
$image_with_css = true; $image_with_css = true;
} }
$imagepath .= '/'.$type;
if ($image_with_css === true) { if ($image_with_css === true) {
$shape_status = get_shape_status_set($type); $shape_status = get_shape_status_set($type);
return ui_print_status_sets($type, $title, $return, $shape_status, $extra_info); return ui_print_status_sets($type, $title, $return, $shape_status, $extra_info);
} else { } else {
$imagepath .= '/'.$type;
if ($options === false) { if ($options === false) {
$options = []; $options = [];
} }
@ -2737,10 +2736,11 @@ function ui_print_status_image(
/** /**
* Returns html code to print a shape for a module. * Returns html code to print a shape for a module.
* *
* @param integer $status Module status. * @param integer $status Module status.
* @param boolean $return True or false. * @param boolean $return True or false.
* @param string $class Custom class or use defined. * @param string $class Custom class or use defined.
* @param string $title Custom title or inherit from module status. * @param string $title Custom title or inherit from module status.
* @param string $div_content Content.
* *
* @return string HTML code for shape. * @return string HTML code for shape.
*/ */
@ -2748,7 +2748,8 @@ function ui_print_module_status(
$status, $status,
$return=false, $return=false,
$class='status_rounded_rectangles', $class='status_rounded_rectangles',
$title=null $title=null,
$div_content=''
) { ) {
$color = modules_get_color_status($status, true); $color = modules_get_color_status($status, true);
if ($title === null) { if ($title === null) {
@ -2758,7 +2759,7 @@ function ui_print_module_status(
$output = '<div style="background: '.$color; $output = '<div style="background: '.$color;
$output .= '" class="'.$class; $output .= '" class="'.$class;
$output .= ' forced_title" data-title="'.$title.'" title="'; $output .= ' forced_title" data-title="'.$title.'" title="';
$output .= $title.'" data-use_title_for_force_title="1"></div>'; $output .= $title.'" data-use_title_for_force_title="1">'.$div_content.'</div>';
if ($return === false) { if ($return === false) {
echo $output; echo $output;
@ -2869,7 +2870,7 @@ function ui_print_status_sets(
$options = []; $options = [];
} }
if (isset($options['style'])) { if (isset($options['style']) === true) {
$options['style'] .= ' display: inline-block;'; $options['style'] .= ' display: inline-block;';
} else { } else {
$options['style'] = 'display: inline-block;'; $options['style'] = 'display: inline-block;';
@ -2879,15 +2880,15 @@ function ui_print_status_sets(
$options['style'] .= ' background: '.modules_get_color_status($status).';'; $options['style'] .= ' background: '.modules_get_color_status($status).';';
} }
if (isset($options['class'])) { if (isset($options['class']) === true) {
$options['class'] = $options['class']; $options['class'] = $options['class'];
} }
if ($title != '') { if (empty($title) === false) {
$options['title'] = empty($extra_info) ? $title : $title.'&#10'.$extra_info; $options['title'] = (empty($extra_info) === true) ? $title : $title.'&#10'.$extra_info;
$options['data-title'] = empty($extra_info) ? $title : $title.'<br>'.$extra_info; $options['data-title'] = (empty($extra_info) === true) ? $title : $title.'<br>'.$extra_info;
$options['data-use_title_for_force_title'] = 1; $options['data-use_title_for_force_title'] = 1;
if (isset($options['class'])) { if (isset($options['class']) === true) {
$options['class'] .= ' forced_title'; $options['class'] .= ' forced_title';
} else { } else {
$options['class'] = 'forced_title'; $options['class'] = 'forced_title';
@ -2899,15 +2900,13 @@ function ui_print_status_sets(
$output .= $k.'="'.$v.'"'; $output .= $k.'="'.$v.'"';
} }
$output .= '>'; $output .= '>&nbsp;</div>';
$output .= '</div>';
if ($return === false) { if ($return === false) {
echo $output; echo $output;
} else {
return $output;
} }
return $output;
} }
@ -3618,6 +3617,15 @@ function ui_print_datatable(array $parameters)
ui_require_javascript_file('buttons.html5.min'); ui_require_javascript_file('buttons.html5.min');
ui_require_javascript_file('buttons.print.min'); ui_require_javascript_file('buttons.print.min');
} else { } else {
// Load datatable.min.css.
$output .= '<link rel="stylesheet" href="';
$output .= ui_get_full_url(
'include/styles/js/datatables.min.css',
false,
false,
false
);
$output .= '"/>';
// Load tables.css. // Load tables.css.
$output .= '<link rel="stylesheet" href="'; $output .= '<link rel="stylesheet" href="';
$output .= ui_get_full_url( $output .= ui_get_full_url(

View File

@ -777,10 +777,13 @@ function users_get_groups_UM($id_user)
/** /**
* Obtiene una matriz con los grupos como clave y si tiene o no permiso UM sobre ese grupo(valor) * Obtiene una matriz con los grupos como clave y si tiene o no permiso UM sobre ese grupo(valor)
* *
* @param string User id * @param string $id_group User id.
* @param boolean $um Um.
* @param boolean $disabled Reurn also disabled users.
*
* @return array Return . * @return array Return .
*/ */
function users_get_users_by_group($id_group, $um=false) function users_get_users_by_group($id_group, $um=false, $disabled=true)
{ {
$sql = sprintf( $sql = sprintf(
"SELECT tusuario.* FROM tusuario "SELECT tusuario.* FROM tusuario
@ -789,6 +792,10 @@ function users_get_users_by_group($id_group, $um=false)
$id_group $id_group
); );
if ($disabled === false) {
$sql .= 'WHERE tusuario.disabled = 0';
}
$users = db_get_all_rows_sql($sql); $users = db_get_all_rows_sql($sql);
$return = []; $return = [];
foreach ($users as $key => $user) { foreach ($users as $key => $user) {

View File

@ -2017,3 +2017,11 @@ function progressBarSvg(option) {
return svg; return svg;
} }
function inArray(needle, haystack) {
var length = haystack.length;
for (var i = 0; i < length; i++) {
if (haystack[i] == needle) return true;
}
return false;
}

View File

@ -0,0 +1,169 @@
/* globals $ */
// eslint-disable-next-line no-unused-vars
function agent_manager_add_secondary_groups(
event,
id_agent,
extra_id,
id_form,
dictionary
) {
event.preventDefault();
var primary_value = $("#grupo").val();
dictionary = JSON.parse(atob(dictionary));
// The selected primary value cannot be selected like secondary.
if (
$(
"#secondary_groups" +
extra_id +
" option:selected[value=" +
primary_value +
"]"
).length > 0
) {
alert(dictionary.primary_group);
return;
}
// On agent creation PHP will update the secondary groups table (not via AJAX).
if (id_agent == 0) {
agent_manager_add_secondary_groups_ui(extra_id);
agent_manager_update_hidden_input_secondary(id_form, extra_id);
return;
}
var selected_items = new Array();
$("#secondary_groups" + extra_id + " option:selected").each(function() {
selected_items.push($(this).val());
});
var data = {
page: "godmode/agentes/agent_manager",
id_agent: id_agent,
groups: selected_items,
add_secondary_groups: 1
};
// Make the AJAX call to update the secondary groups.
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "html",
data: data,
success: function(data) {
if (data == 1) {
agent_manager_add_secondary_groups_ui(extra_id);
} else {
console.error("Error in AJAX call to add secondary groups");
}
},
error: function(data) {
console.error(
"Fatal error in AJAX call to add secondary groups: " + data
);
}
});
}
// eslint-disable-next-line no-unused-vars
function agent_manager_remove_secondary_groups(
event,
id_agent,
extra_id,
id_form,
dictionary
) {
event.preventDefault();
dictionary = JSON.parse(atob(dictionary));
// On agent creation PHP will update the secondary groups table (not via AJAX).
if (id_agent == 0) {
agent_manager_remove_secondary_groups_ui(dictionary.strNone, extra_id);
agent_manager_update_hidden_input_secondary(id_form, extra_id);
return;
}
var selected_items = new Array();
$("#secondary_groups_selected" + extra_id + " option:selected").each(
function() {
selected_items.push($(this).val());
}
);
var data = {
page: "godmode/agentes/agent_manager",
id_agent: id_agent,
groups: selected_items,
remove_secondary_groups: 1
};
// Make the AJAX call to update the secondary groups.
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "html",
data: data,
success: function(data) {
if (data == 1) {
agent_manager_remove_secondary_groups_ui(dictionary.strNone, extra_id);
} else {
console.error("Error in AJAX call to add secondary groups");
}
},
error: function(data) {
console.error(
"Fatal error in AJAX call to add secondary groups: " + data
);
}
});
}
// Move from left input to right input.
function agent_manager_add_secondary_groups_ui(extra_id) {
$("#secondary_groups_selected" + extra_id + " option[value=0]").remove();
$("#secondary_groups" + extra_id + " option:selected").each(function() {
$(this)
.remove()
.appendTo("#secondary_groups_selected" + extra_id);
});
}
// Move from right input to left input.
function agent_manager_remove_secondary_groups_ui(strNone, extra_id) {
// Remove the groups selected if success.
$("#secondary_groups_selected" + extra_id + " option:selected").each(
function() {
$(this)
.remove()
.appendTo("#secondary_groups" + extra_id);
}
);
// Add none if empty select.
if ($("#secondary_groups_selected" + extra_id + " option").length == 0) {
$("#secondary_groups_selected" + extra_id).append(
$("<option>", {
value: 0,
text: strNone
})
);
}
}
function agent_manager_update_hidden_input_secondary(id_form, extra_id) {
var groups = [];
if (!$("#" + id_form + " #secondary_hidden" + extra_id).length) {
$("#" + id_form).append(
'<input name="secondary_hidden' +
extra_id +
'" type="hidden" id="secondary_hidden' +
extra_id +
'">'
);
}
$("#secondary_groups_selected" + extra_id + " option").each(function() {
groups.push($(this).val());
});
$("#secondary_hidden" + extra_id).val(groups.join(","));
}

View File

@ -59,7 +59,26 @@ function show_event_dialog(event, dialog_page, result) {
background: "black" background: "black"
}, },
width: 710, width: 710,
height: 600 height: 600,
autoOpen: true,
open: function() {
if (
$.ui &&
$.ui.dialog &&
$.ui.dialog.prototype._allowInteraction
) {
var ui_dialog_interaction =
$.ui.dialog.prototype._allowInteraction;
$.ui.dialog.prototype._allowInteraction = function(e) {
if ($(e.target).closest(".select2-dropdown").length)
return true;
return ui_dialog_interaction.apply(this, arguments);
};
}
},
_allowInteraction: function(event) {
return !!$(event.target).is(".select2-input") || this._super(event);
}
}) })
.show(); .show();
$.post({ $.post({

View File

@ -0,0 +1,32 @@
/* globals $, uniqId, confirmDialog*/
// eslint-disable-next-line no-unused-vars
function dialogAgentModulesAffected(settings) {
confirmDialog({
title: settings.title,
size: 500,
message: function() {
var id = "div-" + uniqId();
var loading = settings.loadingText;
$.ajax({
method: "post",
url: settings.url,
data: {
page: "godmode/agentes/planned_downtime.list",
show_info_agents_modules_affected: 1,
id: settings.id
},
dataType: "html",
success: function(data) {
$("#" + id)
.empty()
.append(data);
},
error: function(error) {
console.error(error);
}
});
return "<div id ='" + id + "'>" + loading + "</div>";
}
});
}

View File

@ -577,28 +577,34 @@ function confirmDialog(settings) {
*/ */
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
function generalShowMsg(data, idMsg) { function generalShowMsg(data, idMsg) {
var title = "Response"; var title = data.title[data.error];
var text = data; var text = data.text[data.error];
var failed = false; var failed = !data.error;
if (typeof data == "object") { if (typeof data.error != "number") {
title = data.title || "Response"; title = "Response";
text = data.text || data.error || data.result; text = data;
failed = failed || data.error; failed = false;
}
if (failed) { if (typeof data == "object") {
title = "Error"; title = data.title || "Response";
text = data.error; text = data.text || data.error || data.result;
} failed = data.failed || data.error;
}
if (idMsg == null) { if (failed) {
idMsg = uniqId(); title = "Error";
} text = data.error;
}
if ($("#" + idMsg).length === 0) { if (idMsg == null) {
$("body").append('<div title="' + title + '" id="' + idMsg + '"></div>'); idMsg = uniqId();
$("#" + idMsg).empty(); }
if ($("#" + idMsg).length === 0) {
$("body").append('<div title="' + title + '" id="' + idMsg + '"></div>');
$("#" + idMsg).empty();
}
} }
$("#" + idMsg).empty(); $("#" + idMsg).empty();

View File

@ -389,7 +389,7 @@ ul li {
.button_collapse { .button_collapse {
margin-top: auto; margin-top: auto;
height: 38px; min-height: 38px;
background-color: #505050; background-color: #505050;
text-align: center; text-align: center;
color: #fff; color: #fff;
@ -427,7 +427,6 @@ ul li {
} }
.button_classic { .button_classic {
width: 215px;
background-image: url(../../images/button_collapse_menu.png); background-image: url(../../images/button_collapse_menu.png);
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
@ -440,7 +439,7 @@ ul li {
} }
/* Menu height: 601px, 720px, 735px */ /* Menu height: 601px, 720px, 735px */
@media screen and (max-height: 720px) { @media screen and (max-height: 750px) {
.menu li, .menu li,
.menu li a, .menu li a,
.menu li div { .menu li div {
@ -448,7 +447,7 @@ ul li {
} }
} }
@media screen and (max-height: 735px) { @media screen and (max-height: 750px) {
.operation { .operation {
padding-top: 10px; padding-top: 10px;
} }

View File

@ -5092,6 +5092,17 @@ input:checked + .p-slider:before {
margin-top: 10px; margin-top: 10px;
} }
#upload_file #upload_file_input_full {
width: 100%;
border: 1px solid #cbcbcb;
border-radius: 2px;
padding: 5px 0;
}
#upload_file_input_full input#file-file::-webkit-file-upload-button {
margin-left: 5px;
}
.file_table_modal_active { .file_table_modal_active {
background-color: #fff; background-color: #fff;
border: 1px solid #e6e6e6; border: 1px solid #e6e6e6;
@ -6038,7 +6049,6 @@ form#modal_form_feedback input[type="email"] {
border: none; border: none;
border-radius: 0; border-radius: 0;
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
font-weight: lighter;
padding: 0px 0px 2px 0px; padding: 0px 0px 2px 0px;
box-sizing: border-box; box-sizing: border-box;
margin-bottom: 4px; margin-bottom: 4px;
@ -7679,6 +7689,11 @@ div.graph div.legend table {
float: left; float: left;
} }
#table3-secondary_groups_added .select2-container,
#table3-secondary_groups_removed .select2-container {
width: 100% !important;
}
.ux_console_module { .ux_console_module {
float: left; float: left;
width: 98%; width: 98%;

View File

@ -129,7 +129,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.760'; $version = '7.0NG.760';
$build = '220222'; $build = '220316';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -1348,6 +1348,12 @@ span.nobold * {
border-radius: 50%; border-radius: 50%;
} }
.status_small_rectangles {
width: 20px;
height: 10px;
display: inline-block;
}
.ui-content .ui-listview, .ui-content .ui-listview,
.ui-panel-inner > .ui-listview { .ui-panel-inner > .ui-listview {
margin: 0 !important; margin: 0 !important;

View File

@ -790,12 +790,11 @@ class Ui
echo ' <title>'.$this->title."</title>\n"; echo ' <title>'.$this->title."</title>\n";
echo " <meta charset='UTF-8' />\n"; echo " <meta charset='UTF-8' />\n";
echo " <meta name='viewport' content='width=device-width, initial-scale=1'>\n"; echo " <meta name='viewport' content='width=device-width, initial-scale=1'>\n";
echo ' <link rel="icon" href="'.ui_get_full_url('/').ui_get_favicon().'" type="image/ico" />'."\n";
echo ' <link rel="shortcut icon" href="'.ui_get_full_url('/').ui_get_favicon().'" type="image/x-icon" />'."\n";
echo " <link rel='stylesheet' href='include/style/main.css' />\n"; echo " <link rel='stylesheet' href='include/style/main.css' />\n";
// echo " <link rel='stylesheet' href='include/style/jquery.mobile-1.4.5.css' />\n";
echo " <link rel='stylesheet' href='include/style/jquery.mobile-1.5.0-rc1.min.css' />\n"; echo " <link rel='stylesheet' href='include/style/jquery.mobile-1.5.0-rc1.min.css' />\n";
// echo " <script src='include/javascript/jquery.js.bakc'></script>\n";
echo " <script src='include/javascript/jquery.js'></script>\n"; echo " <script src='include/javascript/jquery.js'></script>\n";
// echo " <script src='include/javascript/jquery.mobile-1.4.5.js'></script>\n";
echo " <script src='include/javascript/jquery.mobile-1.5.0-rc1.js'></script>\n"; echo " <script src='include/javascript/jquery.mobile-1.5.0-rc1.js'></script>\n";
echo " <script src='../include/javascript/pandora.js'></script>\n"; echo " <script src='../include/javascript/pandora.js'></script>\n";
echo " <script src='../include/javascript/pandora_ui.js'></script>\n"; echo " <script src='../include/javascript/pandora_ui.js'></script>\n";

View File

@ -1,15 +1,33 @@
<?php <?php
// Pandora FMS - http://pandorafms.com // phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
// ================================================== /**
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Agent view for mobile
// Please see http://pandorafms.org for full contribution list *
// This program is free software; you can redistribute it and/or * @category Mobile
// modify it under the terms of the GNU General Public License * @package Pandora FMS
// as published by the Free Software Foundation for version 2. * @subpackage Community
// This program is distributed in the hope that it will be useful, * @version 1.0.0
// but WITHOUT ANY WARRANTY; without even the implied warranty of * @license See below
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
// GNU General Public License for more details. * ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* 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.
require_once '../include/functions_users.php'; require_once '../include/functions_users.php';
class Agent class Agent
@ -41,7 +59,7 @@ class Agent
var isgentoo = /Gentoo/i.test(navigator.userAgent); var isgentoo = /Gentoo/i.test(navigator.userAgent);
var iscentos = /CentOS/i.test(navigator.userAgent); var iscentos = /CentOS/i.test(navigator.userAgent);
var issuse = /SUSE/i.test(navigator.userAgent); var issuse = /SUSE/i.test(navigator.userAgent);
if(!(ismobile) && !(iswindows) && !(ismac) && !(isubuntu) && !(isfedora) && !(isredhat) && !(isdebian) && !(isgentoo) && !(iscentos) if(!(ismobile) && !(iswindows) && !(ismac) && !(isubuntu) && !(isfedora) && !(isredhat) && !(isdebian) && !(isgentoo) && !(iscentos)
&& !(issuse)){ && !(issuse)){
window.location.href = '".$config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$this->id."'; window.location.href = '".$config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$this->id."';
@ -256,10 +274,9 @@ class Agent
SECONDS_1DAY, SECONDS_1DAY,
'', '',
true, true,
false,
true, true,
1, 500,
'' 1
); );
$html .= '</div>'; $html .= '</div>';
$html .= '</div>'; $html .= '</div>';

View File

@ -1,15 +1,33 @@
<?php <?php
// Pandora FMS - http://pandorafms.com // phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
// ================================================== /**
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Agents list view for mobile
// Please see http://pandorafms.org for full contribution list *
// This program is free software; you can redistribute it and/or * @category Mobile
// modify it under the terms of the GNU General Public License * @package Pandora FMS
// as published by the Free Software Foundation for version 2. * @subpackage Community
// This program is distributed in the hope that it will be useful, * @version 1.0.0
// but WITHOUT ANY WARRANTY; without even the implied warranty of * @license See below
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
// GNU General Public License for more details. * ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* 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.
class Agents class Agents
{ {
@ -67,7 +85,7 @@ class Agents
$listAgents = $this->getListAgents($page, true); $listAgents = $this->getListAgents($page, true);
if (!empty($listAgents['agents'])) { if (empty($listAgents['agents']) === false) {
$end = 0; $end = 0;
$agents = []; $agents = [];
@ -96,7 +114,7 @@ class Agents
$system = System::getInstance(); $system = System::getInstance();
$user = User::getInstance(); $user = User::getInstance();
// Default // Default.
$filters = [ $filters = [
'free_search' => '', 'free_search' => '',
'status' => -1, 'status' => -1,
@ -104,7 +122,7 @@ class Agents
]; ];
$serialized_filters = (string) $system->getRequest('agents_filter'); $serialized_filters = (string) $system->getRequest('agents_filter');
if (!empty($serialized_filters)) { if (empty($serialized_filters) === true) {
$filters_unsafe = json_decode(base64_decode($serialized_filters, true), true); $filters_unsafe = json_decode(base64_decode($serialized_filters, true), true);
if ($filters_unsafe) { if ($filters_unsafe) {
$filters = $system->safeInput($filters_unsafe); $filters = $system->safeInput($filters_unsafe);
@ -144,8 +162,8 @@ class Agents
$filters['group'] = $this->group; $filters['group'] = $this->group;
} }
if (!empty($filters)) { if (empty($filters) === false) {
// Store the filter // Store the filter.
$this->serializedFilters = base64_encode(json_encode($system->safeOutput($filters))); $this->serializedFilters = base64_encode(json_encode($system->safeOutput($filters)));
} }
} }
@ -260,7 +278,7 @@ class Agents
$search_sql = ''; $search_sql = '';
if (!empty($this->free_search)) { if (empty($this->free_search) === false) {
$search_sql = " AND ( $search_sql = " AND (
alias LIKE '%".$this->free_search."%' alias LIKE '%".$this->free_search."%'
OR nombre LIKE '%".$this->free_search."%' OR nombre LIKE '%".$this->free_search."%'
@ -461,15 +479,13 @@ class Agents
"<script type=\"text/javascript\"> "<script type=\"text/javascript\">
var load_more_rows = 1; var load_more_rows = 1;
var page = 1; var page = 1;
function custom_scroll() { function custom_scroll() {
if (load_more_rows) { if (load_more_rows) {
if ($(this).scrollTop() + $(this).height() if ($(this).scrollTop() + $(this).height()
>= ($(document).height() - 100)) { >= ($(document).height() - 100)) {
load_more_rows = 0; load_more_rows = 0;
postvars = {}; postvars = {};
postvars[\"action\"] = \"ajax\"; postvars[\"action\"] = \"ajax\";
postvars[\"parameter1\"] = \"agents\"; postvars[\"parameter1\"] = \"agents\";
@ -479,7 +495,7 @@ class Agents
postvars[\"free_search\"] = $(\"input[name='free_search']\").val(); postvars[\"free_search\"] = $(\"input[name='free_search']\").val();
postvars[\"page\"] = page; postvars[\"page\"] = page;
page++; page++;
$.post(\"index.php\", $.post(\"index.php\",
postvars, postvars,
function (data) { function (data) {
@ -499,23 +515,26 @@ class Agents
\"<td class='cell_6'>\" + agent[8] + \"</td>\" + \"<td class='cell_6'>\" + agent[8] + \"</td>\" +
\"</tr>\"); \"</tr>\");
}); });
load_more_rows = 1; load_more_rows = 1;
refresh_link_listener_list_agents(); refresh_link_listener_list_agents();
} }
}, },
\"json\"); \"json\");
// Clean
$('#loading_rows').remove();
} }
} }
} }
$(document).ready(function() { $(document).ready(function() {
// Be sure of fill all of screen first.
custom_scroll();
$(window).bind(\"scroll\", function () { $(window).bind(\"scroll\", function () {
custom_scroll(); custom_scroll();
}); });
$(window).on(\"touchmove\", function(event) { $(window).on(\"touchmove\", function(event) {
custom_scroll(); custom_scroll();
}); });

View File

@ -1,15 +1,33 @@
<?php <?php
// Pandora FMS - http://pandorafms.com // phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
// ================================================== /**
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Alerts list view for mobile
// Please see http://pandorafms.org for full contribution list *
// This program is free software; you can redistribute it and/or * @category Mobile
// modify it under the terms of the GNU General Public License * @package Pandora FMS
// as published by the Free Software Foundation for version 2. * @subpackage Community
// This program is distributed in the hope that it will be useful, * @version 1.0.0
// but WITHOUT ANY WARRANTY; without even the implied warranty of * @license See below
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
// GNU General Public License for more details. * ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* 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.
class Alerts class Alerts
{ {

View File

@ -1,15 +1,33 @@
<?php <?php
// Pandora FMS - http://pandorafms.com // phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
// ================================================== /**
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Modules list view for mobile
// Please see http://pandorafms.org for full contribution list *
// This program is free software; you can redistribute it and/or * @category Mobile
// modify it under the terms of the GNU General Public License * @package Pandora FMS
// as published by the Free Software Foundation for version 2. * @subpackage Community
// This program is distributed in the hope that it will be useful, * @version 1.0.0
// but WITHOUT ANY WARRANTY; without even the implied warranty of * @license See below
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
// GNU General Public License for more details. * ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* 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.
class Modules class Modules
{ {
@ -106,7 +124,7 @@ class Modules
} }
if (isset($filters['status'])) { if (isset($filters['status'])) {
$this->status = $filters['status']; $this->status = (int) $filters['status'];
} }
if (isset($filters['name'])) { if (isset($filters['name'])) {
@ -143,7 +161,7 @@ class Modules
} }
$this->status = $system->getRequest('status', __('Status')); $this->status = $system->getRequest('status', __('Status'));
if (($this->status === __('Status')) || ($this->status == AGENT_MODULE_STATUS_ALL)) { if (($this->status === __('Status')) || ((int) $this->status === AGENT_MODULE_STATUS_ALL)) {
$this->status = AGENT_MODULE_STATUS_ALL; $this->status = AGENT_MODULE_STATUS_ALL;
} else { } else {
$this->default = false; $this->default = false;
@ -390,35 +408,28 @@ class Modules
} }
// Part SQL fro Status // Part SQL fro Status
if ($this->status == AGENT_MODULE_STATUS_NORMAL) { if ((int) $this->status == AGENT_MODULE_STATUS_NORMAL) {
// Normal // Normal.
$sql_conditions .= ' AND tagente_estado.estado = 0 $sql_conditions .= ' AND tagente_estado.estado = 0
AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100))) '; AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100))) ';
} else if ($this->status == AGENT_MODULE_STATUS_CRITICAL_BAD) { } else if ((int) $this->status === AGENT_MODULE_STATUS_CRITICAL_BAD) {
// Critical // Critical.
$sql_conditions .= ' AND tagente_estado.estado = 1 AND utimestamp > 0'; $sql_conditions .= ' AND tagente_estado.estado = 1 AND utimestamp > 0';
} else if ($this->status == AGENT_MODULE_STATUS_WARNING) { } else if ((int) $this->status === AGENT_MODULE_STATUS_WARNING) {
// Warning // Warning.
$sql_conditions .= ' AND tagente_estado.estado = 2 AND utimestamp > 0'; $sql_conditions .= ' AND tagente_estado.estado = 2 AND utimestamp > 0';
} else if ($this->status == AGENT_MODULE_STATUS_NOT_NORMAL) { } else if ((int) $this->status === AGENT_MODULE_STATUS_NOT_NORMAL) {
// Not normal // Not normal.
$sql_conditions .= ' AND tagente_estado.estado <> 0'; $sql_conditions .= ' AND tagente_estado.estado <> 0';
} else if ($this->status == AGENT_MODULE_STATUS_UNKNOWN) { } else if ((int) $this->status === AGENT_MODULE_STATUS_UNKNOWN) {
// Unknown // Unknown.
$sql_conditions .= ' AND tagente_estado.estado = 3 AND tagente_estado.utimestamp <> 0'; $sql_conditions .= ' AND tagente_estado.estado = 3 AND tagente_estado.utimestamp <> 0';
} else if ($this->status == AGENT_MODULE_STATUS_NOT_INIT) { } else if ((int) $this->status === AGENT_MODULE_STATUS_NOT_INIT) {
// Not init // Not init.
$sql_conditions .= ' AND tagente_estado.utimestamp = 0 $sql_conditions .= ' AND tagente_estado.utimestamp = 0
AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)'; AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)';
} }
if ($this->status != AGENT_MODULE_STATUS_NOT_INIT) {
// When filter is not "not init"
// Not show not init modules. It's only operation view
$sql_conditions .= ' AND (tagente_estado.utimestamp != 0
OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))';
}
if ($this->tag > 0) { if ($this->tag > 0) {
$sql_conditions .= ' AND tagente_modulo.id_agente_modulo IN ( $sql_conditions .= ' AND tagente_modulo.id_agente_modulo IN (
SELECT ttag_module.id_agente_modulo SELECT ttag_module.id_agente_modulo
@ -435,7 +446,7 @@ class Modules
SELECT ttag_module.id_tag SELECT ttag_module.id_tag
FROM ttag_module FROM ttag_module
WHERE ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo)) WHERE ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo))
AS tags, AS tags,
tagente_modulo.id_agente_modulo, tagente_modulo.id_agente_modulo,
tagente.intervalo AS agent_interval, tagente.intervalo AS agent_interval,
tagente.nombre AS agent_name, tagente.nombre AS agent_name,
@ -476,6 +487,7 @@ class Modules
ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo'.$sql_conditions_all; ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo'.$sql_conditions_all;
$sql_limit = 'ORDER BY tagente.nombre ASC '; $sql_limit = 'ORDER BY tagente.nombre ASC ';
if (!$this->all_modules) { if (!$this->all_modules) {
$sql_limit = ' LIMIT '.(int) ($page * $system->getPageSize()).','.(int) $system->getPageSize(); $sql_limit = ' LIMIT '.(int) ($page * $system->getPageSize()).','.(int) $system->getPageSize();
} }

View File

@ -365,7 +365,7 @@ $data[1] = ui_progress(
($agent['intervalo'] - (strtotime('now') - strtotime($agent['ultimo_contacto']))).' s', ($agent['intervalo'] - (strtotime('now') - strtotime($agent['ultimo_contacto']))).' s',
[ [
'page' => 'operation/agentes/ver_agente', 'page' => 'operation/agentes/ver_agente',
'interval' => (100 / $agent['intervalo']), 'interval' => (empty($agent['intervalo']) === true) ? 0 : (100 / $agent['intervalo']),
'data' => [ 'data' => [
'id_agente' => $id_agente, 'id_agente' => $id_agente,
'refresh_contact' => 1, 'refresh_contact' => 1,

View File

@ -176,6 +176,7 @@ function load_agents_selector(group) {
{ {
"page" : "operation/agentes/ver_agente", "page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1, "get_agents_group_json" : 1,
"get_agents_also_interfaces" : 1,
"id_group" : group, "id_group" : group,
"privilege" : "AW", "privilege" : "AW",
"keys_prefix" : "_", "keys_prefix" : "_",
@ -216,6 +217,7 @@ $("#checkbox-recursion").change (function () {
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente", {"page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1, "get_agents_group_json" : 1,
"get_agents_also_interfaces" : 1,
"id_group" : $("#group_id").val(), "id_group" : $("#group_id").val(),
"privilege" : "AW", "privilege" : "AW",
"keys_prefix" : "_", "keys_prefix" : "_",
@ -226,7 +228,6 @@ $("#checkbox-recursion").change (function () {
$("#module").html(''); $("#module").html('');
jQuery.each (data, function (id, value) { jQuery.each (data, function (id, value) {
id = id.substring(1); id = id.substring(1);
option = $("<option></option>") option = $("<option></option>")
.attr ("value", value["id_agente"]) .attr ("value", value["id_agente"])
.html (value["alias"]); .html (value["alias"]);

View File

@ -49,6 +49,7 @@ if (is_ajax()) {
$get_agent_modules_json = (bool) get_parameter('get_agent_modules_json'); $get_agent_modules_json = (bool) get_parameter('get_agent_modules_json');
$get_agent_status_tooltip = (bool) get_parameter('get_agent_status_tooltip'); $get_agent_status_tooltip = (bool) get_parameter('get_agent_status_tooltip');
$get_agents_group_json = (bool) get_parameter('get_agents_group_json'); $get_agents_group_json = (bool) get_parameter('get_agents_group_json');
$get_agents_also_interfaces = (bool) get_parameter('get_agents_also_interfaces');
$get_modules_group_json = (bool) get_parameter('get_modules_group_json'); $get_modules_group_json = (bool) get_parameter('get_modules_group_json');
$filter_modules_group_json = (bool) get_parameter('filter_modules_group_json'); $filter_modules_group_json = (bool) get_parameter('filter_modules_group_json');
$get_modules_group_value_name_json = (bool) get_parameter('get_modules_group_value_name_json'); $get_modules_group_value_name_json = (bool) get_parameter('get_modules_group_value_name_json');
@ -103,15 +104,15 @@ if (is_ajax()) {
// Build filter. // Build filter.
$filter = []; $filter = [];
if (!empty($id_os)) { if (empty($id_os) === false) {
$filter['id_os'] = $id_os; $filter['id_os'] = $id_os;
} }
if (!empty($agent_name)) { if (empty($agent_name) === false) {
$filter['nombre'] = '%'.$agent_name.'%'; $filter['nombre'] = '%'.$agent_name.'%';
} }
if (!empty($agent_alias)) { if (empty($agent_alias) === false) {
$filter['alias'] = '%'.$agent_alias.'%'; $filter['alias'] = '%'.$agent_alias.'%';
} }
@ -147,6 +148,20 @@ if (is_ajax()) {
} }
} }
if ($get_agents_also_interfaces === true) {
$listAgentsWithIface = db_get_all_rows_sql("SELECT DISTINCT id_agente FROM tagente_modulo WHERE nombre LIKE '%_ifOperStatus'");
if (empty($listAgentsWithIface) === false) {
$filter['matchIds'] = array_reduce(
$listAgentsWithIface,
function ($carry, $item) {
$carry[] = $item['id_agente'];
return $carry;
},
[]
);
}
}
// Perform search. // Perform search.
$agents = agents_get_group_agents( $agents = agents_get_group_agents(
// Id_group. // Id_group.
@ -171,7 +186,7 @@ if (is_ajax()) {
(bool) is_metaconsole() (bool) is_metaconsole()
); );
if (empty($agents)) { if (empty($agents) === true) {
$agents = []; $agents = [];
} }

View File

@ -108,5 +108,6 @@ filemanager_file_explorer(
'', '',
false, false,
'', '',
false false,
['all' => true]
); );

View File

@ -45,6 +45,8 @@ $group_id = (int) get_parameter('group_id');
$tag_id = (int) get_parameter('tag_id'); $tag_id = (int) get_parameter('tag_id');
$strict_acl = (bool) db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); $strict_acl = (bool) db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$serach_hirearchy = (bool) get_parameter('searchHirearchy', false); $serach_hirearchy = (bool) get_parameter('searchHirearchy', false);
$show_disabled = get_parameter('show_disabled', false);
// ---------------------Tabs ------------------------------------------- // ---------------------Tabs -------------------------------------------
$enterpriseEnable = false; $enterpriseEnable = false;
if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT_HOOK) { if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT_HOOK) {
@ -249,6 +251,10 @@ $row[] = html_print_input_hidden('show_not_init_modules_hidden', $show_not_init_
if (is_metaconsole() === true) { if (is_metaconsole() === true) {
$table->data[] = $row; $table->data[] = $row;
$row = []; $row = [];
$row[] = __('Show only disabled');
$row[] = html_print_checkbox('show_disabled', $show_disabled, false, true);
$table->data[] = $row;
$row = [];
} }
$row[] = html_print_submit_button(__('Filter'), 'uptbutton', false, 'class="sub search"', true); $row[] = html_print_submit_button(__('Filter'), 'uptbutton', false, 'class="sub search"', true);
@ -323,7 +329,7 @@ html_print_image(
echo "<div id='tree-controller-recipient'>"; echo "<div id='tree-controller-recipient'>";
echo '</div>'; echo '</div>';
if (is_metaconsole()) { if (is_metaconsole() === true) {
echo '</div>'; echo '</div>';
} }
@ -331,7 +337,7 @@ enterprise_hook('close_meta_frame');
?> ?>
<?php if (!is_metaconsole()) { ?> <?php if (is_metaconsole() === false) { ?>
<script type="text/javascript" src="include/javascript/fixed-bottom-box.js"></script> <script type="text/javascript" src="include/javascript/fixed-bottom-box.js"></script>
<?php } else { ?> <?php } else { ?>
<script type="text/javascript" src="../../include/javascript/fixed-bottom-box.js"></script> <script type="text/javascript" src="../../include/javascript/fixed-bottom-box.js"></script>
@ -341,12 +347,12 @@ enterprise_hook('close_meta_frame');
var treeController = TreeController.getController(); var treeController = TreeController.getController();
processTreeSearch(); processTreeSearch();
$("form#tree_search").submit(function(e) { $("form#tree_search").submit(function(e) {
e.preventDefault(); e.preventDefault();
processTreeSearch(); processTreeSearch();
}); });
function processTreeSearch () { function processTreeSearch () {
// Clear the tree // Clear the tree
if (typeof treeController.recipient != 'undefined' && treeController.recipient.length > 0) if (typeof treeController.recipient != 'undefined' && treeController.recipient.length > 0)
@ -390,6 +396,13 @@ enterprise_hook('close_meta_frame');
$('#hidden-show_not_init_modules_hidden').val(0); $('#hidden-show_not_init_modules_hidden').val(0);
} }
if($("#checkbox-show_disabled").is(':checked')){
parameters['filter']['show_disabled'] = 1;
}
else{
parameters['filter']['show_disabled'] = 0;
}
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>", url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",

View File

@ -557,13 +557,13 @@ $table_ichanges = '<div class="autorefresh_select">
</div> </div>
<div class="autorefresh_select_arrows" style="display:grid"> <div class="autorefresh_select_arrows" style="display:grid">
<a href="javascript:">'.html_print_image( <a href="javascript:">'.html_print_image(
'images/darrowright_green.png', 'images/darrowright_green.png',
true, true,
[ [
'id' => 'right_autorefreshlist', 'id' => 'right_autorefreshlist',
'alt' => __('Push selected pages into autorefresh list'), 'alt' => __('Push selected pages into autorefresh list'),
'title' => __('Push selected pages into autorefresh list'), 'title' => __('Push selected pages into autorefresh list'),
] ]
).'</a> ).'</a>
<a href="javascript:">'.html_print_image( <a href="javascript:">'.html_print_image(
'images/darrowleft_green.png', 'images/darrowleft_green.png',

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.760 %define version 7.0NG.760
%define release 220222 %define release 220316
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.760 %define version 7.0NG.760
%define release 220222 %define release 220316
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.760 %define version 7.0NG.760
%define release 220222 %define release 220316
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -605,10 +605,7 @@ CREATE TABLE IF NOT EXISTS `talert_special_days` (
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_execution_queue` ( CREATE TABLE IF NOT EXISTS `talert_execution_queue` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_alert_template_module` INT UNSIGNED NOT NULL, `data` LONGTEXT,
`alert_mode` TINYINT NOT NULL,
`data` MEDIUMTEXT,
`extra_macros` TEXT,
`utimestamp` BIGINT NOT NULL DEFAULT 0, `utimestamp` BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
@ -2583,6 +2580,21 @@ CREATE TABLE IF NOT EXISTS `tpolicy_groups` (
UNIQUE (`id_policy`, `id_group`) UNIQUE (`id_policy`, `id_group`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
-- -----------------------------------------------------
-- Table `tpolicy_group_agents`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tpolicy_group_agents` (
`id` SERIAL,
`id_policy` INT UNSIGNED,
`id_agent` INT UNSIGNED,
`direct` TINYINT UNSIGNED DEFAULT 0,
FOREIGN KEY (`id_policy`) REFERENCES `tpolicies`(`id`)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tdashboard` -- Table `tdashboard`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
@ -4215,3 +4227,17 @@ CREATE TABLE IF NOT EXISTS `tncm_firmware` (
`path` TEXT, `path` TEXT,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
-- ----------------------------------------------------------------------
-- Table `tbackup`
-- ----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tbackup` (
`id` SERIAL,
`utimestamp` BIGINT DEFAULT 0,
`filename` VARCHAR(512) DEFAULT '',
`id_user` VARCHAR(60) DEFAULT '',
`description` MEDIUMTEXT,
`pid` INT UNSIGNED DEFAULT 0,
`filepath` VARCHAR(512) DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;

View File

@ -985,14 +985,6 @@ INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `t
INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (783,'Check&#x20;Informix&#x20;Port','',19,9,0,0,300,1526,'','','public','',2,2,0,'','','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (783,'Check&#x20;Informix&#x20;Port','',19,9,0,0,300,1526,'','','public','',2,2,0,'','','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','','');
INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (784,'Check&#x20;port&#x20;DB2','',49,9,0,0,300,50000,'','','public','',2,2,0,'','','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (784,'Check&#x20;port&#x20;DB2','',49,9,0,0,300,50000,'','','public','',2,2,0,'','','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','','');
INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `max_retries`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `unit`, `wizard_level`, `macros`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `critical_inverse`, `warning_inverse`, `id_category`, `tags`, `disabled_types_event`, `module_macros`, `min_ff_event_normal`, `min_ff_event_warning`, `min_ff_event_critical`, `each_ff`) VALUES (785,'Packet&#x20;Loss','Measure&#x20;packet&#x20;loss&#x20;in&#x20;the&#x20;network,&#x20;using&#x20;a&#x20;flood&#x20;ping&#x20;&#40;50&#x20;ping&#x20;in&#x20;8&#x20;secons&#41;&#x20;and&#x20;counting&#x20;back&#x20;missing&#x20;packets.&#x20;It&#x20;should&#x20;be&#x20;zero&#x20;on&#x20;most&#x20;cases.&#x20;',10,1,0,0,300,0,'','','','',2,4,9,'','','',0,0,1,10.00,0.00,'',30.00,0.00,'',0,'','','',0,0,0.00000,'%','nowizard','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Test&#x20;time\",\"help\":\"\",\"value\":\"8\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Target&#x20;IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','You&#x20;should&#x20;check&#x20;manually&#x20;the&#x20;packet&#x20;loss&#x20;of&#x20;the&#x20;network&#x20;with&#x20;a&#x20;flood&#x20;ping&#x20;on&#x20;targeted&#x20;host&#x20;&#40;ping&#x20;-c&#x20;100&#x20;-f&#x20;xxxx&#41;.&#x20;Aditionally,&#x20;and&#x20;due&#x20;the&#x20;major&#x20;packet&#x20;loss,&#x20;probably&#x20;you&#x20;can&#x20;see&#x20;a&#x20;simple&#x20;ping&#x20;failing&#x20;here.&#x20;Check&#x20;your&#x20;network&#x20;equipment.','You&#x20;should&#x20;check&#x20;manually&#x20;the&#x20;packet&#x20;loss&#x20;of&#x20;the&#x20;network&#x20;with&#x20;a&#x20;flood&#x20;ping&#x20;on&#x20;targeted&#x20;host&#x20;&#40;ping&#x20;-c&#x20;100&#x20;-f&#x20;xxxx&#41;','',0,0,0,'','{\"going_unknown\":0}','',0,0,0,0); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `max_retries`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `unit`, `wizard_level`, `macros`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `critical_inverse`, `warning_inverse`, `id_category`, `tags`, `disabled_types_event`, `module_macros`, `min_ff_event_normal`, `min_ff_event_warning`, `min_ff_event_critical`, `each_ff`) VALUES (785,'Packet&#x20;Loss','Measure&#x20;packet&#x20;loss&#x20;in&#x20;the&#x20;network,&#x20;using&#x20;a&#x20;flood&#x20;ping&#x20;&#40;50&#x20;ping&#x20;in&#x20;8&#x20;secons&#41;&#x20;and&#x20;counting&#x20;back&#x20;missing&#x20;packets.&#x20;It&#x20;should&#x20;be&#x20;zero&#x20;on&#x20;most&#x20;cases.&#x20;',10,1,0,0,300,0,'','','','',2,4,9,'','','',0,0,1,10.00,0.00,'',30.00,0.00,'',0,'','','',0,0,0.00000,'%','nowizard','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Test&#x20;time\",\"help\":\"\",\"value\":\"8\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Target&#x20;IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','You&#x20;should&#x20;check&#x20;manually&#x20;the&#x20;packet&#x20;loss&#x20;of&#x20;the&#x20;network&#x20;with&#x20;a&#x20;flood&#x20;ping&#x20;on&#x20;targeted&#x20;host&#x20;&#40;ping&#x20;-c&#x20;100&#x20;-f&#x20;xxxx&#41;.&#x20;Aditionally,&#x20;and&#x20;due&#x20;the&#x20;major&#x20;packet&#x20;loss,&#x20;probably&#x20;you&#x20;can&#x20;see&#x20;a&#x20;simple&#x20;ping&#x20;failing&#x20;here.&#x20;Check&#x20;your&#x20;network&#x20;equipment.','You&#x20;should&#x20;check&#x20;manually&#x20;the&#x20;packet&#x20;loss&#x20;of&#x20;the&#x20;network&#x20;with&#x20;a&#x20;flood&#x20;ping&#x20;on&#x20;targeted&#x20;host&#x20;&#40;ping&#x20;-c&#x20;100&#x20;-f&#x20;xxxx&#41;','',0,0,0,'','{\"going_unknown\":0}','',0,0,0,0);
INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `max_retries`, `history_data`, `min_warning`, `max_warning`, `max_critical`, `str_warning`, `min_ff_event`, `min_critical`, `custom_string_2`, `str_critical`, `custom_integer_1`, `custom_string_1`, `post_process`, `custom_string_3`, `wizard_level`, `custom_integer_2`, `critical_instructions`, `unit`, `unknown_instructions`, `macros`, `warning_inverse`, `warning_instructions`, `tags`, `critical_inverse`, `module_macros`, `id_category`, `min_ff_event_warning`, `disabled_types_event`, `ff_type`, `min_ff_event_normal`, `dynamic_interval`, `min_ff_event_critical`, `dynamic_min`, `each_ff`, `dynamic_two_tailed`, `dynamic_max`, `dynamic_next`) VALUES (786,'N.&#x20;total&#x20;processes','Number&#x20;of&#x20;running&#x20;processes&#x20;in&#x20;a&#x20;Windows&#x20;system.',11,34,0,0,300,0,'tasklist&#x20;/NH&#x20;|&#x20;find&#x20;/c&#x20;/v&#x20;&quot;&quot;','','','',6,2,0,'','','',0,0,1,0.00,0.00,'',0.00,0.00,'',0,'','windows','',0,0,0.000000000000000,'','nowizard','','','','',0,0,0,'','{\"going_unknown\":1}','',0,0,0,0,0,0,0,0,0,0);
INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `max_retries`, `history_data`, `min_warning`, `max_warning`, `max_critical`, `str_warning`, `min_ff_event`, `min_critical`, `custom_string_2`, `str_critical`, `custom_integer_1`, `custom_string_1`, `post_process`, `custom_string_3`, `wizard_level`, `custom_integer_2`, `critical_instructions`, `unit`, `unknown_instructions`, `macros`, `warning_inverse`, `warning_instructions`, `tags`, `critical_inverse`, `module_macros`, `id_category`, `min_ff_event_warning`, `disabled_types_event`, `ff_type`, `min_ff_event_normal`, `dynamic_interval`, `min_ff_event_critical`, `dynamic_min`, `each_ff`, `dynamic_two_tailed`, `dynamic_max`, `dynamic_next`) VALUES (787,'Free&#x20;space&#x20;in&#x20;C:','Free&#x20;space&#x20;available&#x20;in&#x20;C:',11,34,0,0,300,0,'powershell&#x20;$obj=&#40;Get-WmiObject&#x20;-class&#x20;&quot;Win32_LogicalDisk&quot;&#x20;-namespace&#x20;&quot;root&#92;CIMV2&quot;&#41;&#x20;;&#x20;$obj.FreeSpace[0]&#x20;*&#x20;100&#x20;/$obj.Size[0]','','','',4,2,0,'','','',0,0,1,0.00,0.00,'',0.00,0.00,'',0,'','windows','',0,0,0.000000000000000,'%','nowizard','','','','',0,0,0,'','{\"going_unknown\":1}','',0,0,0,0,0,0,0,0,0,0);
INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `max_retries`, `history_data`, `min_warning`, `max_warning`, `max_critical`, `str_warning`, `min_ff_event`, `min_critical`, `custom_string_2`, `str_critical`, `custom_integer_1`, `custom_string_1`, `post_process`, `custom_string_3`, `wizard_level`, `custom_integer_2`, `critical_instructions`, `unit`, `unknown_instructions`, `macros`, `warning_inverse`, `warning_instructions`, `tags`, `critical_inverse`, `module_macros`, `id_category`, `min_ff_event_warning`, `disabled_types_event`, `ff_type`, `min_ff_event_normal`, `dynamic_interval`, `min_ff_event_critical`, `dynamic_min`, `each_ff`, `dynamic_two_tailed`, `dynamic_max`, `dynamic_next`) VALUES (788,'Linux&#x20;uptime','System&#x20;uptime',43,36,0,0,300,0,'uptime&#x20;|sed&#x20;s/us&#92;.*$//g&#x20;|&#x20;sed&#x20;s/,&#92;.*$//g','','','',4,2,0,'','','',0,0,1,0.00,0.00,'',0.00,0.00,'',0,'','linux','',0,0,0.000000000000000,'','nowizard','','','','',0,0,0,'','{\"going_unknown\":1}','',0,0,0,0,0,0,0,0,0,0);
INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `max_retries`, `history_data`, `min_warning`, `max_warning`, `max_critical`, `str_warning`, `min_ff_event`, `min_critical`, `custom_string_2`, `str_critical`, `custom_integer_1`, `custom_string_1`, `post_process`, `custom_string_3`, `wizard_level`, `custom_integer_2`, `critical_instructions`, `unit`, `unknown_instructions`, `macros`, `warning_inverse`, `warning_instructions`, `tags`, `critical_inverse`, `module_macros`, `id_category`, `min_ff_event_warning`, `disabled_types_event`, `ff_type`, `min_ff_event_normal`, `dynamic_interval`, `min_ff_event_critical`, `dynamic_min`, `each_ff`, `dynamic_two_tailed`, `dynamic_max`, `dynamic_next`) VALUES (789,'Linux&#x20;processes','Running&#x20;processes',43,34,0,0,300,0,'ps&#x20;elf&#x20;|&#x20;wc&#x20;-l','','','',6,2,0,'','','',0,0,1,0.00,0.00,'',0.00,0.00,'',0,'','linux','',0,0,0.000000000000000,'','nowizard','','','','',0,0,0,'','{\"going_unknown\":1}','',0,0,0,0,0,0,0,0,0,0);
INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `max_retries`, `history_data`, `min_warning`, `max_warning`, `max_critical`, `str_warning`, `min_ff_event`, `min_critical`, `custom_string_2`, `str_critical`, `custom_integer_1`, `custom_string_1`, `post_process`, `custom_string_3`, `wizard_level`, `custom_integer_2`, `critical_instructions`, `unit`, `unknown_instructions`, `macros`, `warning_inverse`, `warning_instructions`, `tags`, `critical_inverse`, `module_macros`, `id_category`, `min_ff_event_warning`, `disabled_types_event`, `ff_type`, `min_ff_event_normal`, `dynamic_interval`, `min_ff_event_critical`, `dynamic_min`, `each_ff`, `dynamic_two_tailed`, `dynamic_max`, `dynamic_next`) VALUES (790,'Linux&#x20;system&#x20;load','Current&#x20;load&#x20;&#40;5&#x20;min&#41;',43,34,0,0,300,0,'uptime&#x20;|&#x20;awk&#x20;&#039;{print&#x20;$&#40;NF-1&#41;}&#039;&#x20;|&#x20;tr&#x20;-d&#x20;&#039;,&#039;','','','',6,2,0,'','','',0,0,1,0.00,0.00,'',0.00,0.00,'',0,'','linux','',0,0,0.000000000000000,'','nowizard','','','','',0,0,0,'','{\"going_unknown\":1}','',0,0,0,0,0,0,0,0,0,0);
INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `max_retries`, `history_data`, `min_warning`, `max_warning`, `max_critical`, `str_warning`, `min_ff_event`, `min_critical`, `custom_string_2`, `str_critical`, `custom_integer_1`, `custom_string_1`, `post_process`, `custom_string_3`, `wizard_level`, `custom_integer_2`, `critical_instructions`, `unit`, `unknown_instructions`, `macros`, `warning_inverse`, `warning_instructions`, `tags`, `critical_inverse`, `module_macros`, `id_category`, `min_ff_event_warning`, `disabled_types_event`, `ff_type`, `min_ff_event_normal`, `dynamic_interval`, `min_ff_event_critical`, `dynamic_min`, `each_ff`, `dynamic_two_tailed`, `dynamic_max`, `dynamic_next`) VALUES (791,'Linux&#x20;available&#x20;memory&#x20;percent','Available&#x20;memory&#x20;%',43,34,0,0,300,0,'free&#x20;|&#x20;grep&#x20;Mem&#x20;|&#x20;awk&#x20;&#039;{print&#x20;$NF/$2&#x20;*&#x20;100}&#039;','','','',4,2,0,'','','',0,0,1,0.00,0.00,'',0.00,0.00,'',0,'','linux','',0,0,0.000000000000000,'%','nowizard','','','','',0,0,0,'','{\"going_unknown\":1}','',0,0,0,0,0,0,0,0,0,0);
INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `max_retries`, `history_data`, `min_warning`, `max_warning`, `max_critical`, `str_warning`, `min_ff_event`, `min_critical`, `custom_string_2`, `str_critical`, `custom_integer_1`, `custom_string_1`, `post_process`, `custom_string_3`, `wizard_level`, `custom_integer_2`, `critical_instructions`, `unit`, `unknown_instructions`, `macros`, `warning_inverse`, `warning_instructions`, `tags`, `critical_inverse`, `module_macros`, `id_category`, `min_ff_event_warning`, `disabled_types_event`, `ff_type`, `min_ff_event_normal`, `dynamic_interval`, `min_ff_event_critical`, `dynamic_min`, `each_ff`, `dynamic_two_tailed`, `dynamic_max`, `dynamic_next`) VALUES (792,'Linux&#x20;available&#x20;disk&#x20;/','Available&#x20;free&#x20;space&#x20;in&#x20;mountpoint&#x20;/',43,34,0,0,300,0,'df&#x20;/&#x20;|&#x20;tail&#x20;-n&#x20;+2&#x20;|&#x20;awk&#x20;&#039;{print&#x20;$&#40;NF-1&#41;}&#039;&#x20;|&#x20;tr&#x20;-d&#x20;&#039;%&#039;','','','',4,2,0,'','','',0,0,1,0.00,0.00,'0.00',0.00,0.00,'',0,'','inherited','',0,0,0.000000000000000,'','nowizard','','nowizard','0','',0,0,0,'','{\"going_unknown\":1}','',0,0,0,0,0,0,0,0,0,0);
-- --
-- Dumping data for table `tnetwork_component_group` -- Dumping data for table `tnetwork_component_group`

View File

@ -5,7 +5,7 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Default lib dir for RPM and DEB packages # Default lib dir for RPM and DEB packages
use lib '/usr/lib/perl5'; BEGIN { push @INC, '/usr/lib/perl5'; }
use strict; use strict;
use Data::Dumper; use Data::Dumper;

View File

@ -12,7 +12,7 @@ use NetAddr::IP;
# Default lib dir for RPM and DEB packages # Default lib dir for RPM and DEB packages
use lib '/usr/lib/perl5'; BEGIN { push @INC, '/usr/lib/perl5'; }
use PandoraFMS::Tools; use PandoraFMS::Tools;
use PandoraFMS::DB; use PandoraFMS::DB;

View File

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

View File

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

View File

@ -24,7 +24,7 @@ use threads;
use Digest::MD5 qw(md5_hex); use Digest::MD5 qw(md5_hex);
# Default lib dir for RPM and DEB packages # Default lib dir for RPM and DEB packages
use lib '/usr/lib/perl5'; BEGIN { push @INC, '/usr/lib/perl5'; }
# Pandora Modules # Pandora Modules
use PandoraFMS::DB; use PandoraFMS::DB;

View File

@ -1,8 +1,8 @@
package PandoraFMS::AlertServer; package PandoraFMS::AlertServer;
########################################################################## ################################################################################
# Pandora FMS Alert Server. # Pandora FMS Alert Server.
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org # Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
########################################################################## ################################################################################
# Copyright (c) 2005-2021 Artica Soluciones Tecnologicas S.L # Copyright (c) 2005-2021 Artica Soluciones Tecnologicas S.L
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
@ -15,7 +15,7 @@ package PandoraFMS::AlertServer;
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
########################################################################## ################################################################################
use strict; use strict;
use warnings; use warnings;
@ -24,6 +24,7 @@ use threads;
use threads::shared; use threads::shared;
use Thread::Semaphore; use Thread::Semaphore;
use MIME::Base64;
use JSON; use JSON;
use POSIX qw(strftime); use POSIX qw(strftime);
@ -47,9 +48,9 @@ my $AlertSem :shared;
my %Alerts :shared; my %Alerts :shared;
my $EventRef :shared = 0; my $EventRef :shared = 0;
######################################################################################## ################################################################################
# Alert Server class constructor. # Alert Server class constructor.
######################################################################################## ################################################################################
sub new ($$$) { sub new ($$$) {
my ($class, $config, $dbh) = @_; my ($class, $config, $dbh) = @_;
@ -69,9 +70,9 @@ sub new ($$$) {
return $self; return $self;
} }
############################################################################### ################################################################################
# Run. # Run.
############################################################################### ################################################################################
sub run ($) { sub run ($) {
my $self = shift; my $self = shift;
my $pa_config = $self->getConfig (); my $pa_config = $self->getConfig ();
@ -81,9 +82,9 @@ sub run ($) {
$self->SUPER::run (\@TaskQueue, \%PendingTasks, $Sem, $TaskSem); $self->SUPER::run (\@TaskQueue, \%PendingTasks, $Sem, $TaskSem);
} }
############################################################################### ################################################################################
# Data producer. # Data producer.
############################################################################### ################################################################################
sub data_producer ($) { sub data_producer ($) {
my $self = shift; my $self = shift;
my ($pa_config, $dbh) = ($self->getConfig (), $self->getDBH ()); my ($pa_config, $dbh) = ($self->getConfig (), $self->getDBH ());
@ -120,14 +121,16 @@ sub data_producer ($) {
return @tasks; return @tasks;
} }
############################################################################### ################################################################################
# Data consumer. # Data consumer.
############################################################################### ################################################################################
sub data_consumer ($$) { sub data_consumer ($$) {
my ($self, $task_id) = @_; my ($self, $task_id) = @_;
my ($pa_config, $dbh) = ($self->getConfig (), $self->getDBH ()); my ($pa_config, $dbh) = ($self->getConfig (), $self->getDBH ());
eval {{ eval {{
local $SIG{__DIE__};
# Get the alert from the queue. # Get the alert from the queue.
my $task = get_db_single_row ($dbh, 'SELECT * FROM talert_execution_queue WHERE id = ?', $task_id); my $task = get_db_single_row ($dbh, 'SELECT * FROM talert_execution_queue WHERE id = ?', $task_id);
if (! defined ($task)) { if (! defined ($task)) {
@ -135,42 +138,40 @@ sub data_consumer ($$) {
last 0; last 0;
} }
# Get the alert data. my $args = PandoraFMS::Tools::p_decode_json(
my $alert = get_db_single_row ($dbh, 'SELECT talert_template_modules.id as id_template_module, $pa_config,
talert_template_modules.*, talert_templates.* decode_base64($task->{'data'})
FROM talert_template_modules, talert_templates );
WHERE talert_template_modules.id_alert_template = talert_templates.id
AND talert_template_modules.id = ?', $task->{'id_alert_template_module'}); if (ref $args ne "ARRAY") {
if (! defined ($alert)) { die ('Invalid alert queued');
logger($pa_config, "Alert ID " . $task->{'id_alert_template_module'} . " not found.", 10);
last;
} }
# Get the agent and module associated with the alert my @args = @{$args};
my $module = get_db_single_row ($dbh, 'SELECT * FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
if (! defined ($module)) {
logger($pa_config, "Module ID " . $alert->{'id_agent_module'} . " not found for alert ID " . $alert->{'id_template_module'} . ".", 10);
last;
}
my $agent = get_db_single_row ($dbh, 'SELECT * FROM tagente WHERE id_agente = ?', $module->{'id_agente'});
if (! defined ($agent)) {
logger($pa_config, "Agent ID " . $module->{'id_agente'} . " not found for module ID " . $module->{'id_agente_modulo'} . " alert ID " . $alert->{'id_template_module'} . ".", 10);
last;
}
# Execute the alert. # You cannot code a DBI object into JSON, use current.
pandora_execute_alert ($pa_config, $task->{'data'}, $agent, $module, $alert, $task->{'alert_mode'}, my $execution_args = [
$dbh, strftime ("%Y-%m-%d %H:%M:%S", localtime()), 0, decode_json($task->{'extra_macros'})); $pa_config,
@args[0..4],
$dbh,
@args[5..$#args]
];
# Execute.
PandoraFMS::Core::pandora_execute_alert(@$execution_args);
}}; }};
if ($@) {
logger ($pa_config,"[ERROR] Executing alert ".$@, 0);
}
# Remove the alert from the queue and unlock. # Remove the alert from the queue and unlock.
db_do($dbh, 'DELETE FROM talert_execution_queue WHERE id=?', $task_id); db_do($dbh, 'DELETE FROM talert_execution_queue WHERE id=?', $task_id);
alert_unlock($pa_config, $task_id); alert_unlock($pa_config, $task_id);
} }
########################################################################## ################################################################################
# Get a lock on the given alert. Return 1 on success, 0 otherwise. # Get a lock on the given alert. Return 1 on success, 0 otherwise.
########################################################################## ################################################################################
sub alert_lock { sub alert_lock {
my ($pa_config, $alert, $locked_alerts) = @_; my ($pa_config, $alert, $locked_alerts) = @_;
@ -186,9 +187,9 @@ sub alert_lock {
return 1; return 1;
} }
########################################################################## ################################################################################
# Remove the lock on the given alert. # Remove the lock on the given alert.
########################################################################## ################################################################################
sub alert_unlock { sub alert_unlock {
my ($pa_config, $alert) = @_; my ($pa_config, $alert) = @_;

View File

@ -22,7 +22,7 @@ use POSIX qw(strftime);
use Time::Local; use Time::Local;
# Default lib dir for RPM and DEB packages # Default lib dir for RPM and DEB packages
use lib '/usr/lib/perl5'; BEGIN { push @INC, '/usr/lib/perl5'; }
use PandoraFMS::Tools; use PandoraFMS::Tools;
use PandoraFMS::DB; use PandoraFMS::DB;
@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.760"; my $pandora_version = "7.0NG.760";
my $pandora_build = "220222"; my $pandora_build = "220316";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash
@ -1388,8 +1388,13 @@ sub pandora_start_log ($){
# Dump all errors to errorlog # Dump all errors to errorlog
open (STDERR, ">> " . $pa_config->{'errorlog_file'}) or die " [ERROR] " . pandora_get_initial_product_name() . " can't write to Errorlog. Aborting : \n $! \n"; open (STDERR, ">> " . $pa_config->{'errorlog_file'}) or die " [ERROR] " . pandora_get_initial_product_name() . " can't write to Errorlog. Aborting : \n $! \n";
my $mode = 0664;
my $file_mode = (stat($pa_config->{'errorlog_file'}))[2] & 0777;
my $min_mode = 0664;
my $mode = $file_mode | $min_mode;
chmod $mode, $pa_config->{'errorlog_file'}; chmod $mode, $pa_config->{'errorlog_file'};
print STDERR strftime ("%Y-%m-%d %H:%M:%S", localtime()) . ' - ' . $pa_config->{'servername'} . " Starting " . pandora_get_initial_product_name() . " Server. Error logging activated.\n"; print STDERR strftime ("%Y-%m-%d %H:%M:%S", localtime()) . ' - ' . $pa_config->{'servername'} . " Starting " . pandora_get_initial_product_name() . " Server. Error logging activated.\n";
} }

View File

@ -145,7 +145,7 @@ if (!$@) {
} }
# Default lib dir for RPM and DEB packages # Default lib dir for RPM and DEB packages
use lib '/usr/lib/perl5'; BEGIN { push @INC, '/usr/lib/perl5'; }
use PandoraFMS::DB; use PandoraFMS::DB;
use PandoraFMS::Config; use PandoraFMS::Config;
@ -551,31 +551,48 @@ sub pandora_evaluate_alert ($$$$$$$;$$$$) {
return $status if ($alert->{$DayNames[$wday]} != 1); return $status if ($alert->{$DayNames[$wday]} != 1);
} }
my $schedule = PandoraFMS::Tools::p_decode_json($pa_config, $alert->{'schedule'}); my $schedule;
if (defined($alert->{'schedule'}) && $alert->{'schedule'} ne '') {
return $status unless defined($schedule) && ref $schedule eq "HASH"; $schedule = PandoraFMS::Tools::p_decode_json($pa_config, $alert->{'schedule'});
return $status unless defined($schedule->{$DayNames[$wday]});
return $status unless ref($schedule->{$DayNames[$wday]}) eq "ARRAY";
my $time = sprintf ("%.2d:%.2d:%.2d", $hour, $min, $sec);
#
# Check time slots
#
my $inSlot = 0;
foreach my $timeBlock (@{$schedule->{$DayNames[$wday]}}) {
if ($timeBlock->{'start'} eq $timeBlock->{'end'}) {
# All day.
$inSlot = 1;
} elsif ($timeBlock->{'start'} le $time && $timeBlock->{'end'} ge $time) {
# In range.
$inSlot = 1;
}
} }
return $status if $inSlot eq 0; if (defined($schedule)) {
# New behaviour.
return $status unless defined($schedule) && ref $schedule eq "HASH";
return $status unless defined($schedule->{$DayNames[$wday]});
return $status unless ref($schedule->{$DayNames[$wday]}) eq "ARRAY";
my $time = sprintf ("%.2d:%.2d:%.2d", $hour, $min, $sec);
#
# Check time slots
#
my $inSlot = 0;
foreach my $timeBlock (@{$schedule->{$DayNames[$wday]}}) {
if ($timeBlock->{'start'} eq $timeBlock->{'end'}) {
# All day.
$inSlot = 1;
} elsif ($timeBlock->{'start'} le $time && $timeBlock->{'end'} ge $time) {
# In range.
$inSlot = 1;
}
}
return $status if $inSlot eq 0;
} else {
# Old behaviour.
# Check time slot
my $time = sprintf ("%.2d:%.2d:%.2d", $hour, $min, $sec);
if (($alert->{'time_from'} ne $alert->{'time_to'})) {
if ($alert->{'time_from'} lt $alert->{'time_to'}) {
return $status if (($time le $alert->{'time_from'}) || ($time ge $alert->{'time_to'}));
} else {
return $status if (($time le $alert->{'time_from'}) && ($time ge $alert->{'time_to'}));
}
}
}
# Check time threshold # Check time threshold
my $limit_utimestamp = $alert->{'last_reference'} + $alert->{'time_threshold'}; my $limit_utimestamp = $alert->{'last_reference'} + $alert->{'time_threshold'};
@ -776,10 +793,12 @@ sub pandora_process_alert ($$$$$$$$;$$) {
db_do($dbh, 'UPDATE talert_template_module_actions SET last_execution = 0 WHERE id_alert_template_module = ?', $id); db_do($dbh, 'UPDATE talert_template_module_actions SET last_execution = 0 WHERE id_alert_template_module = ?', $id);
} }
if ($pa_config->{'alertserver'} == 1 && defined ($alert->{'id_template_module'})) { if ($pa_config->{'alertserver'} == 1) {
pandora_queue_alert($pa_config, $dbh, $data, $alert, 0, $extra_macros); pandora_queue_alert($pa_config, $dbh, [$data, $agent, $module,
$alert, 0, $timestamp, 0, $extra_macros, $is_correlated_alert]);
} else { } else {
pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 0, $dbh, $timestamp, 0, $extra_macros, $is_correlated_alert); pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 0, $dbh,
$timestamp, 0, $extra_macros, $is_correlated_alert);
} }
return; return;
} }
@ -820,8 +839,9 @@ sub pandora_process_alert ($$$$$$$$;$$) {
last_fired = ?, internal_counter = ? ' . $new_interval . ' WHERE id = ?', last_fired = ?, internal_counter = ? ' . $new_interval . ' WHERE id = ?',
$alert->{'times_fired'}, $utimestamp, $alert->{'internal_counter'}, $id); $alert->{'times_fired'}, $utimestamp, $alert->{'internal_counter'}, $id);
if ($pa_config->{'alertserver'} == 1 && defined ($alert->{'id_template_module'})) { if ($pa_config->{'alertserver'} == 1) {
pandora_queue_alert($pa_config, $dbh, $data, $alert, 1, $extra_macros); pandora_queue_alert($pa_config, $dbh, [$data, $agent, $module,
$alert, 1, $timestamp, 0, $extra_macros, $is_correlated_alert]);
} else { } else {
pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 1, pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 1,
$dbh, $timestamp, 0, $extra_macros, $is_correlated_alert); $dbh, $timestamp, 0, $extra_macros, $is_correlated_alert);
@ -837,7 +857,7 @@ Execute the given alert.
=cut =cut
########################################################################## ##########################################################################
sub pandora_execute_alert ($$$$$$$$$;$$) { sub pandora_execute_alert {
my ($pa_config, $data, $agent, $module, my ($pa_config, $data, $agent, $module,
$alert, $alert_mode, $dbh, $timestamp, $forced_alert, $alert, $alert_mode, $dbh, $timestamp, $forced_alert,
$extra_macros, $is_correlated_alert) = @_; $extra_macros, $is_correlated_alert) = @_;
@ -1081,17 +1101,15 @@ Queue the given alert for execution.
=cut =cut
########################################################################## ##########################################################################
sub pandora_queue_alert ($$$$$;$) { sub pandora_queue_alert ($$$) {
my ($pa_config, $dbh, $data, $alert, $alert_mode, $extra_macros) = @_; my ($pa_config, $dbh, $arguments) = @_;
my $json_macros = '{}';
eval { my $json_arguments = PandoraFMS::Tools::p_encode_json($pa_config, $arguments);
local $SIG{__DIE__};
$json_macros = encode_json($extra_macros);
};
db_do ($dbh, "INSERT INTO talert_execution_queue (id_alert_template_module, data, alert_mode, extra_macros, utimestamp) $json_arguments = encode_base64($json_arguments);
VALUES (?, ?, ?, ?, ?)", $alert->{'id_template_module'}, $data, $alert_mode, $json_macros, time());
db_do ($dbh, "INSERT INTO talert_execution_queue (data, utimestamp)
VALUES (?, ?)", $json_arguments, time());
} }
########################################################################## ##########################################################################
@ -5522,6 +5540,9 @@ sub pandora_process_policy_queue ($) {
next; next;
} }
# Refresh policy agents.
enterprise_hook('pandora_apply_policy_groups', [$pa_config, $dbh]);
my $operation = enterprise_hook('get_first_policy_queue', [$dbh]); my $operation = enterprise_hook('get_first_policy_queue', [$dbh]);
next unless (defined ($operation) && $operation ne ''); next unless (defined ($operation) && $operation ne '');

View File

@ -22,7 +22,7 @@ use warnings;
use DBI; use DBI;
use Carp qw/croak/; use Carp qw/croak/;
use lib '/usr/lib/perl5'; BEGIN { push @INC, '/usr/lib/perl5'; }
use PandoraFMS::Tools; use PandoraFMS::Tools;
#use Data::Dumper; #use Data::Dumper;
@ -555,6 +555,7 @@ sub get_agentmodule_status_str($$$) {
FROM tagente_estado FROM tagente_estado
WHERE id_agente_modulo = ?', $agent_module_id); WHERE id_agente_modulo = ?', $agent_module_id);
return 'N/A' unless defined($status);
return 'Normal' if ($status == 0); return 'Normal' if ($status == 0);
return 'Critical' if ($status == 1); return 'Critical' if ($status == 1);
return 'Warning' if ($status == 2); return 'Warning' if ($status == 2);

View File

@ -41,7 +41,7 @@ use Encode::Locale ();
use LWP::Simple; use LWP::Simple;
# Default lib dir for RPM and DEB packages # Default lib dir for RPM and DEB packages
use lib '/usr/lib/perl5'; BEGIN { push @INC, '/usr/lib/perl5'; }
use PandoraFMS::Tools; use PandoraFMS::Tools;
use PandoraFMS::DB; use PandoraFMS::DB;

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