Merge branch 'develop' into 'ent-8611-vulnerabilidad-en-bulk-operations'
# Conflicts: # pandora_console/include/functions_groups.php
This commit is contained in:
commit
81da96ac33
|
@ -1,11 +1,12 @@
|
|||
FROM pandorafms/pandorafms-base
|
||||
FROM pandorafms/pandorafms-base:centos7
|
||||
|
||||
# Build variables.
|
||||
ARG BRANCH=develop
|
||||
ARG DB_PASS=pandora
|
||||
|
||||
# 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.
|
||||
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
|
||||
|
||||
# Install the Pandora FMS Console.
|
||||
RUN service mysqld start && \
|
||||
/usr/bin/mysqladmin -u root password "$DB_PASS" && \
|
||||
service httpd 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
|
||||
RUN rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql && \
|
||||
mkdir -p /var/log/mysql/ && chown mysql. /var/log/mysql && \
|
||||
chown mysql. -R /var/lib/mysql && \
|
||||
sudo -u mysql mysqld --initialize --explicit_defaults_for_timestamp && \
|
||||
sudo -u mysql mysqld --daemonize & \
|
||||
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.
|
||||
RUN echo '<meta http-equiv="refresh" content="0;url=/pandora_console">' > /var/www/html/index.html
|
||||
|
||||
# Create the entrypoint script.
|
||||
RUN echo -e '#/bin/bash\n \
|
||||
service mysqld start &&\n \
|
||||
service httpd start &&\n \
|
||||
service crond start &&\n \
|
||||
sudo -u mysql mysqld --daemonize &&\n \
|
||||
httpd -k start &&\n \
|
||||
/usr/sbin/crond &&\n \
|
||||
/etc/init.d/pandora_agent_daemon start && \
|
||||
/etc/init.d/pandora_server start && \
|
||||
tail -f /var/log/pandora/pandora_server.log' \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.760-220222
|
||||
Version: 7.0NG.760-220309
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.760-220222"
|
||||
pandora_version="7.0NG.760-220309"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -39,7 +39,7 @@ BEGIN {
|
|||
|
||||
use File::Copy;
|
||||
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
|
||||
|
@ -312,7 +312,7 @@ BEGIN {
|
|||
$YAML = 1;
|
||||
}
|
||||
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
our @ISA = ("Exporter");
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
|
||||
|
@ -1003,7 +1003,7 @@ use IO::Socket;
|
|||
use Sys::Syslog;
|
||||
use Time::Local;
|
||||
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
# Agent XML data
|
||||
my $Xml;
|
||||
|
@ -1015,7 +1015,7 @@ my $Sem = undef;
|
|||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.760';
|
||||
use constant AGENT_BUILD => '220222';
|
||||
use constant AGENT_BUILD => '220309';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.760
|
||||
%define release 220222
|
||||
%define release 220309
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.760
|
||||
%define release 220222
|
||||
%define release 220309
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -42,6 +42,8 @@ pidof_pandora () {
|
|||
elif [ "$OS_NAME" = "SunOS" ]
|
||||
then
|
||||
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`
|
||||
if [ -x $ZONENAME_CMD ]
|
||||
then
|
||||
|
@ -59,7 +61,7 @@ pidof_pandora () {
|
|||
then
|
||||
# Virtuozzo/OpenVZ
|
||||
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
|
||||
do
|
||||
_ctid=`/usr/sbin/vzpid $_pid | awk '$1 == '$_pid' { print $2 }'`
|
||||
|
@ -71,9 +73,9 @@ pidof_pandora () {
|
|||
done
|
||||
elif [ "$OS_NAME" = "AIX" ]; then
|
||||
# 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
|
||||
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
|
||||
|
||||
echo $PANDORA_PID
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.760"
|
||||
PI_BUILD="220222"
|
||||
PI_BUILD="220309"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
|
|
@ -14,7 +14,7 @@ use strict;
|
|||
use LWP::Simple;
|
||||
use LWP::UserAgent;
|
||||
use MIME::Base64;
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
use PandoraFMS::Tools;
|
||||
|
||||
# Init
|
||||
|
|
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{220222}
|
||||
{220309}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -11,7 +11,7 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use File::Basename;
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
use PandoraFMS::PluginTools;
|
||||
use PandoraFMS::Omnishell;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.760 Build 220222")
|
||||
#define PANDORA_VERSION ("7.0NG.760 Build 220309")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
|||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.760(Build 220222))"
|
||||
VALUE "ProductVersion", "(7.0NG.760(Build 220309))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 7.0NG.760-220222
|
||||
Version: 7.0NG.760-220309
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.760-220222"
|
||||
pandora_version="7.0NG.760-220309"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -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 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 `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;
|
||||
|
||||
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;
|
||||
|
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -213,6 +213,20 @@ CREATE TABLE IF NOT EXISTS `tpolicy_groups` (
|
|||
UNIQUE (`id_policy`, `id_group`)
|
||||
) 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`
|
||||
-- ---------------------------------------------------------------------
|
||||
|
@ -4124,14 +4138,11 @@ ALTER TABLE `tperfil` ADD COLUMN `network_config_management`tinyint(1) NOT NULL
|
|||
-- Table `talert_execution_queue`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `talert_execution_queue` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_alert_template_module` int(10) unsigned NOT NULL,
|
||||
`alert_mode` tinyint(1) NOT NULL,
|
||||
`data` mediumtext NOT NULL,
|
||||
`extra_macros` text,
|
||||
`utimestamp` bigint(20) NOT NULL default '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`data` LONGTEXT,
|
||||
`utimestamp` BIGINT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
UPDATE `tlanguage` SET `name` = 'Deutsch' WHERE `id_language` = 'de';
|
||||
|
|
@ -36,30 +36,32 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
|
|||
).'</div>';
|
||||
|
||||
// ======= Servers List ===============================================
|
||||
$servers_list = '<div id="servers_list">';
|
||||
$servers = [];
|
||||
$servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver');
|
||||
if ($servers['all'] != 0) {
|
||||
$servers['up'] = (int) servers_check_status();
|
||||
$servers['down'] = ($servers['all'] - $servers['up']);
|
||||
if ($servers['up'] == 0) {
|
||||
// All Servers down or no servers at all.
|
||||
$servers_check_img = html_print_image('images/header_down_gray.png', true, ['alt' => 'cross', 'class' => 'bot', 'title' => __('All systems').': '.__('Down')]);
|
||||
} else if ($servers['down'] != 0) {
|
||||
// Some servers down.
|
||||
$servers_check_img = html_print_image('images/header_warning_gray.png', true, ['alt' => 'error', 'class' => 'bot', 'title' => $servers['down'].' '.__('servers down')]);
|
||||
} else {
|
||||
// All servers up.
|
||||
$servers_check_img = html_print_image('images/header_ready_gray.png', true, ['alt' => 'ok', 'class' => 'bot', 'title' => __('All systems').': '.__('Ready')]);
|
||||
}
|
||||
if ((bool) check_acl($config['id_user'], 0, 'AW') !== false) {
|
||||
$servers_list = '<div id="servers_list">';
|
||||
$servers = [];
|
||||
$servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver');
|
||||
if ($servers['all'] != 0) {
|
||||
$servers['up'] = (int) servers_check_status();
|
||||
$servers['down'] = ($servers['all'] - $servers['up']);
|
||||
if ($servers['up'] == 0) {
|
||||
// All Servers down or no servers at all.
|
||||
$servers_check_img = html_print_image('images/header_down_gray.png', true, ['alt' => 'cross', 'class' => 'bot', 'title' => __('All systems').': '.__('Down')]);
|
||||
} else if ($servers['down'] != 0) {
|
||||
// Some servers down.
|
||||
$servers_check_img = html_print_image('images/header_warning_gray.png', true, ['alt' => 'error', 'class' => 'bot', 'title' => $servers['down'].' '.__('servers down')]);
|
||||
} else {
|
||||
// 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);
|
||||
// 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 .= $servers_check_img;
|
||||
$servers_check_img_link .= '</a>';
|
||||
};
|
||||
$servers_list .= $servers_check_img_link.'</div>';
|
||||
unset($servers);
|
||||
// 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 .= $servers_check_img;
|
||||
$servers_check_img_link .= '</a>';
|
||||
};
|
||||
$servers_list .= $servers_check_img_link.'</div>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ $(document).ready(function(){
|
|||
var menuType_value = "<?php echo ($_SESSION['menu_type'] ?? ''); ?>";
|
||||
|
||||
if (menuType_value === '' || menuType_value === 'classic') {
|
||||
$('ul.submenu').css('left', '214px');
|
||||
$('ul.submenu').css('left', '214px');
|
||||
}
|
||||
else{
|
||||
$('ul.submenu').css('left', '59px');
|
||||
|
@ -107,7 +107,12 @@ echo '</a></div>';
|
|||
require 'operation/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>';
|
||||
// Menu_container.
|
||||
|
@ -122,7 +127,7 @@ if (isset($config['fixed_header']) === true) {
|
|||
<script type="text/javascript" language="javascript">
|
||||
/* <![CDATA[ */
|
||||
|
||||
$('#button_collapse').on('click', function() {
|
||||
$('#button_collapse').on('click', function() {
|
||||
|
||||
if($('#menu_full').hasClass('menu_full_classic')){
|
||||
localStorage.setItem("menuType", "collapsed");
|
||||
|
@ -155,7 +160,7 @@ $('#button_collapse').on('click', function() {
|
|||
|
||||
$('.logo_full').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');
|
||||
$('div#title_menu').toggleClass('title_menu_classic title_menu_collapsed');
|
||||
$('div#page').toggleClass('page_classic page_collapsed');
|
||||
|
@ -389,9 +394,9 @@ $(document).ready(function() {
|
|||
if( typeof(table_hover) != 'undefined')
|
||||
$("ul#sub"+table_hover[0].id).hide();
|
||||
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() {
|
||||
openTime = 4000;
|
||||
if( typeof(table_hover) != 'undefined')
|
||||
|
@ -399,7 +404,7 @@ $(document).ready(function() {
|
|||
if( typeof(table_hover2) != 'undefined')
|
||||
$("ul#sub"+table_hover2[0].id).hide();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
global $config;
|
||||
|
||||
enterprise_include('godmode/agentes/configurar_agente.php');
|
||||
enterprise_include('include/functions_policies.php');
|
||||
enterprise_include_once('include/functions_modules.php');
|
||||
enterprise_include('include/functions_policies.php');
|
||||
require_once $config['homedir'].'/include/functions_agents.php';
|
||||
require_once $config['homedir'].'/include/functions_cron.php';
|
||||
ui_require_javascript_file('encode_decode_base64');
|
||||
|
@ -307,23 +307,6 @@ if ($create_agent) {
|
|||
|
||||
$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.'",
|
||||
"IP":"'.$direccion_agente.'",
|
||||
"Group":"'.$grupo.'",
|
||||
|
@ -1117,12 +1100,6 @@ if ($update_agent) {
|
|||
// 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]);
|
||||
|
||||
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 = '{
|
||||
"id_agente":"'.$id_agente.'",
|
||||
"alias":"'.$alias.'",
|
||||
|
|
|
@ -533,10 +533,10 @@ if ($search != '') {
|
|||
$search_sql .= ')';
|
||||
} else {
|
||||
$search_sql = sprintf(
|
||||
' AND ( nombre
|
||||
LIKE "%%%s%%" OR alias
|
||||
LIKE "%%%s%%" OR comentarios LIKE "%%%s%%"
|
||||
OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND description LIKE "%%%s%%")',
|
||||
' AND ( nombre
|
||||
LIKE "%%%s%%" OR alias
|
||||
LIKE "%%%s%%" OR comentarios LIKE "%%%s%%"
|
||||
OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND description LIKE "%%%s%%"))',
|
||||
$search,
|
||||
$search,
|
||||
$search,
|
||||
|
|
|
@ -639,20 +639,20 @@ $table->data[5][1] = "
|
|||
<tr><td>".ui_get_using_system_timezone_warning().'</td></tr>
|
||||
<tr>
|
||||
<td>'.__('Type Periodicity:').' '.html_print_select(
|
||||
[
|
||||
'weekly' => __('Weekly'),
|
||||
'monthly' => __('Monthly'),
|
||||
],
|
||||
'type_periodicity',
|
||||
$type_periodicity,
|
||||
'change_type_periodicity();',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
$disabled_in_execution
|
||||
[
|
||||
'weekly' => __('Weekly'),
|
||||
'monthly' => __('Monthly'),
|
||||
],
|
||||
'type_periodicity',
|
||||
$type_periodicity,
|
||||
'change_type_periodicity();',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
$disabled_in_execution
|
||||
)."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -672,31 +672,31 @@ $table->data[5][1] = "
|
|||
<tr>
|
||||
<td>".__('From day:').'</td>
|
||||
<td>'.html_print_select(
|
||||
$days,
|
||||
'periodically_day_from',
|
||||
$periodically_day_from,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
$disabled_in_execution
|
||||
$days,
|
||||
'periodically_day_from',
|
||||
$periodically_day_from,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
$disabled_in_execution
|
||||
).'</td>
|
||||
<td>'.__('To day:').'</td>
|
||||
<td>'.html_print_select(
|
||||
$days,
|
||||
'periodically_day_to',
|
||||
$periodically_day_to,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
$disabled_in_execution
|
||||
$days,
|
||||
'periodically_day_to',
|
||||
$periodically_day_to,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
$disabled_in_execution
|
||||
).'</td>
|
||||
<td>'.ui_print_help_tip(__('The end day must be higher than the start day'), true).'</td>
|
||||
</tr>
|
||||
|
@ -705,26 +705,26 @@ $table->data[5][1] = "
|
|||
<tr>
|
||||
<td>'.__('From hour:').'</td>
|
||||
<td>'.html_print_input_text(
|
||||
'periodically_time_from',
|
||||
$periodically_time_from,
|
||||
'',
|
||||
7,
|
||||
7,
|
||||
true,
|
||||
$disabled_in_execution
|
||||
'periodically_time_from',
|
||||
$periodically_time_from,
|
||||
'',
|
||||
7,
|
||||
7,
|
||||
true,
|
||||
$disabled_in_execution
|
||||
).ui_print_help_tip(
|
||||
__('The end time must be higher than the start time'),
|
||||
true
|
||||
).'</td>
|
||||
<td>'.__('To hour:').'</td>
|
||||
<td>'.html_print_input_text(
|
||||
'periodically_time_to',
|
||||
$periodically_time_to,
|
||||
'',
|
||||
7,
|
||||
7,
|
||||
true,
|
||||
$disabled_in_execution
|
||||
'periodically_time_to',
|
||||
$periodically_time_to,
|
||||
'',
|
||||
7,
|
||||
7,
|
||||
true,
|
||||
$disabled_in_execution
|
||||
).ui_print_help_tip(
|
||||
__('The end time must be higher than the start time'),
|
||||
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"
|
||||
onclick="if(!confirm(\''.__('Are you sure?').'\')) return false;"
|
||||
href="">'.html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
[
|
||||
'border' => '0',
|
||||
'alt' => __('Delete'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
'images/cross.png',
|
||||
true,
|
||||
[
|
||||
'border' => '0',
|
||||
'alt' => __('Delete'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>'."</td>
|
||||
</tr>
|
||||
<tr class='datos2' id='add_modules_row'>
|
||||
|
|
|
@ -1,27 +1,53 @@
|
|||
<?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
|
||||
// ==================================================
|
||||
// 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
|
||||
// Load global vars.
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
$read_permisson = check_acl($config['id_user'], 0, 'AR');
|
||||
$write_permisson = check_acl($config['id_user'], 0, 'AD');
|
||||
$manage_permisson = check_acl($config['id_user'], 0, 'AW');
|
||||
$access = ($read_permisson == true) ? 'AR' : (($write_permisson == true) ? 'AD' : (($manage_permisson == true) ? 'AW' : 'AR'));
|
||||
$read_permisson = (bool) check_acl($config['id_user'], 0, 'AR');
|
||||
$write_permisson = (bool) check_acl($config['id_user'], 0, 'AD');
|
||||
$manage_permisson = (bool) check_acl($config['id_user'], 0, 'AW');
|
||||
$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(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'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_reporting.php';
|
||||
|
||||
$malformed_downtimes = planned_downtimes_get_malformed();
|
||||
$malformed_downtimes_exist = !empty($malformed_downtimes) ? true : false;
|
||||
if (is_ajax() === true) {
|
||||
$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');
|
||||
if ($migrate_malformed) {
|
||||
if ($migrate_malformed === true) {
|
||||
$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(
|
||||
__('An error occurred while migrating the malformed scheduled downtimes').'. '.__('Please run the migration again or contact with the administrator')
|
||||
__($str).'. '.__($str2)
|
||||
);
|
||||
echo '<br>';
|
||||
}
|
||||
|
@ -63,12 +182,15 @@ ui_print_page_header(
|
|||
$id_downtime = (int) get_parameter('id_downtime', 0);
|
||||
|
||||
$stop_downtime = (bool) get_parameter('stop_downtime');
|
||||
// STOP DOWNTIME
|
||||
if ($stop_downtime) {
|
||||
// STOP DOWNTIME.
|
||||
if ($stop_downtime === true) {
|
||||
$downtime = db_get_row('tplanned_downtime', 'id', $id_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'))) {
|
||||
// Check AD permission on the downtime.
|
||||
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(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access downtime scheduler'
|
||||
|
@ -80,7 +202,9 @@ if ($stop_downtime) {
|
|||
$result = planned_downtimes_stop($downtime);
|
||||
|
||||
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 {
|
||||
echo $result['message'];
|
||||
}
|
||||
|
@ -88,11 +212,14 @@ if ($stop_downtime) {
|
|||
|
||||
$delete_downtime = (int) get_parameter('delete_downtime');
|
||||
// DELETE WHOLE DOWNTIME!
|
||||
if ($delete_downtime) {
|
||||
if (empty($delete_downtime) === false) {
|
||||
$downtime = db_get_row('tplanned_downtime', 'id', $id_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'))) {
|
||||
// Check AD permission on the downtime.
|
||||
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(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access downtime scheduler'
|
||||
|
@ -102,10 +229,13 @@ if ($delete_downtime) {
|
|||
}
|
||||
|
||||
// The downtime shouldn't be running!!
|
||||
if ($downtime['executed']) {
|
||||
if ((bool) $downtime['executed'] === true) {
|
||||
ui_print_error_message(__('This scheduled downtime is running'));
|
||||
} 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(
|
||||
$result,
|
||||
|
@ -119,15 +249,25 @@ if ($delete_downtime) {
|
|||
$offset = (int) get_parameter('offset');
|
||||
$filter_params = [];
|
||||
|
||||
$search_text = $filter_params['search_text'] = (string) get_parameter('search_text');
|
||||
$date_from = $filter_params['date_from'] = (string) get_parameter('date_from');
|
||||
$date_to = $filter_params['date_to'] = (string) get_parameter('date_to');
|
||||
$execution_type = $filter_params['execution_type'] = (string) get_parameter('execution_type');
|
||||
$show_archived = $filter_params['archived'] = (bool) get_parameter('archived');
|
||||
$agent_id = $filter_params['agent_id'] = (int) get_parameter('agent_id');
|
||||
$agent_name = $filter_params['agent_name'] = (string) (!empty($agent_id) ? get_parameter('agent_name') : '');
|
||||
$module_id = $filter_params['module_id'] = (int) get_parameter('module_name_hidden');
|
||||
$module_name = $filter_params['module_name'] = (string) (!empty($module_id) ? get_parameter('module_name') : '');
|
||||
$search_text = (string) get_parameter('search_text');
|
||||
$date_from = (string) get_parameter('date_from');
|
||||
$date_to = (string) get_parameter('date_to');
|
||||
$execution_type = (string) get_parameter('execution_type');
|
||||
$show_archived = (bool) get_parameter('archived');
|
||||
$agent_id = (int) get_parameter('agent_id');
|
||||
$agent_name = (string) ((empty($agent_id) === false) ? get_parameter('agent_name') : '');
|
||||
$module_id = (int) get_parameter('module_name_hidden');
|
||||
$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);
|
||||
|
||||
|
@ -141,11 +281,32 @@ $table_form->data = [];
|
|||
$row = [];
|
||||
|
||||
// Search text.
|
||||
$row[] = __('Search').' '.html_print_input_text('search_text', $search_text, '', 50, 250, true);
|
||||
$row[] = __('Search').' '.html_print_input_text(
|
||||
'search_text',
|
||||
$search_text,
|
||||
'',
|
||||
50,
|
||||
250,
|
||||
true
|
||||
);
|
||||
// Dates.
|
||||
$date_inputs = __('From').' '.html_print_input_text('date_from', $date_from, '', 10, 10, true);
|
||||
$date_inputs = __('From').' '.html_print_input_text(
|
||||
'date_from',
|
||||
$date_from,
|
||||
'',
|
||||
10,
|
||||
10,
|
||||
true
|
||||
);
|
||||
$date_inputs .= ' ';
|
||||
$date_inputs .= __('To').' '.html_print_input_text('date_to', $date_to, '', 10, 10, true);
|
||||
$date_inputs .= __('To').' '.html_print_input_text(
|
||||
'date_to',
|
||||
$date_to,
|
||||
'',
|
||||
10,
|
||||
10,
|
||||
true
|
||||
);
|
||||
$row[] = $date_inputs;
|
||||
|
||||
$table_form->data[] = $row;
|
||||
|
@ -157,9 +318,24 @@ $execution_type_fields = [
|
|||
'once' => __('Once'),
|
||||
'periodically' => __('Periodically'),
|
||||
];
|
||||
$row[] = __('Execution type').' '.html_print_select($execution_type_fields, 'execution_type', $execution_type, '', __('Any'), '', true, false, false);
|
||||
$row[] = __('Execution type').' '.html_print_select(
|
||||
$execution_type_fields,
|
||||
'execution_type',
|
||||
$execution_type,
|
||||
'',
|
||||
__('Any'),
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
// Show past downtimes.
|
||||
$row[] = __('Show past downtimes').' '.html_print_checkbox('archived', 1, $show_archived, true);
|
||||
$row[] = __('Show past downtimes').' '.html_print_checkbox(
|
||||
'archived',
|
||||
1,
|
||||
$show_archived,
|
||||
true
|
||||
);
|
||||
|
||||
$table_form->data[] = $row;
|
||||
|
||||
|
@ -178,48 +354,84 @@ $agent_input = __('Agent').' '.ui_print_agent_autocomplete_input($params);
|
|||
$row[] = $agent_input;
|
||||
|
||||
// Module.
|
||||
$row[] = __('Module').' '.html_print_autocomplete_modules('module_name', $module_name, false, true, '', [], true);
|
||||
$row[] = __('Module').' '.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;
|
||||
// End of table filter.
|
||||
// Useful to know if the user has done a form filtering.
|
||||
$filter_performed = false;
|
||||
|
||||
$downtimes = [];
|
||||
$groups = users_get_groups(false, $access);
|
||||
if (!empty($groups)) {
|
||||
if (empty($groups) === false) {
|
||||
$where_values = '1=1';
|
||||
|
||||
$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.
|
||||
if (!empty($search_text)) {
|
||||
if (empty($search_text) === false) {
|
||||
$filter_performed = true;
|
||||
|
||||
$where_values .= " AND (name LIKE '%$search_text%' OR description LIKE '%$search_text%')";
|
||||
$where_values .= sprintf(
|
||||
' AND (name LIKE "%%%s%%" OR description LIKE "%%%s%%")',
|
||||
$search_text,
|
||||
$search_text
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($execution_type)) {
|
||||
if (empty($execution_type) === false) {
|
||||
$filter_performed = true;
|
||||
|
||||
$where_values .= " AND type_execution = '$execution_type'";
|
||||
$where_values .= sprintf(' AND type_execution = "%s"', $execution_type);
|
||||
}
|
||||
|
||||
if (!empty($date_from)) {
|
||||
if (empty($date_from) === false) {
|
||||
$filter_performed = true;
|
||||
|
||||
$where_values .= " AND (type_execution = 'periodically' OR (type_execution = 'once' AND date_from >= '".strtotime("$date_from 00:00:00")."'))";
|
||||
$where_values .= sprintf(
|
||||
' 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;
|
||||
|
||||
$periodically_monthly_w = "type_periodicity = 'monthly'
|
||||
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
|
||||
AND (periodically_day_from <= '".date('d', strtotime($date_from))."' OR periodically_day_to >= '".date('d', strtotime($date_to))."')))";
|
||||
$periodically_monthly_w = sprintf(
|
||||
'type_periodicity = "monthly" AND (
|
||||
(
|
||||
periodically_day_from <= "%s"
|
||||
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 = [];
|
||||
$date_from_aux = strtotime($date_from);
|
||||
|
@ -229,7 +441,7 @@ if (!empty($groups)) {
|
|||
while ($date_from_aux <= $date_end && $days_number < 7) {
|
||||
$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);
|
||||
$days_number++;
|
||||
|
@ -237,36 +449,60 @@ if (!empty($groups)) {
|
|||
|
||||
$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;
|
||||
|
||||
$where_values .= " AND (type_execution = 'periodically' OR (type_execution = 'once' AND date_to >= '".time()."'))";
|
||||
$where_values .= sprintf(
|
||||
' 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;
|
||||
|
||||
$where_values .= " AND id IN (SELECT id_downtime FROM tplanned_downtime_agents WHERE id_agent = $agent_id)";
|
||||
$where_values .= sprintf(
|
||||
' 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;
|
||||
|
||||
$where_values .= " AND (id IN (SELECT id_downtime
|
||||
FROM tplanned_downtime_modules
|
||||
WHERE id_agent_module = $module_id)
|
||||
OR id IN (SELECT id_downtime
|
||||
FROM tplanned_downtime_agents tpda, tagente_modulo tam
|
||||
WHERE tpda.id_agent = tam.id_agente
|
||||
AND tam.id_agente_modulo = $module_id
|
||||
AND tpda.all_modules = 1))";
|
||||
$where_values .= sprintf(
|
||||
' AND (id IN (
|
||||
SELECT id_downtime
|
||||
FROM tplanned_downtime_modules
|
||||
WHERE id_agent_module = %d)
|
||||
OR id IN (
|
||||
SELECT id_downtime
|
||||
FROM tplanned_downtime_agents tpda, tagente_modulo tam
|
||||
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.
|
||||
|
@ -296,68 +532,41 @@ if (!empty($groups)) {
|
|||
'id_user',
|
||||
];
|
||||
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
$columns_str = implode(',', $columns);
|
||||
$sql = "SELECT $columns_str
|
||||
FROM tplanned_downtime
|
||||
WHERE $where_values
|
||||
ORDER BY type_execution DESC, date_from DESC
|
||||
LIMIT ".$config['block_size']."
|
||||
OFFSET $offset";
|
||||
break;
|
||||
$columns_str = implode(',', $columns);
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
FROM tplanned_downtime
|
||||
WHERE %s
|
||||
ORDER BY type_execution DESC, date_from DESC
|
||||
LIMIT %d
|
||||
OFFSET %d',
|
||||
$columns_str,
|
||||
$where_values,
|
||||
$config['block_size'],
|
||||
$offset
|
||||
);
|
||||
|
||||
case 'oracle':
|
||||
// Oracle doesn't have TIME type, so we should transform the DATE value
|
||||
$new_time_from = "TO_CHAR(periodically_time_from, 'HH24:MI:SS') AS periodically_time_from";
|
||||
$new_time_to = "TO_CHAR(periodically_time_to, 'HH24:MI:SS') AS periodically_time_to";
|
||||
|
||||
$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";
|
||||
$sql_count = sprintf(
|
||||
'SELECT COUNT(id) AS num
|
||||
FROM tplanned_downtime
|
||||
WHERE %s',
|
||||
$where_values
|
||||
);
|
||||
|
||||
$downtimes = db_get_all_rows_sql($sql);
|
||||
$downtimes_number_res = db_get_all_rows_sql($sql_count);
|
||||
$downtimes_number = $downtimes_number_res != false ? $downtimes_number_res[0]['num'] : 0;
|
||||
} else {
|
||||
$downtimes = [];
|
||||
$downtimes_number = ($downtimes_number_res !== false) ? $downtimes_number_res[0]['num'] : 0;
|
||||
}
|
||||
|
||||
$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.
|
||||
if (!$downtimes && !$filter_performed) {
|
||||
if ($downtimes === false && $filter_performed === false) {
|
||||
include_once $config['homedir'].'/general/first_task/planned_downtime.php';
|
||||
}
|
||||
// No downtimes cause the user performed a search.
|
||||
else if (!$downtimes) {
|
||||
} else if ($downtimes === false) {
|
||||
// No downtimes cause the user performed a search.
|
||||
// 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);
|
||||
echo '</form>';
|
||||
|
||||
|
@ -367,22 +576,25 @@ else if (!$downtimes) {
|
|||
echo '<div class="action-buttons w100p" >';
|
||||
|
||||
// Create button.
|
||||
if ($write_permisson) {
|
||||
if ($write_permisson === true) {
|
||||
echo ' ';
|
||||
echo '<form method="post" class="display_in" action="index.php?sec=extensions&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"');
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
// Has downtimes.
|
||||
else {
|
||||
echo "<form method='post' action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'>";
|
||||
} else {
|
||||
// Has downtimes.
|
||||
echo '<form method="post" action="'.$url_list.'">';
|
||||
html_print_table($table_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.
|
||||
$groupsAD = users_get_groups($config['id_user'], $access);
|
||||
|
@ -402,8 +614,11 @@ else {
|
|||
$table->head['execution'] = __('Execution');
|
||||
$table->head['configuration'] = __('Configuration');
|
||||
$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['copy'] = __('Copy');
|
||||
$table->head['edit'] = __('Edit');
|
||||
|
@ -414,7 +629,9 @@ else {
|
|||
$table->align['group'] = 'center';
|
||||
$table->align['running'] = 'center';
|
||||
|
||||
if ($write_permisson || $manage_permisson) {
|
||||
if ($write_permisson === true
|
||||
|| $manage_permisson === true
|
||||
) {
|
||||
$table->align['stop'] = 'center';
|
||||
$table->align['edit'] = 'center';
|
||||
$table->align['delete'] = 'center';
|
||||
|
@ -430,7 +647,7 @@ else {
|
|||
WHERE id_downtime = '.$downtime['id']
|
||||
);
|
||||
|
||||
$data['name'] = $downtime['name']." ($total)";
|
||||
$data['name'] = $downtime['name'].' ('.$total.')';
|
||||
$data['description'] = $downtime['description'];
|
||||
$data['group'] = ui_print_group_icon($downtime['id_group'], true);
|
||||
|
||||
|
@ -451,7 +668,7 @@ else {
|
|||
|
||||
$data['configuration'] = reporting_format_planned_downtime_dates($downtime);
|
||||
|
||||
if ($downtime['executed'] == 0) {
|
||||
if ((int) $downtime['executed'] === 0) {
|
||||
$data['running'] = html_print_image(
|
||||
'images/pixel_red.png',
|
||||
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 (in_array($downtime['id_group'], $groupsAD)) {
|
||||
// Stop button
|
||||
if ($downtime['type_execution'] == 'once' && $downtime['executed'] == 1) {
|
||||
if (check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW')
|
||||
|| check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD')
|
||||
if (in_array($downtime['id_group'], $groupsAD) === true) {
|
||||
// Stop button.
|
||||
if ($downtime['type_execution'] === 'once'
|
||||
&& (int) $downtime['executed'] === 1
|
||||
) {
|
||||
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 {
|
||||
$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 {
|
||||
$data['stop'] = '';
|
||||
}
|
||||
|
||||
// Edit & delete buttons.
|
||||
if ($downtime['executed'] == 0) {
|
||||
if (check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW')
|
||||
|| check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD')
|
||||
if ((int) $downtime['executed'] === 0) {
|
||||
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.
|
||||
$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.
|
||||
$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.
|
||||
$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 {
|
||||
$data['edit'] = '';
|
||||
$data['delete'] = '';
|
||||
}
|
||||
} else if ($downtime['executed'] == 1 && $downtime['type_execution'] == 'once') {
|
||||
if (check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW')
|
||||
|| check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD')
|
||||
} else if ((int) $downtime['executed'] === 1
|
||||
&& $downtime['type_execution'] === 'once'
|
||||
) {
|
||||
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.
|
||||
$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.
|
||||
$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.
|
||||
$data['delete'] = __('N/A');
|
||||
} else {
|
||||
|
@ -529,7 +826,9 @@ else {
|
|||
$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);
|
||||
$table->cellstyle[$next_row_num][0] = 'color: red';
|
||||
$table->cellstyle[$next_row_num][1] = 'color: red';
|
||||
|
@ -542,7 +841,17 @@ else {
|
|||
}
|
||||
|
||||
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.'">';
|
||||
|
||||
// CSV export button.
|
||||
|
@ -551,32 +860,44 @@ else {
|
|||
__('Export to CSV'),
|
||||
'csv_export',
|
||||
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"'
|
||||
);
|
||||
echo '</div>';
|
||||
|
||||
// Create button.
|
||||
if ($write_permisson) {
|
||||
if ($write_permisson === true) {
|
||||
echo ' ';
|
||||
echo '<form method="post" action="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor" class="display_in" >';
|
||||
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
|
||||
echo '<form method="post" action="'.$url_editor.'" class="display_in" >';
|
||||
html_print_submit_button(
|
||||
__('Create'),
|
||||
'create',
|
||||
false,
|
||||
'class="sub next"'
|
||||
);
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
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">
|
||||
|
||||
$("input[name=module_name_hidden]").val(<?php echo (int) $module_id; ?>);
|
||||
|
||||
$(document).ready (function () {
|
||||
$("#text-date_from, #text-date_to").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
|
||||
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
|
||||
$("#text-date_from, #text-date_to")
|
||||
.datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
|
||||
|
||||
$.datepicker
|
||||
.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
|
||||
|
||||
$("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'); ?>")) {
|
||||
|
|
|
@ -61,50 +61,7 @@ if (defined('LAST_STEP') === false) {
|
|||
}
|
||||
|
||||
// Default events calendar.
|
||||
$default_events_calendar = [
|
||||
'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',
|
||||
],
|
||||
],
|
||||
];
|
||||
$default_events_calendar = default_events_calendar($id, 'talert_templates');
|
||||
|
||||
if ($duplicate_template === true) {
|
||||
$source_id = (int) get_parameter('source_id');
|
||||
|
@ -370,7 +327,12 @@ function update_template($step)
|
|||
|
||||
$result = alerts_update_alert_template($id, $values);
|
||||
} 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');
|
||||
$threshold = (int) get_parameter('threshold');
|
||||
$max_alerts = (int) get_parameter('max_alerts');
|
||||
|
@ -389,12 +351,7 @@ function update_template($step)
|
|||
}
|
||||
|
||||
$values = [
|
||||
'schedule' => json_encode(
|
||||
json_decode(
|
||||
io_safe_output($schedule),
|
||||
true
|
||||
)
|
||||
),
|
||||
'schedule' => $schedule,
|
||||
'special_day' => $special_day,
|
||||
'time_threshold' => $threshold,
|
||||
'id_alert_action' => $default_action,
|
||||
|
@ -485,7 +442,6 @@ $type = '';
|
|||
$value = '';
|
||||
$max = '';
|
||||
$min = '';
|
||||
|
||||
$schedule = json_encode(
|
||||
$default_events_calendar
|
||||
);
|
||||
|
@ -614,7 +570,9 @@ if ($id && ! $create_template) {
|
|||
$min = $template['min_value'];
|
||||
$matches = $template['matches_value'];
|
||||
|
||||
$schedule = $template['schedule'];
|
||||
$schedule = json_encode(
|
||||
$default_events_calendar
|
||||
);
|
||||
$special_day = (int) $template['special_day'];
|
||||
$max_alerts = $template['max_alerts'];
|
||||
$min_alerts = $template['min_alerts'];
|
||||
|
|
|
@ -90,6 +90,8 @@ $data[1] = html_print_input_text(
|
|||
'',
|
||||
50,
|
||||
255,
|
||||
true,
|
||||
false,
|
||||
true
|
||||
);
|
||||
$data[1] .= html_print_input_hidden('id_response', $event_response['id'], true);
|
||||
|
|
|
@ -218,14 +218,9 @@ if ($update_agents) {
|
|||
$old_interval_value = db_get_value_filter('intervalo', 'tagente', ['id_agente' => $id_agent]);
|
||||
|
||||
if (!empty($values)) {
|
||||
$group_old = false;
|
||||
$disabled_old = false;
|
||||
if ($values['id_grupo'] || isset($values['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'])) {
|
||||
$disabled_old = $values_old['disabled'];
|
||||
}
|
||||
|
@ -274,74 +269,6 @@ if ($update_agents) {
|
|||
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 = [];
|
||||
|
|
|
@ -4004,23 +4004,23 @@ function print_SLA_list($width, $action, $idItem=null)
|
|||
],
|
||||
]
|
||||
);
|
||||
if (!empty($services_tmp)
|
||||
&& $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
|
||||
if (!empty($services_tmp)
|
||||
&& $services_tmp != ENTERPRISE_NOT_HOOK
|
||||
) {
|
||||
$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 html_print_select(
|
||||
|
|
|
@ -938,7 +938,7 @@ switch ($action) {
|
|||
$table->head[$next] = __('Private');
|
||||
$table->headstyle[$next] = 'min-width: 40px;text-align: left;';
|
||||
$table->size[$next] = '2%';
|
||||
if (defined('METACONSOLE')) {
|
||||
if (is_metaconsole() === true) {
|
||||
$table->align[$next] = '';
|
||||
} else {
|
||||
$table->align[$next] = 'left';
|
||||
|
@ -952,7 +952,7 @@ switch ($action) {
|
|||
|
||||
$next++;
|
||||
$op_column = false;
|
||||
if (!defined('METACONSOLE')) {
|
||||
if (is_metaconsole() === false) {
|
||||
$op_column = true;
|
||||
$table->head[$next] = '<span title="Operations">'.__('Op.').'</span>'.html_print_checkbox(
|
||||
'all_delete',
|
||||
|
@ -967,6 +967,8 @@ switch ($action) {
|
|||
// $table->size = array ();
|
||||
$table->size[$next] = '10%';
|
||||
$table->align[$next] = 'right';
|
||||
} else {
|
||||
$table->size[1] = '40%';
|
||||
}
|
||||
|
||||
$columnview = false;
|
||||
|
@ -1266,7 +1268,7 @@ switch ($action) {
|
|||
|| 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.'">';
|
||||
if (defined('METACONSOLE')) {
|
||||
if (is_metaconsole() === true) {
|
||||
echo '<div class="action-buttons w100p">';
|
||||
} else {
|
||||
echo '<div class="action-buttons w100p">';
|
||||
|
|
|
@ -289,11 +289,16 @@ if (is_array($config) === true
|
|||
&& (bool) $config['history_db_enabled'] === true
|
||||
) {
|
||||
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(
|
||||
$config['history_db_host'],
|
||||
$config['history_db_name'],
|
||||
$config['history_db_user'],
|
||||
io_output_password($config['history_db_pass']),
|
||||
$password,
|
||||
$config['history_db_port']
|
||||
);
|
||||
ob_get_clean();
|
||||
|
@ -312,6 +317,11 @@ $insecure = false;
|
|||
$pandora_url = ui_get_full_url('godmode/um_client', false, false, false);
|
||||
|
||||
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) {
|
||||
$config['secure_update_manager'] = null;
|
||||
}
|
||||
|
@ -425,6 +435,7 @@ $ui = new Manager(
|
|||
'remote_config' => $remote_config,
|
||||
'propagate_updates' => $is_metaconsole,
|
||||
'proxy' => $proxy,
|
||||
'allowOfflinePatches' => $allowOfflinePatches,
|
||||
'set_maintenance_mode' => function () {
|
||||
if (function_exists('config_update_value') === true) {
|
||||
config_update_value('maintenance_mode', 1);
|
||||
|
|
|
@ -84,6 +84,13 @@ class Manager
|
|||
*/
|
||||
private $authCode;
|
||||
|
||||
/**
|
||||
* Allow install offline packages not following current version.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $allowOfflinePatches = false;
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
|
@ -144,6 +151,10 @@ class Manager
|
|||
$settings['offline'] = true;
|
||||
}
|
||||
|
||||
if (isset($settings['allowOfflinePatches']) === true) {
|
||||
$this->allowOfflinePatches = (bool) $settings['allowOfflinePatches'];
|
||||
}
|
||||
|
||||
$this->umc = new Client($settings);
|
||||
}
|
||||
|
||||
|
@ -228,18 +239,19 @@ class Manager
|
|||
View::render(
|
||||
'offline',
|
||||
[
|
||||
'version' => $this->umc->getVersion(),
|
||||
'mr' => $this->umc->getMR(),
|
||||
'error' => $this->umc->getLastError(),
|
||||
'asset' => function ($rp) {
|
||||
'version' => $this->umc->getVersion(),
|
||||
'mr' => $this->umc->getMR(),
|
||||
'error' => $this->umc->getLastError(),
|
||||
'asset' => function ($rp) {
|
||||
echo $this->getUrl($rp);
|
||||
},
|
||||
'authCode' => $this->authCode,
|
||||
'ajax' => $this->ajaxUrl,
|
||||
'ajaxPage' => $this->ajaxPage,
|
||||
'progress' => $this->umc->getUpdateProgress(),
|
||||
'running' => $this->umc->isRunning(),
|
||||
'insecure' => $this->umc->isInsecure(),
|
||||
'authCode' => $this->authCode,
|
||||
'ajax' => $this->ajaxUrl,
|
||||
'ajaxPage' => $this->ajaxPage,
|
||||
'progress' => $this->umc->getUpdateProgress(),
|
||||
'running' => $this->umc->isRunning(),
|
||||
'insecure' => $this->umc->isInsecure(),
|
||||
'allowOfflinePatches' => $this->allowOfflinePatches,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* exported form_upload */
|
||||
/* global $,ajax,cleanExit,preventExit,umConfirm,umErrorMsg */
|
||||
/* global texts,ajaxPage,insecureMode */
|
||||
/* global ImSureWhatImDoing */
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -204,7 +205,9 @@ function form_upload(url, auth, current_package) {
|
|||
|
||||
let number_update = res.version;
|
||||
let server_update = res.server_update;
|
||||
let current_version = parseFloat(current_package);
|
||||
let target_version = Math.round(parseFloat(current_package)) + 1;
|
||||
let target_patch = parseFloat(current_package) + 0.1;
|
||||
|
||||
if (number_update === null) {
|
||||
umConfirm({
|
||||
|
@ -221,7 +224,31 @@ function form_upload(url, auth, current_package) {
|
|||
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({
|
||||
message:
|
||||
'<span class="warning"></span><p>' +
|
||||
|
|
|
@ -181,7 +181,7 @@ class ClientTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
// Load the conf.
|
||||
try {
|
||||
$this->conf = new \Config('client/conf/test.ini');
|
||||
$this->conf = new \Config(__DIR__.'/../conf/test.ini');
|
||||
} catch (\Exception $e) {
|
||||
$this->fail($e->getMessage());
|
||||
}
|
||||
|
|
|
@ -83,7 +83,9 @@
|
|||
'fileList': "<?php echo __('Files included in this package'); ?>",
|
||||
'ignoresign': "<?php echo __('Ignore'); ?>",
|
||||
'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'; ?>;
|
||||
|
@ -96,4 +98,6 @@
|
|||
);
|
||||
}
|
||||
|
||||
var ImSureWhatImDoing = <?php echo (false === $allowOfflinePatches) ? 'false' : 'true'; ?>;
|
||||
|
||||
</script>
|
||||
|
|
|
@ -93,6 +93,10 @@ if (!$action_update_url_update_manager) {
|
|||
'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) {
|
||||
$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()) {
|
||||
$result = config_update_value(
|
||||
'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_user = get_parameter('update_manager_proxy_user', '');
|
||||
$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) {
|
||||
|
@ -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()) {
|
||||
$result = config_update_value('identification_reminder', $identification_reminder);
|
||||
}
|
||||
|
@ -288,33 +307,39 @@ $table->data[5][1] = html_print_input_password(
|
|||
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[6][1] = '<i>'.$config['pandora_uid'].'</i>';
|
||||
$table->data[7][0] = __('Registration ID:');
|
||||
$table->data[7][1] = '<i>'.$config['pandora_uid'].'</i>';
|
||||
|
||||
if (update_manager_verify_registration() === true && users_is_admin()) {
|
||||
$table->data[7][0] = __('Cancel registration:');
|
||||
$table->data[7][1] = '<a href="';
|
||||
$table->data[8][0] = __('Cancel registration:');
|
||||
$table->data[8][1] = '<a href="';
|
||||
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'
|
||||
);
|
||||
} 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'
|
||||
);
|
||||
}
|
||||
|
||||
$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()) {
|
||||
$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[8][1] = __('Yes').' '.html_print_radio_button('identification_reminder', 1, '', $config['identification_reminder'], true).' ';
|
||||
$table->data[8][1] .= __('No').' '.html_print_radio_button('identification_reminder', 0, '', $config['identification_reminder'], 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[9][1] = __('Yes').' '.html_print_radio_button('identification_reminder', 1, '', $config['identification_reminder'], true).' ';
|
||||
$table->data[9][1] .= __('No').' '.html_print_radio_button('identification_reminder', 0, '', $config['identification_reminder'], true);
|
||||
}
|
||||
|
||||
html_print_input_hidden('action_update_url_update_manager', 1);
|
||||
|
|
|
@ -544,11 +544,6 @@ class AgentWizard extends HTML
|
|||
// Get the 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.
|
||||
if (isset($rows) === true && is_array($rows) === true) {
|
||||
foreach ($rows as $row) {
|
||||
|
|
|
@ -158,7 +158,9 @@ class CredentialStore extends Wizard
|
|||
// Check access.
|
||||
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(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access credential store'
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC220222';
|
||||
$build_version = 'PC220309';
|
||||
$pandora_version = 'v7.0NG.760';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
|
|
@ -1243,6 +1243,11 @@ function agents_get_group_agents(
|
|||
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) {
|
||||
$name = io_safe_input($search['name']);
|
||||
$filter[] = "nombre LIKE '$name'";
|
||||
|
@ -3223,8 +3228,8 @@ function agents_get_network_interfaces($agents=false, $agents_filter=false)
|
|||
$ni_by_agents = [];
|
||||
foreach ($agents as $agent) {
|
||||
$agent_id = (isset($agent['id_agente'])) ? $agent['id_agente'] : $agent;
|
||||
$agent_group_id = $agent['id_grupo'];
|
||||
$agent_name = $agent['alias'];
|
||||
$agent_group_id = (isset($agent['id_grupo']) === true) ? $agent['id_grupo'] : '';
|
||||
$agent_name = (isset($agent['alias']) === true) ? $agent['alias'] : '';
|
||||
$agent_interfaces = [];
|
||||
|
||||
$accepted_module_types = [];
|
||||
|
|
|
@ -3395,3 +3395,120 @@ function alerts_get_templates_name_array($array_ids)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -1535,10 +1535,6 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3)
|
|||
'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(
|
||||
'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(
|
||||
|
@ -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(
|
||||
'tagente',
|
||||
$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);
|
||||
}
|
||||
|
||||
$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.'",
|
||||
"IP":"'.$direccion_agente.'",
|
||||
"Group":"'.$grupo.'",
|
||||
|
|
|
@ -567,11 +567,7 @@ function groups_get_groups_tree_recursive($groups, $trash=0, $trash2=0)
|
|||
|
||||
$tree = $groups;
|
||||
foreach ($groups as $key => $group) {
|
||||
if ($group === __('None')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($group['id_grupo'] == 0) {
|
||||
if (is_array($group) === false || (int) $group['id_grupo'] === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -4936,7 +4936,13 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['modal']) === true) ? $data['modal'] : false),
|
||||
((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;
|
||||
|
||||
|
|
|
@ -989,7 +989,7 @@ function planned_downtimes_copy($id_downtime)
|
|||
foreach ($planned_modules as $planned_module) {
|
||||
// Unset id.
|
||||
unset($planned_module['id']);
|
||||
// Set id_planned downtime
|
||||
// Set id_planned downtime.
|
||||
$planned_module['id_downtime'] = $result['id_downtime'];
|
||||
$result['id_modules'][] = db_process_sql_insert(
|
||||
'tplanned_downtime_moduless',
|
||||
|
@ -1004,3 +1004,82 @@ function planned_downtimes_copy($id_downtime)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -3618,6 +3618,15 @@ function ui_print_datatable(array $parameters)
|
|||
ui_require_javascript_file('buttons.html5.min');
|
||||
ui_require_javascript_file('buttons.print.min');
|
||||
} 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.
|
||||
$output .= '<link rel="stylesheet" href="';
|
||||
$output .= ui_get_full_url(
|
||||
|
|
|
@ -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>";
|
||||
}
|
||||
});
|
||||
}
|
|
@ -389,7 +389,7 @@ ul li {
|
|||
|
||||
.button_collapse {
|
||||
margin-top: auto;
|
||||
height: 38px;
|
||||
min-height: 38px;
|
||||
background-color: #505050;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
|
@ -427,7 +427,6 @@ ul li {
|
|||
}
|
||||
|
||||
.button_classic {
|
||||
width: 215px;
|
||||
background-image: url(../../images/button_collapse_menu.png);
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
|
@ -440,7 +439,7 @@ ul li {
|
|||
}
|
||||
|
||||
/* Menu height: 601px, 720px, 735px */
|
||||
@media screen and (max-height: 720px) {
|
||||
@media screen and (max-height: 750px) {
|
||||
.menu li,
|
||||
.menu li a,
|
||||
.menu li div {
|
||||
|
@ -448,7 +447,7 @@ ul li {
|
|||
}
|
||||
}
|
||||
|
||||
@media screen and (max-height: 735px) {
|
||||
@media screen and (max-height: 750px) {
|
||||
.operation {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.760';
|
||||
$build = '220222';
|
||||
$build = '220309';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
|
|
@ -176,6 +176,7 @@ function load_agents_selector(group) {
|
|||
{
|
||||
"page" : "operation/agentes/ver_agente",
|
||||
"get_agents_group_json" : 1,
|
||||
"get_agents_also_interfaces" : 1,
|
||||
"id_group" : group,
|
||||
"privilege" : "AW",
|
||||
"keys_prefix" : "_",
|
||||
|
@ -216,6 +217,7 @@ $("#checkbox-recursion").change (function () {
|
|||
jQuery.post ("ajax.php",
|
||||
{"page" : "operation/agentes/ver_agente",
|
||||
"get_agents_group_json" : 1,
|
||||
"get_agents_also_interfaces" : 1,
|
||||
"id_group" : $("#group_id").val(),
|
||||
"privilege" : "AW",
|
||||
"keys_prefix" : "_",
|
||||
|
@ -226,7 +228,6 @@ $("#checkbox-recursion").change (function () {
|
|||
$("#module").html('');
|
||||
jQuery.each (data, function (id, value) {
|
||||
id = id.substring(1);
|
||||
|
||||
option = $("<option></option>")
|
||||
.attr ("value", value["id_agente"])
|
||||
.html (value["alias"]);
|
||||
|
|
|
@ -49,6 +49,7 @@ if (is_ajax()) {
|
|||
$get_agent_modules_json = (bool) get_parameter('get_agent_modules_json');
|
||||
$get_agent_status_tooltip = (bool) get_parameter('get_agent_status_tooltip');
|
||||
$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');
|
||||
$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');
|
||||
|
@ -103,15 +104,15 @@ if (is_ajax()) {
|
|||
// Build filter.
|
||||
$filter = [];
|
||||
|
||||
if (!empty($id_os)) {
|
||||
if (empty($id_os) === false) {
|
||||
$filter['id_os'] = $id_os;
|
||||
}
|
||||
|
||||
if (!empty($agent_name)) {
|
||||
if (empty($agent_name) === false) {
|
||||
$filter['nombre'] = '%'.$agent_name.'%';
|
||||
}
|
||||
|
||||
if (!empty($agent_alias)) {
|
||||
if (empty($agent_alias) === false) {
|
||||
$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.
|
||||
$agents = agents_get_group_agents(
|
||||
// Id_group.
|
||||
|
@ -171,7 +186,7 @@ if (is_ajax()) {
|
|||
(bool) is_metaconsole()
|
||||
);
|
||||
|
||||
if (empty($agents)) {
|
||||
if (empty($agents) === true) {
|
||||
$agents = [];
|
||||
}
|
||||
|
||||
|
|
|
@ -557,13 +557,13 @@ $table_ichanges = '<div class="autorefresh_select">
|
|||
</div>
|
||||
<div class="autorefresh_select_arrows" style="display:grid">
|
||||
<a href="javascript:">'.html_print_image(
|
||||
'images/darrowright_green.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'right_autorefreshlist',
|
||||
'alt' => __('Push selected pages into autorefresh list'),
|
||||
'title' => __('Push selected pages into autorefresh list'),
|
||||
]
|
||||
'images/darrowright_green.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'right_autorefreshlist',
|
||||
'alt' => __('Push selected pages into autorefresh list'),
|
||||
'title' => __('Push selected pages into autorefresh list'),
|
||||
]
|
||||
).'</a>
|
||||
<a href="javascript:">'.html_print_image(
|
||||
'images/darrowleft_green.png',
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.760
|
||||
%define release 220222
|
||||
%define release 220309
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.760
|
||||
%define release 220222
|
||||
%define release 220309
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.760
|
||||
%define release 220222
|
||||
%define release 220309
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
|
|
@ -605,10 +605,7 @@ CREATE TABLE IF NOT EXISTS `talert_special_days` (
|
|||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `talert_execution_queue` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_alert_template_module` INT UNSIGNED NOT NULL,
|
||||
`alert_mode` TINYINT NOT NULL,
|
||||
`data` MEDIUMTEXT,
|
||||
`extra_macros` TEXT,
|
||||
`data` LONGTEXT,
|
||||
`utimestamp` BIGINT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
@ -2583,6 +2580,21 @@ CREATE TABLE IF NOT EXISTS `tpolicy_groups` (
|
|||
UNIQUE (`id_policy`, `id_group`)
|
||||
) 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`
|
||||
-- ---------------------------------------------------------------------
|
||||
|
|
|
@ -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 Informix 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 port 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 Loss','Measure packet loss in the network, using a flood ping (50 ping in 8 secons) and counting back missing packets. It should be zero on most cases. ',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 time\",\"help\":\"\",\"value\":\"8\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Target IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','You should check manually the packet loss of the network with a flood ping on targeted host (ping -c 100 -f xxxx). Aditionally, and due the major packet loss, probably you can see a simple ping failing here. Check your network equipment.','You should check manually the packet loss of the network with a flood ping on targeted host (ping -c 100 -f xxxx)','',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. total processes','Number of running processes in a Windows system.',11,34,0,0,300,0,'tasklist /NH | find /c /v ""','','','',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 space in C:','Free space available in C:',11,34,0,0,300,0,'powershell $obj=(Get-WmiObject -class "Win32_LogicalDisk" -namespace "root\CIMV2") ; $obj.FreeSpace[0] * 100 /$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 uptime','System uptime',43,36,0,0,300,0,'uptime |sed s/us\.*$//g | sed s/,\.*$//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 processes','Running processes',43,34,0,0,300,0,'ps elf | wc -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 system load','Current load (5 min)',43,34,0,0,300,0,'uptime | awk '{print $(NF-1)}' | tr -d ','','','','',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 available memory percent','Available memory %',43,34,0,0,300,0,'free | grep Mem | awk '{print $NF/$2 * 100}'','','','',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 available disk /','Available free space in mountpoint /',43,34,0,0,300,0,'df / | tail -n +2 | awk '{print $(NF-1)}' | tr -d '%'','','','',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`
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# ----------------------------------------------------------------------
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use strict;
|
||||
use Data::Dumper;
|
||||
|
|
|
@ -12,7 +12,7 @@ use NetAddr::IP;
|
|||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-server
|
||||
Version: 7.0NG.760-220222
|
||||
Version: 7.0NG.760-220309
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.760-220222"
|
||||
pandora_version="7.0NG.760-220309"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -24,7 +24,7 @@ use threads;
|
|||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
# Pandora Modules
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package PandoraFMS::AlertServer;
|
||||
##########################################################################
|
||||
################################################################################
|
||||
# Pandora FMS Alert Server.
|
||||
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
|
||||
##########################################################################
|
||||
################################################################################
|
||||
# Copyright (c) 2005-2021 Artica Soluciones Tecnologicas S.L
|
||||
#
|
||||
# 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
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##########################################################################
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
@ -24,6 +24,7 @@ use threads;
|
|||
use threads::shared;
|
||||
use Thread::Semaphore;
|
||||
|
||||
use MIME::Base64;
|
||||
use JSON;
|
||||
use POSIX qw(strftime);
|
||||
|
||||
|
@ -47,9 +48,9 @@ my $AlertSem :shared;
|
|||
my %Alerts :shared;
|
||||
my $EventRef :shared = 0;
|
||||
|
||||
########################################################################################
|
||||
################################################################################
|
||||
# Alert Server class constructor.
|
||||
########################################################################################
|
||||
################################################################################
|
||||
sub new ($$$) {
|
||||
my ($class, $config, $dbh) = @_;
|
||||
|
||||
|
@ -69,9 +70,9 @@ sub new ($$$) {
|
|||
return $self;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
################################################################################
|
||||
# Run.
|
||||
###############################################################################
|
||||
################################################################################
|
||||
sub run ($) {
|
||||
my $self = shift;
|
||||
my $pa_config = $self->getConfig ();
|
||||
|
@ -81,9 +82,9 @@ sub run ($) {
|
|||
$self->SUPER::run (\@TaskQueue, \%PendingTasks, $Sem, $TaskSem);
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
################################################################################
|
||||
# Data producer.
|
||||
###############################################################################
|
||||
################################################################################
|
||||
sub data_producer ($) {
|
||||
my $self = shift;
|
||||
my ($pa_config, $dbh) = ($self->getConfig (), $self->getDBH ());
|
||||
|
@ -120,14 +121,16 @@ sub data_producer ($) {
|
|||
return @tasks;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
################################################################################
|
||||
# Data consumer.
|
||||
###############################################################################
|
||||
################################################################################
|
||||
sub data_consumer ($$) {
|
||||
my ($self, $task_id) = @_;
|
||||
my ($pa_config, $dbh) = ($self->getConfig (), $self->getDBH ());
|
||||
|
||||
eval {{
|
||||
local $SIG{__DIE__};
|
||||
|
||||
# Get the alert from the queue.
|
||||
my $task = get_db_single_row ($dbh, 'SELECT * FROM talert_execution_queue WHERE id = ?', $task_id);
|
||||
if (! defined ($task)) {
|
||||
|
@ -135,42 +138,40 @@ sub data_consumer ($$) {
|
|||
last 0;
|
||||
}
|
||||
|
||||
# Get the alert data.
|
||||
my $alert = get_db_single_row ($dbh, 'SELECT talert_template_modules.id as id_template_module,
|
||||
talert_template_modules.*, talert_templates.*
|
||||
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 (! defined ($alert)) {
|
||||
logger($pa_config, "Alert ID " . $task->{'id_alert_template_module'} . " not found.", 10);
|
||||
last;
|
||||
my $args = PandoraFMS::Tools::p_decode_json(
|
||||
$pa_config,
|
||||
decode_base64($task->{'data'})
|
||||
);
|
||||
|
||||
if (ref $args ne "ARRAY") {
|
||||
die ('Invalid alert queued');
|
||||
}
|
||||
|
||||
# Get the agent and module associated with the alert
|
||||
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;
|
||||
}
|
||||
my @args = @{$args};
|
||||
|
||||
# Execute the alert.
|
||||
pandora_execute_alert ($pa_config, $task->{'data'}, $agent, $module, $alert, $task->{'alert_mode'},
|
||||
$dbh, strftime ("%Y-%m-%d %H:%M:%S", localtime()), 0, decode_json($task->{'extra_macros'}));
|
||||
# You cannot code a DBI object into JSON, use current.
|
||||
my $execution_args = [
|
||||
$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.
|
||||
db_do($dbh, 'DELETE FROM talert_execution_queue WHERE id=?', $task_id);
|
||||
alert_unlock($pa_config, $task_id);
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
################################################################################
|
||||
# Get a lock on the given alert. Return 1 on success, 0 otherwise.
|
||||
##########################################################################
|
||||
################################################################################
|
||||
sub alert_lock {
|
||||
my ($pa_config, $alert, $locked_alerts) = @_;
|
||||
|
||||
|
@ -186,9 +187,9 @@ sub alert_lock {
|
|||
return 1;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
################################################################################
|
||||
# Remove the lock on the given alert.
|
||||
##########################################################################
|
||||
################################################################################
|
||||
sub alert_unlock {
|
||||
my ($pa_config, $alert) = @_;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ use POSIX qw(strftime);
|
|||
use Time::Local;
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
@ -46,7 +46,7 @@ our @EXPORT = qw(
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.760";
|
||||
my $pandora_build = "220222";
|
||||
my $pandora_build = "220309";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
@ -1388,8 +1388,13 @@ sub pandora_start_log ($){
|
|||
|
||||
# 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";
|
||||
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'};
|
||||
|
||||
print STDERR strftime ("%Y-%m-%d %H:%M:%S", localtime()) . ' - ' . $pa_config->{'servername'} . " Starting " . pandora_get_initial_product_name() . " Server. Error logging activated.\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ if (!$@) {
|
|||
}
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::DB;
|
||||
use PandoraFMS::Config;
|
||||
|
@ -551,31 +551,48 @@ sub pandora_evaluate_alert ($$$$$$$;$$$$) {
|
|||
return $status if ($alert->{$DayNames[$wday]} != 1);
|
||||
}
|
||||
|
||||
my $schedule = PandoraFMS::Tools::p_decode_json($pa_config, $alert->{'schedule'});
|
||||
|
||||
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;
|
||||
}
|
||||
my $schedule;
|
||||
if (defined($alert->{'schedule'}) && $alert->{'schedule'} ne '') {
|
||||
$schedule = PandoraFMS::Tools::p_decode_json($pa_config, $alert->{'schedule'});
|
||||
}
|
||||
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
if ($pa_config->{'alertserver'} == 1 && defined ($alert->{'id_template_module'})) {
|
||||
pandora_queue_alert($pa_config, $dbh, $data, $alert, 0, $extra_macros);
|
||||
if ($pa_config->{'alertserver'} == 1) {
|
||||
pandora_queue_alert($pa_config, $dbh, [$data, $agent, $module,
|
||||
$alert, 0, $timestamp, 0, $extra_macros, $is_correlated_alert]);
|
||||
} 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;
|
||||
}
|
||||
|
@ -820,8 +839,9 @@ sub pandora_process_alert ($$$$$$$$;$$) {
|
|||
last_fired = ?, internal_counter = ? ' . $new_interval . ' WHERE id = ?',
|
||||
$alert->{'times_fired'}, $utimestamp, $alert->{'internal_counter'}, $id);
|
||||
|
||||
if ($pa_config->{'alertserver'} == 1 && defined ($alert->{'id_template_module'})) {
|
||||
pandora_queue_alert($pa_config, $dbh, $data, $alert, 1, $extra_macros);
|
||||
if ($pa_config->{'alertserver'} == 1) {
|
||||
pandora_queue_alert($pa_config, $dbh, [$data, $agent, $module,
|
||||
$alert, 1, $timestamp, 0, $extra_macros, $is_correlated_alert]);
|
||||
} else {
|
||||
pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 1,
|
||||
$dbh, $timestamp, 0, $extra_macros, $is_correlated_alert);
|
||||
|
@ -837,7 +857,7 @@ Execute the given alert.
|
|||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_execute_alert ($$$$$$$$$;$$) {
|
||||
sub pandora_execute_alert {
|
||||
my ($pa_config, $data, $agent, $module,
|
||||
$alert, $alert_mode, $dbh, $timestamp, $forced_alert,
|
||||
$extra_macros, $is_correlated_alert) = @_;
|
||||
|
@ -1081,17 +1101,15 @@ Queue the given alert for execution.
|
|||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_queue_alert ($$$$$;$) {
|
||||
my ($pa_config, $dbh, $data, $alert, $alert_mode, $extra_macros) = @_;
|
||||
my $json_macros = '{}';
|
||||
sub pandora_queue_alert ($$$) {
|
||||
my ($pa_config, $dbh, $arguments) = @_;
|
||||
|
||||
eval {
|
||||
local $SIG{__DIE__};
|
||||
$json_macros = encode_json($extra_macros);
|
||||
};
|
||||
my $json_arguments = PandoraFMS::Tools::p_encode_json($pa_config, $arguments);
|
||||
|
||||
db_do ($dbh, "INSERT INTO talert_execution_queue (id_alert_template_module, data, alert_mode, extra_macros, utimestamp)
|
||||
VALUES (?, ?, ?, ?, ?)", $alert->{'id_template_module'}, $data, $alert_mode, $json_macros, time());
|
||||
$json_arguments = encode_base64($json_arguments);
|
||||
|
||||
db_do ($dbh, "INSERT INTO talert_execution_queue (data, utimestamp)
|
||||
VALUES (?, ?)", $json_arguments, time());
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
|
@ -5522,6 +5540,9 @@ sub pandora_process_policy_queue ($) {
|
|||
next;
|
||||
}
|
||||
|
||||
# Refresh policy agents.
|
||||
enterprise_hook('pandora_apply_policy_groups', [$pa_config, $dbh]);
|
||||
|
||||
my $operation = enterprise_hook('get_first_policy_queue', [$dbh]);
|
||||
next unless (defined ($operation) && $operation ne '');
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ use warnings;
|
|||
use DBI;
|
||||
use Carp qw/croak/;
|
||||
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
use PandoraFMS::Tools;
|
||||
|
||||
#use Data::Dumper;
|
||||
|
@ -555,6 +555,7 @@ sub get_agentmodule_status_str($$$) {
|
|||
FROM tagente_estado
|
||||
WHERE id_agente_modulo = ?', $agent_module_id);
|
||||
|
||||
return 'N/A' unless defined($status);
|
||||
return 'Normal' if ($status == 0);
|
||||
return 'Critical' if ($status == 1);
|
||||
return 'Warning' if ($status == 2);
|
||||
|
|
|
@ -41,7 +41,7 @@ use Encode::Locale ();
|
|||
use LWP::Simple;
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -33,7 +33,7 @@ use File::Basename qw(dirname);
|
|||
use File::Copy;
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -53,7 +53,7 @@ use warnings;
|
|||
use Geo::IP;
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::DB;
|
||||
use PandoraFMS::Tools;
|
||||
|
|
|
@ -30,7 +30,7 @@ use HTML::Entities;
|
|||
use POSIX qw(strftime);
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -11,7 +11,7 @@ use warnings;
|
|||
use File::Copy;
|
||||
use File::Basename qw(dirname basename);
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
use PandoraFMS::PluginTools qw/init read_configuration read_file empty trim/;
|
||||
|
||||
my $YAML = 0;
|
||||
|
@ -25,7 +25,7 @@ if ($@) {
|
|||
$YAML = 1;
|
||||
}
|
||||
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
our @ISA = ("Exporter");
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
|
||||
|
|
|
@ -30,7 +30,7 @@ use JSON qw(decode_json);
|
|||
use Encode qw(encode_utf8 decode_utf8);
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.760";
|
||||
my $pandora_build = "220222";
|
||||
my $pandora_build = "220309";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
|
|
@ -29,7 +29,7 @@ use Net::Ping;
|
|||
use POSIX qw(floor strftime);
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -26,7 +26,7 @@ use Thread::Semaphore;
|
|||
use Time::HiRes qw(usleep);
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::DB;
|
||||
use PandoraFMS::Core;
|
||||
|
|
|
@ -12,7 +12,7 @@ use IO::Socket::INET;
|
|||
use POSIX qw/ceil/;
|
||||
use Socket qw/inet_aton/;
|
||||
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::Recon::NmapParser;
|
||||
use PandoraFMS::Recon::Util;
|
||||
|
|
|
@ -7,7 +7,7 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
# Default lib dir for RPM and DEB packages.
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use Socket qw/inet_aton/;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ use XML::Simple;
|
|||
use Scalar::Util qw(looks_like_number);
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -25,7 +25,7 @@ use threads;
|
|||
use threads::shared;
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::DB;
|
||||
use PandoraFMS::Core;
|
||||
|
|
|
@ -34,7 +34,7 @@ use threads::shared;
|
|||
use JSON;
|
||||
use Encode qw/decode_utf8 encode_utf8/;
|
||||
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
use PandoraFMS::Sendmail;
|
||||
|
||||
# New in 3.2. Used to sendmail internally, without external scripts
|
||||
|
@ -126,6 +126,7 @@ our @EXPORT = qw(
|
|||
is_offline
|
||||
is_empty
|
||||
is_in_array
|
||||
array_diff
|
||||
add_hashes
|
||||
to_number
|
||||
clean_blank
|
||||
|
@ -868,6 +869,19 @@ sub is_in_array {
|
|||
return 0;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Check if a value is in an array
|
||||
################################################################################
|
||||
sub array_diff($$) {
|
||||
my ($a, $b) = @_;
|
||||
|
||||
my %diff;
|
||||
@diff{ @{$a} } = @{$a};
|
||||
delete @diff{ @{$b} };
|
||||
|
||||
return keys %diff;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Mix hashses
|
||||
################################################################################
|
||||
|
@ -1130,9 +1144,9 @@ sub enterprise_hook ($$) {
|
|||
my $output = eval { &$func (@args); };
|
||||
|
||||
# Discomment to debug.
|
||||
if ($@) {
|
||||
print STDERR $@;
|
||||
}
|
||||
#if ($@) {
|
||||
# print STDERR $@;
|
||||
#}
|
||||
|
||||
# Check for errors
|
||||
#return undef if ($@);
|
||||
|
@ -2640,7 +2654,7 @@ sub p_encode_json {
|
|||
};
|
||||
if ($@){
|
||||
if (defined($data)) {
|
||||
logger($pa_config, 'Failed to encode data: '.$@, 5);
|
||||
logger($pa_config, 'Failed to encode data: '.$@, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ use POSIX qw(strftime);
|
|||
use HTML::Entities;
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.760
|
||||
%define release 220222
|
||||
%define release 220309
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.760
|
||||
%define release 220222
|
||||
%define release 220309
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.760"
|
||||
PI_BUILD="220222"
|
||||
PI_BUILD="220309"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
|
|
@ -26,7 +26,7 @@ use POSIX qw(strftime);
|
|||
use Time::HiRes qw(usleep);
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Core;
|
||||
use PandoraFMS::Config;
|
||||
|
|
|
@ -13,7 +13,7 @@ use Sys::Hostname;
|
|||
use POSIX qw(strftime);
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ use POSIX qw(strftime);
|
|||
use Time::HiRes qw( clock_gettime clock ) ;
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -27,7 +27,7 @@ use File::Path qw(rmtree);
|
|||
use Time::HiRes qw(usleep);
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Core;
|
||||
use PandoraFMS::Tools;
|
||||
|
@ -35,7 +35,7 @@ use PandoraFMS::Config;
|
|||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.760 Build 220222";
|
||||
my $version = "7.0NG.760 Build 220309";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
@ -1032,11 +1032,61 @@ sub pandora_delete_old_session_data {
|
|||
db_do ($dbh, "DELETE FROM tsessions_php WHERE data IS NULL OR id_session REGEXP '^cron-'");
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Delete old data from the history database.
|
||||
###############################################################################
|
||||
sub pandoradb_history ($$) {
|
||||
my ($conf, $dbh) = @_;
|
||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime());
|
||||
my $ulimit_access_timestamp = time() - 86400;
|
||||
my $ulimit_timestamp = time() - (86400 * $conf->{'_days_purge'});
|
||||
|
||||
log_message ('', "Starting at ". strftime ("%Y-%m-%d %H:%M:%S", localtime()) . "\n");
|
||||
|
||||
# Delete old numeric data.
|
||||
if ($conf->{'_days_purge'} > 0) {
|
||||
pandora_delete_old_module_data ($dbh, 'tagente_datos', $ulimit_access_timestamp, $ulimit_timestamp);
|
||||
} else {
|
||||
log_message ('PURGE', 'days_purge is set to 0. Old data will not be deleted.');
|
||||
}
|
||||
|
||||
# Delete old string data.
|
||||
$conf->{'_string_purge'} = 7 unless defined($conf->{'_string_purge'});
|
||||
if ($conf->{'_string_purge'} > 0) {
|
||||
$ulimit_access_timestamp = time() - 86400;
|
||||
$ulimit_timestamp = time() - (86400 * $conf->{'_string_purge'});
|
||||
pandora_delete_old_module_data ($dbh, 'tagente_datos_string', $ulimit_access_timestamp, $ulimit_timestamp);
|
||||
} else {
|
||||
log_message ('PURGE', 'string_purge is set to 0. Old string data will not be deleted.');
|
||||
}
|
||||
|
||||
# Delete old events.
|
||||
if ($conf->{'_event_purge'} > 0) {
|
||||
log_message ('PURGE', "Deleting events older than " . $conf->{'_event_purge'} . " days from tevento.", '');
|
||||
|
||||
my $event_limit = time() - 86400 * $conf->{'_event_purge'};
|
||||
my $events_to_delete = get_db_value ($dbh, "SELECT COUNT(*) FROM tevento WHERE utimestamp < ?", $event_limit);
|
||||
while($events_to_delete > 0) {
|
||||
db_delete_limit($dbh, 'tevento', "utimestamp < ?", $BIG_OPERATION_STEP, $event_limit);
|
||||
$events_to_delete = $events_to_delete - $BIG_OPERATION_STEP;
|
||||
|
||||
# Mark the progress.
|
||||
log_message ('', ".");
|
||||
|
||||
# Do not overload the MySQL server.
|
||||
usleep (10000);
|
||||
}
|
||||
log_message ('', "\n");
|
||||
}
|
||||
|
||||
log_message ('', "Ending at ". strftime ("%Y-%m-%d %H:%M:%S", localtime()) . "\n");
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Main
|
||||
###############################################################################
|
||||
sub pandoradb_main ($$$;$) {
|
||||
my ($conf, $dbh, $history_dbh, $running_in_history) = @_;
|
||||
my ($conf, $dbh, $history_dbh) = @_;
|
||||
|
||||
log_message ('', "Starting at ". strftime ("%Y-%m-%d %H:%M:%S", localtime()) . "\n");
|
||||
|
||||
|
@ -1059,8 +1109,7 @@ sub pandoradb_main ($$$;$) {
|
|||
|
||||
# Only active database should be compacted. Disabled for historical database.
|
||||
# Compact on if enable and DaysCompact are below DaysPurge
|
||||
if (!$running_in_history
|
||||
&& ($conf->{'_onlypurge'} == 0)
|
||||
if (($conf->{'_onlypurge'} == 0)
|
||||
&& ($conf->{'_days_compact'} < $conf->{'_days_purge'})
|
||||
) {
|
||||
pandora_compactdb ($conf, defined ($history_dbh) ? $history_dbh : $dbh, $dbh);
|
||||
|
@ -1181,13 +1230,8 @@ if (defined($history_dbh)) {
|
|||
# Keep base settings.
|
||||
$h_conf->{'_onlypurge'} = $conf{'_onlypurge'};
|
||||
|
||||
# Re-launch maintenance process for historical database.
|
||||
pandoradb_main(
|
||||
$h_conf,
|
||||
$history_dbh,
|
||||
undef,
|
||||
1 # Disable certain funcionality while runningn in historical database.
|
||||
);
|
||||
# Launch maintenance process for historical database.
|
||||
pandoradb_history($h_conf, $history_dbh);
|
||||
|
||||
# Handle partitions.
|
||||
enterprise_hook('handle_partitions', [$h_conf, $history_dbh]);
|
||||
|
|
|
@ -35,7 +35,7 @@ use Math::Trig; # Math functions
|
|||
use Time::HiRes qw ( clock_gettime CLOCK_REALTIME);
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
# Pandora Modules
|
||||
use PandoraFMS::Config;
|
||||
|
|
|
@ -15,7 +15,7 @@ use threads::shared;
|
|||
use File::Path qw(rmtree);
|
||||
|
||||
# Default lib dir for Pandora FMS RPM and DEB packages.
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -24,7 +24,7 @@ use LWP::Simple;
|
|||
use Data::Dumper;
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
|||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.760 Build 220222";
|
||||
my $version = "7.0NG.760 Build 220309";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
|
|
@ -13,7 +13,7 @@ use JSON;
|
|||
use IO::Socket::INET;
|
||||
use File::Copy;
|
||||
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Config;
|
||||
use PandoraFMS::Tools;
|
||||
|
|
|
@ -18,7 +18,7 @@ use Data::Dumper;
|
|||
use JSON qw(encode_json);
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -18,7 +18,7 @@ use Data::Dumper;
|
|||
use JSON qw(encode_json);
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -10,7 +10,7 @@ use POSIX qw (strftime floor);
|
|||
use Sys::Hostname;
|
||||
use Time::HiRes qw(gettimeofday tv_interval);
|
||||
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
# Pandora Modules.
|
||||
use PandoraFMS::Config;
|
||||
|
|
|
@ -16,7 +16,7 @@ use POSIX;
|
|||
use HTML::Entities; # Encode or decode strings with HTML entities
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
|
@ -14,7 +14,7 @@ use strict;
|
|||
use LWP::Simple;
|
||||
use LWP::UserAgent;
|
||||
use MIME::Base64;
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
use PandoraFMS::Tools;
|
||||
|
||||
# Init
|
||||
|
|
|
@ -81,7 +81,7 @@ function pidof_pandora () {
|
|||
# in a "strech" term, ps aux don't report more than COLUMNS
|
||||
# characters and this will not work.
|
||||
COLUMNS=300
|
||||
PANDORA_PID=`ps aux | grep "$PANDORA_DAEMON $PANDORA_HOME" | grep -v grep | tail -1 | awk '{ print $2 }'`
|
||||
PANDORA_PID=`ps aux | grep "$PANDORA_DAEMON" | grep "$PANDORA_HOME" | grep -v grep | tail -1 | awk '{ print $2 }'`
|
||||
echo $PANDORA_PID
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ function pidof_pandora_ha () {
|
|||
# in a "strech" term, ps aux don't report more than COLUMNS
|
||||
# characters and this will not work.
|
||||
COLUMNS=300
|
||||
PANDORA_PID=`ps aux | grep "$PANDORA_HA -d -p $PID_DIR/pandora_ha.pid $PANDORA_HOME" | grep -v grep | tail -1 | awk '{ print $2 }'`
|
||||
PANDORA_PID=`ps aux | grep "$PANDORA_HA" | grep "$PANDORA_HOME" | grep -v grep | tail -1 | awk '{ print $2 }'`
|
||||
echo $PANDORA_PID
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use warnings;
|
|||
|
||||
use Net::SMPP;
|
||||
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
use PandoraFMS::PluginTools qw(read_configuration);
|
||||
|
||||
my $HELP =<<EO_H;
|
||||
|
|
|
@ -16,7 +16,7 @@ use POSIX;
|
|||
use HTML::Entities; # Encode or decode strings with HTML entities
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
BEGIN { push @INC, '/usr/lib/perl5'; }
|
||||
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue