mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 15:54:29 +02:00
Merge remote-tracking branch 'origin/develop' into ent-10485-fix-inconsistency-between-lag-calculation-on-server-and-cosole
This commit is contained in:
commit
c5b98a30aa
@ -9,7 +9,7 @@
|
||||
# RedHat 8.5
|
||||
|
||||
#Constants
|
||||
S_VERSION='202302081'
|
||||
S_VERSION='202302201'
|
||||
LOGFILE="/tmp/deploy-ext-db-$(date +%F).log"
|
||||
|
||||
|
||||
@ -275,6 +275,8 @@ EO_CONFIG_F
|
||||
if [ "$MYVER" -eq '80' ] ; then
|
||||
sed -i -e "/query_cache.*/ s/^#*/#/g" /etc/my.cnf
|
||||
sed -i -e "s/#skip-log-bin/skip-log-bin/g" /etc/my.cnf
|
||||
sed -i -e "s/character-set-server=utf8/character-set-server=utf8mb4/g" /etc/my.cnf
|
||||
|
||||
fi
|
||||
|
||||
execute_cmd "systemctl restart mysqld" "Configuring database engine"
|
||||
|
@ -4,6 +4,7 @@
|
||||
##############################################################################################################
|
||||
## Tested versions ##
|
||||
# Ubuntu 22.04.1
|
||||
# Ubuntu 22.04.2
|
||||
|
||||
#avoid promps
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
@ -16,7 +17,7 @@ PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
|
||||
WORKDIR=/opt/pandora/deploy
|
||||
|
||||
|
||||
S_VERSION='202302081'
|
||||
S_VERSION='202302201'
|
||||
LOGFILE="/tmp/deploy-ext-db-$(date +%F).log"
|
||||
rm -f $LOGFILE &> /dev/null # remove last log before start
|
||||
|
||||
@ -181,7 +182,7 @@ cat > /etc/mysql/my.cnf << EOF_DB
|
||||
[mysqld]
|
||||
datadir=/var/lib/mysql
|
||||
user=mysql
|
||||
character-set-server=utf8
|
||||
character-set-server=utf8mb4
|
||||
skip-character-set-client-handshake
|
||||
# Disabling symbolic-links is recommended to prevent assorted security risks
|
||||
symbolic-links=0
|
||||
@ -196,7 +197,7 @@ innodb_flush_log_at_trx_commit = 0
|
||||
innodb_flush_method = O_DIRECT
|
||||
innodb_log_file_size = 64M
|
||||
innodb_log_buffer_size = 16M
|
||||
innodb_io_capacity = 100
|
||||
innodb_io_capacity = 300
|
||||
thread_cache_size = 8
|
||||
thread_stack = 256K
|
||||
max_connections = 100
|
||||
|
@ -431,7 +431,7 @@ execute_cmd "curl -LSs --output pandorafms_agent_linux-7.0NG.noarch.rpm ${PANDOR
|
||||
execute_cmd "yum install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "installing PandoraFMS packages"
|
||||
|
||||
# Copy gotty utility
|
||||
execute_cmd "wget https://pandorafms.com/library/wp-content/uploads/2019/11/gotty_linux_amd64.tar.gz" 'Dowloading gotty util'
|
||||
execute_cmd "wget https://firefly.pandorafms.com/pandorafms/utils/gotty_linux_amd64.tar.gz" 'Dowloading gotty util'
|
||||
tar xvzf gotty_linux_amd64.tar.gz &>> $LOGFILE
|
||||
execute_cmd "mv gotty /usr/bin/" 'Installing gotty util'
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
## Tested versions ##
|
||||
# Centos 8.4, 8.5
|
||||
# Rocky 8.4, 8.5, 8.6, 8.7
|
||||
# Almalinuz 8.4, 8.5
|
||||
# Almalinux 8.4, 8.5
|
||||
# RedHat 8.5
|
||||
|
||||
#Constants
|
||||
@ -14,7 +14,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf
|
||||
PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
|
||||
|
||||
|
||||
S_VERSION='202301251'
|
||||
S_VERSION='202302201'
|
||||
LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
|
||||
|
||||
# define default variables
|
||||
@ -107,6 +107,17 @@ check_root_permissions () {
|
||||
fi
|
||||
}
|
||||
|
||||
installing_docker () {
|
||||
#Installing docker for debug
|
||||
echo "Start installig docker" &>> "$LOGFILE"
|
||||
dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo &>> "$LOGFILE"
|
||||
dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin &>> "$LOGFILE"
|
||||
systemctl disable --now docker &>> "$LOGFILE"
|
||||
systemctl disable docker.socket --now &>> "$LOGFILE"
|
||||
echo "End installig docker" &>> "$LOGFILE"
|
||||
}
|
||||
|
||||
|
||||
## Main
|
||||
echo "Starting PandoraFMS Community deployment EL8 ver. $S_VERSION"
|
||||
|
||||
@ -207,6 +218,7 @@ else
|
||||
execute_cmd "dnf config-manager --set-enabled powertools" "Configuring Powertools"
|
||||
fi
|
||||
|
||||
execute_cmd "installing_docker" "Installing Docker for debug"
|
||||
|
||||
#Installing wget
|
||||
execute_cmd "dnf install -y wget" "Installing wget"
|
||||
@ -454,7 +466,7 @@ innodb_flush_log_at_trx_commit = 0
|
||||
innodb_flush_method = O_DIRECT
|
||||
innodb_log_file_size = 64M
|
||||
innodb_log_buffer_size = 16M
|
||||
innodb_io_capacity = 100
|
||||
innodb_io_capacity = 300
|
||||
thread_cache_size = 8
|
||||
thread_stack = 256K
|
||||
max_connections = 100
|
||||
@ -483,6 +495,7 @@ EO_CONFIG_F
|
||||
if [ "$MYVER" -eq '80' ] ; then
|
||||
sed -i -e "/query_cache.*/ s/^#*/#/g" /etc/my.cnf
|
||||
sed -i -e "s/#skip-log-bin/skip-log-bin/g" /etc/my.cnf
|
||||
sed -i -e "s/character-set-server=utf8/character-set-server=utf8mb4/g" /etc/my.cnf
|
||||
fi
|
||||
|
||||
execute_cmd "systemctl restart mysqld" "Configuring database engine"
|
||||
@ -517,7 +530,7 @@ execute_cmd "curl -LSs --output pandorafms_agent_linux-7.0NG.noarch.rpm ${PANDOR
|
||||
execute_cmd "dnf install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "Installing Pandora FMS packages"
|
||||
|
||||
# Copy gotty utility
|
||||
execute_cmd "wget https://pandorafms.com/library/wp-content/uploads/2019/11/gotty_linux_amd64.tar.gz" 'Dowloading gotty util'
|
||||
execute_cmd "wget https://firefly.pandorafms.com/pandorafms/utils/gotty_linux_amd64.tar.gz" 'Dowloading gotty util'
|
||||
tar xvzf gotty_linux_amd64.tar.gz &>> $LOGFILE
|
||||
execute_cmd "mv gotty /usr/bin/" 'Installing gotty util'
|
||||
|
||||
@ -743,7 +756,7 @@ execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent"
|
||||
|
||||
cat > /etc/issue.net << EOF_banner
|
||||
|
||||
Welcome to Pandora FMS appliance on CentOS
|
||||
Welcome to Pandora FMS appliance on RHEL/Rocky Linux 8
|
||||
------------------------------------------
|
||||
Go to Public http://$ipplublic/pandora_console$to to login web console
|
||||
$(ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v "172.17.0.1" | awk '{print $2}' | awk -F '/' '{print "Go to Local http://"$1"/pandora_console to login web console"}')
|
||||
|
@ -4,6 +4,7 @@
|
||||
##############################################################################################################
|
||||
## Tested versions ##
|
||||
# Ubuntu 22.04.1
|
||||
# Ubuntu 22.04.2
|
||||
|
||||
#avoid promps
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
@ -16,7 +17,7 @@ PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
|
||||
WORKDIR=/opt/pandora/deploy
|
||||
|
||||
|
||||
S_VERSION='202301251'
|
||||
S_VERSION='202302201'
|
||||
LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
|
||||
rm -f $LOGFILE &> /dev/null # remove last log before start
|
||||
|
||||
@ -106,6 +107,21 @@ check_root_permissions () {
|
||||
fi
|
||||
}
|
||||
|
||||
installing_docker () {
|
||||
#Installing docker for debug
|
||||
echo "Start installig docker" &>> "$LOGFILE"
|
||||
mkdir -m 0755 -p /etc/apt/keyrings &>> "$LOGFILE"
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --yes --dearmor -o /etc/apt/keyrings/docker.gpg &>> "$LOGFILE"
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
|
||||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list &>> "$LOGFILE"
|
||||
apt update -y &>> "$LOGFILE"
|
||||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin &>> "$LOGFILE"
|
||||
systemctl disable docker --now &>> "$LOGFILE"
|
||||
systemctl disable docker.socket --now &>> "$LOGFILE"
|
||||
echo "End installig docker" &>> "$LOGFILE"
|
||||
}
|
||||
|
||||
## Main
|
||||
echo "Starting PandoraFMS Community deployment Ubuntu 22.04 ver. $S_VERSION"
|
||||
|
||||
@ -173,7 +189,7 @@ execute_cmd "cd $WORKDIR" "Moving to workdir: $WORKDIR"
|
||||
|
||||
## Install utils
|
||||
execute_cmd "apt update" "Updating repos"
|
||||
execute_cmd "apt install -y net-tools vim curl wget software-properties-common apt-transport-https" "Installing utils"
|
||||
execute_cmd "apt install -y net-tools vim curl wget software-properties-common apt-transport-https ca-certificates gnupg lsb-release" "Installing utils"
|
||||
|
||||
#Installing Apache and php-fpm
|
||||
[ -e "/etc/apt/sources.list.d/ondrej-ubuntu-php-jammy.list" ] || execute_cmd "add-apt-repository ppa:ondrej/php -y" "Enable ppa:ondrej/php repo"
|
||||
@ -221,7 +237,8 @@ systemctl restart php$PHPVER-fpm &>> "$LOGFILE"
|
||||
php$PHPVER-xml \
|
||||
php$PHPVER-yaml \
|
||||
libnet-telnet-perl \
|
||||
whois"
|
||||
whois \
|
||||
cron"
|
||||
execute_cmd "apt install -y $console_dependencies" "Installing Pandora FMS Console dependencies"
|
||||
|
||||
# Server dependencies
|
||||
@ -254,10 +271,13 @@ server_dependencies=" \
|
||||
libnet-telnet-perl \
|
||||
libjson-perl \
|
||||
libencode-perl \
|
||||
cron \
|
||||
libgeo-ip-perl \
|
||||
openjdk-8-jdk "
|
||||
execute_cmd "apt install -y $server_dependencies" "Installing Pandora FMS Server dependencies"
|
||||
|
||||
execute_cmd "installing_docker" "Installing Docker for debug"
|
||||
|
||||
# wmic and pandorawmic
|
||||
execute_cmd "curl -O https://firefly.artica.es/pandorafms/utils/bin/wmic" "Downloading wmic"
|
||||
execute_cmd "curl -O https://firefly.artica.es/pandorafms/utils/bin/pandorawmic" "Downloading pandorawmic"
|
||||
@ -393,7 +413,7 @@ cat > /etc/mysql/my.cnf << EOF_DB
|
||||
[mysqld]
|
||||
datadir=/var/lib/mysql
|
||||
user=mysql
|
||||
character-set-server=utf8
|
||||
character-set-server=utf8mb4
|
||||
skip-character-set-client-handshake
|
||||
# Disabling symbolic-links is recommended to prevent assorted security risks
|
||||
symbolic-links=0
|
||||
@ -408,7 +428,7 @@ innodb_flush_log_at_trx_commit = 0
|
||||
innodb_flush_method = O_DIRECT
|
||||
innodb_log_file_size = 64M
|
||||
innodb_log_buffer_size = 16M
|
||||
innodb_io_capacity = 100
|
||||
innodb_io_capacity = 300
|
||||
thread_cache_size = 8
|
||||
thread_stack = 256K
|
||||
max_connections = 100
|
||||
@ -477,7 +497,7 @@ check_cmd_status "Error installing PandoraFMS Agent"
|
||||
|
||||
# Copy gotty utility
|
||||
cd $WORKDIR &>> "$LOGFILE"
|
||||
execute_cmd "wget https://pandorafms.com/library/wp-content/uploads/2019/11/gotty_linux_amd64.tar.gz" 'Dowloading gotty util'
|
||||
execute_cmd "wget https://firefly.pandorafms.com/pandorafms/utils/gotty_linux_amd64.tar.gz" 'Dowloading gotty util'
|
||||
tar xvzf gotty_linux_amd64.tar.gz &>> $LOGFILE
|
||||
execute_cmd "mv gotty /usr/bin/" 'Installing gotty util'
|
||||
|
||||
@ -731,10 +751,15 @@ systemctl enable pandora_server &>> "$LOGFILE"
|
||||
execute_cmd "service tentacle_serverd start" "Starting Tentacle Server"
|
||||
systemctl enable tentacle_serverd &>> "$LOGFILE"
|
||||
|
||||
# Enabling condole cron
|
||||
# Enabling console cron
|
||||
execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron"
|
||||
echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab
|
||||
|
||||
# Enabling pandoradb cron
|
||||
execute_cmd "echo 'enabling pandoradb cron' >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS pandoradb cron"
|
||||
echo "@hourly root bash -c /etc/cron.hourly/pandora_db" >> /etc/crontab
|
||||
|
||||
|
||||
## Enabling agent adn configuring Agente
|
||||
sed -i "s/^remote_config.*$/remote_config 1/g" $PANDORA_AGENT_CONF &>> "$LOGFILE"
|
||||
execute_cmd "/etc/init.d/pandora_agent_daemon start" "Starting PandoraFSM Agent"
|
||||
@ -748,7 +773,7 @@ sed --follow-symlinks -i -e "s/^openssl_conf = openssl_init/#openssl_conf = open
|
||||
|
||||
cat > /etc/issue.net << EOF_banner
|
||||
|
||||
Welcome to Pandora FMS appliance on CentOS
|
||||
Welcome to Pandora FMS appliance on Ubuntu
|
||||
------------------------------------------
|
||||
Go to Public http://$ipplublic/pandora_console$to to login web console
|
||||
$(ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v "172.17.0.1" | awk '{print $2}' | awk -F '/' '{print "Go to Local http://"$1"/pandora_console to login web console"}')
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.769-230220
|
||||
Version: 7.0NG.769-230303
|
||||
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.769-230220"
|
||||
pandora_version="7.0NG.769-230303"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
@ -1023,7 +1023,7 @@ my $Sem = undef;
|
||||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.769';
|
||||
use constant AGENT_BUILD => '230220';
|
||||
use constant AGENT_BUILD => '230303';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
@ -4,7 +4,7 @@
|
||||
%global __os_install_post %{nil}
|
||||
%define name pandorafms_agent_linux
|
||||
%define version 7.0NG.769
|
||||
%define release 230220
|
||||
%define release 230303
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -4,7 +4,7 @@
|
||||
%global __os_install_post %{nil}
|
||||
%define name pandorafms_agent_linux
|
||||
%define version 7.0NG.769
|
||||
%define release 230220
|
||||
%define release 230303
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -10,7 +10,7 @@
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.769"
|
||||
PI_BUILD="230220"
|
||||
PI_BUILD="230303"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
||||
{}
|
||||
|
||||
Version
|
||||
{230220}
|
||||
{230303}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
||||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.769 Build 230220")
|
||||
#define PANDORA_VERSION ("7.0NG.769 Build 230303")
|
||||
|
||||
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.769(Build 230220))"
|
||||
VALUE "ProductVersion", "(7.0NG.769(Build 230303))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-console
|
||||
Version: 7.0NG.769-230220
|
||||
Version: 7.0NG.769-230303
|
||||
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.769-230220"
|
||||
pandora_version="7.0NG.769-230303"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
@ -227,7 +227,7 @@ function dbmgr_extension_main()
|
||||
'dbport' => $node->dbport(),
|
||||
'dbname' => $node->dbname(),
|
||||
'dbuser' => $node->dbuser(),
|
||||
'dbpass' => $node->dbpass(),
|
||||
'dbpass' => io_output_password($node->dbpass()),
|
||||
]
|
||||
);
|
||||
$error = '';
|
||||
|
30
pandora_console/extras/mr/62.sql
Normal file
30
pandora_console/extras/mr/62.sql
Normal file
@ -0,0 +1,30 @@
|
||||
START TRANSACTION;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tagent_filter` (
|
||||
`id_filter` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_name` VARCHAR(600) NOT NULL,
|
||||
`id_group_filter` INT NOT NULL DEFAULT 0,
|
||||
`group_id` INT NOT NULL DEFAULT 0,
|
||||
`recursion` TEXT,
|
||||
`status` INT NOT NULL DEFAULT -1,
|
||||
`search` TEXT,
|
||||
`id_os` INT NOT NULL DEFAULT 0,
|
||||
`policies` TEXT,
|
||||
`search_custom` TEXT,
|
||||
`ag_custom_fields` TEXT,
|
||||
PRIMARY KEY (`id_filter`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
CREATE TABLE `tevent_sound` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`name` TEXT NULL,
|
||||
`sound` TEXT NULL,
|
||||
`active` TINYINT NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE INDEX agente_modulo_estado ON tevento (estado, id_agentmodule);
|
||||
CREATE INDEX idx_disabled ON talert_template_modules (disabled);
|
||||
|
||||
INSERT INTO `treport_custom_sql` (`name`, `sql`) VALUES ('Agent safe mode not enable', 'select alias from tagente where safe_mode_module = 0');
|
||||
|
||||
COMMIT;
|
@ -359,6 +359,10 @@ if ($config['enterprise_installed']) {
|
||||
}
|
||||
|
||||
// CSRF validation.
|
||||
if (isset($_SESSION['csrf_code']) === true) {
|
||||
unset($_SESSION['csrf_code']);
|
||||
}
|
||||
|
||||
html_print_csrf_hidden();
|
||||
|
||||
echo '</form></div>';
|
||||
|
@ -89,8 +89,7 @@ $password_fields = [];
|
||||
|
||||
// If there are $macros, we create the form fields
|
||||
if (!empty($macros)) {
|
||||
$macros = json_decode($macros, true);
|
||||
|
||||
$macros = json_decode(io_safe_output($macros), true);
|
||||
foreach ($macros as $k => $m) {
|
||||
$data = [];
|
||||
$data[0] = $m['desc'];
|
||||
|
@ -391,7 +391,7 @@ foreach ($actions as $action) {
|
||||
|
||||
$data = [];
|
||||
|
||||
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&id='.$action['id'].'&pure='.$pure.'">'.$action['name'].'</a>';
|
||||
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&id='.$action['id'].'&pure='.$pure.'&offset='.$offset.'">'.$action['name'].'</a>';
|
||||
if ($action['id_group'] == 0 && $can_edit_all == false) {
|
||||
$data[0] .= ui_print_help_tip(__('You cannot edit this action, You don\'t have the permission to edit All group.'), true);
|
||||
}
|
||||
@ -467,7 +467,7 @@ if (isset($data)) {
|
||||
|
||||
if (is_management_allowed() === true) {
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&pure='.$pure.'">';
|
||||
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&pure='.$pure.'&offset='.$offset.'">';
|
||||
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
|
||||
html_print_input_hidden('create_alert', 1);
|
||||
echo '</form>';
|
||||
|
@ -795,15 +795,15 @@ foreach ($commands as $command) {
|
||||
);
|
||||
$data['action'] = '';
|
||||
$table->cellclass[]['action'] = 'action_buttons';
|
||||
|
||||
$offset_delete = ($offset >= ($total_commands - 1)) ? ($offset - $limit) : $offset;
|
||||
// (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group.
|
||||
if ($is_management_allowed === true && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) {
|
||||
if (is_user_admin($config['id_user']) === true) {
|
||||
$data['action'] = '<span class="inline_flex">';
|
||||
$data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&copy_command=1&id='.$command['id'].'&pure='.$pure.'"
|
||||
$data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&copy_command=1&id='.$command['id'].'&pure='.$pure.'&offset='.$offset.'"
|
||||
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/copy.png', true, ['class' => 'invert_filter']).'</a>';
|
||||
|
||||
$data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&delete_command=1&id='.$command['id'].'&pure='.$pure.'"
|
||||
$data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&delete_command=1&id='.$command['id'].'&pure='.$pure.'&offset='.$offset_delete.'"
|
||||
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['class' => 'invert_filter']).'</a>';
|
||||
$data['action'] .= '</span>';
|
||||
}
|
||||
|
@ -352,7 +352,8 @@ if ($search_string) {
|
||||
$filter[] = "(name LIKE '%".$search_string."%' OR description LIKE '%".$search_string."%' OR value LIKE '%".$search_string."%')";
|
||||
}
|
||||
|
||||
$filter['offset'] = (int) get_parameter('offset');
|
||||
$offset = (int) get_parameter('offset');
|
||||
$filter['offset'] = $offset;
|
||||
$filter['limit'] = (int) $config['block_size'];
|
||||
if (!is_user_admin($config['id_user'])) {
|
||||
$filter['id_group'] = array_keys(users_get_groups(false, 'LM'));
|
||||
@ -420,7 +421,7 @@ foreach ($templates as $template) {
|
||||
&& check_acl($config['id_user'], $template['id_group'], 'LM')
|
||||
) {
|
||||
$table->cellclass[][4] = 'action_buttons';
|
||||
$data[4] = '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&pure='.$pure.'" class="float-left inline_line">';
|
||||
$data[4] = '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&pure='.$pure.'&offset='.$offset.'" class="float-left inline_line">';
|
||||
$data[4] .= html_print_input_hidden('duplicate_template', 1, true);
|
||||
$data[4] .= html_print_input_hidden('source_id', $template['id'], true);
|
||||
$data[4] .= html_print_input_image(
|
||||
|
@ -372,8 +372,9 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
|
||||
);
|
||||
}
|
||||
|
||||
$offset = (int) get_parameter('offset', 0);
|
||||
|
||||
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions&pure='.$pure.'">';
|
||||
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions&pure='.$pure.'&offset='.$offset.'">';
|
||||
$table_html = html_print_table($table, true);
|
||||
|
||||
echo $table_html;
|
||||
|
@ -1147,9 +1147,10 @@ if ($step == 2) {
|
||||
echo ui_get_using_system_timezone_warning();
|
||||
}
|
||||
|
||||
$offset = (int) get_parameter('offset');
|
||||
// If it's the last step it will redirect to template lists.
|
||||
if ($step >= LAST_STEP) {
|
||||
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_templates&pure='.$pure.'">';
|
||||
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_templates&pure='.$pure.'&offset='.$offset.'">';
|
||||
} else {
|
||||
echo '<form method="post">';
|
||||
}
|
||||
|
71
pandora_console/godmode/events/configuration_sounds.php
Normal file
71
pandora_console/godmode/events/configuration_sounds.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Audit log View.
|
||||
*
|
||||
* @category Audit log
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/class/EventSound.class.php';
|
||||
|
||||
$ajaxPage = 'godmode/events/configuration_sounds';
|
||||
|
||||
// Control call flow.
|
||||
try {
|
||||
// User access and validation is being processed on class constructor.
|
||||
$controller = new EventSound($ajaxPage);
|
||||
} catch (Exception $e) {
|
||||
if ((bool) is_ajax() === true) {
|
||||
echo json_encode(['error' => '[EventSound]'.$e->getMessage() ]);
|
||||
exit;
|
||||
} else {
|
||||
echo '[EventSound]'.$e->getMessage();
|
||||
}
|
||||
|
||||
// Stop this execution, but continue 'globally'.
|
||||
return;
|
||||
}
|
||||
|
||||
// AJAX controller.
|
||||
if ((bool) is_ajax() === true) {
|
||||
$method = get_parameter('method');
|
||||
|
||||
if (method_exists($controller, $method) === true) {
|
||||
if ($controller->ajaxMethod($method) === true) {
|
||||
$controller->{$method}();
|
||||
} else {
|
||||
$controller->error('Unavailable method.');
|
||||
}
|
||||
} else {
|
||||
$controller->error('Method not found. ['.$method.']');
|
||||
}
|
||||
|
||||
// Stop any execution.
|
||||
exit;
|
||||
} else {
|
||||
// Run.
|
||||
$controller->run();
|
||||
}
|
@ -40,6 +40,7 @@ $custom_id = '';
|
||||
|
||||
$create_group = (bool) get_parameter('create_group');
|
||||
$id_group = (int) get_parameter('id_group');
|
||||
$offset = (int) get_parameter('offset', 0);
|
||||
|
||||
if ($id_group) {
|
||||
$group = db_get_row('tmodule_group', 'id_mg', $id_group);
|
||||
@ -70,9 +71,9 @@ $table->data[0][1] = html_print_input_text('name', $name, '', 35, 100, true);
|
||||
|
||||
echo '</span>';
|
||||
if (is_metaconsole()) {
|
||||
echo '<form name="grupo" method="post" action="index.php?sec=advanced&sec2=advanced/component_management&tab=module_group">';
|
||||
echo '<form name="grupo" method="post" action="index.php?sec=advanced&sec2=advanced/component_management&tab=module_group&offset='.$offset.'">';
|
||||
} else {
|
||||
echo '<form name="grupo" method="post" action="index.php?sec=gmodules&sec2=godmode/groups/modu_group_list">';
|
||||
echo '<form name="grupo" method="post" action="index.php?sec=gmodules&sec2=godmode/groups/modu_group_list&offset='.$offset.'">';
|
||||
}
|
||||
|
||||
html_print_table($table);
|
||||
|
@ -262,18 +262,18 @@ if (empty($groups) === false) {
|
||||
}
|
||||
|
||||
$table->data = [];
|
||||
|
||||
$offset_delete = ($offset >= $total_groups - 1) ? ($offset - $config['block_size']) : $offset;
|
||||
foreach ($groups as $id_group) {
|
||||
$data = [];
|
||||
$data[0] = $id_group['id_mg'];
|
||||
|
||||
if ($is_management_allowed === true) {
|
||||
$data[1] = '<strong><a href="index.php?sec=gmodules&sec2=godmode/groups/configure_modu_group&id_group='.$id_group['id_mg'].'">'.ui_print_truncate_text($id_group['name'], GENERIC_SIZE_TEXT).'</a></strong>';
|
||||
$data[1] = '<strong><a href="index.php?sec=gmodules&sec2=godmode/groups/configure_modu_group&id_group='.$id_group['id_mg'].'&offset='.$offset.'">'.ui_print_truncate_text($id_group['name'], GENERIC_SIZE_TEXT).'</a></strong>';
|
||||
if (is_metaconsole() === true) {
|
||||
$data[2] = '<a href="index.php?sec=advanced&sec2=advanced/component_management&tab=module_group&id_group='.$id_group['id_mg'].'&delete_group=1" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['border' => '0']).'</a>';
|
||||
$data[2] = '<a href="index.php?sec=advanced&sec2=advanced/component_management&tab=module_group&id_group='.$id_group['id_mg'].'&delete_group=1&offset='.$offset_delete.'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['border' => '0']).'</a>';
|
||||
} else {
|
||||
$table->cellclass[][2] = 'action_buttons';
|
||||
$data[2] = '<a href="index.php?sec=gmodules&sec2=godmode/groups/modu_group_list&id_group='.$id_group['id_mg'].'&delete_group=1" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['border' => '0']).'</a>';
|
||||
$data[2] = '<a href="index.php?sec=gmodules&sec2=godmode/groups/modu_group_list&id_group='.$id_group['id_mg'].'&delete_group=1&offset='.$offset_delete.'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['border' => '0']).'</a>';
|
||||
}
|
||||
} else {
|
||||
$data[1] = '<strong>';
|
||||
|
@ -2094,46 +2094,21 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
|
||||
switch ($field) {
|
||||
case 'id_plugin':
|
||||
if ($value != 0) {
|
||||
$value_field_1 = get_parameter('_field1_', '');
|
||||
$value_field_1_desc = get_parameter('desc_field1_', '');
|
||||
|
||||
$value_field_2 = get_parameter('_field2_', '');
|
||||
$value_field_2_desc = get_parameter('desc_field2_', '');
|
||||
|
||||
$value_field_3 = get_parameter('_field3_', '');
|
||||
$value_field_3_desc = get_parameter('desc_field3_', '');
|
||||
|
||||
$value_field_4 = get_parameter('_field4_', '');
|
||||
$value_field_4_desc = get_parameter('desc_field4_', '');
|
||||
|
||||
$value_field_5 = get_parameter('_field5_', '');
|
||||
$value_field_5_desc = get_parameter('desc_field5_', '');
|
||||
|
||||
$values['macros'] = '{"1":{"macro":"_field1_","desc":"'.io_safe_input($value_field_1_desc).'","help":"'.io_safe_input($value_field_1_desc).'","value":"'.$value_field_1.'"}';
|
||||
|
||||
if ($value_field_2_desc != '') {
|
||||
$values['macros'] .= ',"2":{"macro":"_field2_","desc":"'.io_safe_input($value_field_2_desc).'","help":"'.io_safe_input($value_field_2_desc).'","value":"'.$value_field_2.'"}';
|
||||
|
||||
if ($value_field_3_desc != '') {
|
||||
$values['macros'] .= ',"3":{"macro":"_field3_","desc":"'.io_safe_input($value_field_3_desc).'","help":"'.io_safe_input($value_field_3_desc).'","value":"'.$value_field_3.'"}';
|
||||
|
||||
if ($value_field_4_desc != '') {
|
||||
$values['macros'] .= ',"4":{"macro":"_field4_","desc":"'.io_safe_input($value_field_4_desc).'","help":"'.io_safe_input($value_field_4_desc).'","value":"'.$value_field_4.'"}';
|
||||
|
||||
if ($value_field_5_desc != '') {
|
||||
$values['macros'] .= ',"5":{"macro":"_field5_","desc":"'.io_safe_input($value_field_5_desc).'","help":"'.io_safe_input($value_field_5_desc).'","value":"'.$value_field_5.'"}';
|
||||
} else {
|
||||
$values['macros'] .= '}';
|
||||
}
|
||||
} else {
|
||||
$values['macros'] .= '}';
|
||||
}
|
||||
} else {
|
||||
$values['macros'] .= '}';
|
||||
for ($i = 0; $i <= 15; $i++) {
|
||||
$value_field = get_parameter('_field'.$i.'_', '');
|
||||
$value_field_desc = get_parameter('desc_field'.$i.'_', '');
|
||||
if ($value_field_desc != '') {
|
||||
$values['macros'][$i] = [
|
||||
'macro' => '_field'.$i.'_',
|
||||
'desc' => io_safe_input($value_field_desc),
|
||||
'help' => io_safe_input($value_field_desc),
|
||||
'value' => $value_field,
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$values['macros'] .= '}';
|
||||
}
|
||||
|
||||
$values['macros'] = json_encode($values['macros']);
|
||||
$values[$field] = $value;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2260,7 +2235,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
|
||||
// Apply at All agents (within valid groups).
|
||||
$modules = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
'SELECT tam.id_agente_modulo, tam.id_tipo_modulo
|
||||
'SELECT tam.id_agente_modulo, tam.id_tipo_modulo,tam.macros, tam.id_plugin
|
||||
FROM tagente_modulo tam INNER JOIN tagente ta
|
||||
ON ta.id_agente = tam.id_agente
|
||||
WHERE ta.id_grupo IN (%s) %s;',
|
||||
@ -2277,6 +2252,8 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
|
||||
[
|
||||
'id_agente_modulo',
|
||||
'id_tipo_modulo',
|
||||
'macros',
|
||||
'id_plugin',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
@ -2289,6 +2266,8 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
|
||||
[
|
||||
'id_agente_modulo',
|
||||
'id_tipo_modulo',
|
||||
'macros',
|
||||
'id_plugin',
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -2346,6 +2325,23 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
|
||||
}
|
||||
}
|
||||
|
||||
if ($module['macros'] && $module['id_plugin'] == $values['id_plugin']) {
|
||||
$module_macros = json_decode($module['macros'], true);
|
||||
$values_macros = json_decode($values['macros'], true);
|
||||
|
||||
foreach ($values_macros as $k => $value_macro) {
|
||||
foreach ($module_macros as $s => $module_macro) {
|
||||
if ($value_macro['macro'] == $module_macro['macro'] && $value_macro['value'] !== '') {
|
||||
$module_macros[$s]['value'] = $value_macro['value'];
|
||||
$module_macros[$s]['desc'] = $value_macro['desc'];
|
||||
$module_macros[$s]['help'] = $value_macro['help'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$values['macros'] = json_encode($module_macros);
|
||||
}
|
||||
|
||||
$result = modules_update_agent_module(
|
||||
$module['id_agente_modulo'],
|
||||
$values,
|
||||
|
@ -435,6 +435,10 @@ if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) check_acl($
|
||||
}
|
||||
}
|
||||
|
||||
$sub['godmode/events/configuration_sounds']['text'] = __('Accoustic console setup');
|
||||
$sub['godmode/events/configuration_sounds']['id'] = 'Accoustic console setup';
|
||||
$sub['godmode/events/configuration_sounds']['pages'] = ['godmode/events/configuration_sounds'];
|
||||
|
||||
$menu_godmode['gextensions']['sub'] = $sub;
|
||||
}
|
||||
|
||||
|
@ -597,9 +597,10 @@ if ((bool) $id !== false || $new_component
|
||||
$search_id_group = (int) get_parameter('search_id_group');
|
||||
$search_string = (string) get_parameter('search_string');
|
||||
|
||||
$offset = (int) get_parameter('offset');
|
||||
$url = ui_get_url_refresh(
|
||||
[
|
||||
'offset' => false,
|
||||
'offset' => $offset,
|
||||
'search_string' => $search_string,
|
||||
'search_id_group' => $search_id_group,
|
||||
'id' => $id,
|
||||
@ -607,7 +608,7 @@ $url = ui_get_url_refresh(
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
$name_url = 'index.php?sec=templates&sec2=godmode/modules/manage_network_components';
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filters';
|
||||
@ -712,8 +713,9 @@ $total_components = network_components_get_network_components(
|
||||
'COUNT(*) AS total'
|
||||
);
|
||||
$total_components = $total_components[0]['total'];
|
||||
ui_pagination($total_components, $url);
|
||||
$filter['offset'] = (int) get_parameter('offset');
|
||||
$offset_delete = ($offset >= ($total_components - 1)) ? ($offset - $config['block_size']) : $offset;
|
||||
ui_pagination($total_components, $name_url);
|
||||
$filter['offset'] = $offset;
|
||||
$filter['limit'] = (int) $config['block_size'];
|
||||
$components = network_components_get_network_components(
|
||||
false,
|
||||
@ -791,7 +793,7 @@ foreach ($components as $component) {
|
||||
true
|
||||
);
|
||||
|
||||
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/modules/manage_network_components&id='.$component['id_nc'].'&pure='.$pure.'">';
|
||||
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/modules/manage_network_components&id='.$component['id_nc'].'&pure='.$pure.'&offset='.$offset.'">';
|
||||
$data[0] .= io_safe_output($component['name']);
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
@ -855,7 +857,7 @@ foreach ($components as $component) {
|
||||
|
||||
if ($is_management_allowed === true) {
|
||||
$table->cellclass[][6] = 'action_buttons';
|
||||
$data[6] = '<a class="inline_line float-left" href="'.$url.'&search_id_group='.$search_id_group.'search_string='.$search_string.'&duplicate_network_component=1&source_id='.$component['id_nc'].'">'.html_print_image(
|
||||
$data[6] = '<a class="inline_line float-left" href="'.$url.'&search_id_group='.$search_id_group.'search_string='.$search_string.'&duplicate_network_component=1&source_id='.$component['id_nc'].'&offset='.$offset.'">'.html_print_image(
|
||||
'images/copy.png',
|
||||
true,
|
||||
[
|
||||
@ -864,7 +866,7 @@ foreach ($components as $component) {
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>';
|
||||
$data[6] .= '<a href="'.$url.'&delete_component=1&id='.$component['id_nc'].'&search_id_group='.$search_id_group.'search_string='.$search_string.'" onclick="if (! confirm (\''.__('Are you sure?').'\')) return false" >'.html_print_image(
|
||||
$data[6] .= '<a href="'.$url.'&delete_component=1&id='.$component['id_nc'].'&search_id_group='.$search_id_group.'search_string='.$search_string.'&offset='.$offset_delete.'" onclick="if (! confirm (\''.__('Are you sure?').'\')) return false" >'.html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
[
|
||||
@ -887,7 +889,7 @@ if (isset($data) === true) {
|
||||
html_print_table($table);
|
||||
ui_pagination(
|
||||
$total_components,
|
||||
$url,
|
||||
$name_url,
|
||||
0,
|
||||
0,
|
||||
false,
|
||||
|
@ -281,7 +281,7 @@ switch ($action) {
|
||||
$server_name = $item['server_name'];
|
||||
|
||||
// Metaconsole db connection.
|
||||
if ($meta && empty($server_name) === false) {
|
||||
if ($meta && empty($server_name) === false && $server_name !== 'all') {
|
||||
$connection = metaconsole_get_connection($server_name);
|
||||
$server_id = $connection['id'];
|
||||
if (metaconsole_load_external_db($connection) != NOERR) {
|
||||
@ -1233,6 +1233,29 @@ $class = 'databox filters';
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
$servers_all_opt = array_merge(['all' => 'All nodes'], $servers);
|
||||
if ($meta) {
|
||||
?>
|
||||
<tr id="row_servers_all_opt" class="datos">
|
||||
<td class="bolder"><?php echo __('Server'); ?></td>
|
||||
<td >
|
||||
<?php
|
||||
html_print_select(
|
||||
$servers_all_opt,
|
||||
'combo_server',
|
||||
$server_name,
|
||||
'',
|
||||
$nothing,
|
||||
$nothing_value
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ($meta) {
|
||||
?>
|
||||
@ -6334,6 +6357,7 @@ function chooseType() {
|
||||
$("#row_alert_templates").hide();
|
||||
$("#row_alert_actions").hide();
|
||||
$("#row_servers").hide();
|
||||
$("#row_servers_all_opt").hide();
|
||||
$("#row_multiple_servers").hide();
|
||||
$("#row_sort").hide();
|
||||
$("#row_date").hide();
|
||||
@ -6648,7 +6672,7 @@ function chooseType() {
|
||||
$("#row_header").show();
|
||||
$("#row_custom").show();
|
||||
$("#row_custom_example").show();
|
||||
$("#row_servers").show();
|
||||
$("#row_servers_all_opt").show();
|
||||
$("#row_historical_db_check").show();
|
||||
break;
|
||||
|
||||
|
@ -992,7 +992,7 @@ if (($create != '') || ($view != '')) {
|
||||
echo '<div id="deploy_messages" class="invisible">';
|
||||
}
|
||||
|
||||
// The '%s' will be replaced in the javascript code of the function 'show_locked_dialog'
|
||||
// The '%s' will be replaced in the javascript code of the function 'show_locked_dialog'.
|
||||
echo "<div id='dialog_locked' title='".__('List of modules and components created by "%s" ')."' class='invisible left'>";
|
||||
echo '</div>';
|
||||
|
||||
@ -1003,50 +1003,49 @@ ui_require_javascript_file('pandora_modules');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
var locked = <?php echo (int) json_encode((int) $locked); ?>;
|
||||
|
||||
|
||||
function update_preview() {
|
||||
var command = $('#form_execute').val();
|
||||
var parameters = $('#form_parameters').val();
|
||||
|
||||
|
||||
var i = 1;
|
||||
|
||||
|
||||
while (1) {
|
||||
if ($('#text-field' + i + '_value').val() == undefined) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ($('#text-field'+i+'_value').val() != '') {
|
||||
parameters = parameters
|
||||
.replace('_field' + i + '_',
|
||||
$('#text-field' + i + '_value').val());
|
||||
}
|
||||
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
$('#command_preview').html(_.escape(command) + ' ' + _.escape(parameters));
|
||||
}
|
||||
|
||||
|
||||
function show_locked_dialog(id_plugin, plugin_name) {
|
||||
var parameters = {};
|
||||
parameters['page'] = "godmode/servers/plugin";
|
||||
parameters["get_list_modules_and_component_locked_plugin"] = 1;
|
||||
parameters["id_plugin"] = id_plugin;
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
data: parameters,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
var title = $("#dialog_locked").prop('title').replace(/%s/, plugin_name);
|
||||
|
||||
var title = 'List of modules and components created by "'+ plugin_name +'"';
|
||||
$("#dialog_locked")
|
||||
.prop('title', title)
|
||||
.html(data)
|
||||
.dialog ({
|
||||
title: title,
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
@ -1061,8 +1060,7 @@ ui_require_javascript_file('pandora_modules');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
// Add macro
|
||||
var add_macro_click_event = function (event) {
|
||||
@ -1092,34 +1090,34 @@ ui_require_javascript_file('pandora_modules');
|
||||
update_preview();
|
||||
}
|
||||
$('div#delete_macro_button>a').click(delete_macro_click_event);
|
||||
|
||||
|
||||
update_preview();
|
||||
|
||||
|
||||
$('.command_component').keyup(function() {
|
||||
update_preview();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
var add_macro_click_locked_event = function (event) {
|
||||
var message = '<?php echo __('Some modules or components are using the plugin'); ?>.'
|
||||
+ '\n' + '<?php echo __('The modules or components should be updated manually or using the bulk operations for plugins after this change'); ?>.'
|
||||
+ '\n'
|
||||
+ '\n' + '<?php echo __('Are you sure you want to perform this action?'); ?>';
|
||||
|
||||
|
||||
if (!confirm(message)) {
|
||||
event.stopImmediatePropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var macros_click_locked_event = function (event) {
|
||||
alert("<?php echo __('The plugin macros cannot be updated because some modules or components are using the plugin'); ?>");
|
||||
}
|
||||
|
||||
|
||||
if (locked) {
|
||||
$('a#add_macro_btn').click(add_macro_click_locked_event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
@ -151,6 +151,11 @@ if ($update_config == 1 && $config['history_db_enabled'] == 1) {
|
||||
}
|
||||
}
|
||||
|
||||
$performance_variables_control = (array) json_decode(io_safe_output($config['performance_variables_control']));
|
||||
|
||||
$total_agents = db_get_value('count(*)', 'tagente');
|
||||
$disable_agentaccess = ($total_agents >= 200 && $config['agentaccess'] == 0) ? true : false;
|
||||
|
||||
$table_status = new StdClass();
|
||||
$table_status->width = '100%';
|
||||
$table_status->class = 'databox filters';
|
||||
@ -261,104 +266,140 @@ $table->data[1][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => 99999,
|
||||
'max' => $performance_variables_control['event_purge']->max,
|
||||
'name' => 'event_purge',
|
||||
'value' => $config['event_purge'],
|
||||
'return' => true,
|
||||
'min' => ((((bool) $config['history_event_enabled'] === true) && $config['history_event_days'] > 0) ? $config['history_event_days'] + 1 : null),
|
||||
'min' => $performance_variables_control['event_purge']->min,
|
||||
'style' => 'width:43px',
|
||||
]
|
||||
);
|
||||
|
||||
$table->data[2][0] = __('Max. days before delete traps');
|
||||
$table->data[2][1] = html_print_input_text(
|
||||
'trap_purge',
|
||||
$config['trap_purge'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
$table->data[2][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['trap_purge']->max,
|
||||
'name' => 'trap_purge',
|
||||
'value' => $config['trap_purge'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['trap_purge']->min,
|
||||
'style' => 'width:43px',
|
||||
]
|
||||
);
|
||||
|
||||
$table->data[3][0] = __('Max. days before delete audit events');
|
||||
$table->data[3][1] = html_print_input_text(
|
||||
'audit_purge',
|
||||
$config['audit_purge'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
$table->data[3][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['audit_purge']->max,
|
||||
'name' => 'audit_purge',
|
||||
'value' => $config['audit_purge'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['audit_purge']->min,
|
||||
'style' => 'width:43px',
|
||||
]
|
||||
);
|
||||
|
||||
$table->data[4][0] = __('Max. days before delete string data');
|
||||
$table->data[4][1] = html_print_input_text(
|
||||
'string_purge',
|
||||
$config['string_purge'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
$table->data[4][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['string_purge']->max,
|
||||
'name' => 'string_purge',
|
||||
'value' => $config['string_purge'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['string_purge']->min,
|
||||
'style' => 'width:43px',
|
||||
]
|
||||
);
|
||||
|
||||
$table->data[5][0] = __('Max. days before delete GIS data');
|
||||
$table->data[5][1] = html_print_input_text(
|
||||
'gis_purge',
|
||||
$config['gis_purge'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
$table->data[5][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['gis_purge']->max,
|
||||
'name' => 'gis_purge',
|
||||
'value' => $config['gis_purge'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['gis_purge']->min,
|
||||
'style' => 'width:43px',
|
||||
]
|
||||
);
|
||||
|
||||
$table->data[6][0] = __('Max. days before purge');
|
||||
$table->data[6][1] = html_print_input_text(
|
||||
'days_purge',
|
||||
$config['days_purge'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
$table->data[6][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['days_purge']->max,
|
||||
'name' => 'days_purge',
|
||||
'value' => $config['days_purge'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['days_purge']->min,
|
||||
'style' => 'width:43px',
|
||||
]
|
||||
);
|
||||
|
||||
$table->data[7][0] = __('Max. days before compact data');
|
||||
$table->data[7][1] = html_print_input_text(
|
||||
'days_compact',
|
||||
$config['days_compact'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
$table->data[7][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['days_compact']->max,
|
||||
'name' => 'days_compact',
|
||||
'value' => $config['days_compact'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['days_compact']->min,
|
||||
'style' => 'width:43px',
|
||||
]
|
||||
);
|
||||
|
||||
$table->data[8][0] = __('Max. days before delete unknown modules');
|
||||
$table->data[8][1] = html_print_input_text(
|
||||
'days_delete_unknown',
|
||||
$config['days_delete_unknown'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
$table->data[8][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['days_delete_unknown']->max,
|
||||
'name' => 'days_delete_unknown',
|
||||
'value' => $config['days_delete_unknown'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['days_delete_unknown']->min,
|
||||
'style' => 'width:43px',
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
$table->data[9][0] = __('Max. days before delete not initialized modules');
|
||||
$table->data[9][1] = html_print_input_text(
|
||||
'days_delete_not_initialized',
|
||||
$config['days_delete_not_initialized'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
$table->data[9][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['days_delete_not_initialized']->max,
|
||||
'name' => 'days_delete_not_initialized',
|
||||
'value' => $config['days_delete_not_initialized'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['days_delete_not_initialized']->min,
|
||||
'style' => 'width:43px',
|
||||
]
|
||||
);
|
||||
|
||||
$table->data[10][0] = __('Max. days before delete autodisabled agents');
|
||||
$table->data[10][1] = html_print_input_text(
|
||||
'days_autodisable_deletion',
|
||||
$config['days_autodisable_deletion'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
$table->data[10][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['days_autodisable_deletion']->max,
|
||||
'name' => 'days_autodisable_deletion',
|
||||
'value' => $config['days_autodisable_deletion'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['days_autodisable_deletion']->min,
|
||||
'style' => 'width:43px',
|
||||
]
|
||||
);
|
||||
|
||||
$table->data[11][0] = __('Retention period of past special days');
|
||||
@ -499,13 +540,17 @@ $table->data[] = [
|
||||
|
||||
$table->data[] = [
|
||||
__('Max. days before delete old network matrix data'),
|
||||
html_print_input_text(
|
||||
'delete_old_network_matrix',
|
||||
$config['delete_old_network_matrix'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['delete_old_network_matrix']->max,
|
||||
'name' => 'delete_old_network_matrix',
|
||||
'value' => $config['delete_old_network_matrix'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['delete_old_network_matrix']->min,
|
||||
'style' => 'width:43px',
|
||||
]
|
||||
),
|
||||
];
|
||||
|
||||
@ -519,13 +564,30 @@ $table_other->size[0] = '70%';
|
||||
$table_other->size[1] = '30%';
|
||||
$i = 0;
|
||||
$table_other->data[$i][0] = __('Item limit for realtime reports');
|
||||
$table_other->data[$i++][1] = html_print_input_text(
|
||||
'report_limit',
|
||||
$config['report_limit'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
$table_other->data[$i++][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['report_limit']->max,
|
||||
'name' => 'report_limit',
|
||||
'value' => $config['report_limit'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['report_limit']->min,
|
||||
'style' => 'width:43px',
|
||||
]
|
||||
);
|
||||
|
||||
$table_other->data[$i][0] = __('Limit of events per query');
|
||||
$table_other->data[$i++][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => 10000,
|
||||
'name' => 'events_per_query',
|
||||
'value' => $config['events_per_query'],
|
||||
'return' => true,
|
||||
'style' => 'width:50px',
|
||||
]
|
||||
);
|
||||
|
||||
$table_other->data[$i][0] = __('Compact interpolation in hours (1 Fine-20 bad)');
|
||||
@ -549,13 +611,17 @@ $intervals[SECONDS_2WEEK] = __('2 weeks');
|
||||
$intervals[SECONDS_1MONTH] = __('Last month');
|
||||
|
||||
$table_other->data[$i][0] = __('Default hours for event view');
|
||||
$table_other->data[$i++][1] = html_print_input_text(
|
||||
'event_view_hr',
|
||||
$config['event_view_hr'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
$table_other->data[$i++][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['event_view_hr']->max,
|
||||
'name' => 'event_view_hr',
|
||||
'value' => $config['event_view_hr'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['event_view_hr']->min,
|
||||
'style' => 'width:43px',
|
||||
]
|
||||
);
|
||||
|
||||
$table_other->data[$i][0] = __('Use realtime statistics');
|
||||
@ -577,7 +643,7 @@ $table_other->data[$i++][1] = html_print_input_text(
|
||||
);
|
||||
|
||||
$table_other->data[$i][0] = __('Use agent access graph');
|
||||
$table_other->data[$i++][1] = html_print_checkbox_switch('agentaccess', 1, $config['agentaccess'], true);
|
||||
$table_other->data[$i++][1] = html_print_checkbox_switch('agentaccess', 1, $config['agentaccess'], true, $disable_agentaccess);
|
||||
|
||||
$table_other->data[$i][0] = __('Max. recommended number of files in attachment directory');
|
||||
$table_other->data[$i++][1] = html_print_input_text(
|
||||
@ -593,23 +659,33 @@ $table_other->data[$i][0] = __('Delete not init modules');
|
||||
$table_other->data[$i++][1] = html_print_checkbox_switch('delete_notinit', 1, $config['delete_notinit'], true);
|
||||
|
||||
$table_other->data[$i][0] = __('Big Operation Step to purge old data');
|
||||
$table_other->data[$i++][1] = html_print_input_text(
|
||||
'big_operation_step_datos_purge',
|
||||
$config['big_operation_step_datos_purge'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
$table_other->data[$i++][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['big_operation_step_datos_purge']->max,
|
||||
'name' => 'big_operation_step_datos_purge',
|
||||
'value' => $config['big_operation_step_datos_purge'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['big_operation_step_datos_purge']->min,
|
||||
'style' => 'width:50px',
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
|
||||
$table_other->data[$i][0] = __('Small Operation Step to purge old data');
|
||||
$table_other->data[$i++][1] = html_print_input_text(
|
||||
'small_operation_step_datos_purge',
|
||||
$config['small_operation_step_datos_purge'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
$table_other->data[$i++][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['small_operation_step_datos_purge']->max,
|
||||
'name' => 'small_operation_step_datos_purge',
|
||||
'value' => $config['small_operation_step_datos_purge'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['small_operation_step_datos_purge']->min,
|
||||
'style' => 'width:50px',
|
||||
]
|
||||
);
|
||||
|
||||
$table_other->data[$i][0] = __('Graph container - Max. Items');
|
||||
@ -633,13 +709,17 @@ $table_other->data[$i++][1] = html_print_input_text(
|
||||
);
|
||||
|
||||
$table_other->data[$i][0] = __('Row limit in csv log');
|
||||
$table_other->data[$i++][1] = html_print_input_text(
|
||||
'row_limit_csv',
|
||||
$config['row_limit_csv'],
|
||||
'',
|
||||
5,
|
||||
10,
|
||||
true
|
||||
$table_other->data[$i++][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['row_limit_csv']->max,
|
||||
'name' => 'row_limit_csv',
|
||||
'value' => $config['row_limit_csv'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['row_limit_csv']->min,
|
||||
'style' => 'width:63px',
|
||||
]
|
||||
);
|
||||
|
||||
$table_other->data[$i][0] = __('SNMP walk binary');
|
||||
|
@ -47,6 +47,8 @@ if (is_ajax()) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$performance_variables_control = (array) json_decode(io_safe_output($config['performance_variables_control']));
|
||||
|
||||
$table = new StdClass();
|
||||
$table->class = 'databox filters';
|
||||
$table->id = 'setup_general';
|
||||
@ -512,13 +514,17 @@ $table->data[$i++][1] = html_print_checkbox_switch(
|
||||
);
|
||||
|
||||
$table->data[$i][0] = __('Limit for bulk operations');
|
||||
$table->data[$i++][1] = html_print_input_text(
|
||||
'limit_parameters_massive',
|
||||
$config['limit_parameters_massive'],
|
||||
'',
|
||||
10,
|
||||
10,
|
||||
true
|
||||
$table->data[$i++][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['limit_parameters_massive']->max,
|
||||
'name' => 'limit_parameters_massive',
|
||||
'value' => $config['limit_parameters_massive'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['limit_parameters_massive']->min,
|
||||
'style' => 'width:50px',
|
||||
]
|
||||
);
|
||||
|
||||
$table->data[$i][0] = __('Include agents manually disabled');
|
||||
|
@ -53,6 +53,8 @@ $row = 0;
|
||||
echo '<form id="form_setup" method="post">';
|
||||
html_print_input_hidden('update_config', 1);
|
||||
|
||||
$performance_variables_control = (array) json_decode(io_safe_output($config['performance_variables_control']));
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// BEHAVIOUR CONFIGURATION
|
||||
// ----------------------------------------------------------------------
|
||||
@ -64,7 +66,18 @@ $table_behaviour->size[0] = '50%';
|
||||
$table_behaviour->data = [];
|
||||
|
||||
$table_behaviour->data[$row][0] = __('Block size for pagination');
|
||||
$table_behaviour->data[$row][1] = html_print_input_text('block_size', $config['global_block_size'], '', 5, 5, true);
|
||||
$table_behaviour->data[$row][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['block_size']->max,
|
||||
'name' => 'block_size',
|
||||
'value' => $config['global_block_size'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['block_size']->min,
|
||||
'style' => 'width:50px',
|
||||
]
|
||||
);
|
||||
$row++;
|
||||
|
||||
$values = [];
|
||||
@ -823,16 +836,19 @@ if (enterprise_installed() === false) {
|
||||
}
|
||||
|
||||
$table_chars->data[$row][0] = __('Data precision');
|
||||
$table_chars->data[$row][1] = html_print_input_text(
|
||||
'graph_precision',
|
||||
$config['graph_precision'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true,
|
||||
$disabled_graph_precision,
|
||||
false,
|
||||
'onChange="change_precision()"'
|
||||
$table_chars->data[$row][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['graph_precision']->max,
|
||||
'name' => 'graph_precision',
|
||||
'value' => $config['graph_precision'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['graph_precision']->min,
|
||||
'style' => 'width:50px',
|
||||
($disabled_graph_precision) ? 'readonly' : '' => 'readonly',
|
||||
'onchange' => 'change_precision()',
|
||||
]
|
||||
);
|
||||
$row++;
|
||||
|
||||
@ -841,17 +857,21 @@ if (isset($config['short_module_graph_data']) === false) {
|
||||
}
|
||||
|
||||
$table_chars->data[$row][0] = __('Data precision in graphs');
|
||||
$table_chars->data[$row][1] = html_print_input_text(
|
||||
'short_module_graph_data',
|
||||
$config['short_module_graph_data'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true,
|
||||
$disabled_graph_precision,
|
||||
false,
|
||||
'onChange="change_precision()"'
|
||||
$table_chars->data[$row][1] = html_print_input(
|
||||
[
|
||||
'type' => 'number',
|
||||
'size' => 5,
|
||||
'max' => $performance_variables_control['short_module_graph_data']->max,
|
||||
'name' => 'short_module_graph_data',
|
||||
'value' => $config['short_module_graph_data'],
|
||||
'return' => true,
|
||||
'min' => $performance_variables_control['short_module_graph_data']->min,
|
||||
'style' => 'width:50px',
|
||||
($disabled_graph_precision) ? 'readonly' : '' => 'readonly',
|
||||
'onchange' => 'change_precision()',
|
||||
]
|
||||
);
|
||||
|
||||
$row++;
|
||||
|
||||
$table_chars->data[$row][0] = __(
|
||||
|
@ -207,14 +207,14 @@ if (empty($tag_name) === false) {
|
||||
|
||||
// If the user has filtered the view.
|
||||
$filter_performed = !empty($filter);
|
||||
|
||||
$filter['offset'] = (int) get_parameter('offset');
|
||||
$offset = (int) get_parameter('offset');
|
||||
$filter['offset'] = $offset;
|
||||
$filter['limit'] = (int) $config['block_size'];
|
||||
|
||||
// Statements for pagination.
|
||||
$url = ui_get_url_refresh();
|
||||
$url = 'index.php?sec=gusuarios&sec2=godmode/tag/tag';
|
||||
$total_tags = tags_get_tag_count($filter);
|
||||
|
||||
$offset_delete = ($offset >= ($total_tags - 1)) ? ($offset - $config['block_size']) : $offset;
|
||||
$result = tags_search_tag(false, $filter);
|
||||
|
||||
// Filter form.
|
||||
@ -392,7 +392,7 @@ if (empty($result) === false) {
|
||||
]
|
||||
);
|
||||
$data[6] .= '</a>';
|
||||
$data[6] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/tag/tag&delete_tag='.$tag['id_tag'].'"onclick="if (! confirm (\''.__('Are you sure?').'\')) return false">'.html_print_image(
|
||||
$data[6] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/tag/tag&delete_tag='.$tag['id_tag'].'&offset='.$offset_delete.'"onclick="if (! confirm (\''.__('Are you sure?').'\')) return false">'.html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
[
|
||||
|
@ -816,7 +816,7 @@ foreach ($info as $user_id => $user_info) {
|
||||
$toDoClass = 'filter_none';
|
||||
}
|
||||
|
||||
$data[6] = '<form method="POST" action="index.php?sec='.$sec.'&sec2=godmode/users/user_list&pure='.$pure.'" class="inline">';
|
||||
$data[6] = '<form method="POST" action="index.php?sec='.$sec.'&sec2=godmode/users/user_list&pure='.$pure.'&offset='.$offset.'" class="inline">';
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'id',
|
||||
$user_info['id_user'],
|
||||
@ -874,7 +874,8 @@ foreach ($info as $user_id => $user_info) {
|
||||
&& $user_info['id_user'] != $config['id_user']
|
||||
&& isset($user_info['not_delete']) === false
|
||||
) {
|
||||
$data[6] .= '<form method="POST" action="index.php?sec='.$sec.'&sec2=godmode/users/user_list&pure='.$pure.'" class="inline">';
|
||||
$offset_delete = ($offset >= count($info) - 1) ? ($offset - $config['block_size']) : $offset;
|
||||
$data[6] .= '<form method="POST" action="index.php?sec='.$sec.'&sec2=godmode/users/user_list&pure='.$pure.'&offset='.$offset_delete.'" class="inline">';
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'delete_user',
|
||||
$user_info['id_user'],
|
||||
|
@ -955,29 +955,42 @@ class DiscoveryTaskList extends HTML
|
||||
)
|
||||
) {
|
||||
if ($ipam === true) {
|
||||
$data[9] .= '<a href="'.ui_get_full_url(
|
||||
sprintf(
|
||||
'index.php?sec=gextensions&sec2=enterprise/tools/ipam/ipam&action=edit&id=%d',
|
||||
$tipam_task_id
|
||||
)
|
||||
).'">'.html_print_image(
|
||||
'images/config.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Edit task'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>';
|
||||
$data[9] .= '<a href="'.ui_get_full_url(
|
||||
'index.php?sec=gextensions&sec2=enterprise/tools/ipam/ipam&action=delete&id='.$tipam_task_id
|
||||
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Delete task'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>';
|
||||
if (empty($tipam_task_id) === false) {
|
||||
$data[9] .= '<a href="'.ui_get_full_url(
|
||||
sprintf(
|
||||
'index.php?sec=gextensions&sec2=enterprise/tools/ipam/ipam&action=edit&id=%d',
|
||||
$tipam_task_id
|
||||
)
|
||||
).'">'.html_print_image(
|
||||
'images/config.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Edit task'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>';
|
||||
$data[9] .= '<a href="'.ui_get_full_url(
|
||||
'index.php?sec=gextensions&sec2=enterprise/tools/ipam/ipam&action=delete&id='.$tipam_task_id
|
||||
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Delete task'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>';
|
||||
} else {
|
||||
$data[9] .= '<a href="'.ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&delete=1&task='.$task['id_rt']
|
||||
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Delete task'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>';
|
||||
}
|
||||
} else {
|
||||
// Check if is a H&D, Cloud or Application or IPAM.
|
||||
$data[9] .= '<a href="'.ui_get_full_url(
|
||||
|
BIN
pandora_console/images/omnishell.png
Normal file
BIN
pandora_console/images/omnishell.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 606 B |
BIN
pandora_console/images/widgets/EventCardboard.png
Normal file
BIN
pandora_console/images/widgets/EventCardboard.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
@ -31,6 +31,15 @@ $get_agents_interfaces = (bool) get_parameter('get_agents_interfaces');
|
||||
$id_agents = get_parameter('id_agents', []);
|
||||
$get_agents_group = (bool) get_parameter('get_agents_group', false);
|
||||
$force_local = (bool) get_parameter('force_local', false);
|
||||
|
||||
// Agent detail filter.
|
||||
$load_filter_modal = get_parameter('load_filter_modal', 0);
|
||||
$save_filter_modal = get_parameter('save_filter_modal', 0);
|
||||
$get_agent_filters = get_parameter('get_agent_filters', 0);
|
||||
$save_agent_filter = get_parameter('save_agent_filter', 0);
|
||||
$update_agent_filter = get_parameter('update_agent_filter', 0);
|
||||
$delete_agent_filter = get_parameter('delete_agent_filter', 0);
|
||||
|
||||
if (https_is_running()) {
|
||||
header('Content-type: application/json');
|
||||
}
|
||||
@ -345,4 +354,656 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Saves an event filter.
|
||||
if ($save_agent_filter) {
|
||||
$values = [];
|
||||
$values['id_name'] = get_parameter('id_name');
|
||||
$values['group_id'] = get_parameter('group_id');
|
||||
$values['recursion'] = get_parameter('recursion');
|
||||
$values['status'] = get_parameter('status');
|
||||
$values['search'] = get_parameter('search');
|
||||
$values['id_os'] = get_parameter('id_os');
|
||||
$values['policies'] = json_encode(get_parameter('policies'));
|
||||
$values['search_custom'] = get_parameter('search_custom');
|
||||
$values['ag_custom_fields'] = get_parameter('ag_custom_fields');
|
||||
$values['id_group_filter'] = get_parameter('id_group_filter');
|
||||
|
||||
$exists = (bool) db_get_value_filter(
|
||||
'id_filter',
|
||||
'tagent_filter',
|
||||
$values
|
||||
);
|
||||
|
||||
if ($exists === true) {
|
||||
echo 'duplicate';
|
||||
} else {
|
||||
$result = db_process_sql_insert('tagent_filter', $values);
|
||||
|
||||
if ($result === false) {
|
||||
echo 'error';
|
||||
} else {
|
||||
echo $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($update_agent_filter) {
|
||||
$values = [];
|
||||
$id = get_parameter('id');
|
||||
|
||||
$values['group_id'] = get_parameter('group_id');
|
||||
$values['recursion'] = get_parameter('recursion');
|
||||
$values['status'] = get_parameter('status');
|
||||
$values['search'] = get_parameter('search');
|
||||
$values['id_os'] = get_parameter('id_os');
|
||||
$values['policies'] = json_encode(get_parameter('policies'));
|
||||
$values['search_custom'] = get_parameter('search_custom');
|
||||
$values['ag_custom_fields'] = get_parameter('ag_custom_fields');
|
||||
|
||||
$result = db_process_sql_update(
|
||||
'tagent_filter',
|
||||
$values,
|
||||
['id_filter' => $id]
|
||||
);
|
||||
|
||||
if ($result === false) {
|
||||
echo 'error';
|
||||
} else {
|
||||
echo 'ok';
|
||||
}
|
||||
}
|
||||
|
||||
if ($delete_agent_filter) {
|
||||
$id = get_parameter('id');
|
||||
|
||||
$user_groups = users_get_groups(
|
||||
$config['id_user'],
|
||||
'AW',
|
||||
users_can_manage_group_all('AW'),
|
||||
true
|
||||
);
|
||||
|
||||
$sql = 'DELETE
|
||||
FROM tagent_filter
|
||||
WHERE id_filter = '.$id.' AND id_group_filter IN ('.implode(',', array_keys($user_groups)).')';
|
||||
|
||||
$agent_filters = db_process_sql($sql);
|
||||
|
||||
if ($agent_filters === false) {
|
||||
echo 'error';
|
||||
} else {
|
||||
echo 'ok';
|
||||
}
|
||||
}
|
||||
|
||||
if ($get_agent_filters) {
|
||||
$user_groups = users_get_groups(
|
||||
$config['id_user'],
|
||||
'AR',
|
||||
users_can_manage_group_all('AR'),
|
||||
true
|
||||
);
|
||||
|
||||
$sql = 'SELECT id_filter, id_name
|
||||
FROM tagent_filter
|
||||
WHERE id_group_filter IN ('.implode(',', array_keys($user_groups)).')';
|
||||
|
||||
$agent_filters = db_get_all_rows_sql($sql);
|
||||
|
||||
$result = [];
|
||||
|
||||
if ($agent_filters !== false) {
|
||||
foreach ($agent_filters as $agent_filter) {
|
||||
$result[$agent_filter['id_filter']] = $agent_filter['id_name'];
|
||||
}
|
||||
}
|
||||
|
||||
echo io_json_mb_encode($result);
|
||||
}
|
||||
|
||||
if ((int) $load_filter_modal === 1) {
|
||||
$user_groups = users_get_groups(
|
||||
$config['id_user'],
|
||||
'AR',
|
||||
users_can_manage_group_all('AR'),
|
||||
true
|
||||
);
|
||||
|
||||
$sql = 'SELECT id_filter, id_name
|
||||
FROM tagent_filter
|
||||
WHERE id_group_filter IN ('.implode(',', array_keys($user_groups)).')';
|
||||
|
||||
$agent_filters = db_get_all_rows_sql($sql);
|
||||
|
||||
$filters = [];
|
||||
foreach ($agent_filters as $agent_filter) {
|
||||
$filters[$agent_filter['id_filter']] = $agent_filter['id_name'];
|
||||
}
|
||||
|
||||
echo '<div id="load-filter-select" class="load-filter-modal">';
|
||||
echo '<form method="post" id="form_load_filter" action="index.php?sec=view&sec2=operation/agentes/estado_agente&pure=">';
|
||||
|
||||
$table = new StdClass;
|
||||
$table->id = 'load_filter_form';
|
||||
$table->width = '100%';
|
||||
$table->cellspacing = 4;
|
||||
$table->cellpadding = 4;
|
||||
$table->class = 'databox';
|
||||
if (is_metaconsole()) {
|
||||
$table->cellspacing = 0;
|
||||
$table->cellpadding = 0;
|
||||
$table->class = 'databox filters';
|
||||
}
|
||||
|
||||
$table->styleTable = 'font-weight: bold; color: #555; text-align:left;';
|
||||
$filter_id_width = '200px';
|
||||
if (is_metaconsole()) {
|
||||
$filter_id_width = '150px';
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$table->rowid[3] = 'update_filter_row1';
|
||||
$data[0] = __('Load filter').$jump;
|
||||
$data[0] .= html_print_select(
|
||||
$filters,
|
||||
'filter_id',
|
||||
$current,
|
||||
'',
|
||||
__('None'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'margin-left:5px; width:'.$filter_id_width.';'
|
||||
);
|
||||
|
||||
$data[1] = html_print_submit_button(
|
||||
__('Load filter'),
|
||||
'load_filter',
|
||||
false,
|
||||
'class="sub upd"',
|
||||
true
|
||||
);
|
||||
$data[1] .= html_print_input_hidden('load_filter', 1, true);
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
html_print_table($table);
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
function show_filter() {
|
||||
$("#load-filter-select").dialog({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: false,
|
||||
closeOnEscape: true,
|
||||
width: 450
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
show_filter();
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php
|
||||
return;
|
||||
}
|
||||
|
||||
if ($save_filter_modal) {
|
||||
echo '<div id="save-filter-select">';
|
||||
if (check_acl($config['id_user'], 0, 'AW')) {
|
||||
echo '<div id="#info_box"></div>';
|
||||
|
||||
$table = new StdClass;
|
||||
$table->id = 'save_filter_form';
|
||||
$table->width = '100%';
|
||||
$table->cellspacing = 4;
|
||||
$table->cellpadding = 4;
|
||||
$table->class = 'databox';
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$table->class = 'databox filters';
|
||||
$table->cellspacing = 0;
|
||||
$table->cellpadding = 0;
|
||||
}
|
||||
|
||||
$table->styleTable = 'font-weight: bold; text-align:left;';
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$table->style[0] = 'width: 50%; width:50%;';
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$table->rowid[0] = 'update_save_selector';
|
||||
$data[0] = html_print_radio_button(
|
||||
'filter_mode',
|
||||
'new',
|
||||
'',
|
||||
true,
|
||||
true
|
||||
).__('New filter').'';
|
||||
|
||||
$data[1] = html_print_radio_button(
|
||||
'filter_mode',
|
||||
'update',
|
||||
'',
|
||||
false,
|
||||
true
|
||||
).__('Update/delete filter').'';
|
||||
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
|
||||
$data = [];
|
||||
$table->rowid[1] = 'save_filter_row1';
|
||||
$data[0] = __('Filter name').$jump;
|
||||
$data[0] .= html_print_input_text('id_name', '', '', 15, 255, true);
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$data[1] = __('Save in Group').$jump;
|
||||
} else {
|
||||
$data[1] = __('Filter group').$jump;
|
||||
}
|
||||
|
||||
$user_groups_array = users_get_groups_for_select(
|
||||
$config['id_user'],
|
||||
'AW',
|
||||
users_can_manage_group_all('AW'),
|
||||
true
|
||||
);
|
||||
|
||||
$data[1] .= html_print_select(
|
||||
$user_groups_array,
|
||||
'id_group_filter_dialog',
|
||||
$id_group_filter,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'w130'
|
||||
);
|
||||
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
|
||||
$data = [];
|
||||
$table->rowid[2] = 'save_filter_row2';
|
||||
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
|
||||
$data = [];
|
||||
$table->rowid[3] = 'update_filter_row1';
|
||||
$data[0] = __('Filter').$jump;
|
||||
|
||||
$user_groups = users_get_groups(
|
||||
$config['id_user'],
|
||||
'AW',
|
||||
users_can_manage_group_all('AW'),
|
||||
true
|
||||
);
|
||||
|
||||
$sql = 'SELECT id_filter, id_name
|
||||
FROM tagent_filter
|
||||
WHERE id_group_filter IN ('.implode(',', array_keys($user_groups)).')';
|
||||
|
||||
$agent_filters = db_get_all_rows_sql($sql);
|
||||
|
||||
$_filters_update = [];
|
||||
|
||||
if ($agent_filters !== false) {
|
||||
foreach ($agent_filters as $agent_filter) {
|
||||
$_filters_update[$agent_filter['id_filter']] = $agent_filter['id_name'];
|
||||
}
|
||||
}
|
||||
|
||||
$data[0] .= html_print_select(
|
||||
$_filters_update,
|
||||
'overwrite_filter',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
|
||||
html_print_table($table);
|
||||
echo '<div id="update_delete_row"><br>';
|
||||
echo html_print_submit_button(
|
||||
__('Update filter'),
|
||||
'update_filter',
|
||||
false,
|
||||
'class="sub upd" onclick="save_update_filter();"',
|
||||
true
|
||||
);
|
||||
echo html_print_submit_button(
|
||||
__('Delete filter'),
|
||||
'delete_filter',
|
||||
false,
|
||||
'class="sub delete float-right" onclick="save_delete_filter();"',
|
||||
true
|
||||
);
|
||||
echo '</div>';
|
||||
echo '<div><br>';
|
||||
echo html_print_submit_button(
|
||||
__('Save current filter'),
|
||||
'save_filter',
|
||||
false,
|
||||
'class="sub upd float-right" onclick="save_new_filter();"',
|
||||
true
|
||||
);
|
||||
echo '</div>';
|
||||
} else {
|
||||
include 'general/noaccess.php';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
function show_save_filter() {
|
||||
$('#save_filter_row1').show();
|
||||
$('#save_filter_row2').show();
|
||||
$('#update_filter_row1').hide();
|
||||
$('#update_delete_row').hide();
|
||||
// Filter save mode selector
|
||||
$("[name='filter_mode']").click(function() {
|
||||
if ($(this).val() == 'new') {
|
||||
$('#save_filter_row1').show();
|
||||
$('#save_filter_row2').show();
|
||||
$('#submit-save_filter').show();
|
||||
$('#update_filter_row1').hide();
|
||||
$('#update_delete_row').hide();
|
||||
}
|
||||
else {
|
||||
$('#save_filter_row1').hide();
|
||||
$('#save_filter_row2').hide();
|
||||
$('#update_filter_row1').show();
|
||||
$('#submit-save_filter').hide();
|
||||
$('#update_delete_row').show();
|
||||
}
|
||||
});
|
||||
$("#save-filter-select").dialog({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: false,
|
||||
closeOnEscape: true
|
||||
});
|
||||
}
|
||||
|
||||
function save_new_filter() {
|
||||
// If the filter name is blank show error
|
||||
if ($('#text-id_name').val() == '') {
|
||||
$('#show_filter_error').html("<h3 class='error'><?php echo __('Filter name cannot be left blank'); ?></h3>");
|
||||
|
||||
// Close dialog
|
||||
$('.ui-dialog-titlebar-close').trigger('click');
|
||||
return false;
|
||||
}
|
||||
|
||||
var custom_fields_values = $('input[name^="ag_custom_fields"]').map(function() {
|
||||
return this.value;
|
||||
}).get();
|
||||
|
||||
var custom_fields_ids = $("input[name^='ag_custom_fields']").map(function() {
|
||||
var name = $(this).attr("name");
|
||||
var number = name.match(/\[(.*?)\]/)[1];
|
||||
|
||||
return number;
|
||||
}).get();
|
||||
|
||||
var ag_custom_fields = custom_fields_ids.reduce(function(result, custom_fields_id, index) {
|
||||
result[custom_fields_id] = custom_fields_values[index];
|
||||
return result;
|
||||
}, {});
|
||||
|
||||
var id_filter_save;
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{
|
||||
"page" : "include/ajax/agent",
|
||||
"save_agent_filter" : 1,
|
||||
"id_name": $("#text-id_name").val(),
|
||||
"id" : $("#overwrite_filter").val(),
|
||||
"group_id" : $("#group_id").val(),
|
||||
"recursion" : $("#checkbox-recursion").is(':checked'),
|
||||
"status" : $("#status").val(),
|
||||
"search" : $("#text-search").val(),
|
||||
"id_os" : $("#os").val(),
|
||||
"policies" : $("#policies").val(),
|
||||
"search_custom" : $("#text-search_custom").val(),
|
||||
"ag_custom_fields": JSON.stringify(ag_custom_fields),
|
||||
"id_group_filter": $("#id_group_filter_dialog").val(),
|
||||
},
|
||||
|
||||
function (data) {
|
||||
$("#info_box").hide();
|
||||
if (data == 'error') {
|
||||
$("#info_box").filter(function(i, item) {
|
||||
if ($(item).data('type_info_box') == "error_create_filter") {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}).show();
|
||||
}
|
||||
else if (data == 'duplicate') {
|
||||
$("#info_box").filter(function(i, item) {
|
||||
if ($(item).data('type_info_box') == "duplicate_create_filter") {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}).show();
|
||||
}
|
||||
else {
|
||||
id_filter_save = data;
|
||||
|
||||
$("#info_box").filter(function(i, item) {
|
||||
if ($(item).data('type_info_box') == "success_create_filter") {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}).show();
|
||||
}
|
||||
|
||||
// First remove all options of filters select.
|
||||
$('#filter_id').find('option').remove().end();
|
||||
|
||||
// Add 'none' option.
|
||||
$('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('None')."'"; ?> ).attr ("value", 0));
|
||||
|
||||
// Reload filters select.
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{
|
||||
"page" : "include/ajax/agent",
|
||||
"get_agent_filters" : 1
|
||||
},
|
||||
function (data) {
|
||||
jQuery.each (data, function (i, val) {
|
||||
s = js_html_entity_decode(val);
|
||||
$('#filter_id').append($('<option></option>').html (s).attr("value", i));
|
||||
});
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
||||
// Close dialog.
|
||||
$("#save-filter-select").dialog('close');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function save_update_filter() {
|
||||
var id_filter_update = $("#overwrite_filter").val();
|
||||
var name_filter_update = $("#overwrite_filter option[value='"+id_filter_update+"']").text();
|
||||
|
||||
var custom_fields_values = $('input[name^="ag_custom_fields"]').map(function() {
|
||||
return this.value;
|
||||
}).get();
|
||||
|
||||
var custom_fields_ids = $("input[name^='ag_custom_fields']").map(function() {
|
||||
var name = $(this).attr("name");
|
||||
var number = name.match(/\[(.*?)\]/)[1];
|
||||
|
||||
return number;
|
||||
}).get();
|
||||
|
||||
var ag_custom_fields = custom_fields_ids.reduce(function(result, custom_fields_id, index) {
|
||||
result[custom_fields_id] = custom_fields_values[index];
|
||||
return result;
|
||||
}, {});
|
||||
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{
|
||||
"page" : "include/ajax/agent",
|
||||
"update_agent_filter" : 1,
|
||||
"id" : $("#overwrite_filter").val(),
|
||||
"group_id" : $("#group_id").val(),
|
||||
"recursion" : $("#checkbox-recursion").is(':checked'),
|
||||
"status" : $("#status").val(),
|
||||
"search" : $("#text-search").val(),
|
||||
"id_os" : $("#os").val(),
|
||||
"policies" : $("#policies").val(),
|
||||
"search_custom" : $("#text-search_custom").val(),
|
||||
"ag_custom_fields": JSON.stringify(ag_custom_fields),
|
||||
},
|
||||
function (data) {
|
||||
$(".info_box").hide();
|
||||
if (data == 'ok') {
|
||||
$(".info_box").filter(function(i, item) {
|
||||
if ($(item).data('type_info_box') == "success_update_filter") {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}).show();
|
||||
}
|
||||
else {
|
||||
$(".info_box").filter(function(i, item) {
|
||||
if ($(item).data('type_info_box') == "error_create_filter") {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}).show();
|
||||
}
|
||||
});
|
||||
|
||||
// First remove all options of filters select.
|
||||
$('#filter_id').find('option').remove().end();
|
||||
|
||||
// Add 'none' option.
|
||||
$('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('None')."'"; ?> ).attr ("value", 0));
|
||||
|
||||
// Reload filters select.
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{
|
||||
"page" : "include/ajax/agent",
|
||||
"get_agent_filters" : 1
|
||||
},
|
||||
function (data) {
|
||||
jQuery.each (data, function (i, val) {
|
||||
s = js_html_entity_decode(val);
|
||||
if (i == id_filter_update) {
|
||||
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
|
||||
}
|
||||
else {
|
||||
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
|
||||
}
|
||||
});
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
||||
// Close dialog
|
||||
$('.ui-dialog-titlebar-close').trigger('click');
|
||||
|
||||
// Update the info with the loaded filter
|
||||
$("#hidden-id_name").val($('#text-id_name').val());
|
||||
$('#filter_loaded_span').html($('#filter_loaded_text').html() + ': ' + name_filter_update);
|
||||
return false;
|
||||
}
|
||||
|
||||
function save_delete_filter() {
|
||||
var id_filter_update = $("#overwrite_filter").val();
|
||||
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{
|
||||
"page" : "include/ajax/agent",
|
||||
"delete_agent_filter" : 1,
|
||||
"id" : $("#overwrite_filter").val(),
|
||||
},
|
||||
function (data) {
|
||||
$(".info_box").hide();
|
||||
if (data == 'ok') {
|
||||
$(".info_box").filter(function(i, item) {
|
||||
if ($(item).data('type_info_box') == "success_update_filter") {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}).show();
|
||||
}
|
||||
else {
|
||||
$(".info_box").filter(function(i, item) {
|
||||
if ($(item).data('type_info_box') == "error_create_filter") {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}).show();
|
||||
}
|
||||
});
|
||||
|
||||
// First remove all options of filters select.
|
||||
$('#filter_id').find('option').remove().end();
|
||||
|
||||
// Add 'none' option.
|
||||
$('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('None')."'"; ?> ).attr ("value", 0));
|
||||
|
||||
// Reload filters select.
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{
|
||||
"page" : "include/ajax/agent",
|
||||
"get_agent_filters" : 1
|
||||
},
|
||||
function (data) {
|
||||
jQuery.each (data, function (i, val) {
|
||||
s = js_html_entity_decode(val);
|
||||
if (i == id_filter_update) {
|
||||
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
|
||||
}
|
||||
else {
|
||||
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
|
||||
}
|
||||
});
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
||||
// Close dialog
|
||||
$('.ui-dialog-titlebar-close').trigger('click');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
show_save_filter();
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -2352,6 +2352,11 @@ if ($drawConsoleSound === true) {
|
||||
'Star_Trek_emergency_simulation.wav' => 'StarTrek emergency simulation',
|
||||
];
|
||||
|
||||
$eventsounds = mysql_db_get_all_rows_sql('SELECT * FROM tevent_sound WHERE active = 1');
|
||||
foreach ($eventsounds as $key => $row) {
|
||||
$sounds[$row['sound']] = $row['name'];
|
||||
}
|
||||
|
||||
$inputs[] = [
|
||||
'class' => 'test-sounds',
|
||||
'direct' => 1,
|
||||
|
@ -73,6 +73,7 @@ if (check_login()) {
|
||||
$get_monitor_filters = get_parameter('get_monitor_filters', 0);
|
||||
$save_monitor_filter = get_parameter('save_monitor_filter', 0);
|
||||
$update_monitor_filter = get_parameter('update_monitor_filter', 0);
|
||||
$delete_monitor_filter = get_parameter('delete_monitor_filter', 0);
|
||||
|
||||
if ($get_agent_modules_json_by_name === true) {
|
||||
$agent_name = get_parameter('agent_name');
|
||||
@ -1740,6 +1741,29 @@ if (check_login()) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($delete_monitor_filter) {
|
||||
$id = get_parameter('id');
|
||||
|
||||
$user_groups = users_get_groups(
|
||||
$config['id_user'],
|
||||
'AW',
|
||||
users_can_manage_group_all('AW'),
|
||||
true
|
||||
);
|
||||
|
||||
$sql = 'DELETE
|
||||
FROM tmonitor_filter
|
||||
WHERE id_filter = '.$id.' AND id_group_filter IN ('.implode(',', array_keys($user_groups)).')';
|
||||
|
||||
$monitor_filters = db_process_sql($sql);
|
||||
|
||||
if ($monitor_filters === false) {
|
||||
echo 'error';
|
||||
} else {
|
||||
echo 'ok';
|
||||
}
|
||||
}
|
||||
|
||||
if ($get_monitor_filters) {
|
||||
$sql = 'SELECT id_filter, id_name FROM tmonitor_filter';
|
||||
|
||||
@ -1760,7 +1784,7 @@ if (check_login()) {
|
||||
$user_groups = users_get_groups(
|
||||
$config['id_user'],
|
||||
'AR',
|
||||
users_can_manage_group_all(),
|
||||
users_can_manage_group_all('AR'),
|
||||
true
|
||||
);
|
||||
|
||||
@ -1886,7 +1910,7 @@ if (check_login()) {
|
||||
'',
|
||||
false,
|
||||
true
|
||||
).__('Update filter').'';
|
||||
).__('Update/delete filter').'';
|
||||
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
@ -1904,7 +1928,7 @@ if (check_login()) {
|
||||
$user_groups_array = users_get_groups_for_select(
|
||||
$config['id_user'],
|
||||
'AW',
|
||||
users_can_manage_group_all(),
|
||||
users_can_manage_group_all('AW'),
|
||||
true
|
||||
);
|
||||
|
||||
@ -1954,21 +1978,30 @@ if (check_login()) {
|
||||
0,
|
||||
true
|
||||
);
|
||||
$data[1] = html_print_submit_button(
|
||||
__('Update filter'),
|
||||
'update_filter',
|
||||
false,
|
||||
'class="sub upd" onclick="save_update_filter();"',
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
|
||||
html_print_table($table);
|
||||
echo '<div>';
|
||||
echo '<div id="update_delete_row"><br>';
|
||||
echo html_print_submit_button(
|
||||
__('Save filter'),
|
||||
__('Update filter'),
|
||||
'update_filter',
|
||||
false,
|
||||
'class="sub upd" onclick="save_update_filter();"',
|
||||
true
|
||||
);
|
||||
echo html_print_submit_button(
|
||||
__('Delete filter'),
|
||||
'delete_filter',
|
||||
false,
|
||||
'class="sub delete float-right" onclick="save_delete_filter();"',
|
||||
true
|
||||
);
|
||||
echo '</div>';
|
||||
echo '<div><br>';
|
||||
echo html_print_submit_button(
|
||||
__('Save current filter'),
|
||||
'save_filter',
|
||||
false,
|
||||
'class="sub upd float-right" onclick="save_new_filter();"',
|
||||
@ -1986,6 +2019,7 @@ if (check_login()) {
|
||||
$('#save_filter_row1').show();
|
||||
$('#save_filter_row2').show();
|
||||
$('#update_filter_row1').hide();
|
||||
$('#update_delete_row').hide();
|
||||
// Filter save mode selector
|
||||
$("[name='filter_mode']").click(function() {
|
||||
if ($(this).val() == 'new') {
|
||||
@ -1993,12 +2027,14 @@ if (check_login()) {
|
||||
$('#save_filter_row2').show();
|
||||
$('#submit-save_filter').show();
|
||||
$('#update_filter_row1').hide();
|
||||
$('#update_delete_row').hide();
|
||||
}
|
||||
else {
|
||||
$('#save_filter_row1').hide();
|
||||
$('#save_filter_row2').hide();
|
||||
$('#update_filter_row1').show();
|
||||
$('#submit-save_filter').hide();
|
||||
$('#update_delete_row').show();
|
||||
}
|
||||
});
|
||||
$("#save-filter-select").dialog({
|
||||
@ -2189,6 +2225,69 @@ if (check_login()) {
|
||||
$('#filter_loaded_span').html($('#filter_loaded_text').html() + ': ' + name_filter_update);
|
||||
return false;
|
||||
}
|
||||
|
||||
function save_delete_filter() {
|
||||
var id_filter_update = $("#overwrite_filter").val();
|
||||
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{
|
||||
"page" : "include/ajax/module",
|
||||
"delete_monitor_filter" : 1,
|
||||
"id" : $("#overwrite_filter").val(),
|
||||
},
|
||||
function (data) {
|
||||
$(".info_box").hide();
|
||||
if (data == 'ok') {
|
||||
$(".info_box").filter(function(i, item) {
|
||||
if ($(item).data('type_info_box') == "success_update_filter") {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}).show();
|
||||
}
|
||||
else {
|
||||
$(".info_box").filter(function(i, item) {
|
||||
if ($(item).data('type_info_box') == "error_create_filter") {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}).show();
|
||||
}
|
||||
});
|
||||
|
||||
// First remove all options of filters select.
|
||||
$('#filter_id').find('option').remove().end();
|
||||
|
||||
// Add 'none' option.
|
||||
$('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('None')."'"; ?> ).attr ("value", 0));
|
||||
|
||||
// Reload filters select.
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{
|
||||
"page" : "include/ajax/module",
|
||||
"get_monitor_filters" : 1
|
||||
},
|
||||
function (data) {
|
||||
jQuery.each (data, function (i, val) {
|
||||
s = js_html_entity_decode(val);
|
||||
if (i == id_filter_update) {
|
||||
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
|
||||
}
|
||||
else {
|
||||
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
|
||||
}
|
||||
});
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
||||
// Close dialog
|
||||
$('.ui-dialog-titlebar-close').trigger('click');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
show_save_filter();
|
||||
|
@ -96,7 +96,10 @@ class AuditLog extends HTML
|
||||
// Datatables list.
|
||||
try {
|
||||
$columns = [
|
||||
'id_usuario',
|
||||
[
|
||||
'text' => 'id_usuario',
|
||||
'class' => 'w50px',
|
||||
],
|
||||
'accion',
|
||||
'fecha',
|
||||
'ip_origen',
|
||||
@ -116,11 +119,11 @@ class AuditLog extends HTML
|
||||
$columns,
|
||||
[
|
||||
'text' => 'security',
|
||||
'class' => 'w80px action_buttons show_security_info',
|
||||
'class' => 'w50px action_buttons show_security_info',
|
||||
],
|
||||
[
|
||||
'text' => 'action',
|
||||
'class' => 'w80px action_buttons show_extended_info',
|
||||
'class' => 'w50px action_buttons show_extended_info',
|
||||
]
|
||||
);
|
||||
|
||||
@ -199,16 +202,28 @@ class AuditLog extends HTML
|
||||
[
|
||||
'label' => __('Free search').ui_print_help_tip(__('Search filter by User, Action, Date, Source IP or Comments fields content'), true),
|
||||
'type' => 'text',
|
||||
'class' => 'w200px',
|
||||
'class' => 'w150px',
|
||||
'id' => 'filter_text',
|
||||
'name' => 'filter_text',
|
||||
],
|
||||
[
|
||||
'label' => __('Max. hours old'),
|
||||
'type' => 'text',
|
||||
'class' => 'w100px',
|
||||
'id' => 'filter_period',
|
||||
'name' => 'filter_period',
|
||||
'label' => __('Max. hours old'),
|
||||
'type' => 'select',
|
||||
'class' => 'w20px',
|
||||
'select2_enable' => true,
|
||||
'sort' => false,
|
||||
'selected' => 168,
|
||||
'fields' => [
|
||||
24 => __('1 day'),
|
||||
168 => __('7 days'),
|
||||
360 => __('15 days'),
|
||||
744 => __('1 month'),
|
||||
2160 => __('3 months'),
|
||||
4320 => __('6 months'),
|
||||
8760 => __('1 Year'),
|
||||
],
|
||||
'id' => 'filter_period',
|
||||
'name' => 'filter_period',
|
||||
],
|
||||
[
|
||||
'label' => __('IP'),
|
||||
@ -223,7 +238,7 @@ class AuditLog extends HTML
|
||||
'nothing' => __('All'),
|
||||
'nothing_value' => '-1',
|
||||
'sql' => 'SELECT DISTINCT(accion), accion AS text FROM tsesion',
|
||||
'class' => 'mw250px',
|
||||
'class' => 'mw200px',
|
||||
'id' => 'filter_type',
|
||||
'name' => 'filter_type',
|
||||
],
|
||||
@ -235,7 +250,7 @@ class AuditLog extends HTML
|
||||
'sql' => 'SELECT id_user, id_user AS text FROM tusuario UNION SELECT "SYSTEM"
|
||||
AS id_user, "SYSTEM" AS text UNION SELECT "N/A"
|
||||
AS id_user, "N/A" AS text',
|
||||
'class' => 'mw250px',
|
||||
'class' => 'mw200px',
|
||||
'id' => 'filter_user',
|
||||
'name' => 'filter_user',
|
||||
],
|
||||
@ -346,9 +361,12 @@ class AuditLog extends HTML
|
||||
).ui_print_timestamp($tmp->utimestamp, true);
|
||||
|
||||
if (enterprise_installed() === true) {
|
||||
$tmp->security = enterprise_hook('cell1EntepriseAudit', [$tmp->id_sesion]);
|
||||
$tmp->action = enterprise_hook('cell2EntepriseAudit', []);
|
||||
$tmp->extendedInfo = enterprise_hook('rowEnterpriseAudit', [$tmp->id_sesion]);
|
||||
$extendedInfo = enterprise_hook('rowEnterpriseAudit', [$tmp->id_sesion]);
|
||||
if (empty($extendedInfo) === false) {
|
||||
$tmp->security = enterprise_hook('cell1EntepriseAudit', [$tmp->id_sesion]);
|
||||
$tmp->action = enterprise_hook('cell2EntepriseAudit', []);
|
||||
$tmp->extendedInfo = $extendedInfo;
|
||||
}
|
||||
}
|
||||
|
||||
$carry[] = $tmp;
|
||||
|
@ -248,6 +248,11 @@ class ConsoleSupervisor
|
||||
|
||||
$this->checkAuditLogOldLocation();
|
||||
|
||||
/*
|
||||
* Check if performance variables are corrects
|
||||
*/
|
||||
$this->checkPerformanceVariables();
|
||||
|
||||
/*
|
||||
* Checks if sync queue is longer than limits.
|
||||
* NOTIF.SYNCQUEUE.LENGTH
|
||||
@ -258,14 +263,21 @@ class ConsoleSupervisor
|
||||
$this->checkSyncQueueStatus();
|
||||
}
|
||||
|
||||
/*
|
||||
* Checkc agent missing libraries.
|
||||
* NOTIF.AGENT.LIBRARY
|
||||
*/
|
||||
/*
|
||||
* Check number of agents is equals and more than 200.
|
||||
* NOTIF.ACCESSSTASTICS.PERFORMANCE
|
||||
*/
|
||||
|
||||
$this->checkAccessStatisticsPerformance();
|
||||
|
||||
/*
|
||||
* Checkc agent missing libraries.
|
||||
* NOTIF.AGENT.LIBRARY
|
||||
*/
|
||||
|
||||
if ((bool) enterprise_installed() === true) {
|
||||
$this->checkLibaryError();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -517,6 +529,11 @@ class ConsoleSupervisor
|
||||
|
||||
$this->checkAuditLogOldLocation();
|
||||
|
||||
/*
|
||||
* Check if performance variables are corrects
|
||||
*/
|
||||
$this->checkPerformanceVariables();
|
||||
|
||||
/*
|
||||
* Checks if sync queue is longer than limits.
|
||||
* NOTIF.SYNCQUEUE.LENGTH
|
||||
@ -527,13 +544,107 @@ class ConsoleSupervisor
|
||||
$this->checkSyncQueueStatus();
|
||||
}
|
||||
|
||||
/*
|
||||
* Check number of agents is equals and more than 200.
|
||||
* NOTIF.ACCESSSTASTICS.PERFORMANCE
|
||||
*/
|
||||
|
||||
$this->checkAccessStatisticsPerformance();
|
||||
|
||||
/*
|
||||
* Checkc agent missing libraries.
|
||||
* NOTIF.AGENT.LIBRARY
|
||||
*/
|
||||
|
||||
if ((bool) enterprise_installed() === true) {
|
||||
$this->checkLibaryError();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if performance variables are corrects
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function checkPerformanceVariables()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$names = [
|
||||
'event_purge' => 'Max. days before events are deleted',
|
||||
'trap_purge' => 'Max. days before traps are deleted',
|
||||
'audit_purge' => 'Max. days before audited events are deleted',
|
||||
'string_purge' => 'Max. days before string data is deleted',
|
||||
'gis_purge' => 'Max. days before GIS data is deleted',
|
||||
'days_purge' => 'Max. days before purge',
|
||||
'days_compact' => 'Max. days before data is compacted',
|
||||
'days_delete_unknown' => 'Max. days before unknown modules are deleted',
|
||||
'days_delete_not_initialized' => 'Max. days before delete not initialized modules',
|
||||
'days_autodisable_deletion' => 'Max. days before autodisabled agents are deleted',
|
||||
'delete_old_network_matrix' => 'Max. days before delete old network matrix data',
|
||||
'report_limit' => 'Item limit for real-time reports',
|
||||
'event_view_hr' => 'Default hours for event view',
|
||||
'big_operation_step_datos_purge' => 'Big Operation Step to purge old data',
|
||||
'small_operation_step_datos_purge' => 'Small Operation Step to purge old data',
|
||||
'row_limit_csv' => 'Row limit in csv log',
|
||||
'limit_parameters_massive' => 'Limit for bulk operations',
|
||||
'block_size' => 'Block size for pagination',
|
||||
'short_module_graph_data' => 'Data precision',
|
||||
'graph_precision' => 'Data precision in graphs',
|
||||
];
|
||||
|
||||
$variables = (array) json_decode(io_safe_output($config['performance_variables_control']));
|
||||
|
||||
foreach ($variables as $variable => $values) {
|
||||
if (empty($config[$variable]) === true || $config[$variable] === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$message = '';
|
||||
$limit_value = '';
|
||||
if ($config[$variable] > $values->max) {
|
||||
$message = 'Check the setting of %s, a value greater than %s is not recommended';
|
||||
$limit_value = $values->max;
|
||||
}
|
||||
|
||||
if ($config[$variable] < $values->min) {
|
||||
$message = 'Check the setting of %s, a value less than %s is not recommended';
|
||||
$limit_value = $values->min;
|
||||
}
|
||||
|
||||
if ($limit_value !== '' && $message !== '') {
|
||||
if (is_metaconsole() === true) {
|
||||
$this->notify(
|
||||
[
|
||||
'type' => 'NOTIF.VARIABLES.PERFORMANCE.'.$variable,
|
||||
'title' => __('Incorrect config value'),
|
||||
'message' => __(
|
||||
$message,
|
||||
$names[$variable],
|
||||
$limit_value
|
||||
),
|
||||
'url' => '__url__index.php?sec=advanced&sec2=advanced/metasetup',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$this->notify(
|
||||
[
|
||||
'type' => 'NOTIF.VARIABLES.PERFORMANCE.'.$variable,
|
||||
'title' => __('Incorrect config value'),
|
||||
'message' => __(
|
||||
$message,
|
||||
$names[$variable],
|
||||
$limit_value
|
||||
),
|
||||
'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -548,6 +659,34 @@ class ConsoleSupervisor
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check number of agents and disable agentaccess token if number
|
||||
* is equals and more than 200.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function checkAccessStatisticsPerformance()
|
||||
{
|
||||
$total_agents = db_get_value('count(*)', 'tagente');
|
||||
|
||||
if ($total_agents >= 200) {
|
||||
db_process_sql_update('tconfig', ['value' => 0], ['token' => 'agentaccess']);
|
||||
$this->notify(
|
||||
[
|
||||
'type' => 'NOTIF.ACCESSSTASTICS.PERFORMANCE',
|
||||
'title' => __('Access statistics performance'),
|
||||
'message' => __(
|
||||
'Usage of agent access statistics IS NOT RECOMMENDED on systems with more than 200 agents due performance penalty'
|
||||
),
|
||||
'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$this->cleanNotifications('NOTIF.ACCESSSTASTICS.PERFORMANCE');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update targets for given notification using object targets.
|
||||
*
|
||||
|
@ -646,7 +646,7 @@ class Diagnostics extends Wizard
|
||||
$currentTime = time();
|
||||
|
||||
$pandoraDbLastRun = __('Pandora DB has never been executed');
|
||||
if ($dateDbMantenaince !== false) {
|
||||
if ($dateDbMantenaince !== false && empty($dateDbMantenaince) === false) {
|
||||
$difference = ($currentTime - $dateDbMantenaince);
|
||||
$pandoraDbLastRun = human_time_description_raw(
|
||||
$difference,
|
||||
|
495
pandora_console/include/class/EventSound.class.php
Normal file
495
pandora_console/include/class/EventSound.class.php
Normal file
@ -0,0 +1,495 @@
|
||||
<?php
|
||||
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||
/**
|
||||
* Controller for Audit Logs
|
||||
*
|
||||
* @category Controller
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
// Necessary classes for extends.
|
||||
require_once $config['homedir'].'/include/class/HTML.class.php';
|
||||
enterprise_include_once('godmode/admin_access_logs.php');
|
||||
|
||||
/**
|
||||
* Class EventSound
|
||||
*/
|
||||
class EventSound extends HTML
|
||||
{
|
||||
|
||||
/**
|
||||
* Allowed methods to be called using AJAX request.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $AJAXMethods = ['draw'];
|
||||
|
||||
/**
|
||||
* Ajax page.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $ajaxController;
|
||||
|
||||
/**
|
||||
* Table id.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $tableId;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param string $ajaxController Ajax controller.
|
||||
*/
|
||||
public function __construct(string $ajaxController)
|
||||
{
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'PM') === false
|
||||
&& is_user_admin($config['id_user']) === true
|
||||
) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access Event Sound'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the ajax controller.
|
||||
$this->ajaxController = $ajaxController;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run view
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
global $config;
|
||||
$tab = get_parameter('tab', '');
|
||||
$action = get_parameter('action', '');
|
||||
$message_ok = 0;
|
||||
$error_msg = __('Name already exist');
|
||||
$ok_msg = __('Successfully created');
|
||||
|
||||
if ($action == 'create') {
|
||||
$name = get_parameter('name', '');
|
||||
$sound = get_parameter('file', '');
|
||||
|
||||
$exist = db_get_all_rows_sql(sprintf('SELECT * FROM tevent_sound WHERE name = "%s"', $name));
|
||||
|
||||
if ($exist === false) {
|
||||
$uploadMaxFilesize = config_return_in_bytes(ini_get('upload_max_filesize'));
|
||||
|
||||
$upload_status = get_file_upload_status('file');
|
||||
$upload_result = translate_file_upload_status($upload_status);
|
||||
if ($uploadMaxFilesize < $sound['size']) {
|
||||
$error_msg = __('File is too large to upload. Check the configuration in php.ini.');
|
||||
} else {
|
||||
$pathname = $config['homedir'].'/include/sounds/';
|
||||
$nameSound = str_replace(' ', '_', $_FILES['file']['name']);
|
||||
$target_file = $pathname.basename($nameSound);
|
||||
|
||||
if (file_exists($target_file)) {
|
||||
$error_msg = __('Sound already are exists.');
|
||||
} else {
|
||||
if (move_uploaded_file($_FILES['file']['tmp_name'], $target_file)) {
|
||||
$insert = db_process_sql_insert(
|
||||
'tevent_sound',
|
||||
[
|
||||
'name' => $name,
|
||||
'sound' => $nameSound,
|
||||
]
|
||||
);
|
||||
$ok_msg = __('Successfully created');
|
||||
} else {
|
||||
$error_msg = __('Fail uploading the sound');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($insert > 0) {
|
||||
$tab = '';
|
||||
$message_ok = 1;
|
||||
}
|
||||
} else {
|
||||
$error_msg = __('Sound already are exists');
|
||||
}
|
||||
} else if ($action == 'change_action') {
|
||||
$id = get_parameter('id', '');
|
||||
$new_action = (int) get_parameter('set_action', '1');
|
||||
|
||||
$exist = db_get_all_rows_sql(sprintf('SELECT * FROM tevent_sound WHERE id = "%s"', $id));
|
||||
|
||||
if ($exist !== false) {
|
||||
$result = db_process_sql_update(
|
||||
'tevent_sound',
|
||||
['active' => $new_action],
|
||||
['id' => $id]
|
||||
);
|
||||
if (false === (bool) $result) {
|
||||
$error_msg = __('Error on update status');
|
||||
} else {
|
||||
$message_ok = 1;
|
||||
}
|
||||
} else {
|
||||
$error_msg = __('Sound not exist');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action) {
|
||||
ui_print_result_message(
|
||||
$message_ok,
|
||||
$ok_msg,
|
||||
$error_msg,
|
||||
'',
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
$base_url = 'index.php?sec=eventos&sec2=godmode/events/configuration_sounds';
|
||||
$setup_url = $base_url.'&tab=add';
|
||||
$tabs = [
|
||||
'list' => [
|
||||
'text' => '<a href="'.$base_url.'">'.html_print_image(
|
||||
'images/eye_show.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Sounds'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>',
|
||||
'active' => (bool) ($tab != 'add'),
|
||||
],
|
||||
'options' => [
|
||||
'text' => '<a href="'.$setup_url.'">'.html_print_image(
|
||||
'images/pen.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Create'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>',
|
||||
'active' => (bool) ($tab == 'add'),
|
||||
],
|
||||
];
|
||||
|
||||
if ($tab === 'add') {
|
||||
$helpHeader = '';
|
||||
$titleHeader = __('Add new sound');
|
||||
} else {
|
||||
$helpHeader = 'servers_ha_clusters_tab';
|
||||
$titleHeader = __('Accoustic console sound list');
|
||||
}
|
||||
|
||||
// Header.
|
||||
ui_print_standard_header(
|
||||
$titleHeader,
|
||||
'images/gm_servers.png',
|
||||
false,
|
||||
$helpHeader,
|
||||
false,
|
||||
$tabs,
|
||||
[
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Admin tools'),
|
||||
],
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Accoustic console setup'),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
// Javascript.
|
||||
ui_require_jquery_file('pandora');
|
||||
// CSS.
|
||||
ui_require_css_file('wizard');
|
||||
ui_require_css_file('discovery');
|
||||
|
||||
if ($tab === 'add') {
|
||||
echo '<form method="post" enctype="multipart/form-data" action="index.php?sec=eventos&sec2=godmode/events/configuration_sounds&tab=add&action=create">';
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
|
||||
$table->class = 'databox filters';
|
||||
$table->data = [];
|
||||
$table->data[0][0] = __('Name:');
|
||||
|
||||
$table->data[0][1] = html_print_input_text(
|
||||
'name',
|
||||
'',
|
||||
'',
|
||||
80,
|
||||
100,
|
||||
true,
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[1][0] = __('WAV Sound');
|
||||
$table->data[1][1] = html_print_input_file('file', true, ['required' => true]);
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
html_print_submit_button(
|
||||
__('Create'),
|
||||
'save_sound',
|
||||
false,
|
||||
'class="sub wand"'
|
||||
);
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
// Load own javascript file.
|
||||
echo $this->loadJS();
|
||||
} else {
|
||||
// Datatables list.
|
||||
try {
|
||||
$columns = [
|
||||
'name',
|
||||
'sound',
|
||||
[
|
||||
'text' => 'options',
|
||||
'class' => 'action_buttons mw120px',
|
||||
],
|
||||
];
|
||||
|
||||
$column_names = [
|
||||
__('Name'),
|
||||
__('Sound'),
|
||||
__('Options'),
|
||||
];
|
||||
|
||||
$this->tableId = 'event_sounds';
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
// Only in case of Metaconsole, format the frame.
|
||||
open_meta_frame();
|
||||
}
|
||||
|
||||
// Load datatables user interface.
|
||||
ui_print_datatable(
|
||||
[
|
||||
'id' => $this->tableId,
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'ajax_url' => $this->ajaxController,
|
||||
'ajax_data' => ['method' => 'draw'],
|
||||
'no_sortable_columns' => [-1],
|
||||
'order' => [
|
||||
'field' => 'id',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
'search_button_class' => 'sub filter',
|
||||
'form' => [
|
||||
'inputs' => [
|
||||
[
|
||||
'label' => __('Free search').ui_print_help_tip(__('Search filter by Name or Sound fields content'), true),
|
||||
'type' => 'text',
|
||||
'class' => 'w200px',
|
||||
'id' => 'filter_text',
|
||||
'name' => 'filter_text',
|
||||
],
|
||||
[
|
||||
'label' => __('Active'),
|
||||
'type' => 'select',
|
||||
'fields' => [
|
||||
'' => __('All'),
|
||||
'0' => __('No'),
|
||||
'1' => __('Yes'),
|
||||
],
|
||||
'class' => 'w100px',
|
||||
'id' => 'active',
|
||||
'name' => 'active',
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
// Close the frame.
|
||||
close_meta_frame();
|
||||
}
|
||||
|
||||
// Load own javascript file.
|
||||
echo $this->loadJS();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the data for draw the table.
|
||||
*
|
||||
* @return void.
|
||||
*/
|
||||
public function draw()
|
||||
{
|
||||
global $config;
|
||||
// Initialice filter.
|
||||
$filter = '1=1';
|
||||
// Init data.
|
||||
$data = [];
|
||||
// Count of total records.
|
||||
$count = 0;
|
||||
// Catch post parameters.
|
||||
$start = get_parameter('start', 0);
|
||||
$length = get_parameter('length', $config['block_size']);
|
||||
// There is a limit of (2^32)^2 (18446744073709551615) rows in a MyISAM table, show for show all use max nrows.
|
||||
$length = ($length != '-1') ? $length : '18446744073709551615';
|
||||
$order = get_datatable_order();
|
||||
$filters = get_parameter('filter', []);
|
||||
$filterText = $filters['filter_text'];
|
||||
$filterActive = $filters['active'];
|
||||
|
||||
if (empty($filterText) === false) {
|
||||
$filter .= sprintf(
|
||||
" AND (name LIKE '%%%s%%' OR sound LIKE '%%%s%%')",
|
||||
$filterText,
|
||||
$filterText
|
||||
);
|
||||
}
|
||||
|
||||
if (in_array($filterActive, [0, 1])) {
|
||||
$filter .= sprintf(
|
||||
' AND active = %s',
|
||||
$filterActive,
|
||||
);
|
||||
}
|
||||
|
||||
$count = (int) db_get_value_sql(sprintf('SELECT COUNT(*) as "total" FROM tevent_sound WHERE %s', $filter));
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT *
|
||||
FROM tevent_sound
|
||||
WHERE %s
|
||||
ORDER BY %s
|
||||
LIMIT %d, %d',
|
||||
$filter,
|
||||
$order,
|
||||
$start,
|
||||
$length
|
||||
);
|
||||
$data = db_get_all_rows_sql($sql);
|
||||
|
||||
foreach ($data as $key => $row) {
|
||||
if ($row['active'] === '1') {
|
||||
$img = 'images/lightbulb.png';
|
||||
$action = __('Disable sound');
|
||||
$new_action = 0;
|
||||
} else {
|
||||
$img = 'images/lightbulb_off.png';
|
||||
$action = __('Enable sound');
|
||||
$new_action = 1;
|
||||
}
|
||||
|
||||
$options = '<a href="index.php?sec=eventos&sec2=godmode/events/configuration_sounds';
|
||||
$options .= '&action=change_action&id='.$row['id'].'&set_action='.$new_action.'">';
|
||||
$options .= html_print_image(
|
||||
$img,
|
||||
true,
|
||||
[
|
||||
'title' => $action,
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
);
|
||||
$options .= '</a>';
|
||||
|
||||
$data[$key]['options'] = $options;
|
||||
}
|
||||
|
||||
echo json_encode(
|
||||
[
|
||||
'data' => $data,
|
||||
'recordsTotal' => $count,
|
||||
'recordsFiltered' => $count,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if target method is available to be called using AJAX.
|
||||
*
|
||||
* @param string $method Target method.
|
||||
*
|
||||
* @return boolean True allowed, false not.
|
||||
*/
|
||||
public function ajaxMethod(string $method)
|
||||
{
|
||||
return in_array($method, $this->AJAXMethods);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load Javascript code.
|
||||
*
|
||||
* @return string.
|
||||
*/
|
||||
public function loadJS()
|
||||
{
|
||||
// Nothing for this moment.
|
||||
ob_start();
|
||||
|
||||
// Javascript content.
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#file-sound').change(function(){
|
||||
var ext = $('#file-sound').val().split('.').pop().toLowerCase();
|
||||
if($.inArray(ext, ['wav']) == -1) {
|
||||
alert('<?php __('invalid extension'); ?>');
|
||||
$('#file-sound').val('');
|
||||
}
|
||||
});
|
||||
|
||||
$('#submit-save_sound').click(function(){
|
||||
console.log("a");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
// EOF Javascript content.
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -413,73 +413,74 @@ class SnmpConsole extends HTML
|
||||
'class' => 'flex-row',
|
||||
'inputs' => [
|
||||
[
|
||||
'label' => __('Alert'),
|
||||
'type' => 'select',
|
||||
'id' => 'filter_alert',
|
||||
'name' => 'filter_alert',
|
||||
'class' => 'w200px',
|
||||
'fields' => $show_alerts,
|
||||
'return' => true,
|
||||
'selected' => $this->filter_alert,
|
||||
'label' => __('Alert'),
|
||||
'type' => 'select',
|
||||
'id' => 'filter_alert',
|
||||
'input_class' => 'filter_input_datatable',
|
||||
'name' => 'filter_alert',
|
||||
'fields' => $show_alerts,
|
||||
'return' => true,
|
||||
'selected' => $this->filter_alert,
|
||||
],
|
||||
[
|
||||
'label' => __('Severity'),
|
||||
'type' => 'select',
|
||||
'id' => 'filter_severity',
|
||||
'name' => 'filter_severity',
|
||||
'class' => 'w200px',
|
||||
'fields' => $severities,
|
||||
'return' => true,
|
||||
'selected' => $this->filter_severity,
|
||||
'label' => __('Severity'),
|
||||
'type' => 'select',
|
||||
'id' => 'filter_severity',
|
||||
'input_class' => 'filter_input_datatable',
|
||||
'name' => 'filter_severity',
|
||||
'fields' => $severities,
|
||||
'return' => true,
|
||||
'selected' => $this->filter_severity,
|
||||
],
|
||||
[
|
||||
'label' => __('Free search'),
|
||||
'type' => 'text',
|
||||
'class' => 'w400px',
|
||||
'id' => 'filter_free_search',
|
||||
'name' => 'filter_free_search',
|
||||
'value' => $this->filter_free_search,
|
||||
'label' => __('Free search'),
|
||||
'type' => 'text',
|
||||
'id' => 'filter_free_search',
|
||||
'input_class' => 'filter_input_datatable',
|
||||
'name' => 'filter_free_search',
|
||||
'value' => $this->filter_free_search,
|
||||
],
|
||||
[
|
||||
'label' => __('Status'),
|
||||
'type' => 'select',
|
||||
'id' => 'filter_status',
|
||||
'name' => 'filter_status',
|
||||
'class' => 'w200px',
|
||||
'fields' => $status_array,
|
||||
'return' => true,
|
||||
'selected' => $this->filter_status,
|
||||
'label' => __('Status'),
|
||||
'type' => 'select',
|
||||
'id' => 'filter_status',
|
||||
'input_class' => 'filter_input_datatable',
|
||||
'name' => 'filter_status',
|
||||
'fields' => $status_array,
|
||||
'return' => true,
|
||||
'selected' => $this->filter_status,
|
||||
],
|
||||
[
|
||||
'label' => __('Group by Enterprise String/IP'),
|
||||
'type' => 'select',
|
||||
'name' => 'filter_group_by',
|
||||
'selected' => $this->filter_group_by,
|
||||
'disabled' => false,
|
||||
'return' => true,
|
||||
'id' => 'filter_group_by',
|
||||
'fields' => [
|
||||
'label' => __('Group by Enterprise String/IP'),
|
||||
'type' => 'select',
|
||||
'name' => 'filter_group_by',
|
||||
'selected' => $this->filter_group_by,
|
||||
'disabled' => false,
|
||||
'return' => true,
|
||||
'id' => 'filter_group_by',
|
||||
'input_class' => 'filter_input_datatable',
|
||||
'fields' => [
|
||||
0 => __('No'),
|
||||
1 => __('Yes'),
|
||||
],
|
||||
],
|
||||
[
|
||||
'label' => __('Max. hours old'),
|
||||
'type' => 'text',
|
||||
'class' => 'w200px',
|
||||
'id' => 'filter_hours_ago',
|
||||
'name' => 'filter_hours_ago',
|
||||
'value' => $this->filter_hours_ago,
|
||||
'label' => __('Max. hours old'),
|
||||
'type' => 'text',
|
||||
'id' => 'filter_hours_ago',
|
||||
'input_class' => 'filter_input_datatable',
|
||||
'name' => 'filter_hours_ago',
|
||||
'value' => $this->filter_hours_ago,
|
||||
],
|
||||
[
|
||||
'label' => __('Trap type'),
|
||||
'type' => 'select',
|
||||
'id' => 'filter_trap_type',
|
||||
'name' => 'filter_trap_type',
|
||||
'class' => 'w200px',
|
||||
'fields' => $trap_types,
|
||||
'return' => true,
|
||||
'selected' => $this->filter_trap_type,
|
||||
'label' => __('Trap type'),
|
||||
'type' => 'select',
|
||||
'id' => 'filter_trap_type',
|
||||
'input_class' => 'filter_input_datatable',
|
||||
'name' => 'filter_trap_type',
|
||||
'fields' => $trap_types,
|
||||
'return' => true,
|
||||
'selected' => $this->filter_trap_type,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
@ -20,7 +20,7 @@
|
||||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC230220';
|
||||
$build_version = 'PC230303';
|
||||
$pandora_version = 'v7.0NG.769';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
@ -6399,11 +6399,34 @@ function getBearerToken()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check whether an instance of pandora_db is running.
|
||||
*
|
||||
* @return boolean Result.
|
||||
*/
|
||||
function is_pandora_db_running()
|
||||
{
|
||||
// Get current DB name: useful for metaconsole connection to node.
|
||||
$db_name = db_get_sql('SELECT DATABASE()');
|
||||
|
||||
$is_free_lock = mysql_db_process_sql(
|
||||
'SELECT IS_FREE_LOCK("'.$db_name.'_pandora_db") AS "value"',
|
||||
'affected_rows',
|
||||
'',
|
||||
false
|
||||
);
|
||||
|
||||
$is_free_lock = (bool) $is_free_lock[0]['value'];
|
||||
|
||||
return !$is_free_lock;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check nms license on api.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
* @return boolean.
|
||||
* */
|
||||
function nms_check_api()
|
||||
{
|
||||
global $config;
|
||||
|
@ -519,6 +519,27 @@ function agents_get_agents(
|
||||
$search_custom = '';
|
||||
}
|
||||
|
||||
if (isset($filter['id_os'])) {
|
||||
$id_os = $filter['id_os'];
|
||||
unset($filter['id_os']);
|
||||
} else {
|
||||
$id_os = '';
|
||||
}
|
||||
|
||||
if (isset($filter['policies'])) {
|
||||
$policies = $filter['policies'];
|
||||
unset($filter['policies']);
|
||||
} else {
|
||||
$policies = '';
|
||||
}
|
||||
|
||||
if (isset($filter['other_condition'])) {
|
||||
$other_condition = $filter['other_condition'];
|
||||
unset($filter['other_condition']);
|
||||
} else {
|
||||
$other_condition = '';
|
||||
}
|
||||
|
||||
if (isset($filter['offset'])) {
|
||||
$offset = $filter['offset'];
|
||||
unset($filter['offset']);
|
||||
@ -692,25 +713,38 @@ function agents_get_agents(
|
||||
$where_nogroup = '1 = 1';
|
||||
}
|
||||
|
||||
$policy_join = '';
|
||||
|
||||
if ($policies !== '') {
|
||||
$policy_join = 'INNER JOIN tpolicy_agents
|
||||
ON tpolicy_agents.id_agent=tagente.id_agente';
|
||||
}
|
||||
|
||||
if ($extra) {
|
||||
$where = sprintf(
|
||||
'(%s OR (%s)) AND (%s) AND (%s) %s AND %s',
|
||||
'(%s OR (%s)) AND (%s) AND (%s) %s AND %s %s %s %s',
|
||||
$sql_extra,
|
||||
$where,
|
||||
$where_nogroup,
|
||||
$status_sql,
|
||||
$search,
|
||||
$disabled
|
||||
$disabled,
|
||||
$id_os,
|
||||
$policies,
|
||||
$other_condition
|
||||
);
|
||||
} else {
|
||||
$where = sprintf(
|
||||
'%s AND %s AND (%s) %s AND %s %s',
|
||||
'%s AND %s AND (%s) %s AND %s %s %s %s %s',
|
||||
$where,
|
||||
$where_nogroup,
|
||||
$status_sql,
|
||||
$search,
|
||||
$disabled,
|
||||
$search_custom
|
||||
$search_custom,
|
||||
$id_os,
|
||||
$policies,
|
||||
$other_condition
|
||||
);
|
||||
}
|
||||
|
||||
@ -720,9 +754,11 @@ function agents_get_agents(
|
||||
FROM `%s` tagente
|
||||
LEFT JOIN tagent_secondary_group
|
||||
ON tagent_secondary_group.id_agent=tagente.id_agente
|
||||
%s
|
||||
WHERE %s %s',
|
||||
implode(',', $fields),
|
||||
$table_name,
|
||||
$policy_join,
|
||||
$where,
|
||||
$order
|
||||
);
|
||||
|
@ -11071,20 +11071,55 @@ function api_set_event_validate_filter($trash1, $trash2, $other, $trash3)
|
||||
|
||||
function api_set_validate_events($id_event, $trash1, $other, $return_type, $user_in_db)
|
||||
{
|
||||
$text = $other['data'];
|
||||
$node_int = 0;
|
||||
if ($other['type'] == 'string') {
|
||||
returnError('Parameter error.');
|
||||
return;
|
||||
} else if ($other['type'] == 'array') {
|
||||
$text = $other['data'][0];
|
||||
if (is_metaconsole() === true) {
|
||||
if (isset($other['data'][1]) === true
|
||||
&& empty($other['data'][1]) === false
|
||||
) {
|
||||
$node_int = $other['data'][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set off the standby mode when close an event
|
||||
$event = events_get_event($id_event);
|
||||
alerts_agent_module_standby($event['id_alert_am'], 0);
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& (int) $node_int > 0
|
||||
) {
|
||||
$node = new Node($node_int);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$result = events_change_status($id_event, EVENT_VALIDATE);
|
||||
// Set off the standby mode when close an event
|
||||
$event = events_get_event($id_event);
|
||||
alerts_agent_module_standby($event['id_alert_am'], 0);
|
||||
$result = events_change_status($id_event, EVENT_VALIDATE);
|
||||
|
||||
if ($result) {
|
||||
if (!empty($text)) {
|
||||
// Set the comment for the validation
|
||||
events_comment($id_event, $text);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
if (is_metaconsole() === true
|
||||
&& $node_int > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$result = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $node_int > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
returnData(
|
||||
'string',
|
||||
[
|
||||
|
@ -844,6 +844,10 @@ function config_update_config()
|
||||
$error_update[] = __('Item limit for realtime reports)');
|
||||
}
|
||||
|
||||
if (config_update_value('events_per_query', (int) get_parameter('events_per_query'), true) === false) {
|
||||
$error_update[] = __('Limit of events per query');
|
||||
}
|
||||
|
||||
if (config_update_value('step_compact', (int) get_parameter('step_compact'), true) === false) {
|
||||
$error_update[] = __('Compact interpolation in hours (1 Fine-20 bad)');
|
||||
}
|
||||
@ -1982,6 +1986,10 @@ function config_process_config()
|
||||
config_update_value('report_limit', 100);
|
||||
}
|
||||
|
||||
if (!isset($config['events_per_query'])) {
|
||||
config_update_value('events_per_query', 5000);
|
||||
}
|
||||
|
||||
if (!isset($config['loginhash_pwd'])) {
|
||||
config_update_value('loginhash_pwd', io_input_password((rand(0, 1000) * rand(0, 1000)).'pandorahash'));
|
||||
}
|
||||
@ -2289,6 +2297,96 @@ function config_process_config()
|
||||
config_update_value('2Fa_auth', '');
|
||||
}
|
||||
|
||||
if (isset($config['performance_variables_control']) === false) {
|
||||
config_update_value(
|
||||
'performance_variables_control',
|
||||
json_encode(
|
||||
[
|
||||
'event_purge' => [
|
||||
'max' => 45,
|
||||
'min' => 1,
|
||||
],
|
||||
'trap_purge' => [
|
||||
'max' => 45,
|
||||
'min' => 1,
|
||||
],
|
||||
'audit_purge' => [
|
||||
'max' => 365,
|
||||
'min' => 7,
|
||||
],
|
||||
'string_purge' => [
|
||||
'max' => 365,
|
||||
'min' => 7,
|
||||
],
|
||||
'gis_purge' => [
|
||||
'max' => 365,
|
||||
'min' => 7,
|
||||
],
|
||||
'days_purge' => [
|
||||
'max' => 365,
|
||||
'min' => 7,
|
||||
],
|
||||
'days_compact' => [
|
||||
'max' => 365,
|
||||
'min' => 0,
|
||||
],
|
||||
'days_delete_unknown' => [
|
||||
'max' => 90,
|
||||
'min' => 0,
|
||||
],
|
||||
'days_delete_not_initialized' => [
|
||||
'max' => 90,
|
||||
'min' => 0,
|
||||
],
|
||||
'days_autodisable_deletion' => [
|
||||
'max' => 90,
|
||||
'min' => 0,
|
||||
],
|
||||
'delete_old_network_matrix' => [
|
||||
'max' => 30,
|
||||
'min' => 1,
|
||||
],
|
||||
'report_limit' => [
|
||||
'max' => 500,
|
||||
'min' => 1,
|
||||
],
|
||||
'event_view_hr' => [
|
||||
'max' => 360,
|
||||
'min' => 1,
|
||||
],
|
||||
'big_operation_step_datos_purge' => [
|
||||
'max' => 10000,
|
||||
'min' => 100,
|
||||
],
|
||||
'small_operation_step_datos_purge' => [
|
||||
'max' => 10000,
|
||||
'min' => 100,
|
||||
],
|
||||
'row_limit_csv' => [
|
||||
'max' => 1000000,
|
||||
'min' => 1,
|
||||
],
|
||||
'limit_parameters_massive' => [
|
||||
'max' => 2000,
|
||||
'min' => 100,
|
||||
],
|
||||
'block_size' => [
|
||||
'max' => 200,
|
||||
'min' => 10,
|
||||
],
|
||||
'short_module_graph_data' => [
|
||||
'max' => 20,
|
||||
'min' => 1,
|
||||
],
|
||||
'graph_precision' => [
|
||||
'max' => 5,
|
||||
'min' => 1,
|
||||
],
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($config['agent_wizard_defaults']) === false) {
|
||||
config_update_value(
|
||||
'agent_wizard_defaults',
|
||||
|
@ -2018,7 +2018,7 @@ function events_change_status(
|
||||
// Update ack info if the new status is validated.
|
||||
$ack_utimestamp = 0;
|
||||
$ack_user = $config['id_user'];
|
||||
if ((int) $new_status === EVENT_STATUS_VALIDATED) {
|
||||
if ((int) $new_status === EVENT_STATUS_VALIDATED || (int) $new_status === EVENT_STATUS_INPROCESS) {
|
||||
$ack_utimestamp = time();
|
||||
}
|
||||
|
||||
@ -2412,14 +2412,17 @@ function events_create_event(
|
||||
$source = get_product_name();
|
||||
}
|
||||
|
||||
// Get Timestamp.
|
||||
$timestamp = time();
|
||||
|
||||
$values = [
|
||||
'id_agente' => $id_agent,
|
||||
'id_usuario' => $id_user,
|
||||
'id_grupo' => $id_group,
|
||||
'estado' => $status,
|
||||
'timestamp' => date('Y-m-d H:i:s'),
|
||||
'timestamp' => date('Y-m-d H:i:s', $timestamp),
|
||||
'evento' => $event,
|
||||
'utimestamp' => time(),
|
||||
'utimestamp' => $timestamp,
|
||||
'event_type' => $event_type,
|
||||
'id_agentmodule' => $id_agent_module,
|
||||
'id_alert_am' => $id_aam,
|
||||
@ -4814,7 +4817,7 @@ function events_page_general($event)
|
||||
$data = [];
|
||||
$data[0] = __('Acknowledged by');
|
||||
|
||||
if ($event['estado'] == 1) {
|
||||
if ($event['estado'] == 1 || $event['estado'] == 2) {
|
||||
if (empty($event['id_usuario']) === true) {
|
||||
$user_ack = __('Autovalidated');
|
||||
} else {
|
||||
@ -4948,7 +4951,7 @@ function events_page_general_acknowledged($event_id)
|
||||
global $config;
|
||||
$Acknowledged = '';
|
||||
$event = db_get_row('tevento', 'id_evento', $event_id);
|
||||
if ($event !== false && $event['estado'] == 1) {
|
||||
if ($event !== false && ($event['estado'] == 1 || $event['estado'] == 2)) {
|
||||
$user_ack = db_get_value(
|
||||
'fullname',
|
||||
'tusuario',
|
||||
@ -5826,3 +5829,58 @@ function get_events_get_response_target(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the count of events by criticity.
|
||||
*
|
||||
* @param integer $utimestamp Utimestamp to search.
|
||||
* @param integer $eventType Event type.
|
||||
* @param array $groupId Groups.
|
||||
* @param integer $eventStatus Event status.
|
||||
* @param array $criticityId Criticity to search.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_count_event_criticity(
|
||||
$utimestamp,
|
||||
$eventType,
|
||||
$groupId,
|
||||
$eventStatus,
|
||||
$criticityId
|
||||
) {
|
||||
$type = ' ';
|
||||
if ($eventType !== '0') {
|
||||
$type = 'AND event_type = "'.$eventType.'"';
|
||||
}
|
||||
|
||||
$groups = ' ';
|
||||
if ((int) $groupId !== 0) {
|
||||
$groups = 'AND id_grupo IN ('.$groupId.')';
|
||||
}
|
||||
|
||||
$status = ' ';
|
||||
if ((int) $eventStatus !== -1) {
|
||||
$status = 'AND estado = '.$eventStatus;
|
||||
}
|
||||
|
||||
$criticity = ' ';
|
||||
if (empty($criticityId) === false) {
|
||||
$criticity = 'AND criticity IN ('.$criticityId.')';
|
||||
}
|
||||
|
||||
$sql_meta = sprintf(
|
||||
'SELECT COUNT(id_evento) AS count,
|
||||
criticity
|
||||
FROM tevento
|
||||
WHERE utimestamp >= %d %s %s %s %s
|
||||
GROUP BY criticity',
|
||||
$utimestamp,
|
||||
$type,
|
||||
$groups,
|
||||
$status,
|
||||
$criticity
|
||||
);
|
||||
|
||||
return db_get_all_rows_sql($sql_meta);
|
||||
}
|
||||
|
@ -84,6 +84,27 @@ function html_debug_print($var, $file='', $oneline=false)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Console log.
|
||||
*/
|
||||
function jslog($var)
|
||||
{
|
||||
$more_info = '';
|
||||
if (is_string($var)) {
|
||||
$more_info = 'size: '.strlen($var);
|
||||
} else if (is_bool($var)) {
|
||||
$more_info = 'val: '.($var ? 'true' : 'false');
|
||||
} else if (is_null($var)) {
|
||||
$more_info = 'is null';
|
||||
} else if (is_array($var)) {
|
||||
$more_info = count($var);
|
||||
}
|
||||
|
||||
echo '<script>console.log("'.date('Y/m/d H:i:s').' ('.gettype($var).') '.$more_info.'");</script>'."\n";
|
||||
echo '<script>console.log('.json_encode($var).');</script>';
|
||||
}
|
||||
|
||||
|
||||
// Alias for "html_debug_print"
|
||||
function html_debug($var, $file='', $oneline=false)
|
||||
{
|
||||
|
@ -159,6 +159,8 @@ function notifications_get_subtypes(?string $source=null)
|
||||
'NOTIF.SERVER.STATUS',
|
||||
'NOTIF.SERVER.QUEUE',
|
||||
'NOTIF.SERVER.MASTER',
|
||||
'NOTIF.ACCESSSTASTICS.PERFORMANCE',
|
||||
'NOTIF.VARIABLES.PERFORMANCE',
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -68,6 +68,7 @@ define('REPORT_STATUS_IGNORED', 5);
|
||||
|
||||
// Clases.
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
use PandoraFMS\Enterprise\Metaconsole\Synchronizer;
|
||||
use PandoraFMS\Event;
|
||||
use PandoraFMS\Module;
|
||||
|
||||
@ -7421,6 +7422,14 @@ function reporting_text($report, $content)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build SQL report item.
|
||||
*
|
||||
* @param array $report Report info.
|
||||
* @param array $content Content info.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function reporting_sql($report, $content)
|
||||
{
|
||||
global $config;
|
||||
@ -7438,15 +7447,98 @@ function reporting_sql($report, $content)
|
||||
$return['description'] = $content['description'];
|
||||
$return['date'] = reporting_get_date_text();
|
||||
|
||||
if ($config['metaconsole'] && !empty($content['server_name'])) {
|
||||
$id_meta = metaconsole_get_id_server(
|
||||
if (is_metaconsole() === true
|
||||
&& empty($content['server_name']) === false
|
||||
&& $content['server_name'] !== 'all'
|
||||
) {
|
||||
$id_server = metaconsole_get_id_server(
|
||||
$content['server_name']
|
||||
);
|
||||
|
||||
$server = metaconsole_get_connection_by_id($id_meta);
|
||||
metaconsole_connect($server);
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true && $content['server_name'] === 'all') {
|
||||
$sync = new Synchronizer();
|
||||
$results = $sync->apply(
|
||||
function ($node) use ($report, $content) {
|
||||
try {
|
||||
$node->connect();
|
||||
$rs = reporting_sql_auxiliary($report, $content);
|
||||
$node->disconnect();
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'error' => __(
|
||||
'Failed to connect to node %s',
|
||||
$node->server_name()
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
if ($rs === false) {
|
||||
return ['result' => []];
|
||||
}
|
||||
|
||||
return ['result' => $rs];
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
$data = [];
|
||||
$return['correct'] = 1;
|
||||
$return['error'] = '';
|
||||
|
||||
foreach ($results as $id_node => $items) {
|
||||
foreach ($items['result']['data'] as $key => $item) {
|
||||
$items['result']['data'][$key] = (['node_id' => $id_node] + $items['result']['data'][$key]);
|
||||
}
|
||||
|
||||
if ((int) $items['result']['correct'] !== 1) {
|
||||
$return['correct'] = 0;
|
||||
}
|
||||
|
||||
if ($items['result']['error'] !== '') {
|
||||
$return['error'] = $items['result']['error'];
|
||||
}
|
||||
|
||||
$return['sql'] = $items['result']['sql'];
|
||||
|
||||
$data = array_merge($data, $items['result']['data']);
|
||||
}
|
||||
|
||||
$return['data'] = $data;
|
||||
} else {
|
||||
try {
|
||||
if (is_metaconsole() === true && $id_server > 0) {
|
||||
$node = new Node($id_server);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$query_result = reporting_sql_auxiliary($report, $content);
|
||||
$return = array_merge($return, $query_result);
|
||||
|
||||
if (is_metaconsole() === true && $id_server > 0) {
|
||||
$node->disconnect();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
if (is_metaconsole() === true && $id_server > 0) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Auxiliary function for reporting_sql.
|
||||
*
|
||||
* @param array $report Report info.
|
||||
* @param array $content Content info.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function reporting_sql_auxiliary($report, $content)
|
||||
{
|
||||
if ($content['treport_custom_sql_id'] != 0) {
|
||||
$sql = io_safe_output(
|
||||
db_get_value_filter(
|
||||
@ -7459,7 +7551,7 @@ function reporting_sql($report, $content)
|
||||
$sql = $content['external_source'];
|
||||
}
|
||||
|
||||
// Check if exist sql macro.
|
||||
// Check if SQL macro exists.
|
||||
$sql = reporting_sql_macro($report, $sql);
|
||||
|
||||
// Do a security check on SQL coming from the user.
|
||||
@ -7514,11 +7606,7 @@ function reporting_sql($report, $content)
|
||||
$return['error'] = __('Illegal query: Due security restrictions, there are some tokens or words you cannot use: *, delete, drop, alter, modify, password, pass, insert or update.');
|
||||
}
|
||||
|
||||
if ($config['metaconsole'] && !empty($content['server_name'])) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
return reporting_check_structure_content($return);
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Auxiliary functions to manage servers.
|
||||
*
|
||||
@ -45,7 +44,7 @@ function servers_get_server($id_server, $filter=false, $fields=false)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_array($filter)) {
|
||||
if (! is_array($filter)) {
|
||||
$filter = [];
|
||||
}
|
||||
|
||||
@ -146,6 +145,7 @@ function servers_get_total_modules()
|
||||
);
|
||||
|
||||
return $modules;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1017,57 +1017,40 @@ function servers_get_info($id_server=-1)
|
||||
// Remote servers LAG Calculation (server_type != 0).
|
||||
if ($server['server_type'] != 0) {
|
||||
// MySQL 8.0 has function lag(). So, lag must be enclosed in quotations.
|
||||
$sql = sprintf(
|
||||
'SELECT COUNT(tam.id_agente_modulo) AS module_lag,
|
||||
AVG(UNIX_TIMESTAMP() - tae.last_execution_try - tae.current_interval) AS "lag"
|
||||
FROM (
|
||||
SELECT tagente_estado.last_execution_try, tagente_estado.current_interval, tagente_estado.id_agente_modulo
|
||||
FROM tagente_estado
|
||||
WHERE tagente_estado.current_interval > 0
|
||||
AND tagente_estado.last_execution_try > 0
|
||||
AND tagente_estado.running_by = %d
|
||||
) tae
|
||||
JOIN (
|
||||
SELECT tagente_modulo.id_agente_modulo
|
||||
FROM tagente_modulo LEFT JOIN tagente
|
||||
ON tagente_modulo.id_agente = tagente.id_agente
|
||||
WHERE tagente.disabled = 0
|
||||
AND tagente_modulo.disabled = 0
|
||||
) tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
WHERE (UNIX_TIMESTAMP() - tae.last_execution_try) > (tae.current_interval)
|
||||
AND (UNIX_TIMESTAMP() - tae.last_execution_try) < ( tae.current_interval * 10)',
|
||||
$server['id_server']
|
||||
$result = db_get_row_sql(
|
||||
'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag,
|
||||
AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS "lag"
|
||||
FROM tagente_estado, tagente_modulo, tagente
|
||||
WHERE utimestamp > 0
|
||||
AND tagente.disabled = 0
|
||||
AND tagente.id_agente = tagente_estado.id_agente
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND current_interval > 0
|
||||
AND running_by = '.$server['id_server'].'
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10)
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) > current_interval'
|
||||
);
|
||||
} else {
|
||||
// Local/Dataserver server LAG calculation.
|
||||
// MySQL 8.0 has function lag(). So, lag must be enclosed in quotations.
|
||||
$sql = sprintf(
|
||||
'SELECT COUNT(tam.id_agente_modulo) AS module_lag,
|
||||
AVG(UNIX_TIMESTAMP() - tae.last_execution_try - tae.current_interval) AS "lag"
|
||||
FROM (
|
||||
SELECT tagente_estado.last_execution_try, tagente_estado.current_interval, tagente_estado.id_agente_modulo
|
||||
FROM tagente_estado
|
||||
WHERE tagente_estado.current_interval > 0
|
||||
AND tagente_estado.last_execution_try > 0
|
||||
AND tagente_estado.running_by = %d
|
||||
) tae
|
||||
JOIN (
|
||||
SELECT tagente_modulo.id_agente_modulo
|
||||
FROM tagente_modulo LEFT JOIN tagente
|
||||
ON tagente_modulo.id_agente = tagente.id_agente
|
||||
WHERE tagente.disabled = 0
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_tipo_modulo < 5
|
||||
) tam
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
WHERE (UNIX_TIMESTAMP() - tae.last_execution_try) > (tae.current_interval * 1.1)
|
||||
AND (UNIX_TIMESTAMP() - tae.last_execution_try) < ( tae.current_interval * 10)',
|
||||
$server['id_server']
|
||||
$result = db_get_row_sql(
|
||||
'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag,
|
||||
AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS "lag"
|
||||
FROM tagente_estado, tagente_modulo, tagente
|
||||
WHERE utimestamp > 0
|
||||
AND tagente.disabled = 0
|
||||
AND tagente.id_agente = tagente_estado.id_agente
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_tipo_modulo < 5
|
||||
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND current_interval > 0
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10)
|
||||
AND running_by = '.$server['id_server'].'
|
||||
AND (UNIX_TIMESTAMP() - utimestamp) > (current_interval * 1.1)'
|
||||
);
|
||||
}
|
||||
|
||||
$result = db_get_row_sql($sql);
|
||||
// Lag over current_interval * 2 is not lag,
|
||||
// it's a timed out module.
|
||||
if (!empty($result['lag'])) {
|
||||
@ -1154,11 +1137,11 @@ function servers_check_remote_config($server_name)
|
||||
$config['remote_config']
|
||||
).'/conf/'.$server_md5.'.srv.conf';
|
||||
|
||||
if (!isset($filenames['conf'])) {
|
||||
if (! isset($filenames['conf'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($filenames['md5'])) {
|
||||
if (! isset($filenames['md5'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -696,6 +696,8 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
|
||||
$go_to_agent .= '<a target=_blank href="'.$console_url.'index.php?sec=reporting&sec2=operation/cluster/cluster&op=update&id='.$cluster->id().'">';
|
||||
$go_to_agent .= html_print_submit_button(__('Go to cluster edition'), 'upd_button', false, 'class="sub config"', true);
|
||||
} else {
|
||||
$go_to_agent .= '<a target=_blank href="'.$console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente.$ent.'&status_hierachy_mode_sent=1&moduletype=dataserver&edit_module=1&updbutton=Create&sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente=2">';
|
||||
$go_to_agent .= html_print_submit_button(__('Go to module creation'), 'upd_button', false, 'class="sub config"', true);
|
||||
$go_to_agent .= '<a target=_blank href="'.$console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$ent.'">';
|
||||
$go_to_agent .= html_print_submit_button(__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true);
|
||||
}
|
||||
|
@ -7084,3 +7084,21 @@ function ui_get_inventory_module_add_form(
|
||||
}
|
||||
|
||||
|
||||
function ui_print_status_div($status)
|
||||
{
|
||||
switch ((int) $status) {
|
||||
case 0:
|
||||
$return = '<div class="status_rounded_rectangles forced_title" style="display: inline-block; background: #82b92e;" title="OK" data-title="OK" data-use_title_for_force_title="1"> </div>';
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$return = '<div class="status_rounded_rectangles forced_title" style="display: inline-block; background: #e63c52;" title="FAILED" data-title="FAILED" data-use_title_for_force_title="1"> </div>';
|
||||
break;
|
||||
|
||||
default:
|
||||
$return = '<div class="status_rounded_rectangles forced_title" style="display: inline-block; background: #fff;" title="UNDEFINED" data-title="UNDEFINED" data-use_title_for_force_title="1"> </div>';
|
||||
break;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
@ -420,6 +420,7 @@ class Widget
|
||||
case 'ColorModuleTabs':
|
||||
case 'BlockHistogram':
|
||||
case 'DataMatrix':
|
||||
case 'EventCardboard':
|
||||
$className .= '\\'.$name;
|
||||
break;
|
||||
|
||||
|
664
pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php
Normal file
664
pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php
Normal file
@ -0,0 +1,664 @@
|
||||
<?php
|
||||
/**
|
||||
* Widget Event cardboard Pandora FMS Console
|
||||
*
|
||||
* @category Console Class
|
||||
* @package Pandora FMS
|
||||
* @subpackage Widget Event cardboard
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2023 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
namespace PandoraFMS\Dashboard;
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
/**
|
||||
* Event cardboard Widgets.
|
||||
*/
|
||||
class EventCardboard extends Widget
|
||||
{
|
||||
|
||||
/**
|
||||
* Name widget.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* Title widget.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* Page widget;
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $page;
|
||||
|
||||
/**
|
||||
* Class name widget.
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
protected $className;
|
||||
|
||||
/**
|
||||
* Values options for each widget.
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
protected $values;
|
||||
|
||||
/**
|
||||
* Configuration required.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $configurationRequired;
|
||||
|
||||
/**
|
||||
* Error load widget.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $loadError;
|
||||
|
||||
/**
|
||||
* Width.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $width;
|
||||
|
||||
/**
|
||||
* Heigth.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $height;
|
||||
|
||||
/**
|
||||
* Grid Width.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $gridWidth;
|
||||
|
||||
/**
|
||||
* Cell ID.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $cellId;
|
||||
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param integer $cellId Cell ID.
|
||||
* @param integer $dashboardId Dashboard ID.
|
||||
* @param integer $widgetId Widget ID.
|
||||
* @param integer|null $width New width.
|
||||
* @param integer|null $height New height.
|
||||
* @param integer|null $gridWidth Grid width.
|
||||
*/
|
||||
public function __construct(
|
||||
int $cellId,
|
||||
int $dashboardId=0,
|
||||
int $widgetId=0,
|
||||
?int $width=0,
|
||||
?int $height=0,
|
||||
?int $gridWidth=0
|
||||
) {
|
||||
global $config;
|
||||
|
||||
include_once $config['homedir'].'/include/functions_agents.php';
|
||||
include_once $config['homedir'].'/include/functions_modules.php';
|
||||
|
||||
// WARNING: Do not edit. This chunk must be in the constructor.
|
||||
parent::__construct(
|
||||
$cellId,
|
||||
$dashboardId,
|
||||
$widgetId
|
||||
);
|
||||
|
||||
// Width.
|
||||
$this->width = $width;
|
||||
|
||||
// Height.
|
||||
$this->height = $height;
|
||||
|
||||
// Grid Width.
|
||||
$this->gridWidth = $gridWidth;
|
||||
|
||||
// Cell Id.
|
||||
$this->cellId = $cellId;
|
||||
|
||||
// Options.
|
||||
$this->values = $this->decoders($this->getOptionsWidget());
|
||||
|
||||
// Positions.
|
||||
$this->position = $this->getPositionWidget();
|
||||
|
||||
// Page.
|
||||
$this->page = basename(__FILE__);
|
||||
|
||||
// ClassName.
|
||||
$class = new \ReflectionClass($this);
|
||||
$this->className = $class->getShortName();
|
||||
|
||||
// Title.
|
||||
$this->title = __('Event cardboard');
|
||||
|
||||
// Name.
|
||||
if (empty($this->name) === true) {
|
||||
$this->name = 'EventCardboard';
|
||||
}
|
||||
|
||||
// This forces at least a first configuration.
|
||||
$this->configurationRequired = false;
|
||||
if (isset($this->values['groupId']) === false) {
|
||||
$this->configurationRequired = true;
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decoders hack for retrocompability.
|
||||
*
|
||||
* @param array $decoder Values.
|
||||
*
|
||||
* @return array Returns the values with the correct key.
|
||||
*/
|
||||
public function decoders(array $decoder): array
|
||||
{
|
||||
$values = [];
|
||||
// Retrieve global - common inputs.
|
||||
$values = parent::decoders($decoder);
|
||||
|
||||
if (isset($decoder['eventType']) === true) {
|
||||
$values['eventType'] = $decoder['eventType'];
|
||||
}
|
||||
|
||||
if (isset($decoder['maxHours']) === true) {
|
||||
$values['maxHours'] = $decoder['maxHours'];
|
||||
}
|
||||
|
||||
if (isset($decoder['eventStatus']) === true) {
|
||||
$values['eventStatus'] = $decoder['eventStatus'];
|
||||
}
|
||||
|
||||
if (isset($decoder['severity']) === true) {
|
||||
$values['severity'] = $decoder['severity'];
|
||||
}
|
||||
|
||||
if (isset($decoder['groupId']) === true) {
|
||||
$values['groupId'] = $decoder['groupId'];
|
||||
}
|
||||
|
||||
if (isset($decoder['nodes']) === true) {
|
||||
$values['nodes'] = $decoder['nodes'];
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates inputs for form (specific).
|
||||
*
|
||||
* @return array Of inputs.
|
||||
*
|
||||
* @throws Exception On error.
|
||||
*/
|
||||
public function getFormInputs(): array
|
||||
{
|
||||
$values = $this->values;
|
||||
|
||||
// Retrieve global - common inputs.
|
||||
$inputs = parent::getFormInputs();
|
||||
|
||||
// Remove background field, this widget doesn't use it.
|
||||
foreach ($inputs as $kIn => $vIn) {
|
||||
if ($vIn['label'] === 'Background') {
|
||||
unset($inputs[$kIn]);
|
||||
}
|
||||
}
|
||||
|
||||
$blocks = [
|
||||
'row1',
|
||||
'row2',
|
||||
];
|
||||
|
||||
$inputs['blocks'] = $blocks;
|
||||
|
||||
foreach ($inputs as $kInput => $vInput) {
|
||||
$inputs['inputs']['row1'][] = $vInput;
|
||||
}
|
||||
|
||||
// Event Type.
|
||||
$fields = get_event_types();
|
||||
$fields['not_normal'] = __('Not normal');
|
||||
|
||||
$inputs['inputs']['row1'][] = [
|
||||
'label' => __('Event type'),
|
||||
'arguments' => [
|
||||
'type' => 'select',
|
||||
'fields' => $fields,
|
||||
'class' => 'event-widget-input',
|
||||
'name' => 'eventType',
|
||||
'selected' => $values['eventType'],
|
||||
'return' => true,
|
||||
'nothing' => __('Any'),
|
||||
'nothing_value' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
// Max. hours old. Default 8.
|
||||
if (isset($values['maxHours']) === false) {
|
||||
$values['maxHours'] = 8;
|
||||
}
|
||||
|
||||
$inputs['inputs']['row1'][] = [
|
||||
'label' => __('Max. hours old'),
|
||||
'arguments' => [
|
||||
'name' => 'maxHours',
|
||||
'type' => 'number',
|
||||
'class' => 'event-widget-input',
|
||||
'value' => $values['maxHours'],
|
||||
'return' => true,
|
||||
'min' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
// Event status.
|
||||
$fields = [
|
||||
-1 => __('All event'),
|
||||
1 => __('Only validated'),
|
||||
0 => __('Only pending'),
|
||||
];
|
||||
|
||||
$inputs['inputs']['row1'][] = [
|
||||
'label' => __('Event status'),
|
||||
'arguments' => [
|
||||
'type' => 'select',
|
||||
'fields' => $fields,
|
||||
'class' => 'event-widget-input',
|
||||
'name' => 'eventStatus',
|
||||
'selected' => $values['eventStatus'],
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
// Groups.
|
||||
$return_all_group = false;
|
||||
$selected_groups_array = explode(',', $values['groupId'][0]);
|
||||
|
||||
if (empty($values['groupId'][0]) === true) {
|
||||
$selected_groups_array = [0];
|
||||
}
|
||||
|
||||
if ((bool) \users_can_manage_group_all('RM') === true
|
||||
|| ($selected_groups_array[0] !== ''
|
||||
&& in_array(0, $selected_groups_array) === true)
|
||||
) {
|
||||
// Return all group if user has permissions or it is a currently
|
||||
// selected group.
|
||||
$return_all_group = true;
|
||||
}
|
||||
|
||||
$inputs['inputs']['row1'][] = [
|
||||
'label' => __('Groups'),
|
||||
'arguments' => [
|
||||
'type' => 'select_groups',
|
||||
'name' => 'groupId[]',
|
||||
'class' => 'event-widget-input',
|
||||
'returnAllGroup' => true,
|
||||
'privilege' => 'AR',
|
||||
'selected' => $selected_groups_array,
|
||||
'return' => true,
|
||||
'multiple' => true,
|
||||
'returnAllGroup' => $return_all_group,
|
||||
'required' => true,
|
||||
],
|
||||
];
|
||||
|
||||
// Nodes.
|
||||
if (is_metaconsole() === true) {
|
||||
$nodes_fields = [];
|
||||
$servers_ids = metaconsole_get_servers();
|
||||
|
||||
foreach ($servers_ids as $server) {
|
||||
$nodes_fields[$server['id']] = $server['server_name'];
|
||||
}
|
||||
|
||||
$nodes_fields[0] = __('Metaconsola');
|
||||
|
||||
$nodes_selected = explode(',', $values['nodes']);
|
||||
|
||||
(isset($values['nodes']) === false) ? $nodes_selected = $servers_ids : '';
|
||||
|
||||
$nodes_height = count($nodes_fields);
|
||||
if (count($nodes_fields) > 5) {
|
||||
$nodes_height = 5;
|
||||
}
|
||||
|
||||
$inputs['inputs']['row2'][] = [
|
||||
'label' => __('Servers'),
|
||||
'arguments' => [
|
||||
'name' => 'nodes',
|
||||
'type' => 'select',
|
||||
'fields' => $nodes_fields,
|
||||
'selected' => $nodes_selected,
|
||||
'return' => true,
|
||||
'multiple' => true,
|
||||
'class' => 'overflow-hidden',
|
||||
'size' => $nodes_height,
|
||||
'select_all' => false,
|
||||
'required' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
// Severity.
|
||||
$fields = get_priorities();
|
||||
|
||||
$severity_selected = explode(',', $values['severity']);
|
||||
|
||||
if (isset($values['severity']) === false) {
|
||||
$severity_selected = array_keys($fields);
|
||||
}
|
||||
|
||||
$inputs['inputs']['row2'][] = [
|
||||
'label' => __('Severity'),
|
||||
'arguments' => [
|
||||
'type' => 'select',
|
||||
'fields' => $fields,
|
||||
'class' => 'event-widget-input',
|
||||
'name' => 'severity',
|
||||
'selected' => $severity_selected,
|
||||
'return' => true,
|
||||
'multiple' => true,
|
||||
],
|
||||
];
|
||||
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Post for widget.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPost():array
|
||||
{
|
||||
// Retrieve global - common inputs.
|
||||
$values = parent::getPost();
|
||||
|
||||
$values['eventType'] = \get_parameter('eventType', 0);
|
||||
$values['maxHours'] = \get_parameter('maxHours', 8);
|
||||
$values['eventStatus'] = \get_parameter('eventStatus', -1);
|
||||
$values['groupId'] = \get_parameter('groupId', []);
|
||||
$values['severity'] = \get_parameter('severity', -1);
|
||||
$values['nodes'] = \get_parameter('nodes', 0);
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw widget.
|
||||
*
|
||||
* @return string;
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
$output = '';
|
||||
|
||||
ui_require_css_file('events', 'include/styles/', true);
|
||||
ui_require_javascript_file('pandora_events', 'include/javascript/', true);
|
||||
|
||||
$eventType = $this->values['eventType'];
|
||||
$groupId = implode(',', $this->values['groupId']);
|
||||
$utimestamp = strtotime('-'.$this->values['maxHours'].' hours');
|
||||
$eventStatus = $this->values['eventStatus'];
|
||||
$severity = $this->values['severity'];
|
||||
|
||||
$priorities = explode(',', $severity);
|
||||
// Sort criticity array.
|
||||
asort($priorities);
|
||||
|
||||
$count_meta = [];
|
||||
$count_meta_tmp = [];
|
||||
if (is_metaconsole() === true) {
|
||||
$meta = false;
|
||||
$nodes = $this->values['nodes'];
|
||||
|
||||
if (isset($nodes) === true) {
|
||||
$servers_ids = explode(',', $nodes);
|
||||
}
|
||||
|
||||
if (in_array(0, $servers_ids) === true) {
|
||||
$meta = true;
|
||||
unset($servers_ids[0]);
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true && $meta === true) {
|
||||
$events_meta_rows = get_count_event_criticity(
|
||||
$utimestamp,
|
||||
$eventType,
|
||||
$groupId,
|
||||
$eventStatus,
|
||||
$severity
|
||||
);
|
||||
|
||||
array_push($count_meta_tmp, $events_meta_rows);
|
||||
}
|
||||
|
||||
foreach ($servers_ids as $server_id) {
|
||||
try {
|
||||
$node = new Node((int) $server_id);
|
||||
$node->connect();
|
||||
|
||||
$events_meta_rows = get_count_event_criticity(
|
||||
$utimestamp,
|
||||
$eventType,
|
||||
$groupId,
|
||||
$eventStatus,
|
||||
$severity
|
||||
);
|
||||
|
||||
array_push($count_meta_tmp, $events_meta_rows);
|
||||
$node->disconnect();
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent envents.
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($count_meta_tmp as $tmpValue) {
|
||||
foreach ($tmpValue as $value) {
|
||||
array_push($count_meta, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$events_rows = [];
|
||||
foreach ($priorities as $pKey) {
|
||||
$count = 0;
|
||||
$tmp['criticity'] = $pKey;
|
||||
foreach ($count_meta as $kEventMeta => $vEventMeta) {
|
||||
if ((int) $pKey === (int) $vEventMeta['criticity']) {
|
||||
$count += (int) $vEventMeta['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$tmp['count'] = $count;
|
||||
array_push($events_rows, $tmp);
|
||||
}
|
||||
} else {
|
||||
$events_rows = get_count_event_criticity(
|
||||
$utimestamp,
|
||||
$eventType,
|
||||
$groupId,
|
||||
$eventStatus,
|
||||
$severity
|
||||
);
|
||||
}
|
||||
|
||||
$output .= '<table class="w100p h100p table-border-0"><tbody><tr>';
|
||||
|
||||
$width_td = (100 / count(explode(',', $severity)));
|
||||
|
||||
$td_count = 0;
|
||||
foreach ($priorities as $key) {
|
||||
$count = 0;
|
||||
foreach ($events_rows as $event) {
|
||||
if ((int) $key === (int) $event['criticity']) {
|
||||
$count = $event['count'];
|
||||
}
|
||||
}
|
||||
|
||||
switch ((int) $key) {
|
||||
case 0:
|
||||
$text = __('Maintenance');
|
||||
$color = get_priority_class((int) $key);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$text = __('Informational');
|
||||
$color = get_priority_class((int) $key);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$text = __('Normal');
|
||||
$color = get_priority_class((int) $key);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$text = __('Warning');
|
||||
$color = get_priority_class((int) $key);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$text = __('Critical');
|
||||
$color = get_priority_class((int) $key);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$text = __('Minor');
|
||||
$color = get_priority_class((int) $key);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$text = __('Major');
|
||||
$color = get_priority_class((int) $key);
|
||||
break;
|
||||
|
||||
case 20:
|
||||
$text = __('Not normal');
|
||||
$color = get_priority_class((int) $key);
|
||||
break;
|
||||
|
||||
case 21:
|
||||
$text = __('Critical').'/'.__('Normal');
|
||||
$color = get_priority_class((int) $key);
|
||||
break;
|
||||
|
||||
case 34:
|
||||
$text = __('Warning').'/'.__('Critical');
|
||||
$color = get_priority_class((int) $key);
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
$border = '';
|
||||
$td_count++;
|
||||
if (count($priorities) > $td_count) {
|
||||
$border = ' border-right: 1px solid white; border-collapse: collapse;';
|
||||
}
|
||||
|
||||
$output .= '<td class="'.$color.'" style="width: '.$width_td.'%;'.$border.'"><span class="med_data">';
|
||||
$output .= $count;
|
||||
$output .= '</span><br>';
|
||||
$output .= $text;
|
||||
$output .= '</td>';
|
||||
}
|
||||
|
||||
$output .= '</tr></tbody></table>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get description.
|
||||
*
|
||||
* @return string.
|
||||
*/
|
||||
public static function getDescription()
|
||||
{
|
||||
return __('Event cardboard');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Name.
|
||||
*
|
||||
* @return string.
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'EventCardboard';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get size Modal Configuration.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSizeModalConfiguration(): array
|
||||
{
|
||||
if (is_metaconsole() === true) {
|
||||
$size = [
|
||||
'width' => 950,
|
||||
'height' => 450,
|
||||
];
|
||||
} else {
|
||||
$size = [
|
||||
'width' => 900,
|
||||
'height' => 450,
|
||||
];
|
||||
}
|
||||
|
||||
return $size;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -144,6 +144,8 @@ class View extends \HTML
|
||||
tinyMCE.init({
|
||||
selector: "#textarea_label",
|
||||
theme: "advanced",
|
||||
convert_urls:false,
|
||||
relative_urls:false,
|
||||
content_css: "'.ui_get_full_url(false, false, false, false).'include/styles/pandora.css",
|
||||
theme_advanced_font_sizes:
|
||||
"4pt=.visual_font_size_4pt, " +
|
||||
|
@ -29,3 +29,18 @@ li#select_multiple_modules_filtered {
|
||||
#menu_tab li.nomn form#form-select-dashboard {
|
||||
margin-top: 0px !important;
|
||||
}
|
||||
|
||||
.table-border-0 {
|
||||
border: none !important;
|
||||
border-spacing: 0px !important;
|
||||
}
|
||||
|
||||
.big_data {
|
||||
text-decoration: none;
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
.med_data {
|
||||
text-decoration: none;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
@ -323,6 +323,27 @@ a.pandora_pagination.current:hover {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.filter_input_datatable {
|
||||
width: 45% !important;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
flex-direction: row;
|
||||
max-width: 450px;
|
||||
min-width: 400px;
|
||||
}
|
||||
.filter_input_datatable input {
|
||||
flex: 1;
|
||||
}
|
||||
.filter_input_datatable label {
|
||||
width: 93px;
|
||||
max-width: 100%;
|
||||
}
|
||||
.filter_input_datatable .select2.select2-container {
|
||||
flex: 1;
|
||||
}
|
||||
.datatable_filter.content li.filter_input_datatable {
|
||||
margin: 1em 0;
|
||||
}
|
||||
/* Default datatable filter style */
|
||||
.datatable_filter.content {
|
||||
display: flex;
|
||||
@ -337,6 +358,7 @@ a.pandora_pagination.current:hover {
|
||||
.datatable_filter.content li {
|
||||
flex: 1 1 auto;
|
||||
margin: 1em auto;
|
||||
padding: 0px 10px;
|
||||
}
|
||||
.sorting_desc {
|
||||
background: url(../../images/sort_down_green.png) no-repeat;
|
||||
|
@ -1049,6 +1049,7 @@ if (isset($_GET['bye'])) {
|
||||
header_remove('Set-Cookie');
|
||||
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
|
||||
|
||||
generate_csrf_code();
|
||||
// Process logout.
|
||||
include 'general/logoff.php';
|
||||
|
||||
|
@ -131,7 +131,7 @@
|
||||
<div style='padding-bottom: 50px'>
|
||||
<?php
|
||||
$version = '7.0NG.769';
|
||||
$build = '230220';
|
||||
$build = '230303';
|
||||
$banner = "v$version Build $build";
|
||||
error_reporting(0);
|
||||
|
||||
|
@ -36,6 +36,7 @@ require_once $config['homedir'].'/include/functions_agents.php';
|
||||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
require_once $config['homedir'].'/include/functions_modules.php';
|
||||
enterprise_include_once('include/functions_config_agents.php');
|
||||
enterprise_include_once('include/functions_policies.php');
|
||||
|
||||
check_login();
|
||||
|
||||
@ -181,6 +182,9 @@ $offset = (int) get_parameter('offset', 0);
|
||||
$refr = get_parameter('refr', 0);
|
||||
$recursion = get_parameter('recursion', 0);
|
||||
$status = (int) get_parameter('status', -1);
|
||||
$os = (int) get_parameter('os', 0);
|
||||
$policies = (array) get_parameter('policies', []);
|
||||
$ag_custom_fields = (array) get_parameter('ag_custom_fields', []);
|
||||
|
||||
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||
$agent_a = (bool) check_acl($config['id_user'], 0, 'AR');
|
||||
@ -189,6 +193,52 @@ $access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR');
|
||||
|
||||
$onheader = [];
|
||||
|
||||
$load_filter_id = (int) get_parameter('filter_id', 0);
|
||||
|
||||
if ($load_filter_id > 0) {
|
||||
$user_groups_fl = users_get_groups(
|
||||
$config['id_user'],
|
||||
'AR',
|
||||
users_can_manage_group_all('AR'),
|
||||
true
|
||||
);
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT id_filter, id_name
|
||||
FROM tagent_filter
|
||||
WHERE id_filter = %d AND id_group_filter IN (%s)',
|
||||
$load_filter_id,
|
||||
implode(',', array_keys($user_groups_fl))
|
||||
);
|
||||
|
||||
$loaded_filter = db_get_row_sql($sql);
|
||||
}
|
||||
|
||||
if ($loaded_filter['id_filter'] > 0) {
|
||||
$query_filter['id_filter'] = $load_filter_id;
|
||||
$filter = db_get_row_filter('tagent_filter', $query_filter, false);
|
||||
|
||||
if ($filter !== false) {
|
||||
$group_id = (int) $filter['group_id'];
|
||||
$recursion = $filter['recursion'];
|
||||
$status = $filter['status'];
|
||||
$search = $filter['search'];
|
||||
$os = $filter['id_os'];
|
||||
$policies = json_decode($filter['policies'], true);
|
||||
$search_custom = $filter['search_custom'];
|
||||
$ag_custom_fields = $filter['ag_custom_fields'];
|
||||
}
|
||||
|
||||
|
||||
if (is_array($ag_custom_fields) === false) {
|
||||
$ag_custom_fields = json_decode(io_safe_output($ag_custom_fields), true);
|
||||
}
|
||||
|
||||
if (is_array($policies) === false) {
|
||||
$policies = json_decode(io_safe_output($policies), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'AW')) {
|
||||
// Prepare the tab system to the future.
|
||||
$tab = 'setup';
|
||||
@ -247,23 +297,44 @@ if (isset($result_delete)) {
|
||||
|
||||
echo '<form method="post" action="?sec=view&sec2=operation/agentes/estado_agente&group_id='.$group_id.'">';
|
||||
|
||||
echo '<table cellpadding="4" cellspacing="4" class="databox filters bolder mrgn_btn_10px" width="100%">';
|
||||
// echo '<table cellpadding="4" cellspacing="4" class="databox filters bolder mrgn_btn_10px" width="100%">';
|
||||
// echo '<tr><td class="nowrap w100px padding-right-2-imp">';
|
||||
// Start Build Search Form.
|
||||
//
|
||||
$table = new StdClass();
|
||||
$table->width = '100%';
|
||||
$table->cellspacing = 0;
|
||||
$table->cellpadding = 0;
|
||||
$table->class = 'databox filters';
|
||||
$table->style[0] = 'font-weight: bold;';
|
||||
$table->style[1] = 'font-weight: bold;';
|
||||
$table->style[2] = 'font-weight: bold;';
|
||||
$table->style[3] = 'font-weight: bold;';
|
||||
$table->style[4] = 'font-weight: bold;';
|
||||
|
||||
echo '<tr><td class="nowrap w100px padding-right-2-imp">';
|
||||
|
||||
echo __('Group').' '.' '.' ';
|
||||
$table->data[0][0] = __('Group');
|
||||
$table->data[0][0] .= '<div class="flex flex-row-vcenter w290px"><div class="w200px">';
|
||||
|
||||
$groups = users_get_groups(false, $access);
|
||||
|
||||
html_print_select_groups(false, $access, true, 'group_id', $group_id, 'this.form.submit()', '', '', false, false, true, '', false);
|
||||
$table->data[0][0] .= html_print_select_groups(false, $access, true, 'group_id', $group_id, '', '', '', true, false, true, '', false);
|
||||
|
||||
echo '</td><td class="nowrap">'.' '.' '.' '.' '.' ';
|
||||
// $table->data[0][1] .= ' ';
|
||||
$table->data[0][0] .= '<br>'.__('Recursion').' '.' '.' ';
|
||||
$table->data[0][0] .= html_print_input(
|
||||
[
|
||||
'type' => 'checkbox',
|
||||
'name' => 'recursion',
|
||||
'return' => true,
|
||||
'checked' => $recursion,
|
||||
'checked' => ($recursion === true || $recursion === 'true' || $recursion === '1') ? 'checked' : false,
|
||||
'value' => 1,
|
||||
]
|
||||
);
|
||||
|
||||
echo __('Recursion').' '.' '.' ';
|
||||
html_print_checkbox('recursion', 1, $recursion, false, false, 'this.form.submit()');
|
||||
|
||||
echo '</td><td class="nowrap">';
|
||||
|
||||
// echo '</td><td class="nowrap">';
|
||||
$fields = [];
|
||||
$fields[AGENT_STATUS_NORMAL] = __('Normal');
|
||||
$fields[AGENT_STATUS_WARNING] = __('Warning');
|
||||
@ -272,31 +343,125 @@ $fields[AGENT_STATUS_UNKNOWN] = __('Unknown');
|
||||
$fields[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
|
||||
$fields[AGENT_STATUS_NOT_INIT] = __('Not init');
|
||||
|
||||
echo __('Status').' '.' '.' ';
|
||||
html_print_select($fields, 'status', $status, 'this.form.submit()', __('All'), AGENT_STATUS_ALL, false, false, true, '', false, 'width: 90px;');
|
||||
$table->data[0][1] = __('Status').' '.' '.' ';
|
||||
$table->data[0][1] .= html_print_select($fields, 'status', $status, '', __('All'), AGENT_STATUS_ALL, true, false, true, '', false, 'width: 90px;');
|
||||
|
||||
echo '</td><td class="nowrap w100px">';
|
||||
$table->data[0][2] = __('Search').' '.' '.' ';
|
||||
$table->data[0][2] .= html_print_input_text('search', $search, '', 15, 255, true);
|
||||
|
||||
echo __('Search').' '.' '.' ';
|
||||
html_print_input_text('search', $search, '', 15);
|
||||
$table->data[1][0] = __('Operating System').' ';
|
||||
|
||||
echo '</td><td class="nowrap w100px">';
|
||||
$pre_fields = db_get_all_rows_sql(
|
||||
'select distinct(tagente.id_os),tconfig_os.name from tagente,tconfig_os where tagente.id_os = tconfig_os.id_os'
|
||||
);
|
||||
$fields = [];
|
||||
|
||||
echo __('Search in custom fields').' '.' '.' ';
|
||||
html_print_input_text('search_custom', $search_custom, '', 15);
|
||||
foreach ($pre_fields as $key => $value) {
|
||||
$fields[$value['id_os']] = $value['name'];
|
||||
}
|
||||
|
||||
echo '</td><td class="nowrap">';
|
||||
$table->data[1][0] .= html_print_select($fields, 'os', $os, '', 'All', 0, true);
|
||||
|
||||
html_print_submit_button(
|
||||
$table->data[1][1] = __('Policies').' ';
|
||||
|
||||
$pre_fields = policies_get_policies(false, ['id', 'name']);
|
||||
$fields = [];
|
||||
|
||||
foreach ($pre_fields as $value) {
|
||||
$fields[$value['id']] = $value['name'];
|
||||
}
|
||||
|
||||
$table->data[1][1] .= html_print_select($fields, 'policies[]', $policies, '', 'All', 0, true, true);
|
||||
|
||||
$table->data[1][2] = __('Search in custom fields').' '.' '.' ';
|
||||
$table->data[1][2] .= html_print_input_text('search_custom', $search_custom, '', 15, 255, true);
|
||||
|
||||
|
||||
$custom_fields = db_get_all_fields_in_table('tagent_custom_fields');
|
||||
if ($custom_fields === false) {
|
||||
$custom_fields = [];
|
||||
}
|
||||
|
||||
$div_custom_fields = '<div class="flex-row">';
|
||||
foreach ($custom_fields as $custom_field) {
|
||||
$custom_field_value = '';
|
||||
if (empty($ag_custom_fields) === false) {
|
||||
$custom_field_value = $ag_custom_fields[$custom_field['id_field']];
|
||||
if (empty($custom_field_value) === true) {
|
||||
$custom_field_value = '';
|
||||
}
|
||||
}
|
||||
|
||||
$div_custom_fields .= '<div class="div-col">';
|
||||
|
||||
$div_custom_fields .= '<div class="div-span">';
|
||||
$div_custom_fields .= '<span >'.$custom_field['name'].'</span>';
|
||||
$div_custom_fields .= '</div>';
|
||||
|
||||
$div_custom_fields .= '<div class="div-input">';
|
||||
$div_custom_fields .= html_print_input_text(
|
||||
'ag_custom_fields['.$custom_field['id_field'].']',
|
||||
$custom_field_value,
|
||||
'',
|
||||
0,
|
||||
300,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
'div-input'
|
||||
);
|
||||
$div_custom_fields .= '</div></div>';
|
||||
}
|
||||
|
||||
$table->colspan[2][0] = 7;
|
||||
$table->cellstyle[2][0] = 'padding-left: 10px;';
|
||||
$table->data[2][0] = ui_toggle(
|
||||
$div_custom_fields,
|
||||
__('Agent custom fields'),
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
'white-box-content',
|
||||
'white_table_graph'
|
||||
);
|
||||
|
||||
|
||||
$table->colspan[4][0] = 4;
|
||||
$table->cellstyle[4][0] = 'padding-top: 0px;';
|
||||
$table->data[4][0] = html_print_button(
|
||||
__('Load filter'),
|
||||
'load-filter',
|
||||
false,
|
||||
'',
|
||||
'class="float-left margin-right-2 sub config"',
|
||||
true
|
||||
);
|
||||
|
||||
$table->cellstyle[4][0] .= 'padding-top: 0px;';
|
||||
$table->data[4][0] .= html_print_button(
|
||||
__('Manage filter'),
|
||||
'save-filter',
|
||||
false,
|
||||
'',
|
||||
'class="float-left margin-right-2 sub wand"',
|
||||
true
|
||||
);
|
||||
|
||||
$table->cellstyle[4][2] = 'padding-top: 0px;';
|
||||
$table->data[4][2] = html_print_submit_button(
|
||||
__('Search'),
|
||||
'srcbutton',
|
||||
'',
|
||||
['class' => 'sub search']
|
||||
['class' => 'sub search'],
|
||||
true
|
||||
);
|
||||
|
||||
echo '</td>';
|
||||
html_print_table($table);
|
||||
|
||||
echo '</tr></table></form>';
|
||||
'</form>';
|
||||
|
||||
if ($search != '') {
|
||||
$filter = ['string' => '%'.$search.'%'];
|
||||
@ -320,6 +485,8 @@ $selectDescriptionUp = false;
|
||||
$selectDescriptionDown = false;
|
||||
$selectLastContactUp = false;
|
||||
$selectLastContactDown = false;
|
||||
$selectLastStatusChangeUp = false;
|
||||
$selectLastStatusChangeDown = false;
|
||||
$order = null;
|
||||
|
||||
switch ($sortField) {
|
||||
@ -479,6 +646,32 @@ switch ($sortField) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'last_status_change':
|
||||
switch ($sort) {
|
||||
case 'up':
|
||||
$selectLastStatusChangeUp = $selected;
|
||||
$order = [
|
||||
'field' => 'last_status_change',
|
||||
'field2' => 'alias',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$selectLastStatusChangeDown = $selected;
|
||||
$order = [
|
||||
'field' => 'last_status_change',
|
||||
'field2' => 'alias',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'description':
|
||||
switch ($sort) {
|
||||
case 'up':
|
||||
@ -518,6 +711,8 @@ switch ($sortField) {
|
||||
$selectDescriptionDown = false;
|
||||
$selectLastContactUp = false;
|
||||
$selectLastContactDown = false;
|
||||
$selectLastStatusChangeUp = false;
|
||||
$selectLastStatusChangeDown = false;
|
||||
$order = [
|
||||
'field' => 'alias',
|
||||
'field2' => 'alias',
|
||||
@ -577,6 +772,24 @@ if (!empty($search_custom)) {
|
||||
$search_sql_custom = '';
|
||||
}
|
||||
|
||||
// Filter by agent custom fields.
|
||||
$sql_conditions_custom_fields = '';
|
||||
if (empty($ag_custom_fields) === false) {
|
||||
$cf_filter = [];
|
||||
foreach ($ag_custom_fields as $field_id => $value) {
|
||||
if (empty($value) === false) {
|
||||
$cf_filter[] = '(tagent_custom_data.id_field = '.$field_id.' AND tagent_custom_data.description LIKE \'%'.$value.'%\')';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($cf_filter) === false) {
|
||||
$sql_conditions_custom_fields = ' AND tagente.id_agente IN (
|
||||
SELECT tagent_custom_data.id_agent
|
||||
FROM tagent_custom_data
|
||||
WHERE '.implode(' AND ', $cf_filter).')';
|
||||
}
|
||||
}
|
||||
|
||||
// Show only selected groups.
|
||||
if ($group_id > 0) {
|
||||
$groups = [$group_id];
|
||||
@ -589,23 +802,41 @@ if ($group_id > 0) {
|
||||
$groups = array_keys($user_groups);
|
||||
}
|
||||
|
||||
$all_policies = in_array(0, ($policies ?? []));
|
||||
|
||||
$id_os_sql = '';
|
||||
$policies_sql = '';
|
||||
|
||||
if ($os > 0) {
|
||||
$id_os_sql = ' AND id_os = '.$os;
|
||||
}
|
||||
|
||||
if ($all_policies === false && is_array($policies) && count($policies) > 0) {
|
||||
$policies_sql = ' AND tpolicy_agents.id_policy IN ('.implode(',', $policies).')';
|
||||
}
|
||||
|
||||
if ($strict_user) {
|
||||
$count_filter = [
|
||||
// 'order' => 'tagente.nombre ASC',
|
||||
'order' => 'tagente.nombre ASC',
|
||||
'disabled' => 0,
|
||||
'status' => $status,
|
||||
'search' => $search,
|
||||
'order' => 'tagente.nombre ASC',
|
||||
'disabled' => 0,
|
||||
'status' => $status,
|
||||
'search' => $search,
|
||||
'id_os' => $id_os_sql,
|
||||
'policies' => $policies_sql,
|
||||
'other_condition' => $sql_conditions_custom_fields,
|
||||
];
|
||||
$filter = [
|
||||
// 'order' => 'tagente.nombre ASC',
|
||||
'order' => 'tagente.nombre ASC',
|
||||
'disabled' => 0,
|
||||
'status' => $status,
|
||||
'search' => $search,
|
||||
'offset' => (int) get_parameter('offset'),
|
||||
'limit' => (int) $config['block_size'],
|
||||
'order' => 'tagente.nombre ASC',
|
||||
'disabled' => 0,
|
||||
'status' => $status,
|
||||
'search' => $search,
|
||||
'offset' => (int) get_parameter('offset'),
|
||||
'limit' => (int) $config['block_size'],
|
||||
'id_os' => $id_os_sql,
|
||||
'policies' => $policies_sql,
|
||||
'other_condition' => $sql_conditions_custom_fields,
|
||||
];
|
||||
|
||||
if ($group_id > 0) {
|
||||
@ -644,28 +875,48 @@ if ($strict_user) {
|
||||
|
||||
$agents = tags_get_all_user_agents(false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
|
||||
} else {
|
||||
$count_filter = [
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $groups,
|
||||
'search' => $search_sql,
|
||||
'search_custom' => $search_sql_custom,
|
||||
'status' => $status,
|
||||
'id_os' => $id_os_sql,
|
||||
'policies' => $policies_sql,
|
||||
'other_condition' => $sql_conditions_custom_fields,
|
||||
];
|
||||
|
||||
$filter = [
|
||||
'order' => 'nombre ASC',
|
||||
'id_grupo' => $groups,
|
||||
'disabled' => 0,
|
||||
'status' => $status,
|
||||
'search_custom' => $search_sql_custom,
|
||||
'search' => $search_sql,
|
||||
'offset' => (int) get_parameter('offset'),
|
||||
'limit' => (int) $config['block_size'],
|
||||
'id_os' => $id_os_sql,
|
||||
'policies' => $policies_sql,
|
||||
'other_condition' => $sql_conditions_custom_fields,
|
||||
];
|
||||
|
||||
$total_agents = agents_count_agents_filter(
|
||||
[
|
||||
'disabled' => 0,
|
||||
'id_grupo' => $groups,
|
||||
'search' => $search_sql,
|
||||
'search_custom' => $search_sql_custom,
|
||||
'status' => $status,
|
||||
],
|
||||
$count_filter,
|
||||
$access
|
||||
);
|
||||
|
||||
$query_order = $order;
|
||||
|
||||
if ($order['field'] === 'last_status_change') {
|
||||
$query_order = [
|
||||
'field' => 'alias',
|
||||
'field2' => 'alias',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
}
|
||||
|
||||
$agents = agents_get_agents(
|
||||
[
|
||||
'order' => 'nombre '.' ASC',
|
||||
'id_grupo' => $groups,
|
||||
'disabled' => 0,
|
||||
'status' => $status,
|
||||
'search_custom' => $search_sql_custom,
|
||||
'search' => $search_sql,
|
||||
'offset' => (int) get_parameter('offset'),
|
||||
'limit' => (int) $config['block_size'],
|
||||
],
|
||||
$filter,
|
||||
[
|
||||
'id_agente',
|
||||
'id_grupo',
|
||||
@ -688,7 +939,7 @@ if ($strict_user) {
|
||||
'agent_version',
|
||||
],
|
||||
$access,
|
||||
$order
|
||||
$query_order
|
||||
);
|
||||
}
|
||||
|
||||
@ -720,7 +971,8 @@ $url_up_group = 'index.php?sec=view&sec2=operation/agentes/estado_agente&
|
||||
$url_down_group = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=group&sort=down';
|
||||
$url_up_last = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=last_contact&sort=up';
|
||||
$url_down_last = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=last_contact&sort=down';
|
||||
|
||||
$url_up_last_status_change = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=last_status_change&sort=up';
|
||||
$url_down_last_status_change = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=last_status_change&sort=down';
|
||||
|
||||
// Prepare pagination.
|
||||
ui_pagination(
|
||||
@ -740,16 +992,16 @@ $table->head[0] = __('Agent').ui_get_sorting_arrows($url_up_agente, $url_down_ag
|
||||
$table->size[0] = '12%';
|
||||
|
||||
$table->head[1] = __('Description').ui_get_sorting_arrows($url_up_description, $url_down_description, $selectDescriptionUp, $selectDescriptionDown);
|
||||
$table->size[1] = '16%';
|
||||
$table->size[1] = '14%';
|
||||
|
||||
$table->head[10] = __('Remote').ui_get_sorting_arrows($url_up_remote, $url_down_remote, $selectRemoteUp, $selectRemoteDown);
|
||||
$table->size[10] = '9%';
|
||||
$table->head[12] = __('Remote').ui_get_sorting_arrows($url_up_remote, $url_down_remote, $selectRemoteUp, $selectRemoteDown);
|
||||
$table->size[12] = '9%';
|
||||
|
||||
$table->head[2] = __('OS').ui_get_sorting_arrows($url_up_os, $url_down_os, $selectOsUp, $selectOsDown);
|
||||
$table->size[2] = '8%';
|
||||
|
||||
$table->head[3] = __('Interval').ui_get_sorting_arrows($url_up_interval, $url_down_interval, $selectIntervalUp, $selectIntervalDown);
|
||||
$table->size[3] = '10%';
|
||||
$table->size[3] = '8%';
|
||||
|
||||
$table->head[4] = __('Group').ui_get_sorting_arrows($url_up_group, $url_down_group, $selectGroupUp, $selectGroupDown);
|
||||
$table->size[4] = '8%';
|
||||
@ -767,7 +1019,13 @@ $table->head[8] = __('Alerts');
|
||||
$table->size[8] = '4%';
|
||||
|
||||
$table->head[9] = __('Last contact').ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastContactUp, $selectLastContactDown);
|
||||
$table->size[9] = '15%';
|
||||
$table->size[9] = '8%';
|
||||
|
||||
$table->head[10] = __('Last status change').ui_get_sorting_arrows($url_up_last_status_change, $url_down_last_status_change, $selectLastStatusChangeUp, $selectLastStatusChangeDown);
|
||||
$table->size[10] = '10%';
|
||||
|
||||
$table->head[11] = __('Agent events');
|
||||
$table->size[11] = '4%';
|
||||
|
||||
$table->align = [];
|
||||
|
||||
@ -779,6 +1037,8 @@ $table->align[6] = 'left';
|
||||
$table->align[7] = 'left';
|
||||
$table->align[8] = 'left';
|
||||
$table->align[9] = 'left';
|
||||
$table->align[10] = 'left';
|
||||
$table->align[11] = 'left';
|
||||
|
||||
$table->style = [];
|
||||
|
||||
@ -881,12 +1141,12 @@ foreach ($agents as $agent) {
|
||||
|
||||
$data[1] = '<span class="'.$custom_font_size.'">'.ui_print_truncate_text($agent['description'], 'description', false, true, true, '[…]').'</span>';
|
||||
|
||||
$data[10] = '';
|
||||
$data[12] = '';
|
||||
|
||||
if (enterprise_installed()) {
|
||||
enterprise_include_once('include/functions_config_agents.php');
|
||||
if (enterprise_hook('config_agents_has_remote_configuration', [$agent['id_agente']])) {
|
||||
$data[10] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente='.$agent['id_agente'].'&disk_conf=1">'.html_print_image(
|
||||
$data[12] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente='.$agent['id_agente'].'&disk_conf=1">'.html_print_image(
|
||||
'images/application_edit.png',
|
||||
true,
|
||||
[
|
||||
@ -930,6 +1190,27 @@ foreach ($agents as $agent) {
|
||||
|
||||
$data[9] = agents_get_interval_status($agent);
|
||||
|
||||
$last_status_change_agent = agents_get_last_status_change($agent['id_agente']);
|
||||
$time_elapsed = !empty($last_status_change_agent) ? human_time_comparation($last_status_change_agent) : '<em>'.__('N/A').'</em>';
|
||||
$data[10] = $time_elapsed;
|
||||
|
||||
$agent_event_filter = [
|
||||
'id_agent' => $agent['id_agente'],
|
||||
'event_view_hr' => 48,
|
||||
'status' => -1,
|
||||
];
|
||||
|
||||
$fb64 = base64_encode(json_encode($agent_event_filter));
|
||||
$data[11] = '<a href="index.php?sec=eventos&sec2=operation/events/events&fb64='.$fb64.'">'.html_print_image(
|
||||
'images/lightning.png',
|
||||
true,
|
||||
[
|
||||
'align' => 'middle',
|
||||
'title' => __('Agent events'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>';
|
||||
|
||||
// This old code was returning "never" on agents without modules, BAD !!
|
||||
// And does not print outdated agents in red. WRONG !!!!
|
||||
// $data[7] = ui_print_timestamp ($agent_info["last_contact"], true);
|
||||
@ -937,6 +1218,20 @@ foreach ($agents as $agent) {
|
||||
}
|
||||
|
||||
if (!empty($table->data)) {
|
||||
if ($order['field'] === 'last_status_change') {
|
||||
$order_direction = $order['order'];
|
||||
usort(
|
||||
$table->data,
|
||||
function ($a, $b) use ($order_direction) {
|
||||
if ($order_direction === 'ASC') {
|
||||
return strtotime($a[10]) > strtotime($b[10]);
|
||||
} else {
|
||||
return strtotime($a[10]) < strtotime($b[10]);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
ui_pagination(
|
||||
@ -975,10 +1270,69 @@ if (!empty($table->data)) {
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
// Load filter div for dialog.
|
||||
echo '<div id="load-modal-filter" style="display:none"></div>';
|
||||
echo '<div id="save-modal-filter" style="display:none"></div>';
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready (function () {
|
||||
var loading = 0;
|
||||
|
||||
/* Filter management */
|
||||
$('#button-load-filter').click(function (event) {
|
||||
if($('#load-filter-select').length) {
|
||||
$('#load-filter-select').dialog();
|
||||
} else {
|
||||
if (loading == 0) {
|
||||
loading = 1
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: '<?php echo ui_get_full_url('ajax.php'); ?>',
|
||||
data: {
|
||||
page: 'include/ajax/agent',
|
||||
load_filter_modal: 1
|
||||
},
|
||||
success: function (data) {
|
||||
$('#load-modal-filter')
|
||||
.empty()
|
||||
.html(data);
|
||||
|
||||
loading = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#button-save-filter').click(function (){
|
||||
// event.preventDefault();
|
||||
if($('#save-filter-select').length) {
|
||||
$('#save-filter-select').dialog();
|
||||
} else {
|
||||
if (loading == 0) {
|
||||
loading = 1
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: '<?php echo ui_get_full_url('ajax.php'); ?>',
|
||||
data: {
|
||||
page: 'include/ajax/agent',
|
||||
save_filter_modal: 1,
|
||||
current_filter: $('#latest_filter_id').val()
|
||||
},
|
||||
success: function (data){
|
||||
$('#save-modal-filter')
|
||||
.empty()
|
||||
.html(data);
|
||||
loading = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$("[class^='left']").mouseenter (function () {
|
||||
$(".agent"+$(this)[0].className).css('visibility', '');
|
||||
}).mouseleave(function () {
|
||||
|
@ -644,6 +644,7 @@ $last_incident = db_get_row_sql(
|
||||
);
|
||||
|
||||
if ($last_incident != false) {
|
||||
$table_incident = new stdClass();
|
||||
$table_incident->id = 'agent_incident_main';
|
||||
$table_incident->width = '100%';
|
||||
$table_incident->cellspacing = 0;
|
||||
|
@ -227,7 +227,7 @@ if ($load_filter_id > 0) {
|
||||
$user_groups_fl = users_get_groups(
|
||||
$config['id_user'],
|
||||
'AR',
|
||||
users_can_manage_group_all(),
|
||||
users_can_manage_group_all('AR'),
|
||||
true
|
||||
);
|
||||
|
||||
@ -287,6 +287,8 @@ if ($loaded_filter['id_filter'] > 0) {
|
||||
}
|
||||
}
|
||||
|
||||
$all_groups = [];
|
||||
|
||||
// Agent group selector.
|
||||
if (!$is_metaconsole) {
|
||||
if ($ag_group > 0 && check_acl($config['id_user'], $ag_group, 'AR')) {
|
||||
@ -937,7 +939,7 @@ $table->data[4][0] = html_print_button(
|
||||
|
||||
$table->cellstyle[4][0] .= 'padding-top: 0px;';
|
||||
$table->data[4][0] .= html_print_button(
|
||||
__('Save filter'),
|
||||
__('Manage filter'),
|
||||
'save-filter',
|
||||
false,
|
||||
'',
|
||||
@ -1469,6 +1471,12 @@ if (!empty($result)) {
|
||||
$table->align[11] = 'left';
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'AR')) {
|
||||
$actions_list = true;
|
||||
$table->head[12] = __('Actions');
|
||||
$table->align[12] = 'left';
|
||||
}
|
||||
|
||||
$id_type_web_content_string = db_get_value(
|
||||
'id_tipo',
|
||||
'ttipo_modulo',
|
||||
@ -1589,31 +1597,6 @@ if (!empty($result)) {
|
||||
if (in_array('data_type', $show_fields) || is_metaconsole()) {
|
||||
$data[2] = html_print_image('images/'.modules_show_icon_type($row['module_type']), true, ['class' => 'invert_filter']);
|
||||
$agent_groups = is_metaconsole() ? $row['groups_in_server'] : agents_get_all_groups_agent($row['id_agent'], $row['id_group']);
|
||||
if (check_acl_one_of_groups($config['id_user'], $agent_groups, 'AW')) {
|
||||
$show_edit_icon = true;
|
||||
if (defined('METACONSOLE')) {
|
||||
if (!can_user_access_node()) {
|
||||
$show_edit_icon = false;
|
||||
}
|
||||
|
||||
$url_edit_module = $row['server_url'].'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'.'&loginhash=auto&loginhash_data='.$row['hashdata'].'&loginhash_user='.str_rot13($row['user']);
|
||||
} else {
|
||||
$url_edit_module = 'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1';
|
||||
}
|
||||
|
||||
if ($show_edit_icon) {
|
||||
$table->cellclass[][2] = 'action_buttons';
|
||||
$data[2] .= '<a href="'.$url_edit_module.'">'.html_print_image(
|
||||
'images/config.png',
|
||||
true,
|
||||
[
|
||||
'alt' => '0',
|
||||
'border' => '',
|
||||
'title' => __('Edit'),
|
||||
]
|
||||
).'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array('module_name', $show_fields) || is_metaconsole()) {
|
||||
@ -2029,7 +2012,7 @@ if (!empty($result)) {
|
||||
} else {
|
||||
$sub_string = substr(io_safe_output($row['datos']), 0, 12);
|
||||
if ($module_value == $sub_string) {
|
||||
if ($module_value == 0 && !$sub_string) {
|
||||
if ((empty($module_value) === true || $module_value == 0) && !$sub_string) {
|
||||
$salida = 0;
|
||||
} else {
|
||||
$data_macro = modules_get_unit_macro($row['datos'], $row['unit']);
|
||||
@ -2089,6 +2072,39 @@ if (!empty($result)) {
|
||||
$data[11] = ui_print_timestamp($row['utimestamp'], true, $option);
|
||||
}
|
||||
|
||||
if (check_acl_one_of_groups($config['id_user'], $agent_groups, 'AW')) {
|
||||
if (defined('METACONSOLE')) {
|
||||
$url_edit_module = $row['server_url'].'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&';
|
||||
$url_edit_module .= 'loginhash=auto&id_agente='.$row['id_agent'];
|
||||
$url_edit_module .= '&tab=module&id_agent_module='.$row['id_agente_modulo'].'&edit_module=1&';
|
||||
$url_edit_module .= 'loginhash_data='.$row['hashdata'].'&loginhash_user='.str_rot13($row['user']);
|
||||
|
||||
$url_delete_module = $row['server_url'].'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente';
|
||||
$url_delete_module .= '&id_agente='.$row['id_agent'].'&delete_module='.$row['id_agente_modulo'];
|
||||
|
||||
$table->cellclass[][2] = 'action_buttons';
|
||||
$data[12] .= '<a href="'.$url_edit_module.'">'.html_print_image(
|
||||
'images/config.png',
|
||||
true,
|
||||
[
|
||||
'alt' => '0',
|
||||
'border' => '',
|
||||
'title' => __('Edit'),
|
||||
]
|
||||
).'</a>';
|
||||
$onclick = 'onclick="javascript: if (!confirm(\''.__('Are you sure to delete?').'\')) return false;';
|
||||
$data[12] .= '<a href="'.$url_delete_module.'" '.$onclick.'" target="_blank">'.html_print_image(
|
||||
'images/delete.png',
|
||||
true,
|
||||
[
|
||||
'alt' => '0',
|
||||
'border' => '',
|
||||
'title' => __('Delete'),
|
||||
]
|
||||
).'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
array_push($table->data, $data);
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ require_once $config['homedir'].'/include/functions_groups.php';
|
||||
require_once $config['homedir'].'/include/functions_modules.php';
|
||||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
enterprise_include_once('include/functions_metaconsole.php');
|
||||
enterprise_include_once('include/functions_omnishell.php');
|
||||
|
||||
ui_require_javascript_file('openlayers.pandora');
|
||||
ui_require_css_file('agent_view');
|
||||
@ -1487,6 +1488,17 @@ if ($policyTab == -1) {
|
||||
$policyTab = '';
|
||||
}
|
||||
|
||||
|
||||
// Omnishell.
|
||||
$tasks = count_tasks_agent($id_agente);
|
||||
|
||||
if ($tasks === true) {
|
||||
$omnishellTab = enterprise_hook('omnishell_tab');
|
||||
if ($omnishellTab == -1) {
|
||||
$omnishellTab = '';
|
||||
}
|
||||
}
|
||||
|
||||
// WUX Console.
|
||||
$modules_wux = enterprise_hook('get_wux_modules', [$id_agente]);
|
||||
if ($modules_wux) {
|
||||
@ -1749,6 +1761,7 @@ $onheader = [
|
||||
'ncm_view' => ($ncm_tab ?? null),
|
||||
'external_tools' => ($external_tools ?? null),
|
||||
'incident' => ($incidenttab ?? null),
|
||||
'omnishell' => ($omnishellTab ?? null),
|
||||
];
|
||||
|
||||
|
||||
@ -1873,6 +1886,10 @@ switch ($tab) {
|
||||
$tab_name = 'Policies';
|
||||
break;
|
||||
|
||||
case 'omnishell':
|
||||
$tab_name = 'Omnishell';
|
||||
break;
|
||||
|
||||
case 'ux_console_tab':
|
||||
$tab_name = 'UX Console';
|
||||
break;
|
||||
@ -2011,6 +2028,10 @@ switch ($tab) {
|
||||
enterprise_include('operation/agentes/policy_view.php');
|
||||
break;
|
||||
|
||||
case 'omnishell':
|
||||
enterprise_include('operation/agentes/omnishell_view.php');
|
||||
break;
|
||||
|
||||
case 'ux_console_tab':
|
||||
enterprise_include('operation/agentes/ux_console_view.php');
|
||||
break;
|
||||
|
@ -239,6 +239,13 @@ $server_id = get_parameter(
|
||||
($filter['server_id'] ?? '')
|
||||
);
|
||||
|
||||
if (empty($id_agent) === true) {
|
||||
$id_agent = get_parameter(
|
||||
'id_agent',
|
||||
($filter['id_agent'] ?? '')
|
||||
);
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$servers = metaconsole_get_servers();
|
||||
if (is_array($servers) === true) {
|
||||
@ -350,7 +357,7 @@ if (is_ajax() === true) {
|
||||
'te.warning_instructions',
|
||||
'te.unknown_instructions',
|
||||
'te.owner_user',
|
||||
'if(te.ack_utimestamp > 0, from_unixtime(te.ack_utimestamp),"") as ack_utimestamp',
|
||||
'if(te.ack_utimestamp > 0, te.ack_utimestamp,"") as ack_utimestamp',
|
||||
'te.custom_data',
|
||||
'te.data',
|
||||
'te.module_status',
|
||||
@ -380,7 +387,7 @@ if (is_ajax() === true) {
|
||||
$order['field'] = 'agent_name';
|
||||
break;
|
||||
|
||||
case 'if(te.ack_utimestamp > 0, from_unixtime(te.ack_utimestamp),"") as ack_utimestamp':
|
||||
case 'if(te.ack_utimestamp > 0, te.ack_utimestamp,"") as ack_utimestamp':
|
||||
$order['field'] = 'ack_utimestamp';
|
||||
break;
|
||||
|
||||
@ -521,14 +528,14 @@ if (is_ajax() === true) {
|
||||
|
||||
$tmp->agent_name = io_safe_output($tmp->agent_name);
|
||||
|
||||
$tmp->ack_utimestamp_raw = strtotime($tmp->ack_utimestamp);
|
||||
$tmp->ack_utimestamp_raw = $tmp->ack_utimestamp;
|
||||
|
||||
$tmp->ack_utimestamp = ui_print_timestamp(
|
||||
(empty($tmp->ack_utimestamp) === true) ? 0 : $tmp->ack_utimestamp,
|
||||
true
|
||||
);
|
||||
$tmp->timestamp = ui_print_timestamp(
|
||||
$tmp->timestamp,
|
||||
$tmp->utimestamp,
|
||||
true
|
||||
);
|
||||
|
||||
@ -1473,7 +1480,7 @@ if ($pure) {
|
||||
]
|
||||
).'</a>';
|
||||
|
||||
// Sound events.
|
||||
// Accoustic console.
|
||||
$sound_event['active'] = false;
|
||||
|
||||
// Sound Events.
|
||||
@ -1496,7 +1503,7 @@ if ($pure) {
|
||||
'images/sound.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Sound events'),
|
||||
'title' => __('Accoustic console'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>';
|
||||
@ -1546,7 +1553,7 @@ if ($pure) {
|
||||
switch ($section) {
|
||||
case 'sound_event':
|
||||
$onheader['sound_event']['active'] = true;
|
||||
$section_string = __('Sound events');
|
||||
$section_string = __('Accoustic console');
|
||||
break;
|
||||
|
||||
case 'history':
|
||||
@ -2413,8 +2420,6 @@ try {
|
||||
100,
|
||||
200,
|
||||
500,
|
||||
1000,
|
||||
-1,
|
||||
],
|
||||
[
|
||||
$config['block_size'],
|
||||
@ -2423,8 +2428,6 @@ try {
|
||||
100,
|
||||
200,
|
||||
500,
|
||||
1000,
|
||||
'All',
|
||||
],
|
||||
],
|
||||
'order' => [
|
||||
|
@ -60,7 +60,7 @@ ob_start();
|
||||
echo '<html>';
|
||||
echo '<head>';
|
||||
|
||||
echo '<title>'.__('Sound Events').'</title>';
|
||||
echo '<title>'.__('Accoustic console').'</title>';
|
||||
ui_require_css_file('wizard');
|
||||
ui_require_css_file('discovery');
|
||||
?>
|
||||
@ -161,7 +161,7 @@ if ($config['style'] === 'pandora_black' && !is_metaconsole()) {
|
||||
|
||||
echo '</head>';
|
||||
echo "<body class='sound_events'>";
|
||||
echo "<h1 class='modalheaderh1'>".__('Sound console').'</h1>';
|
||||
echo "<h1 class='modalheaderh1'>".__('Accoustic console').'</h1>';
|
||||
|
||||
// Connection lost alert.
|
||||
ui_require_css_file('register', 'include/styles/', true);
|
||||
@ -252,6 +252,11 @@ $sounds = [
|
||||
'Star_Trek_emergency_simulation.wav' => 'StarTrek emergency simulation',
|
||||
];
|
||||
|
||||
$eventsounds = mysql_db_get_row_sql('SELECT * FROM tevent_sound WHERE active = 1');
|
||||
foreach ($eventsounds as $key => $row) {
|
||||
$sounds[$row['sound']] = $row['name'];
|
||||
}
|
||||
|
||||
$inputs[] = [
|
||||
'label' => \__('Sounds'),
|
||||
'class' => 'flex-row',
|
||||
|
@ -432,11 +432,11 @@ if ($access_console_node === true) {
|
||||
$sub['operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&fb64='.$fb64]['type'] = 'direct';
|
||||
}
|
||||
|
||||
// Sound Events.
|
||||
// Accoustic console.
|
||||
$data_sound = base64_encode(
|
||||
json_encode(
|
||||
[
|
||||
'title' => __('Sound Console'),
|
||||
'title' => __('Accoustic console'),
|
||||
'start' => __('Start'),
|
||||
'stop' => __('Stop'),
|
||||
'noAlert' => __('No alert'),
|
||||
@ -449,8 +449,8 @@ if ($access_console_node === true) {
|
||||
);
|
||||
|
||||
$javascript = 'javascript: openSoundEventModal(`'.$data_sound.'`);';
|
||||
$sub[$javascript]['text'] = __('Sound Events');
|
||||
$sub[$javascript]['id'] = 'Sound Events Modal';
|
||||
$sub[$javascript]['text'] = __('Accoustic console');
|
||||
$sub[$javascript]['id'] = 'Accoustic console Modal';
|
||||
$sub[$javascript]['type'] = 'direct';
|
||||
|
||||
echo '<div id="modal-sound" style="display:none;"></div>';
|
||||
@ -603,7 +603,6 @@ if ($access_console_node === true) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($sub)) {
|
||||
$menu_operation['extensions']['text'] = __('Tools');
|
||||
$menu_operation['extensions']['sec2'] = 'operation/extensions';
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.769
|
||||
%define release 230220
|
||||
%define release 230303
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.769
|
||||
%define release 230220
|
||||
%define release 230303
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.769
|
||||
%define release 230220
|
||||
%define release 230303
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
@ -557,7 +557,8 @@ CREATE TABLE IF NOT EXISTS `talert_template_modules` (
|
||||
FOREIGN KEY (`id_alert_template`) REFERENCES talert_templates(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
UNIQUE (`id_agent_module`, `id_alert_template`, `id_policy_alerts`),
|
||||
INDEX force_execution (`force_execution`)
|
||||
INDEX force_execution (`force_execution`),
|
||||
INDEX idx_disabled (disabled)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
@ -719,7 +720,8 @@ CREATE TABLE IF NOT EXISTS `tevento` (
|
||||
PRIMARY KEY (`id_evento`),
|
||||
KEY `idx_agente` (`id_agente`),
|
||||
KEY `idx_agentmodule` (`id_agentmodule`),
|
||||
KEY `idx_utimestamp` USING BTREE (`utimestamp`)
|
||||
KEY `idx_utimestamp` USING BTREE (`utimestamp`),
|
||||
INDEX `agente_modulo_estado`(`estado`, `id_agentmodule`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
-- Criticity: 0 - Maintance (grey)
|
||||
-- Criticity: 1 - Informational (blue)
|
||||
@ -4177,3 +4179,30 @@ CREATE TABLE IF NOT EXISTS `tmonitor_filter` (
|
||||
`ag_custom_fields` TEXT,
|
||||
PRIMARY KEY (`id_filter`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tagent_filter`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tagent_filter` (
|
||||
`id_filter` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_name` VARCHAR(600) NOT NULL,
|
||||
`id_group_filter` INT NOT NULL DEFAULT 0,
|
||||
`group_id` INT NOT NULL DEFAULT 0,
|
||||
`recursion` TEXT,
|
||||
`status` INT NOT NULL DEFAULT -1,
|
||||
`search` TEXT,
|
||||
`id_os` INT NOT NULL DEFAULT 0,
|
||||
`policies` TEXT,
|
||||
`search_custom` TEXT,
|
||||
`ag_custom_fields` TEXT,
|
||||
PRIMARY KEY (`id_filter`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
-- Table `tevent_sound`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE `tevent_sound` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`name` TEXT NULL,
|
||||
`sound` TEXT NULL,
|
||||
`active` TINYINT NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
@ -1,9 +1,9 @@
|
||||
-- Pandora FMS - the Flexible Monitoring System
|
||||
-- ============================================
|
||||
-- Copyright (c) 2014-2021 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
-- Please see http://www.pandorafms.org for full contribution list
|
||||
-- Copyright (c) 2014-2023 Artica PFMS
|
||||
-- Please see http://www.pandorafms.com
|
||||
|
||||
-- Database Data for Pandora FMS 5.1
|
||||
-- Database Data for Pandora FMS NG
|
||||
|
||||
-- PLEASE NO NOT USE MULTILINE COMMENTS
|
||||
-- Because Pandora Installer don't understand them
|
||||
@ -39,17 +39,18 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
|
||||
('block_size','20'),
|
||||
('days_purge','45'),
|
||||
('days_delete_unknown','0'),
|
||||
('days_delete_not_initialized','0'),
|
||||
('days_delete_not_initialized','7'),
|
||||
('days_compact','0'),
|
||||
('days_autodisable_deletion','30'),
|
||||
('graph_res','5'),
|
||||
('step_compact','1'),
|
||||
('db_scheme_first_version', '6.0dev'),
|
||||
('db_scheme_version','6.0RC1'),
|
||||
('db_scheme_build','PD150908'),
|
||||
('db_scheme_first_version', '7.0NG'),
|
||||
('db_scheme_version','7.0NG'),
|
||||
('db_scheme_build','PD230303'),
|
||||
('show_unknown','0'),
|
||||
('show_lastalerts','1'),
|
||||
('style','pandora'),
|
||||
('graph_image_height', '250'),
|
||||
('graph_color1', '#99dd00'),
|
||||
('graph_color2', '#336600'),
|
||||
('graph_color3', '#3399cc'),
|
||||
@ -97,14 +98,14 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
|
||||
('first_login', 0),
|
||||
('mins_fail_pass', 5),
|
||||
('number_attempts', 5),
|
||||
('enable_pass_policy_admin', 0),
|
||||
('enable_pass_policy_admin', 1),
|
||||
('enable_pass_history', 0),
|
||||
('compare_pass', 3),
|
||||
('meta_style', 'meta_pandora'),
|
||||
('enable_refr', 0),
|
||||
('meta_num_elements', 100),
|
||||
('update_manager_installed', 1),
|
||||
('num_files_attachment', 250),
|
||||
('num_files_attachment', 500),
|
||||
('show_vc', 1),
|
||||
('inventory_changes_blacklist', '1,2,20,21'),
|
||||
('custom_report_front', 0),
|
||||
@ -220,10 +221,10 @@ UNLOCK TABLES;
|
||||
LOCK TABLES `tlink` WRITE;
|
||||
INSERT INTO `tlink` VALUES
|
||||
(1,'Documentation','https://pandorafms.com/manual'),
|
||||
(2,'Enterprise Edition','http://pandorafms.com'),
|
||||
(2,'Get support','https://pandorafms.com/en/technical-support/'),
|
||||
(3,'Report a bug','https://github.com/pandorafms/pandorafms/issues'),
|
||||
(4,'Suggest new feature','https://pandorafms.com/community/beta-program/'),
|
||||
(5,'Module library','http://library.pandorafms.com/');
|
||||
(5,'Module library','https://pandorafms.com/library/');
|
||||
|
||||
UNLOCK TABLES;
|
||||
|
||||
@ -1165,6 +1166,7 @@ INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (1, 'Monitoring&#x
|
||||
INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (2, 'Monitoring Report Modules', 'select (select tagente.alias from tagente where tagente.id_agente = tagente_modulo.id_agente) as agent_nombre, nombre , (select tmodule_group.name from tmodule_group where tmodule_group.id_mg = tagente_modulo.id_module_group) as module_group, module_interval from tagente_modulo where delete_pending = 0 order by nombre;');
|
||||
INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (3, 'Monitoring Report Alerts', 'select t1.alias as agent_name, t2.nombre as module_name, (select talert_templates.name from talert_templates where talert_templates.id = t3.id_alert_template) as template, (select group_concat(t02.name) from talert_template_module_actions as t01 inner join talert_actions as t02 on t01.id_alert_action = t02.id where t01.id_alert_template_module = t3.id group by t01.id_alert_template_module) as actions from tagente as t1 inner join tagente_modulo as t2 on t1.id_agente = t2.id_agente inner join talert_template_modules as t3 on t2.id_agente_modulo = t3.id_agent_module order by agent_name, module_name;');
|
||||
INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (4, 'Group view', 'select t1.nombre, (select count(t3.id_agente) from tagente as t3 where t1.id_grupo = t3.id_grupo) as agents, (SELECT COUNT(t4.id_agente) FROM tagente as t4 WHERE t4.id_grupo = t1.id_grupo AND t4.disabled = 0 AND t4.ultimo_contacto < NOW() - (intervalo / (1/2))) as agent_unknown, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo NOT IN(21,22,23,24,100) AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval / (1/2))) as monitor_unknow, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,24) AND utimestamp = 0) as monitor_no_init, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 0 AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval / (1/2)) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24)))) as monitor_ok, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 1 AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval / (1/2)) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0) as monitor_critical, (SELECT COUNT(talert_template_modules.id) FROM talert_template_modules, tagente_modulo, tagente_estado, tagente WHERE tagente.id_grupo = t1.id_grupo AND tagente_modulo.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo AND times_fired > 0) as monitor_alert_fired from tgrupo as t1 where 0 < (select count(t2.id_agente) from tagente as t2 where t1.id_grupo = t2.id_grupo)');
|
||||
INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (5, 'Agent safe mode not enable', 'select alias from tagente where safe_mode_module = 0');
|
||||
|
||||
-- trecon scripts
|
||||
INSERT INTO `trecon_script` (`type`,`name`,`description`,`script`,`macros`) VALUES (1, 'Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/recon_scripts/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}');
|
||||
|
@ -1,7 +1,13 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import gspread
|
||||
import argparse
|
||||
import argparse,json,sys
|
||||
from oauth2client.service_account import ServiceAccountCredentials
|
||||
from pprint import pprint
|
||||
from os import remove
|
||||
|
||||
import base64
|
||||
|
||||
__author__ = "Alejandro Sánchez Carrion"
|
||||
__copyright__ = "Copyright 2022, PandoraFMS"
|
||||
@ -15,33 +21,61 @@ Version = {__version__}
|
||||
|
||||
Manual execution
|
||||
|
||||
python3 pandora_googlesheets.py --cred <file credentials> --row <number-row> --column <number-column>
|
||||
python3 pandora_googlesheets.py --creds_json/creds_base64 <file credentials> --name <name document> --sheet <name-sheet> --cell <Number cell> --row <number-row> --column <number-column>
|
||||
|
||||
"""
|
||||
|
||||
parser = argparse.ArgumentParser(description= info, formatter_class=argparse.RawTextHelpFormatter)
|
||||
parser.add_argument('--cred', help='')
|
||||
parser.add_argument('--name', help='')
|
||||
parser.add_argument('--row', help='',type=int)
|
||||
parser.add_argument('--column', help='',type=int)
|
||||
parser.add_argument('--creds_json', help='To authenticate with a json file.')
|
||||
parser.add_argument('--creds_base64', help='To authenticate with a file that includes the credentials for base64 authentication.')
|
||||
parser.add_argument('--name', help='Name of the google sheets document.')
|
||||
parser.add_argument('--cell', help='To collect the value of a cell.')
|
||||
parser.add_argument('--row', help='To collect the value of a row.',type=int)
|
||||
parser.add_argument('--column', help='To collect the value of a column.',type=int)
|
||||
parser.add_argument('--sheet', help='To indicate the name of the document sheet, put it in quotation marks and count spaces and capital letters.',type=str)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
|
||||
creds = ServiceAccountCredentials.from_json_keyfile_name(args.cred, scope)
|
||||
|
||||
|
||||
|
||||
|
||||
## authenticate with file json input
|
||||
if args.creds_json is not None and args.creds_base64 == None:
|
||||
creds = ServiceAccountCredentials.from_json_keyfile_name(args.creds_json, scope)
|
||||
## authenticate with base64 input
|
||||
elif args.creds_base64 is not None and args.creds_json== None:
|
||||
## base64 to json
|
||||
text=base64.b64decode(args.creds_base64).decode('utf-8')
|
||||
with open("cred.json", "w") as outfile:
|
||||
outfile.write(text)
|
||||
creds = ServiceAccountCredentials.from_json_keyfile_name("cred.json", scope)
|
||||
remove("cred.json")
|
||||
else:
|
||||
print("You need to use the --creds_json or creds_base 64 parameter to authenticate. You can only select one.")
|
||||
sys.exit()
|
||||
|
||||
client = gspread.authorize(creds)
|
||||
|
||||
sheet = client.open(args.name).sheet1 # Open the spreadhseet
|
||||
sheet = client.open(args.name) # Open the spreadhseet
|
||||
worksheet = sheet.worksheet(args.sheet) # Open worksheet
|
||||
|
||||
data = sheet.get_all_records() # Get a list of all records
|
||||
if args.cell is not None and args.row==None and args.column==None :
|
||||
|
||||
if args.row is not None and args.column==None:
|
||||
row = sheet.row_values(args.row) # Get a specific row
|
||||
print(row)
|
||||
elif args.row ==None and args.column is not None:
|
||||
col = sheet.col_values(args.column) # Get a specific column
|
||||
print(col)
|
||||
elif args.row is not None and args.column is not None:
|
||||
cell = sheet.cell(args.row,args.column).value # Get the value of a specific cell
|
||||
print(cell)
|
||||
val = worksheet.acell(args.cell).value
|
||||
|
||||
elif args.row is not None and args.column==None and args.cell == None:
|
||||
|
||||
val = worksheet.row_values(args.row) # Get a specific row
|
||||
|
||||
elif args.column is not None and args.row== None and args.cell == None:
|
||||
|
||||
val = worksheet.col_values(args.column) # Get a specific column
|
||||
|
||||
else:
|
||||
print("To search for data in a cell use the --cell parameter, for data in a column --column and in a row --row, only one of these parameters can be used at a time.")
|
||||
sys.exit()
|
||||
|
||||
|
||||
print(val)
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-server
|
||||
Version: 7.0NG.769-230220
|
||||
Version: 7.0NG.769-230303
|
||||
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.769-230220"
|
||||
pandora_version="7.0NG.769-230303"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
@ -42,9 +42,6 @@ use PandoraFMS::PredictionServer;
|
||||
use PandoraFMS::WebServer;
|
||||
use PandoraFMS::InventoryServer;
|
||||
|
||||
# Constants for Win32 services.
|
||||
use constant WIN32_SERVICE_STOPPED => 0x01;
|
||||
use constant WIN32_SERVICE_RUNNING => 0x04;
|
||||
|
||||
# Global vars
|
||||
my %Config :shared;
|
||||
@ -255,7 +252,6 @@ sub pandora_crash () {
|
||||
print_message (\%Config, " Error description:\n", 0);
|
||||
print_message (\%Config, $full_error, 0);
|
||||
|
||||
callback_stop() if ($^O eq 'MSWin32' && defined($Config{'win32_service'}));
|
||||
}
|
||||
|
||||
########################################################################################
|
||||
@ -510,135 +506,6 @@ sub pandora_server_tasks ($) {
|
||||
db_disconnect($dbh);
|
||||
}
|
||||
|
||||
################################################################################
|
||||
## Install the Windows service.
|
||||
################################################################################
|
||||
sub win32_install_service() {
|
||||
|
||||
# Load Win32::Daemon.
|
||||
eval "use Win32::Daemon";
|
||||
die($@) if ($@);
|
||||
|
||||
# Configure and install the service.
|
||||
my $service_path = $0;
|
||||
my $service_params = "-S run \"" . $Config{'pandora_path'} ."\"";
|
||||
my %service_hash = (
|
||||
machine => '',
|
||||
name => 'PANDORAFMSSRV',
|
||||
display => 'Pandora FMS Server',
|
||||
path => $service_path,
|
||||
user => '',
|
||||
pwd => '',
|
||||
description => 'Pandora FMS Server http://pandorafms.com/',
|
||||
parameters => $service_params
|
||||
);
|
||||
|
||||
if (Win32::Daemon::CreateService(\%service_hash)) {
|
||||
print "Successfully added.\n";
|
||||
exit 0;
|
||||
} else {
|
||||
print "Failed to add service: " . Win32::FormatMessage(Win32::Daemon::GetLastError()) . "\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
## Install the Windows service.
|
||||
################################################################################
|
||||
sub win32_uninstall_service() {
|
||||
|
||||
# Load Win32::Daemon.
|
||||
eval "use Win32::Daemon";
|
||||
die($@) if ($@);
|
||||
|
||||
# Uninstall the service.
|
||||
if (Win32::Daemon::DeleteService('', 'PANDORAFMSSRV')) {
|
||||
print "Successfully deleted.\n";
|
||||
exit 0;
|
||||
} else {
|
||||
print "Failed to delete service: " . Win32::FormatMessage(Win32::Daemon::GetLastError()) . "\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
## Windows service callback function for the running event.
|
||||
################################################################################
|
||||
sub callback_running {
|
||||
if (Win32::Daemon::State() == WIN32_SERVICE_RUNNING) {
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
## Windows service callback function for the start event.
|
||||
################################################################################
|
||||
sub callback_start {
|
||||
no strict;
|
||||
|
||||
# Accept_connections ();
|
||||
my $thr = threads->create(\&main);
|
||||
if (!defined($thr)) {
|
||||
Win32::Daemon::State(WIN32_SERVICE_STOPPED);
|
||||
Win32::Daemon::StopService();
|
||||
return;
|
||||
}
|
||||
$thr->detach();
|
||||
|
||||
Win32::Daemon::State(WIN32_SERVICE_RUNNING);
|
||||
}
|
||||
|
||||
################################################################################
|
||||
## Windows service callback function for the stop event.
|
||||
################################################################################
|
||||
sub callback_stop {
|
||||
|
||||
$RUN = 0;
|
||||
Win32::Daemon::State(WIN32_SERVICE_STOPPED);
|
||||
Win32::Daemon::StopService();
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Run as a Windows service.
|
||||
################################################################################
|
||||
sub win32_service_run() {
|
||||
|
||||
# Load Win32::Daemon.
|
||||
eval "use Win32::Daemon";
|
||||
die($@) if ($@);
|
||||
|
||||
# Run the Pandora FMS Server as a Windows service.
|
||||
Win32::Daemon::RegisterCallbacks({
|
||||
start => \&callback_start,
|
||||
running => \&callback_running,
|
||||
stop => \&callback_stop,
|
||||
});
|
||||
Win32::Daemon::StartService();
|
||||
}
|
||||
|
||||
################################################################################
|
||||
## Parse command line options.
|
||||
################################################################################
|
||||
sub parse_service_options ($) {
|
||||
my $config = shift;
|
||||
|
||||
# Sanity checks.
|
||||
return unless defined($config->{'win32_service'});
|
||||
die ("[ERROR] Windows services are only available on Win32.\n\n") if ($^O ne 'MSWin32');
|
||||
|
||||
# Win32 service management.
|
||||
eval "use Win32::Daemon";
|
||||
die($@) if ($@);
|
||||
|
||||
if ($config->{'win32_service'} eq 'install') {
|
||||
win32_install_service();
|
||||
} elsif ($config->{'win32_service'} eq 'uninstall') {
|
||||
win32_uninstall_service();
|
||||
} elsif ($config->{'win32_service'} eq 'run') {
|
||||
} else {
|
||||
die("[ERROR] Unknown action: " . $config->{'win32_service'});
|
||||
}
|
||||
}
|
||||
|
||||
################################################################
|
||||
################################################################
|
||||
## Main.
|
||||
@ -967,17 +834,9 @@ $SIG{'ALRM'} = 'IGNORE';
|
||||
pandora_init(\%Config, pandora_get_initial_product_name() . ' Server');
|
||||
pandora_load_config (\%Config);
|
||||
|
||||
# Parse command line options.
|
||||
parse_service_options(\%Config);
|
||||
|
||||
# Run as a regular process.
|
||||
if (!defined($Config{'win32_service'})) {
|
||||
main();
|
||||
}
|
||||
# Run as a Windows service.
|
||||
else {
|
||||
win32_service_run();
|
||||
}
|
||||
main();
|
||||
|
||||
################################################################################
|
||||
# Kill any scripts started by the Pandora FMS Server that are still running.
|
||||
|
@ -46,7 +46,7 @@ our @EXPORT = qw(
|
||||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.769";
|
||||
my $pandora_build = "230220";
|
||||
my $pandora_build = "230303";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
@ -64,7 +64,6 @@ sub help_screen {
|
||||
print " -d : Debug mode activated. Writes extensive information in the logfile \n";
|
||||
print " -D : Daemon mode (runs in background)\n";
|
||||
print " -P <file> : Store PID to file.\n";
|
||||
print " -S <install|uninstall|run>: Manage the win32 service.\n";
|
||||
print " -h : This screen. Shows a little help screen \n";
|
||||
print " \n";
|
||||
exit;
|
||||
@ -111,9 +110,6 @@ sub pandora_init {
|
||||
elsif ($parametro =~ m/-D\z/) {
|
||||
$pa_config->{"daemon"}=1;
|
||||
}
|
||||
elsif ($parametro =~ m/^-S\z/i) {
|
||||
$pa_config->{'win32_service'}= clean_blank($ARGV[$ax+1]);
|
||||
}
|
||||
else {
|
||||
($pa_config->{"pandora_path"} = $parametro);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
|
||||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.769";
|
||||
my $pandora_build = "230220";
|
||||
my $pandora_build = "230303";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
@ -118,12 +118,12 @@ sub check_lib_version {
|
||||
|
||||
$plugin_version = "0NG.0" if empty($plugin_version);
|
||||
|
||||
my ($main,$oum) = split /NG./, $plugin_version;
|
||||
my ($main,$oum) = ($plugin_version =~ m/(\d*\.?\d+)NG\.(\d*\.?\d+)/);
|
||||
|
||||
$main = 0 if empty($main) || !looks_like_number($main);
|
||||
$oum = 0 if empty($oum) || !looks_like_number($oum);
|
||||
|
||||
my ($libmain,$liboum) = split /NG./, $pandora_version;
|
||||
my ($libmain,$liboum) = ($pandora_version =~ m/(\d*\.?\d+)NG\.(\d*\.?\d+)/);
|
||||
|
||||
if (($liboum < $oum)
|
||||
|| ($libmain != $main)) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
%global __os_install_post %{nil}
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.769
|
||||
%define release 230220
|
||||
%define release 230303
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
@ -4,7 +4,7 @@
|
||||
%global __os_install_post %{nil}
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.769
|
||||
%define release 230220
|
||||
%define release 230303
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
@ -9,7 +9,7 @@
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.769"
|
||||
PI_BUILD="230220"
|
||||
PI_BUILD="230303"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
@ -35,7 +35,7 @@ use PandoraFMS::Config;
|
||||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.769 Build 230220";
|
||||
my $version = "7.0NG.769 Build 230303";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
||||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.769 Build 230220";
|
||||
my $version = "7.0NG.769 Build 230303";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user