Conflict solution

This commit is contained in:
Jonathan 2023-03-06 11:04:05 +01:00
commit cf29caedcd
162 changed files with 32126 additions and 24459 deletions

View File

@ -0,0 +1,322 @@
#!/bin/bash
#######################################################
# PandoraFMS Community online installation script
#######################################################
## Tested versions ##
# Centos 8.4, 8.5
# Rocky 8.4, 8.5, 8.6, 8.7
# Almalinuz 8.4, 8.5
# RedHat 8.5
#Constants
S_VERSION='202302201'
LOGFILE="/tmp/deploy-ext-db-$(date +%F).log"
# define default variables
[ "$TZ" ] || TZ="Europe/Madrid"
[ "$MYVER" ] || MYVER=57
[ "$DBHOST" ] || DBHOST=127.0.0.1
[ "$DBNAME" ] || DBNAME=pandora
[ "$DBUSER" ] || DBUSER=pandora
[ "$DBPASS" ] || DBPASS=pandora
[ "$DBPORT" ] || DBPORT=3306
[ "$DBROOTUSER" ] || DBROOTUSER=root
[ "$DBROOTPASS" ] || DBROOTPASS=pandora
[ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0
[ "$SKIP_KERNEL_OPTIMIZATIONS" ] || SKIP_KERNEL_OPTIMIZATIONS=0
[ "$POOL_SIZE" ] || POOL_SIZE=$(grep -i total /proc/meminfo | head -1 | awk '{printf "%.2f \n", $(NF-1)*0.4/1024}' | sed "s/\\..*$/M/g")
# Ansi color code variables
red="\e[0;91m"
green="\e[0;92m"
cyan="\e[0;36m"
reset="\e[0m"
# Functions
execute_cmd () {
local cmd="$1"
local msg="$2"
echo -e "${cyan}$msg...${reset}"
$cmd &>> "$LOGFILE"
if [ $? -ne 0 ]; then
echo -e "${red}Fail${reset}"
[ "$3" ] && echo "$3"
echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE"
rm -rf "$HOME"/pandora_deploy_tmp &>> "$LOGFILE"
exit 1
else
echo -e "\e[1A\e ${cyan}$msg...${reset} ${green}OK${reset}"
return 0
fi
}
check_cmd_status () {
if [ $? -ne 0 ]; then
echo -e "${red}Fail${reset}"
[ "$1" ] && echo "$1"
echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE"
rm -rf "$HOME"/pandora_deploy_tmp/*.rpm* &>> "$LOGFILE"
exit 1
else
echo -e "${green}OK${reset}"
return 0
fi
}
check_root_permissions () {
echo -en "${cyan}Checking root account... ${reset}"
if [ "$(whoami)" != "root" ]; then
echo -e "${red}Fail${reset}"
echo "Please use a root account or sudo for installing Pandora FMS"
echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE"
exit 1
else
echo -e "${green}OK${reset}"
fi
}
## Main
echo "Starting PandoraFMS External DB deployment EL8 ver. $S_VERSION"
# Centos Version
if [ ! "$(grep -Ei 'centos|rocky|Almalinux|Red Hat Enterprise' /etc/redhat-release)" ]; then
printf "\n ${red}Error this is not a Centos/Rocky/Almalinux Base system, this installer is compatible with RHEL/Almalinux/Centos/Rockylinux systems only${reset}\n"
exit 1
fi
echo -en "${cyan}Check Centos Version...${reset}"
[ $(sed -nr 's/VERSION_ID+=\s*"([0-9]).*"$/\1/p' /etc/os-release) -eq '8' ]
check_cmd_status 'Error OS version, RHEL/Almalinux/Centos/Rockylinux 8+ is expected'
#Detect OS
os_name=$(grep ^PRETTY_NAME= /etc/os-release | cut -d '=' -f2 | tr -d '"')
execute_cmd "echo $os_name" "OS detected: ${os_name}"
# initialice logfile
execute_cmd "echo 'Starting community deployment' > $LOGFILE" "All installer activity is logged on $LOGFILE"
echo "Community installer version: $S_VERSION" >> "$LOGFILE"
# Pre checks
# Root permisions
check_root_permissions
# Systemd
execute_cmd "systemctl status" "Checking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env please check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8'
# Check memomry greather or equal to 2G
execute_cmd "[ $(grep MemTotal /proc/meminfo | awk '{print $2}') -ge 1700000 ]" 'Checking memory (required: 2 GB)'
# Check disk size at least 10 Gb free space
execute_cmd "[ $(df -BM / | tail -1 | awk '{print $4}' | tr -d M) -gt 10000 ]" 'Checking Disk (required: 10 GB free min)'
# Setting timezone
rm -rf /etc/localtime &>> "$LOGFILE"
execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ"
# Execute tools check
execute_cmd "awk --version" 'Checking needed tools: awk'
execute_cmd "grep --version" 'Checking needed tools: grep'
execute_cmd "sed --version" 'Checking needed tools: sed'
execute_cmd "dnf --version" 'Checking needed tools: dnf'
# Creating working directory
rm -rf "$HOME"/pandora_deploy_tmp/*.rpm* &>> "$LOGFILE"
mkdir "$HOME"/pandora_deploy_tmp &>> "$LOGFILE"
execute_cmd "cd $HOME/pandora_deploy_tmp" "Moving to workspace: $HOME/pandora_deploy_tmp"
## Extra steps on redhat envs
if [ "$(grep -Ei 'Red Hat Enterprise' /etc/redhat-release)" ]; then
## In case REDHAT
# Check susbscription manager status:
echo -en "${cyan}Checking Red Hat Enterprise subscription... ${reset}"
subscription-manager list &>> "$LOGFILE"
subscription-manager status &>> "$LOGFILE"
check_cmd_status 'Error checking subscription status, make sure your server is activated and suscribed to Red Hat Enterprise repositories'
# Ckeck repolist
dnf repolist &>> "$LOGFILE"
echo -en "${cyan}Checking Red Hat Enterprise repolist... ${reset}"
dnf repolist | grep 'rhel-8-for-x86_64-baseos-rpms' &>> "$LOGFILE"
check_cmd_status 'Error checking repositories status, could try a subscription-manager attach command or contact sysadmin'
#install extra repos
extra_repos=" \
tar \
dnf-utils \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
https://repo.percona.com/yum/percona-release-latest.noarch.rpm"
execute_cmd "dnf install -y $extra_repos" "Installing extra repositories"
execute_cmd "subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms" "Enabling subscription to codeready-builder"
else
# For alma/rocky/centos
extra_repos=" \
tar \
dnf-utils \
epel-release \
https://repo.percona.com/yum/percona-release-latest.noarch.rpm"
execute_cmd "dnf install -y $extra_repos" "Installing extra repositories"
execute_cmd "dnf config-manager --set-enabled powertools" "Configuring Powertools"
fi
#Installing wget
execute_cmd "dnf install -y wget" "Installing wget"
# Install percona Database
execute_cmd "dnf module disable -y mysql" "Disabiling mysql module"
if [ "$MYVER" -eq '80' ] ; then
execute_cmd "percona-release setup ps80 -y" "Enabling mysql80 module"
execute_cmd "dnf install -y percona-server-server percona-xtrabackup-24" "Installing Percona Server 80"
fi
if [ "$MYVER" -ne '80' ] ; then
execute_cmd "dnf install -y Percona-Server-server-57 percona-xtrabackup-24" "Installing Percona Server 57"
fi
# Disabling SELINUX and firewalld
setenforce 0 &>> "$LOGFILE"
sed -i -e "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config &>> "$LOGFILE"
systemctl disable firewalld --now &>> "$LOGFILE"
# Adding standar cnf for initial setup.
cat > /etc/my.cnf << EO_CONFIG_TMP
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
EO_CONFIG_TMP
#Configuring Database
if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then
execute_cmd "systemctl start mysqld" "Starting database engine"
export MYSQL_PWD=$(grep "temporary password" /var/log/mysqld.log | rev | cut -d' ' -f1 | rev)
if [ "$MYVER" -eq '80' ] ; then
echo """
SET PASSWORD FOR '$DBROOTUSER'@'localhost' = 'Pandor4!';
UNINSTALL COMPONENT 'file://component_validate_password';
SET PASSWORD FOR '$DBROOTUSER'@'localhost' = '$DBROOTPASS';
""" | mysql --connect-expired-password -u$DBROOTUSER &>> "$LOGFILE"
fi
if [ "$MYVER" -ne '80' ] ; then
echo """
SET PASSWORD FOR '$DBROOTUSER'@'localhost' = PASSWORD('Pandor4!');
UNINSTALL PLUGIN validate_password;
SET PASSWORD FOR '$DBROOTUSER'@'localhost' = PASSWORD('$DBROOTPASS');
""" | mysql --connect-expired-password -u$DBROOTUSER &>> "$LOGFILE"fi
fi
export MYSQL_PWD=$DBROOTPASS
echo -en "${cyan}Creating Pandora FMS database...${reset}"
echo "create database $DBNAME" | mysql -u$DBROOTUSER -P$DBPORT -h$DBHOST
check_cmd_status "Error creating database $DBNAME, is this an empty node? if you have a previus installation please contact with support."
echo "CREATE USER \"$DBUSER\"@'%' IDENTIFIED BY \"$DBPASS\";" | mysql -u$DBROOTUSER -P$DBPORT -h$DBHOST
echo "ALTER USER \"$DBUSER\"@'%' IDENTIFIED WITH mysql_native_password BY \"$DBPASS\"" | mysql -u$DBROOTUSER -P$DBPORT -h$DBHOST
echo "GRANT ALL PRIVILEGES ON $DBNAME.* TO \"$DBUSER\"@'%'" | mysql -u$DBROOTUSER -P$DBPORT -h$DBHOST
#Generating my.cnf
cat > /etc/my.cnf << EO_CONFIG_F
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
character-set-server=utf8
skip-character-set-client-handshake
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Mysql optimizations for Pandora FMS
# Please check the documentation in http://pandorafms.com for better results
max_allowed_packet = 64M
innodb_buffer_pool_size = $POOL_SIZE
innodb_lock_wait_timeout = 90
innodb_file_per_table
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
thread_cache_size = 8
thread_stack = 256K
max_connections = 100
key_buffer_size=4M
read_buffer_size=128K
read_rnd_buffer_size=128K
sort_buffer_size=128K
join_buffer_size=4M
query_cache_type = 1
query_cache_size = 64M
query_cache_min_res_unit = 2k
query_cache_limit = 256K
#skip-log-bin
sql_mode=""
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
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"
execute_cmd "systemctl enable mysqld --now" "Enabling Database service"
fi
export MYSQL_PWD=$DBPASS
# Kernel optimization
if [ "$SKIP_KERNEL_OPTIMIZATIONS" -eq '0' ] ; then
cat >> /etc/sysctl.conf <<EO_KO
# Pandora FMS Optimization
# default=5
net.ipv4.tcp_syn_retries = 3
# default=5
net.ipv4.tcp_synack_retries = 3
# default=1024
net.ipv4.tcp_max_syn_backlog = 65536
# default=124928
net.core.wmem_max = 8388608
# default=131071
net.core.rmem_max = 8388608
# default = 128
net.core.somaxconn = 1024
# default = 20480
net.core.optmem_max = 81920
EO_KO
[ -d /dev/lxd/ ] || execute_cmd "sysctl --system" "Applying Kernel optimization"
fi
execute_cmd "echo done" "Percona server installed"
cd
execute_cmd "rm -rf $HOME/pandora_deploy_tmp" "Removing temporary files"

View File

@ -0,0 +1,258 @@
#!/bin/bash
##############################################################################################################
# PandoraFMS Community online installation script for Ubuntu 22.04
##############################################################################################################
## Tested versions ##
# Ubuntu 22.04.1
# Ubuntu 22.04.2
#avoid promps
export DEBIAN_FRONTEND=noninteractive
export NEEDRESTART_SUSPEND=1
#Constants
PANDORA_CONSOLE=/var/www/html/pandora_console
PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf
PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
WORKDIR=/opt/pandora/deploy
S_VERSION='202302201'
LOGFILE="/tmp/deploy-ext-db-$(date +%F).log"
rm -f $LOGFILE &> /dev/null # remove last log before start
# define default variables
[ "$TZ" ] || TZ="Europe/Madrid"
[ "$DBHOST" ] || DBHOST=127.0.0.1
[ "$DBNAME" ] || DBNAME=pandora
[ "$DBUSER" ] || DBUSER=pandora
[ "$DBPASS" ] || DBPASS=pandora
[ "$DBPORT" ] || DBPORT=3306
[ "$DBROOTPASS" ] || DBROOTPASS=pandora
[ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0
[ "$SKIP_KERNEL_OPTIMIZATIONS" ] || SKIP_KERNEL_OPTIMIZATIONS=0
[ "$POOL_SIZE" ] || POOL_SIZE=$(grep -i total /proc/meminfo | head -1 | awk '{printf "%.2f \n", $(NF-1)*0.4/1024}' | sed "s/\\..*$/M/g")
# Ansi color code variables
red="\e[0;91m"
green="\e[0;92m"
cyan="\e[0;36m"
reset="\e[0m"
# Functions
execute_cmd () {
local cmd="$1"
local msg="$2"
echo -e "${cyan}$msg...${reset}"
$cmd &>> "$LOGFILE"
if [ $? -ne 0 ]; then
echo -e "${red}Fail${reset}"
[ "$3" ] && echo "$3"
echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE"
rm -rf "$WORKDIR" &>> "$LOGFILE"
exit 1
else
echo -e "\e[1A\e ${cyan}$msg...${reset} ${green}OK${reset}"
return 0
fi
}
check_cmd_status () {
if [ $? -ne 0 ]; then
echo -e "${red}Fail${reset}"
[ "$1" ] && echo "$1"
echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE"
rm -rf "$WORKDIR" &>> "$LOGFILE"
exit 1
else
echo -e "${green}OK${reset}"
return 0
fi
}
check_root_permissions () {
echo -en "${cyan}Checking root account... ${reset}"
if [ "$(whoami)" != "root" ]; then
echo -e "${red}Fail${reset}"
echo "Please use a root account or sudo for installing Pandora FMS"
echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE"
exit 1
else
echo -e "${green}OK${reset}"
fi
}
## Main
echo "Starting PandoraFMS External DB deployment Ubuntu 22.04 ver. $S_VERSION"
# Ubuntu Version
if [ ! "$(grep -Ei 'Ubuntu' /etc/lsb-release)" ]; then
printf "\n ${red}Error this is not a Ubuntu system, this installer is compatible with Ubuntu systems only${reset}\n"
exit 1
fi
echo -en "${cyan}Check Ubuntu Version...${reset}"
[ $(sed -nr 's/VERSION_ID+=\s*"([0-9][0-9].[0-9][0-9])"$/\1/p' /etc/os-release) == "22.04" ]
check_cmd_status 'Error OS version, Ubuntu 22.04 is expected'
#Detect OS
os_name=$(grep ^PRETTY_NAME= /etc/os-release | cut -d '=' -f2 | tr -d '"')
execute_cmd "echo $os_name" "OS detected: ${os_name}"
# initialice logfile
execute_cmd "echo 'Starting community deployment' > $LOGFILE" "All installer activity is logged on $LOGFILE"
echo "Community installer version: $S_VERSION" >> "$LOGFILE"
# Pre checks
# Root permisions
check_root_permissions
#Install awk, sed, grep if not present
execute_cmd "apt install -y gawk sed grep" 'Installing needed tools'
# Systemd
execute_cmd "systemctl --version" "Checking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env please check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8'
# Check memomry greather or equal to 2G
execute_cmd "[ $(grep MemTotal /proc/meminfo | awk '{print $2}') -ge 1700000 ]" 'Checking memory (required: 2 GB)'
# Check disk size at least 10 Gb free space
execute_cmd "[ $(df -BM / | tail -1 | awk '{print $4}' | tr -d M) -gt 10000 ]" 'Checking Disk (required: 10 GB free min)'
# Setting timezone
rm -rf /etc/localtime &>> "$LOGFILE"
execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ"
# Execute tools check
execute_cmd "awk --version" 'Checking needed tools: awk'
execute_cmd "grep --version" 'Checking needed tools: grep'
execute_cmd "sed --version" 'Checking needed tools: sed'
execute_cmd "apt --version" 'Checking needed tools: apt'
# Creating working directory
rm -rf "$WORKDIR" &>> "$LOGFILE"
mkdir -p "$WORKDIR" &>> "$LOGFILE"
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"
# Disabling apparmor and ufw
systemctl stop ufw.service &>> "$LOGFILE"
systemctl disable ufw &>> "$LOGFILE"
systemctl stop apparmor &>> "$LOGFILE"
systemctl disable apparmor &>> "$LOGFILE"
#install mysql
execute_cmd "curl -O https://repo.percona.com/apt/percona-release_latest.generic_all.deb" "Downloading Percona repository for MySQL8"
execute_cmd "apt install -y gnupg2 lsb-release ./percona-release_latest.generic_all.deb" "Installing Percona repository for MySQL8"
execute_cmd "percona-release setup ps80" "Configuring Percona repository for MySQL8"
echo -en "${cyan}Installing Percona Server for MySQL8...${reset}"
env DEBIAN_FRONTEND=noninteractive apt install -y percona-server-server &>> "$LOGFILE"
check_cmd_status "Error Installing MySql Server"
#Configuring Database
if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then
execute_cmd "systemctl start mysql" "Starting database engine"
echo """
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '$DBROOTPASS';
""" | mysql -uroot &>> "$LOGFILE"
export MYSQL_PWD=$DBROOTPASS
echo -en "${cyan}Creating Pandora FMS database...${reset}"
echo "create database $DBNAME" | mysql -uroot -P$DBPORT -h$DBHOST
check_cmd_status "Error creating database $DBNAME, is this an empty node? if you have a previus installation please contact with support."
echo "CREATE USER \"$DBUSER\"@'%' IDENTIFIED BY \"$DBPASS\";" | mysql -uroot -P$DBPORT -h$DBHOST
echo "ALTER USER \"$DBUSER\"@'%' IDENTIFIED WITH mysql_native_password BY \"$DBPASS\"" | mysql -uroot -P$DBPORT -h$DBHOST
echo "GRANT ALL PRIVILEGES ON $DBNAME.* TO \"$DBUSER\"@'%'" | mysql -uroot -P$DBPORT -h$DBHOST
fi
export MYSQL_PWD=$DBPASS
#Generating my.cnf
cat > /etc/mysql/my.cnf << EOF_DB
[mysqld]
datadir=/var/lib/mysql
user=mysql
character-set-server=utf8mb4
skip-character-set-client-handshake
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Mysql optimizations for Pandora FMS
# Please check the documentation in http://pandorafms.com for better results
max_allowed_packet = 64M
innodb_buffer_pool_size = $POOL_SIZE
innodb_lock_wait_timeout = 90
innodb_file_per_table
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 = 300
thread_cache_size = 8
thread_stack = 256K
max_connections = 100
key_buffer_size=4M
read_buffer_size=128K
read_rnd_buffer_size=128K
sort_buffer_size=128K
join_buffer_size=4M
skip-log-bin
sql_mode=""
log-error=/var/log/mysql/error.log
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
EOF_DB
execute_cmd "systemctl restart mysql" "Configuring and restarting database engine"
# Kernel optimization
if [ "$SKIP_KERNEL_OPTIMIZATIONS" -eq '0' ] ; then
cat >> /etc/sysctl.conf <<EO_KO
# Pandora FMS Optimization
# default=5
net.ipv4.tcp_syn_retries = 3
# default=5
net.ipv4.tcp_synack_retries = 3
# default=1024
net.ipv4.tcp_max_syn_backlog = 65536
# default=124928
net.core.wmem_max = 8388608
# default=131071
net.core.rmem_max = 8388608
# default = 128
net.core.somaxconn = 1024
# default = 20480
net.core.optmem_max = 81920
EO_KO
[ -d /dev/lxd/ ] || execute_cmd "sysctl --system" "Applying Kernel optimization"
fi
# Remove temporary files
execute_cmd "echo done" "Percona server installed"
cd "$HOME"
execute_cmd "rm -rf $WORKDIR" "Removing temporary files"

View File

@ -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" execute_cmd "yum install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "installing PandoraFMS packages"
# Copy gotty utility # 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 tar xvzf gotty_linux_amd64.tar.gz &>> $LOGFILE
execute_cmd "mv gotty /usr/bin/" 'Installing gotty util' execute_cmd "mv gotty /usr/bin/" 'Installing gotty util'
@ -639,8 +639,8 @@ systemctl enable tentacle_serverd &>> $LOGFILE
execute_cmd "service tentacle_serverd start" "Starting Tentacle Server" execute_cmd "service tentacle_serverd start" "Starting Tentacle Server"
# Enabling condole cron # Enabling condole cron
execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS 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 http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab 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 agent ## Enabling agent
systemctl enable pandora_agent_daemon &>> $LOGFILE systemctl enable pandora_agent_daemon &>> $LOGFILE
execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent" execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent"

View File

@ -5,7 +5,7 @@
## Tested versions ## ## Tested versions ##
# Centos 8.4, 8.5 # Centos 8.4, 8.5
# Rocky 8.4, 8.5, 8.6, 8.7 # Rocky 8.4, 8.5, 8.6, 8.7
# Almalinuz 8.4, 8.5 # Almalinux 8.4, 8.5
# RedHat 8.5 # RedHat 8.5
#Constants #Constants
@ -14,7 +14,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf
PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
S_VERSION='202301251' S_VERSION='202302201'
LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables # define default variables
@ -107,6 +107,17 @@ check_root_permissions () {
fi 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 ## Main
echo "Starting PandoraFMS Community deployment EL8 ver. $S_VERSION" echo "Starting PandoraFMS Community deployment EL8 ver. $S_VERSION"
@ -207,6 +218,7 @@ else
execute_cmd "dnf config-manager --set-enabled powertools" "Configuring Powertools" execute_cmd "dnf config-manager --set-enabled powertools" "Configuring Powertools"
fi fi
execute_cmd "installing_docker" "Installing Docker for debug"
#Installing wget #Installing wget
execute_cmd "dnf install -y wget" "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_flush_method = O_DIRECT
innodb_log_file_size = 64M innodb_log_file_size = 64M
innodb_log_buffer_size = 16M innodb_log_buffer_size = 16M
innodb_io_capacity = 100 innodb_io_capacity = 300
thread_cache_size = 8 thread_cache_size = 8
thread_stack = 256K thread_stack = 256K
max_connections = 100 max_connections = 100
@ -483,6 +495,7 @@ EO_CONFIG_F
if [ "$MYVER" -eq '80' ] ; then if [ "$MYVER" -eq '80' ] ; then
sed -i -e "/query_cache.*/ s/^#*/#/g" /etc/my.cnf 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/#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 fi
execute_cmd "systemctl restart mysqld" "Configuring database engine" 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" execute_cmd "dnf install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "Installing Pandora FMS packages"
# Copy gotty utility # 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 tar xvzf gotty_linux_amd64.tar.gz &>> $LOGFILE
execute_cmd "mv gotty /usr/bin/" 'Installing gotty util' execute_cmd "mv gotty /usr/bin/" 'Installing gotty util'
@ -732,8 +745,8 @@ systemctl enable tentacle_serverd &>> "$LOGFILE"
execute_cmd "service tentacle_serverd start" "Starting Tentacle Server" execute_cmd "service tentacle_serverd start" "Starting Tentacle Server"
# Enabling condole cron # Enabling condole cron
execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS 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 http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab 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 agent ## Enabling agent
systemctl enable pandora_agent_daemon &>> "$LOGFILE" systemctl enable pandora_agent_daemon &>> "$LOGFILE"
execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent" execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent"
@ -743,7 +756,7 @@ execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent"
cat > /etc/issue.net << EOF_banner 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 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"}') $(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"}')

View File

@ -4,6 +4,7 @@
############################################################################################################## ##############################################################################################################
## Tested versions ## ## Tested versions ##
# Ubuntu 22.04.1 # Ubuntu 22.04.1
# Ubuntu 22.04.2
#avoid promps #avoid promps
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
@ -16,7 +17,7 @@ PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
WORKDIR=/opt/pandora/deploy WORKDIR=/opt/pandora/deploy
S_VERSION='202301251' S_VERSION='202302201'
LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
rm -f $LOGFILE &> /dev/null # remove last log before start rm -f $LOGFILE &> /dev/null # remove last log before start
@ -106,6 +107,21 @@ check_root_permissions () {
fi 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 ## Main
echo "Starting PandoraFMS Community deployment Ubuntu 22.04 ver. $S_VERSION" 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 ## Install utils
execute_cmd "apt update" "Updating repos" 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 #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" [ -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-xml \
php$PHPVER-yaml \ php$PHPVER-yaml \
libnet-telnet-perl \ libnet-telnet-perl \
whois" whois \
cron"
execute_cmd "apt install -y $console_dependencies" "Installing Pandora FMS Console dependencies" execute_cmd "apt install -y $console_dependencies" "Installing Pandora FMS Console dependencies"
# Server dependencies # Server dependencies
@ -254,10 +271,13 @@ server_dependencies=" \
libnet-telnet-perl \ libnet-telnet-perl \
libjson-perl \ libjson-perl \
libencode-perl \ libencode-perl \
cron \
libgeo-ip-perl \ libgeo-ip-perl \
openjdk-8-jdk " openjdk-8-jdk "
execute_cmd "apt install -y $server_dependencies" "Installing Pandora FMS Server dependencies" execute_cmd "apt install -y $server_dependencies" "Installing Pandora FMS Server dependencies"
execute_cmd "installing_docker" "Installing Docker for debug"
# wmic and pandorawmic # 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/wmic" "Downloading wmic"
execute_cmd "curl -O https://firefly.artica.es/pandorafms/utils/bin/pandorawmic" "Downloading pandorawmic" 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] [mysqld]
datadir=/var/lib/mysql datadir=/var/lib/mysql
user=mysql user=mysql
character-set-server=utf8 character-set-server=utf8mb4
skip-character-set-client-handshake skip-character-set-client-handshake
# Disabling symbolic-links is recommended to prevent assorted security risks # Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0 symbolic-links=0
@ -408,7 +428,7 @@ innodb_flush_log_at_trx_commit = 0
innodb_flush_method = O_DIRECT innodb_flush_method = O_DIRECT
innodb_log_file_size = 64M innodb_log_file_size = 64M
innodb_log_buffer_size = 16M innodb_log_buffer_size = 16M
innodb_io_capacity = 100 innodb_io_capacity = 300
thread_cache_size = 8 thread_cache_size = 8
thread_stack = 256K thread_stack = 256K
max_connections = 100 max_connections = 100
@ -477,7 +497,7 @@ check_cmd_status "Error installing PandoraFMS Agent"
# Copy gotty utility # Copy gotty utility
cd $WORKDIR &>> "$LOGFILE" 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 tar xvzf gotty_linux_amd64.tar.gz &>> $LOGFILE
execute_cmd "mv gotty /usr/bin/" 'Installing gotty util' execute_cmd "mv gotty /usr/bin/" 'Installing gotty util'
@ -731,9 +751,14 @@ systemctl enable pandora_server &>> "$LOGFILE"
execute_cmd "service tentacle_serverd start" "Starting Tentacle Server" execute_cmd "service tentacle_serverd start" "Starting Tentacle Server"
systemctl enable tentacle_serverd &>> "$LOGFILE" systemctl enable tentacle_serverd &>> "$LOGFILE"
# Enabling condole cron # Enabling console cron
execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS 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 http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab 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 ## Enabling agent adn configuring Agente
sed -i "s/^remote_config.*$/remote_config 1/g" $PANDORA_AGENT_CONF &>> "$LOGFILE" sed -i "s/^remote_config.*$/remote_config 1/g" $PANDORA_AGENT_CONF &>> "$LOGFILE"
@ -748,7 +773,7 @@ sed --follow-symlinks -i -e "s/^openssl_conf = openssl_init/#openssl_conf = open
cat > /etc/issue.net << EOF_banner 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 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"}') $(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"}')

View File

@ -277,8 +277,8 @@ export ORACLE_HOME=/usr/lib/oracle/$VERSION/client64
EOF_ENV EOF_ENV
echo ">> Enable discovery cron: " echo ">> Enable discovery cron: "
#while true ; do wget -q -O - --no-check-certificate http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/pandora_console.log && sleep 60 ; done & #while true ; do wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/pandora_console.log && sleep 60 ; done &
echo "*/5 * * * * wget -q -O - --no-check-certificate http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/log/cron.log" >> /opt/pandora/crontasks echo "*/5 * * * * wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/log/cron.log" >> /opt/pandora/crontasks
echo ">> Enable pandora_db cron: " echo ">> Enable pandora_db cron: "
/usr/bin/perl /usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf /usr/bin/perl /usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
# #
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%global __os_install_post %{nil}
%define name pandorafms_agent_linux %define name pandorafms_agent_linux
%define version 4.0 %define version 4.0
%define release 1 %define release 1

View File

@ -1,6 +1,7 @@
# #
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%global __os_install_post %{nil}
%define name pandorafms_agent_linux %define name pandorafms_agent_linux
%define version 4.0.1 %define version 4.0.1
%define release 1 %define release 1

View File

@ -1,15 +1,8 @@
#!/usr/bin/perl #!/usr/bin/perl
########################################################################## ################################################################################
# pandora_agent_exec # pandora_exec - Execute a command with a time limit.
# #
# Executes the given command and prints its output to stdout. If the # Copyright (c) 2008-2023 Artica PFMS S.L.
# execution times out or the command does not exist nothing is printed
# to stdout. This is part of Pandora FMS Plugin server, do not delete!.
#
# Usage: pandora_agent_exec <timeout in seconds> <command>
##########################################################################
# Copyright (c) 2008-2010 Ramon Novoa, rnovoa@gmail.com
# (c) 2008-2010 Artica Soluciones Tecnologicas S.L
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@ -22,37 +15,41 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
########################################################################## ################################################################################
use strict; use strict;
use warnings; use warnings;
use POSIX qw(WEXITSTATUS WIFEXITED);
# Check command line parameters # Check command line arguments.
if ($#ARGV < 1) { if ($#ARGV < 1) {
print("Usage: $0 <timeout in seconds> <command>\n");
exit 1; exit 1;
} }
my @opts = @ARGV; my @opts = @ARGV;
my $timeout = shift(@opts); my $timeout = shift(@opts);
my $command = join(' ', @opts); my $command = ($0 =~ m/_agent_exec$/) ? # For backward compatibility with pandora_agent.
my $output = ''; join(' ', @opts) :
my $ReturnCode = 0; join(' ', map { quotemeta($_) } @opts);
# Execute the command # Fork:
eval { # * The child will run the command.
local $SIG{ALRM} = sub { die "alarm\n" }; # * The parent will timeout if needed
alarm $timeout; # and exit with the appropriate exit status.
my $pid = fork();
$output = `$command`; if ($pid == 0) {
$ReturnCode = ($? >> 8) & 0xff; setpgrp();
alarm 0; exec($command);
}; } else {
eval {
# Timeout local $SIG{ALRM} = sub { kill(9, -$pid); exit 1; };
if ($@ eq "alarm\n") { alarm $timeout;
exit 3; waitpid($pid, 0);
alarm 0;
if (WIFEXITED(${^CHILD_ERROR_NATIVE})) {
exit WEXITSTATUS(${^CHILD_ERROR_NATIVE});
}
};
} }
print $output; exit 1;
exit $ReturnCode;

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
# #
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%global __os_install_post %{nil}
%define name pandorafms_agent %define name pandorafms_agent
%define version 3.2 %define version 3.2
Summary: Pandora FMS Linux agent Summary: Pandora FMS Linux agent

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.768-230201 Version: 7.0NG.769-230306
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -556,30 +556,38 @@ BEGIN {
sub runCommand { sub runCommand {
my ($self, $ref, $output_mode) = @_; my ($self, $ref, $output_mode) = @_;
my $result;
if($self->load_libraries()) { if($self->load_libraries()) {
# Functionality possible. # Functionality possible.
my $command = $self->{'commands'}->{$ref}; my $command = $self->{'commands'}->{$ref};
my $result = $self->evaluate_command($ref); $result = $self->evaluate_command($ref);
if (ref($result) eq "HASH") { } else {
# Process command result. $result = {
if (defined($output_mode) && $output_mode eq 'xml') { 'stderr' => 'Cannot use commands without YAML dependency, please install it.',
my $output = ''; 'name' => 'YAML::Tiny',
$output .= "<cmd_report>\n"; 'error_level' => 2,
$output .= " <cmd_response>\n"; };
$output .= " <cmd_name><![CDATA[".$result->{'name'}."]]></cmd_name>\n"; }
$output .= " <cmd_key><![CDATA[".$ref."]]></cmd_key>\n";
$output .= " <cmd_errorlevel><![CDATA[".$result->{'error_level'}."]]></cmd_errorlevel>\n";
$output .= " <cmd_stdout><![CDATA[".$result->{'stdout'}."]]></cmd_stdout>\n";
$output .= " <cmd_stderr><![CDATA[".$result->{'stderr'}."]]></cmd_stderr>\n";
$output .= " </cmd_response>\n";
$output .= "</cmd_report>\n";
return $output; if (ref($result) eq "HASH") {
} # Process command result.
return $result; if (defined($output_mode) && $output_mode eq 'xml') {
} else { my $output = '';
$self->set_last_error('Failed to process ['.$ref.']: '.$result); $output .= "<cmd_report>\n";
$output .= " <cmd_response>\n";
$output .= " <cmd_name><![CDATA[".$result->{'name'}."]]></cmd_name>\n";
$output .= " <cmd_key><![CDATA[".$ref."]]></cmd_key>\n";
$output .= " <cmd_errorlevel><![CDATA[".$result->{'error_level'}."]]></cmd_errorlevel>\n";
$output .= " <cmd_stdout><![CDATA[".$result->{'stdout'}."]]></cmd_stdout>\n";
$output .= " <cmd_stderr><![CDATA[".$result->{'stderr'}."]]></cmd_stderr>\n";
$output .= " </cmd_response>\n";
$output .= "</cmd_report>\n";
return $output;
} }
return $result;
} else {
$self->set_last_error('Failed to process ['.$ref.']: '.$result);
} }
return undef; return undef;
@ -1014,8 +1022,8 @@ my $Sem = undef;
# Semaphore used to control the number of threads # Semaphore used to control the number of threads
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.768'; use constant AGENT_VERSION => '7.0NG.769';
use constant AGENT_BUILD => '230201'; use constant AGENT_BUILD => '230306';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -1,9 +1,10 @@
# #
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%global __os_install_post %{nil}
%define name pandorafms_agent_linux %define name pandorafms_agent_linux
%define version 7.0NG.768 %define version 7.0NG.769
%define release 230201 %define release 230306
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -1,9 +1,10 @@
# #
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%global __os_install_post %{nil}
%define name pandorafms_agent_linux %define name pandorafms_agent_linux
%define version 7.0NG.768 %define version 7.0NG.769
%define release 230201 %define release 230306
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -1,15 +1,8 @@
#!/usr/bin/perl #!/usr/bin/perl
########################################################################## ################################################################################
# pandora_agent_exec # pandora_exec - Execute a command with a time limit.
# #
# Executes the given command and prints its output to stdout. If the # Copyright (c) 2008-2023 Artica PFMS S.L.
# execution times out or the command does not exist nothing is printed
# to stdout. This is part of Pandora FMS Plugin server, do not delete!.
#
# Usage: pandora_agent_exec <timeout in seconds> <command>
##########################################################################
# Copyright (c) 2008-2010 Ramon Novoa, rnovoa@gmail.com
# (c) 2008-2010 Artica Soluciones Tecnologicas S.L
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@ -22,37 +15,41 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
########################################################################## ################################################################################
use strict; use strict;
use warnings; use warnings;
use POSIX qw(WEXITSTATUS WIFEXITED);
# Check command line parameters # Check command line arguments.
if ($#ARGV < 1) { if ($#ARGV < 1) {
print("Usage: $0 <timeout in seconds> <command>\n");
exit 1; exit 1;
} }
my @opts = @ARGV; my @opts = @ARGV;
my $timeout = shift(@opts); my $timeout = shift(@opts);
my $command = join(' ', @opts); my $command = ($0 =~ m/_agent_exec$/) ? # For backward compatibility with pandora_agent.
my $output = ''; join(' ', @opts) :
my $ReturnCode = 0; join(' ', map { quotemeta($_) } @opts);
# Execute the command # Fork:
eval { # * The child will run the command.
local $SIG{ALRM} = sub { die "alarm\n" }; # * The parent will timeout if needed
alarm $timeout; # and exit with the appropriate exit status.
my $pid = fork();
$output = `$command`; if ($pid == 0) {
$ReturnCode = ($? >> 8) & 0xff; setpgrp();
alarm 0; exec($command);
}; } else {
eval {
# Timeout local $SIG{ALRM} = sub { kill(9, -$pid); exit 1; };
if ($@ eq "alarm\n") { alarm $timeout;
exit 3; waitpid($pid, 0);
alarm 0;
if (WIFEXITED(${^CHILD_ERROR_NATIVE})) {
exit WEXITSTATUS(${^CHILD_ERROR_NATIVE});
}
};
} }
print $output; exit 1;
exit $ReturnCode;

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.768 Build 230201") #define PANDORA_VERSION ("7.0NG.769 Build 230306")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.768-230201 Version: 7.0NG.769-230306
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -227,7 +227,7 @@ function dbmgr_extension_main()
'dbport' => $node->dbport(), 'dbport' => $node->dbport(),
'dbname' => $node->dbname(), 'dbname' => $node->dbname(),
'dbuser' => $node->dbuser(), 'dbuser' => $node->dbuser(),
'dbpass' => $node->dbpass(), 'dbpass' => io_output_password($node->dbpass()),
] ]
); );
$error = ''; $error = '';

View File

@ -1,5 +1,29 @@
START TRANSACTION; START TRANSACTION;
ALTER TABLE `tserver` ADD COLUMN `server_keepalive_utimestamp` BIGINT NOT NULL DEFAULT 0;
ALTER TABLE `tmap` MODIFY COLUMN `id_group` TEXT NOT NULL default '';
CREATE TABLE IF NOT EXISTS `tmonitor_filter` (
`id_filter` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_name` VARCHAR(600) NOT NULL,
`id_group_filter` INT NOT NULL DEFAULT 0,
`ag_group` INT NOT NULL DEFAULT 0,
`recursion` TEXT,
`status` INT NOT NULL DEFAULT -1,
`ag_modulename` TEXT,
`ag_freestring` TEXT,
`tag_filter` TEXT,
`moduletype` TEXT,
`module_option` INT DEFAULT 1,
`modulegroup` INT NOT NULL DEFAULT -1,
`min_hours_status` TEXT,
`datatype` TEXT,
`not_condition` TEXT,
`ag_custom_fields` TEXT,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
CREATE TABLE IF NOT EXISTS `tsesion_filter` ( CREATE TABLE IF NOT EXISTS `tsesion_filter` (
`id_filter` INT NOT NULL AUTO_INCREMENT, `id_filter` INT NOT NULL AUTO_INCREMENT,
`id_name` TEXT NULL, `id_name` TEXT NULL,

View 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&#x20;safe&#x20;mode&#x20;not&#x20;enable', 'select&#x20;alias&#x20;from&#x20;tagente&#x20;where&#x20;safe_mode_module&#x20;=&#x20;0');
COMMIT;

View File

@ -359,6 +359,10 @@ if ($config['enterprise_installed']) {
} }
// CSRF validation. // CSRF validation.
if (isset($_SESSION['csrf_code']) === true) {
unset($_SESSION['csrf_code']);
}
html_print_csrf_hidden(); html_print_csrf_hidden();
echo '</form></div>'; echo '</form></div>';

View File

@ -498,10 +498,12 @@ if ($id_agente) {
} }
// Collection. // Collection.
$collectiontab = enterprise_hook('collection_tab'); if ((int) $config['license_nms'] !== 1) {
$collectiontab = enterprise_hook('collection_tab');
if ($collectiontab == -1) { if ($collectiontab == -1) {
$collectiontab = ''; $collectiontab = '';
}
} }
// NetworkConfigManager tab. // NetworkConfigManager tab.
@ -1994,7 +1996,7 @@ if ($create_module) {
$agent = db_get_row('tagente', 'id_agente', $id_agente); $agent = db_get_row('tagente', 'id_agente', $id_agente);
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_AGENT_MANAGEMENT, AUDIT_LOG_AGENT_MANAGEMENT,
"Added module '".io_safe_output($name)."' for agent ".io_safe_output($agent['alias']), "Added module '".db_escape_string_sql($name)."' for agent ".io_safe_output($agent['alias']),
false, false,
true, true,
io_json_mb_encode($values) io_json_mb_encode($values)

View File

@ -89,8 +89,7 @@ $password_fields = [];
// If there are $macros, we create the form fields // If there are $macros, we create the form fields
if (!empty($macros)) { if (!empty($macros)) {
$macros = json_decode($macros, true); $macros = json_decode(io_safe_output($macros), true);
foreach ($macros as $k => $m) { foreach ($macros as $k => $m) {
$data = []; $data = [];
$data[0] = $m['desc']; $data[0] = $m['desc'];

View File

@ -391,7 +391,7 @@ foreach ($actions as $action) {
$data = []; $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) { 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); $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) { if (is_management_allowed() === true) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; 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_submit_button(__('Create'), 'create', false, 'class="sub next"');
html_print_input_hidden('create_alert', 1); html_print_input_hidden('create_alert', 1);
echo '</form>'; echo '</form>';

View File

@ -795,15 +795,15 @@ foreach ($commands as $command) {
); );
$data['action'] = ''; $data['action'] = '';
$table->cellclass[]['action'] = 'action_buttons'; $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. // (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_management_allowed === true && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) {
if (is_user_admin($config['id_user']) === true) { if (is_user_admin($config['id_user']) === true) {
$data['action'] = '<span class="inline_flex">'; $data['action'] = '<span class="inline_flex">';
$data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&amp;copy_command=1&id='.$command['id'].'&pure='.$pure.'" $data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&amp;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>'; 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>'; onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['class' => 'invert_filter']).'</a>';
$data['action'] .= '</span>'; $data['action'] .= '</span>';
} }

View File

@ -352,7 +352,8 @@ if ($search_string) {
$filter[] = "(name LIKE '%".$search_string."%' OR description LIKE '%".$search_string."%' OR value LIKE '%".$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']; $filter['limit'] = (int) $config['block_size'];
if (!is_user_admin($config['id_user'])) { if (!is_user_admin($config['id_user'])) {
$filter['id_group'] = array_keys(users_get_groups(false, 'LM')); $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') && check_acl($config['id_user'], $template['id_group'], 'LM')
) { ) {
$table->cellclass[][4] = 'action_buttons'; $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('duplicate_template', 1, true);
$data[4] .= html_print_input_hidden('source_id', $template['id'], true); $data[4] .= html_print_input_hidden('source_id', $template['id'], true);
$data[4] .= html_print_input_image( $data[4] .= html_print_input_image(

View File

@ -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); $table_html = html_print_table($table, true);
echo $table_html; echo $table_html;

View File

@ -1147,9 +1147,10 @@ if ($step == 2) {
echo ui_get_using_system_timezone_warning(); 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 it's the last step it will redirect to template lists.
if ($step >= LAST_STEP) { 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 { } else {
echo '<form method="post">'; echo '<form method="post">';
} }

View File

@ -0,0 +1,71 @@
<?php
/**
* Audit log View.
*
* @category Audit log
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
global $config;
require_once $config['homedir'].'/include/class/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();
}

View File

@ -40,6 +40,7 @@ $custom_id = '';
$create_group = (bool) get_parameter('create_group'); $create_group = (bool) get_parameter('create_group');
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
$offset = (int) get_parameter('offset', 0);
if ($id_group) { if ($id_group) {
$group = db_get_row('tmodule_group', 'id_mg', $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>'; echo '</span>';
if (is_metaconsole()) { 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 { } 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); html_print_table($table);

View File

@ -262,18 +262,18 @@ if (empty($groups) === false) {
} }
$table->data = []; $table->data = [];
$offset_delete = ($offset >= $total_groups - 1) ? ($offset - $config['block_size']) : $offset;
foreach ($groups as $id_group) { foreach ($groups as $id_group) {
$data = []; $data = [];
$data[0] = $id_group['id_mg']; $data[0] = $id_group['id_mg'];
if ($is_management_allowed === true) { 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) { 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 { } else {
$table->cellclass[][2] = 'action_buttons'; $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 { } else {
$data[1] = '<strong>'; $data[1] = '<strong>';

View File

@ -2094,46 +2094,21 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
switch ($field) { switch ($field) {
case 'id_plugin': case 'id_plugin':
if ($value != 0) { if ($value != 0) {
$value_field_1 = get_parameter('_field1_', ''); for ($i = 0; $i <= 15; $i++) {
$value_field_1_desc = get_parameter('desc_field1_', ''); $value_field = get_parameter('_field'.$i.'_', '');
$value_field_desc = get_parameter('desc_field'.$i.'_', '');
$value_field_2 = get_parameter('_field2_', ''); if ($value_field_desc != '') {
$value_field_2_desc = get_parameter('desc_field2_', ''); $values['macros'][$i] = [
'macro' => '_field'.$i.'_',
$value_field_3 = get_parameter('_field3_', ''); 'desc' => io_safe_input($value_field_desc),
$value_field_3_desc = get_parameter('desc_field3_', ''); 'help' => io_safe_input($value_field_desc),
'value' => $value_field,
$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'] .= '}';
} }
} else {
$values['macros'] .= '}';
} }
$values['macros'] = json_encode($values['macros']);
$values[$field] = $value;
} }
break; break;
@ -2260,7 +2235,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
// Apply at All agents (within valid groups). // Apply at All agents (within valid groups).
$modules = db_get_all_rows_sql( $modules = db_get_all_rows_sql(
sprintf( 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 FROM tagente_modulo tam INNER JOIN tagente ta
ON ta.id_agente = tam.id_agente ON ta.id_agente = tam.id_agente
WHERE ta.id_grupo IN (%s) %s;', 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_agente_modulo',
'id_tipo_modulo', 'id_tipo_modulo',
'macros',
'id_plugin',
] ]
); );
} else { } else {
@ -2289,6 +2266,8 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
[ [
'id_agente_modulo', 'id_agente_modulo',
'id_tipo_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( $result = modules_update_agent_module(
$module['id_agente_modulo'], $module['id_agente_modulo'],
$values, $values,

View File

@ -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; $menu_godmode['gextensions']['sub'] = $sub;
} }

View File

@ -597,9 +597,10 @@ if ((bool) $id !== false || $new_component
$search_id_group = (int) get_parameter('search_id_group'); $search_id_group = (int) get_parameter('search_id_group');
$search_string = (string) get_parameter('search_string'); $search_string = (string) get_parameter('search_string');
$offset = (int) get_parameter('offset');
$url = ui_get_url_refresh( $url = ui_get_url_refresh(
[ [
'offset' => false, 'offset' => $offset,
'search_string' => $search_string, 'search_string' => $search_string,
'search_id_group' => $search_id_group, 'search_id_group' => $search_id_group,
'id' => $id, 'id' => $id,
@ -607,7 +608,7 @@ $url = ui_get_url_refresh(
true, true,
false false
); );
$name_url = 'index.php?sec=templates&sec2=godmode/modules/manage_network_components';
$table = new stdClass(); $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->class = 'databox filters'; $table->class = 'databox filters';
@ -712,8 +713,9 @@ $total_components = network_components_get_network_components(
'COUNT(*) AS total' 'COUNT(*) AS total'
); );
$total_components = $total_components[0]['total']; $total_components = $total_components[0]['total'];
ui_pagination($total_components, $url); $offset_delete = ($offset >= ($total_components - 1)) ? ($offset - $config['block_size']) : $offset;
$filter['offset'] = (int) get_parameter('offset'); ui_pagination($total_components, $name_url);
$filter['offset'] = $offset;
$filter['limit'] = (int) $config['block_size']; $filter['limit'] = (int) $config['block_size'];
$components = network_components_get_network_components( $components = network_components_get_network_components(
false, false,
@ -791,7 +793,7 @@ foreach ($components as $component) {
true 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] .= io_safe_output($component['name']);
$data[0] .= '</a>'; $data[0] .= '</a>';
} else { } else {
@ -855,7 +857,7 @@ foreach ($components as $component) {
if ($is_management_allowed === true) { if ($is_management_allowed === true) {
$table->cellclass[][6] = 'action_buttons'; $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', 'images/copy.png',
true, true,
[ [
@ -864,7 +866,7 @@ foreach ($components as $component) {
'class' => 'invert_filter', 'class' => 'invert_filter',
] ]
).'</a>'; ).'</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', 'images/cross.png',
true, true,
[ [
@ -887,7 +889,7 @@ if (isset($data) === true) {
html_print_table($table); html_print_table($table);
ui_pagination( ui_pagination(
$total_components, $total_components,
$url, $name_url,
0, 0,
0, 0,
false, false,

View File

@ -281,7 +281,7 @@ switch ($action) {
$server_name = $item['server_name']; $server_name = $item['server_name'];
// Metaconsole db connection. // Metaconsole db connection.
if ($meta && empty($server_name) === false) { if ($meta && empty($server_name) === false && $server_name !== 'all') {
$connection = metaconsole_get_connection($server_name); $connection = metaconsole_get_connection($server_name);
$server_id = $connection['id']; $server_id = $connection['id'];
if (metaconsole_load_external_db($connection) != NOERR) { 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 <?php
if ($meta) { if ($meta) {
?> ?>
@ -6334,6 +6357,7 @@ function chooseType() {
$("#row_alert_templates").hide(); $("#row_alert_templates").hide();
$("#row_alert_actions").hide(); $("#row_alert_actions").hide();
$("#row_servers").hide(); $("#row_servers").hide();
$("#row_servers_all_opt").hide();
$("#row_multiple_servers").hide(); $("#row_multiple_servers").hide();
$("#row_sort").hide(); $("#row_sort").hide();
$("#row_date").hide(); $("#row_date").hide();
@ -6648,7 +6672,7 @@ function chooseType() {
$("#row_header").show(); $("#row_header").show();
$("#row_custom").show(); $("#row_custom").show();
$("#row_custom_example").show(); $("#row_custom_example").show();
$("#row_servers").show(); $("#row_servers_all_opt").show();
$("#row_historical_db_check").show(); $("#row_historical_db_check").show();
break; break;

View File

@ -141,11 +141,13 @@ if (isset($_GET['server'])) {
]; ];
$buttons['collections'] = [ if ((int) $config['license_nms'] !== 1) {
'active' => false, $buttons['collections'] = [
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=collections&pure='.$pure.'">'.html_print_image('images/collection.png', true, ['title' => __('Collections')]).'</a>', 'active' => false,
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=collections&pure='.$pure.'">'.html_print_image('images/collection.png', true, ['title' => __('Collections')]).'</a>',
]; ];
}
} }
$buttons[$tab]['active'] = true; $buttons[$tab]['active'] = true;

View File

@ -230,9 +230,64 @@ if ($filemanager) {
$directory = filemanager_safe_directory($directory, $fallback_directory); $directory = filemanager_safe_directory($directory, $fallback_directory);
} }
$base_url = 'index.php?sec=gservers&sec2=godmode/servers/plugin';
$setup_url = $base_url.'&filemanager=1&tab=Attachments';
$tab = get_parameter('tab', null);
$tabs = [
'list' => [
'text' => '<a href="'.$base_url.'">'.html_print_image(
'images/eye_show.png',
true,
[
'title' => __('Plugins'),
'class' => 'invert_filter',
]
).'</a>',
'active' => (bool) ($tab != 'Attachments'),
],
'options' => [
'text' => '<a href="'.$setup_url.'">'.html_print_image(
'images/collection.png',
true,
[
'title' => __('Attachments'),
'class' => 'invert_filter',
]
).'</a>',
'active' => (bool) ($tab == 'Attachments'),
],
];
if ($tab === 'Attachments') {
$helpHeader = '';
$titleHeader = __('Index of attachment/plugin');
} else {
$helpHeader = 'servers_ha_clusters_tab';
$titleHeader = __('Plug-ins registered on %s', get_product_name());
}
// Header.
ui_print_standard_header(
$titleHeader,
'images/gm_servers.png',
false,
$helpHeader,
false,
$tabs,
[
[
'link' => '',
'label' => __('Servers'),
],
[
'link' => '',
'label' => __('Plugins'),
],
]
);
$real_directory = realpath($config['homedir'].'/'.$directory); $real_directory = realpath($config['homedir'].'/'.$directory);
echo '<h4>'.__('Index of %s', $directory).'</h4>';
$chunck_url = '&view='.$id_plugin; $chunck_url = '&view='.$id_plugin;
if ($id_plugin == 0) { if ($id_plugin == 0) {
@ -255,7 +310,7 @@ if ($filemanager) {
filemanager_file_explorer( filemanager_file_explorer(
$real_directory, $real_directory,
$directory, $directory,
'index.php?sec=gservers&sec2=godmode/servers/plugin&filemanager=1&id_plugin='.$id_plugin, 'index.php?sec=gservers&sec2=godmode/servers/plugin&filemanager=1&id_plugin='.$id_plugin.'&tab=Attachments',
$fallback_directory, $fallback_directory,
true, true,
false, false,
@ -401,7 +456,7 @@ if (($create != '') || ($view != '')) {
$data[0] = __('Plugin command').ui_print_help_tip(__('Specify interpreter and plugin path. The server needs permissions to run it.'), true); $data[0] = __('Plugin command').ui_print_help_tip(__('Specify interpreter and plugin path. The server needs permissions to run it.'), true);
$data[1] = '<input type="text" name="form_execute" id="form_execute" class="command_component command_advanced_conf text_input" size=100 value="'.$form_execute.'" >'; $data[1] = '<input type="text" name="form_execute" id="form_execute" class="command_component command_advanced_conf text_input" size=100 value="'.$form_execute.'" >';
$data[1] .= ' <a href="index.php?sec=gservers&sec2=godmode/servers/plugin&filemanager=1&id_plugin='.$form_id.'" class="bot">'; $data[1] .= ' <a href="index.php?sec=gservers&sec2=godmode/servers/plugin&filemanager=1&tab=Attachments&id_plugin='.$form_id.'" class="bot">';
$data[1] .= html_print_image('images/file.png', true, ['class' => 'invert_filter'], false, true); $data[1] .= html_print_image('images/file.png', true, ['class' => 'invert_filter'], false, true);
$data[1] .= '</a>'; $data[1] .= '</a>';
$table->data['plugin_command'] = $data; $table->data['plugin_command'] = $data;
@ -597,15 +652,60 @@ if (($create != '') || ($view != '')) {
); );
} }
} else { } else {
ui_print_page_header( $base_url = 'index.php?sec=gservers&sec2=godmode/servers/plugin';
__( $setup_url = $base_url.'&filemanager=1&tab=Attachments';
'Plug-ins registered on %s', $tab = get_parameter('tab', null);
get_product_name() $tabs = [
), 'list' => [
'text' => '<a href="'.$base_url.'">'.html_print_image(
'images/eye_show.png',
true,
[
'title' => __('Plugins'),
'class' => 'invert_filter',
]
).'</a>',
'active' => (bool) ($tab != 'Attachments'),
],
'options' => [
'text' => '<a href="'.$setup_url.'">'.html_print_image(
'images/collection.png',
true,
[
'title' => __('Attachments'),
'class' => 'invert_filter',
]
).'</a>',
'active' => (bool) ($tab == 'Attachments'),
],
];
if ($tab === 'Attachments') {
$helpHeader = '';
$titleHeader = __('Index of attachment/plugin');
} else {
$helpHeader = 'servers_ha_clusters_tab';
$titleHeader = __('Plug-ins registered on %s', get_product_name());
}
// Header.
ui_print_standard_header(
$titleHeader,
'images/gm_servers.png', 'images/gm_servers.png',
false, false,
'', $helpHeader,
true false,
$tabs,
[
[
'link' => '',
'label' => __('Servers'),
],
[
'link' => '',
'label' => __('Plugins'),
],
]
); );
$management_allowed = is_management_allowed(); $management_allowed = is_management_allowed();
@ -892,7 +992,7 @@ if (($create != '') || ($view != '')) {
echo '<div id="deploy_messages" class="invisible">'; 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 id='dialog_locked' title='".__('List of modules and components created by "%s" ')."' class='invisible left'>";
echo '</div>'; echo '</div>';
@ -903,50 +1003,49 @@ ui_require_javascript_file('pandora_modules');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
var locked = <?php echo (int) json_encode((int) $locked); ?>; var locked = <?php echo (int) json_encode((int) $locked); ?>;
function update_preview() { function update_preview() {
var command = $('#form_execute').val(); var command = $('#form_execute').val();
var parameters = $('#form_parameters').val(); var parameters = $('#form_parameters').val();
var i = 1; var i = 1;
while (1) { while (1) {
if ($('#text-field' + i + '_value').val() == undefined) { if ($('#text-field' + i + '_value').val() == undefined) {
break; break;
} }
if ($('#text-field'+i+'_value').val() != '') { if ($('#text-field'+i+'_value').val() != '') {
parameters = parameters parameters = parameters
.replace('_field' + i + '_', .replace('_field' + i + '_',
$('#text-field' + i + '_value').val()); $('#text-field' + i + '_value').val());
} }
i++; i++;
} }
$('#command_preview').html(_.escape(command) + ' ' + _.escape(parameters)); $('#command_preview').html(_.escape(command) + ' ' + _.escape(parameters));
} }
function show_locked_dialog(id_plugin, plugin_name) { function show_locked_dialog(id_plugin, plugin_name) {
var parameters = {}; var parameters = {};
parameters['page'] = "godmode/servers/plugin"; parameters['page'] = "godmode/servers/plugin";
parameters["get_list_modules_and_component_locked_plugin"] = 1; parameters["get_list_modules_and_component_locked_plugin"] = 1;
parameters["id_plugin"] = id_plugin; parameters["id_plugin"] = id_plugin;
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>", url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
data: parameters, data: parameters,
dataType: "html", dataType: "html",
success: function(data) { 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") $("#dialog_locked")
.prop('title', title)
.html(data) .html(data)
.dialog ({ .dialog ({
title: title,
resizable: true, resizable: true,
draggable: true, draggable: true,
modal: true, modal: true,
@ -961,8 +1060,7 @@ ui_require_javascript_file('pandora_modules');
} }
}); });
} }
$(document).ready(function() { $(document).ready(function() {
// Add macro // Add macro
var add_macro_click_event = function (event) { var add_macro_click_event = function (event) {
@ -992,34 +1090,34 @@ ui_require_javascript_file('pandora_modules');
update_preview(); update_preview();
} }
$('div#delete_macro_button>a').click(delete_macro_click_event); $('div#delete_macro_button>a').click(delete_macro_click_event);
update_preview(); update_preview();
$('.command_component').keyup(function() { $('.command_component').keyup(function() {
update_preview(); update_preview();
}); });
}); });
var add_macro_click_locked_event = function (event) { var add_macro_click_locked_event = function (event) {
var message = '<?php echo __('Some modules or components are using the plugin'); ?>.' 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' + '<?php echo __('The modules or components should be updated manually or using the bulk operations for plugins after this change'); ?>.'
+ '\n' + '\n'
+ '\n' + '<?php echo __('Are you sure you want to perform this action?'); ?>'; + '\n' + '<?php echo __('Are you sure you want to perform this action?'); ?>';
if (!confirm(message)) { if (!confirm(message)) {
event.stopImmediatePropagation(); event.stopImmediatePropagation();
event.preventDefault(); event.preventDefault();
} }
} }
var macros_click_locked_event = function (event) { 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'); ?>"); alert("<?php echo __('The plugin macros cannot be updated because some modules or components are using the plugin'); ?>");
} }
if (locked) { if (locked) {
$('a#add_macro_btn').click(add_macro_click_locked_event); $('a#add_macro_btn').click(add_macro_click_locked_event);
} }
</script> </script>

View File

@ -110,6 +110,12 @@ foreach ($servers as $server) {
]; ];
$data[0] = '<span title="'.$server['version'].'">'.strip_tags($server['name']).'</span>'; $data[0] = '<span title="'.$server['version'].'">'.strip_tags($server['name']).'</span>';
$server_keepalive = time_w_fixed_tz($server['keepalive']);
if ($server['server_keepalive_utimestamp'] > 0) {
$server_keepalive = $server['server_keepalive_utimestamp'];
}
// Status. // Status.
$data[1] = ui_print_status_image(STATUS_SERVER_OK, '', true); $data[1] = ui_print_status_image(STATUS_SERVER_OK, '', true);
if ($server['status'] == -1) { if ($server['status'] == -1) {
@ -119,7 +125,7 @@ foreach ($servers as $server) {
true true
); );
} else if ((int) ($server['status'] === 0) } else if ((int) ($server['status'] === 0)
|| (($date - time_w_fixed_tz($server['keepalive'])) > ($server['server_keepalive']) * 2) || (($date - $server_keepalive) > ($server['server_keepalive']) * 2)
) { ) {
$data[1] = ui_print_status_image( $data[1] = ui_print_status_image(
STATUS_SERVER_DOWN, STATUS_SERVER_DOWN,

View File

@ -87,6 +87,20 @@ $create_text_file = (bool) get_parameter('create_text_file');
$default_real_directory = realpath($config['homedir'].'/'); $default_real_directory = realpath($config['homedir'].'/');
// Remove double dot in filename path.
$file_name = $_FILES['file']['name'];
$path_parts = explode('/', $file_name);
$stripped_parts = array_filter(
$path_parts,
function ($value) {
return $value !== '..';
}
);
$stripped_path = implode('/', $stripped_parts);
$_FILES['file']['name'] = $stripped_path;
if ($upload_file === true) { if ($upload_file === true) {
upload_file( upload_file(
$upload_file, $upload_file,

View File

@ -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 = new StdClass();
$table_status->width = '100%'; $table_status->width = '100%';
$table_status->class = 'databox filters'; $table_status->class = 'databox filters';
@ -261,104 +266,140 @@ $table->data[1][1] = html_print_input(
[ [
'type' => 'number', 'type' => 'number',
'size' => 5, 'size' => 5,
'max' => 99999, 'max' => $performance_variables_control['event_purge']->max,
'name' => 'event_purge', 'name' => 'event_purge',
'value' => $config['event_purge'], 'value' => $config['event_purge'],
'return' => true, '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', 'style' => 'width:43px',
] ]
); );
$table->data[2][0] = __('Max. days before delete traps'); $table->data[2][0] = __('Max. days before delete traps');
$table->data[2][1] = html_print_input_text( $table->data[2][1] = html_print_input(
'trap_purge', [
$config['trap_purge'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['trap_purge']->max,
5, 'name' => 'trap_purge',
true '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][0] = __('Max. days before delete audit events');
$table->data[3][1] = html_print_input_text( $table->data[3][1] = html_print_input(
'audit_purge', [
$config['audit_purge'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['audit_purge']->max,
5, 'name' => 'audit_purge',
true '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][0] = __('Max. days before delete string data');
$table->data[4][1] = html_print_input_text( $table->data[4][1] = html_print_input(
'string_purge', [
$config['string_purge'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['string_purge']->max,
5, 'name' => 'string_purge',
true '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][0] = __('Max. days before delete GIS data');
$table->data[5][1] = html_print_input_text( $table->data[5][1] = html_print_input(
'gis_purge', [
$config['gis_purge'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['gis_purge']->max,
5, 'name' => 'gis_purge',
true '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][0] = __('Max. days before purge');
$table->data[6][1] = html_print_input_text( $table->data[6][1] = html_print_input(
'days_purge', [
$config['days_purge'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['days_purge']->max,
5, 'name' => 'days_purge',
true '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][0] = __('Max. days before compact data');
$table->data[7][1] = html_print_input_text( $table->data[7][1] = html_print_input(
'days_compact', [
$config['days_compact'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['days_compact']->max,
5, 'name' => 'days_compact',
true '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][0] = __('Max. days before delete unknown modules');
$table->data[8][1] = html_print_input_text( $table->data[8][1] = html_print_input(
'days_delete_unknown', [
$config['days_delete_unknown'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['days_delete_unknown']->max,
5, 'name' => 'days_delete_unknown',
true '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][0] = __('Max. days before delete not initialized modules');
$table->data[9][1] = html_print_input_text( $table->data[9][1] = html_print_input(
'days_delete_not_initialized', [
$config['days_delete_not_initialized'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['days_delete_not_initialized']->max,
5, 'name' => 'days_delete_not_initialized',
true '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][0] = __('Max. days before delete autodisabled agents');
$table->data[10][1] = html_print_input_text( $table->data[10][1] = html_print_input(
'days_autodisable_deletion', [
$config['days_autodisable_deletion'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['days_autodisable_deletion']->max,
5, 'name' => 'days_autodisable_deletion',
true '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'); $table->data[11][0] = __('Retention period of past special days');
@ -499,13 +540,17 @@ $table->data[] = [
$table->data[] = [ $table->data[] = [
__('Max. days before delete old network matrix data'), __('Max. days before delete old network matrix data'),
html_print_input_text( html_print_input(
'delete_old_network_matrix', [
$config['delete_old_network_matrix'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['delete_old_network_matrix']->max,
5, 'name' => 'delete_old_network_matrix',
true '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%'; $table_other->size[1] = '30%';
$i = 0; $i = 0;
$table_other->data[$i][0] = __('Item limit for realtime reports'); $table_other->data[$i][0] = __('Item limit for realtime reports');
$table_other->data[$i++][1] = html_print_input_text( $table_other->data[$i++][1] = html_print_input(
'report_limit', [
$config['report_limit'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['report_limit']->max,
5, 'name' => 'report_limit',
true '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)'); $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'); $intervals[SECONDS_1MONTH] = __('Last month');
$table_other->data[$i][0] = __('Default hours for event view'); $table_other->data[$i][0] = __('Default hours for event view');
$table_other->data[$i++][1] = html_print_input_text( $table_other->data[$i++][1] = html_print_input(
'event_view_hr', [
$config['event_view_hr'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['event_view_hr']->max,
5, 'name' => 'event_view_hr',
true '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'); $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][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][0] = __('Max. recommended number of files in attachment directory');
$table_other->data[$i++][1] = html_print_input_text( $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++][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][0] = __('Big Operation Step to purge old data');
$table_other->data[$i++][1] = html_print_input_text( $table_other->data[$i++][1] = html_print_input(
'big_operation_step_datos_purge', [
$config['big_operation_step_datos_purge'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['big_operation_step_datos_purge']->max,
5, 'name' => 'big_operation_step_datos_purge',
true '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][0] = __('Small Operation Step to purge old data');
$table_other->data[$i++][1] = html_print_input_text( $table_other->data[$i++][1] = html_print_input(
'small_operation_step_datos_purge', [
$config['small_operation_step_datos_purge'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['small_operation_step_datos_purge']->max,
5, 'name' => 'small_operation_step_datos_purge',
true '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'); $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][0] = __('Row limit in csv log');
$table_other->data[$i++][1] = html_print_input_text( $table_other->data[$i++][1] = html_print_input(
'row_limit_csv', [
$config['row_limit_csv'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['row_limit_csv']->max,
10, 'name' => 'row_limit_csv',
true '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'); $table_other->data[$i][0] = __('SNMP walk binary');

View File

@ -47,6 +47,8 @@ if (is_ajax()) {
exit(); exit();
} }
$performance_variables_control = (array) json_decode(io_safe_output($config['performance_variables_control']));
$table = new StdClass(); $table = new StdClass();
$table->class = 'databox filters'; $table->class = 'databox filters';
$table->id = 'setup_general'; $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][0] = __('Limit for bulk operations');
$table->data[$i++][1] = html_print_input_text( $table->data[$i++][1] = html_print_input(
'limit_parameters_massive', [
$config['limit_parameters_massive'], 'type' => 'number',
'', 'size' => 5,
10, 'max' => $performance_variables_control['limit_parameters_massive']->max,
10, 'name' => 'limit_parameters_massive',
true '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'); $table->data[$i][0] = __('Include agents manually disabled');

View File

@ -53,6 +53,8 @@ $row = 0;
echo '<form id="form_setup" method="post">'; echo '<form id="form_setup" method="post">';
html_print_input_hidden('update_config', 1); html_print_input_hidden('update_config', 1);
$performance_variables_control = (array) json_decode(io_safe_output($config['performance_variables_control']));
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// BEHAVIOUR CONFIGURATION // BEHAVIOUR CONFIGURATION
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -64,7 +66,18 @@ $table_behaviour->size[0] = '50%';
$table_behaviour->data = []; $table_behaviour->data = [];
$table_behaviour->data[$row][0] = __('Block size for pagination'); $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++; $row++;
$values = []; $values = [];
@ -823,16 +836,19 @@ if (enterprise_installed() === false) {
} }
$table_chars->data[$row][0] = __('Data precision'); $table_chars->data[$row][0] = __('Data precision');
$table_chars->data[$row][1] = html_print_input_text( $table_chars->data[$row][1] = html_print_input(
'graph_precision', [
$config['graph_precision'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['graph_precision']->max,
5, 'name' => 'graph_precision',
true, 'value' => $config['graph_precision'],
$disabled_graph_precision, 'return' => true,
false, 'min' => $performance_variables_control['graph_precision']->min,
'onChange="change_precision()"' 'style' => 'width:50px',
($disabled_graph_precision) ? 'readonly' : '' => 'readonly',
'onchange' => 'change_precision()',
]
); );
$row++; $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][0] = __('Data precision in graphs');
$table_chars->data[$row][1] = html_print_input_text( $table_chars->data[$row][1] = html_print_input(
'short_module_graph_data', [
$config['short_module_graph_data'], 'type' => 'number',
'', 'size' => 5,
5, 'max' => $performance_variables_control['short_module_graph_data']->max,
5, 'name' => 'short_module_graph_data',
true, 'value' => $config['short_module_graph_data'],
$disabled_graph_precision, 'return' => true,
false, 'min' => $performance_variables_control['short_module_graph_data']->min,
'onChange="change_precision()"' 'style' => 'width:50px',
($disabled_graph_precision) ? 'readonly' : '' => 'readonly',
'onchange' => 'change_precision()',
]
); );
$row++; $row++;
$table_chars->data[$row][0] = __( $table_chars->data[$row][0] = __(

View File

@ -207,14 +207,14 @@ if (empty($tag_name) === false) {
// If the user has filtered the view. // If the user has filtered the view.
$filter_performed = !empty($filter); $filter_performed = !empty($filter);
$offset = (int) get_parameter('offset');
$filter['offset'] = (int) get_parameter('offset'); $filter['offset'] = $offset;
$filter['limit'] = (int) $config['block_size']; $filter['limit'] = (int) $config['block_size'];
// Statements for pagination. // Statements for pagination.
$url = ui_get_url_refresh(); $url = 'index.php?sec=gusuarios&sec2=godmode/tag/tag';
$total_tags = tags_get_tag_count($filter); $total_tags = tags_get_tag_count($filter);
$offset_delete = ($offset >= ($total_tags - 1)) ? ($offset - $config['block_size']) : $offset;
$result = tags_search_tag(false, $filter); $result = tags_search_tag(false, $filter);
// Filter form. // Filter form.
@ -392,7 +392,7 @@ if (empty($result) === false) {
] ]
); );
$data[6] .= '</a>'; $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', 'images/cross.png',
true, true,
[ [

View File

@ -402,6 +402,11 @@ if ($delete_user === true) {
__('There was a problem deleting the profile') __('There was a problem deleting the profile')
); );
} else if ($disable_user !== false) { } else if ($disable_user !== false) {
// CSRF Validator.
if (html_print_csrf_error()) {
return;
}
// Disable_user. // Disable_user.
$id_user = get_parameter('id', 0); $id_user = get_parameter('id', 0);
@ -646,6 +651,8 @@ $limit = (int) $config['block_size'];
$rowPair = true; $rowPair = true;
$iterator = 0; $iterator = 0;
$cont = 0; $cont = 0;
// Creates csrf.
$csrf = html_print_csrf_hidden(true);
foreach ($info as $user_id => $user_info) { foreach ($info as $user_id => $user_info) {
if (empty($user_id) === true) { if (empty($user_id) === true) {
continue; continue;
@ -809,12 +816,14 @@ foreach ($info as $user_id => $user_info) {
$toDoClass = 'filter_none'; $toDoClass = 'filter_none';
} }
$data[6] = '<form method="POST" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;pure='.$pure.'" class="inline">'; $data[6] = '<form method="POST" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;pure='.$pure.'&offset='.$offset.'" class="inline">';
$data[6] .= html_print_input_hidden( $data[6] .= html_print_input_hidden(
'id', 'id',
$user_info['id_user'], $user_info['id_user'],
true true
); );
// Same csrf for every disable button for submit.
$data[6] .= $csrf;
$data[6] .= html_print_input_hidden( $data[6] .= html_print_input_hidden(
'disable_user', 'disable_user',
$toDoAction, $toDoAction,
@ -865,7 +874,8 @@ foreach ($info as $user_id => $user_info) {
&& $user_info['id_user'] != $config['id_user'] && $user_info['id_user'] != $config['id_user']
&& isset($user_info['not_delete']) === false && isset($user_info['not_delete']) === false
) { ) {
$data[6] .= '<form method="POST" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;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.'&amp;sec2=godmode/users/user_list&amp;pure='.$pure.'&offset='.$offset_delete.'" class="inline">';
$data[6] .= html_print_input_hidden( $data[6] .= html_print_input_hidden(
'delete_user', 'delete_user',
$user_info['id_user'], $user_info['id_user'],

View File

@ -955,29 +955,42 @@ class DiscoveryTaskList extends HTML
) )
) { ) {
if ($ipam === true) { if ($ipam === true) {
$data[9] .= '<a href="'.ui_get_full_url( if (empty($tipam_task_id) === false) {
sprintf( $data[9] .= '<a href="'.ui_get_full_url(
'index.php?sec=gextensions&sec2=enterprise/tools/ipam/ipam&action=edit&id=%d', sprintf(
$tipam_task_id 'index.php?sec=gextensions&sec2=enterprise/tools/ipam/ipam&action=edit&id=%d',
) $tipam_task_id
).'">'.html_print_image( )
'images/config.png', ).'">'.html_print_image(
true, 'images/config.png',
[ true,
'title' => __('Edit task'), [
'class' => 'invert_filter', 'title' => __('Edit task'),
] 'class' => 'invert_filter',
).'</a>'; ]
$data[9] .= '<a href="'.ui_get_full_url( ).'</a>';
'index.php?sec=gextensions&sec2=enterprise/tools/ipam/ipam&action=delete&id='.$tipam_task_id $data[9] .= '<a href="'.ui_get_full_url(
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image( 'index.php?sec=gextensions&sec2=enterprise/tools/ipam/ipam&action=delete&id='.$tipam_task_id
'images/cross.png', ).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
true, 'images/cross.png',
[ true,
'title' => __('Delete task'), [
'class' => 'invert_filter', 'title' => __('Delete task'),
] 'class' => 'invert_filter',
).'</a>'; ]
).'</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 { } else {
// Check if is a H&D, Cloud or Application or IPAM. // Check if is a H&D, Cloud or Application or IPAM.
$data[9] .= '<a href="'.ui_get_full_url( $data[9] .= '<a href="'.ui_get_full_url(

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -31,6 +31,15 @@ $get_agents_interfaces = (bool) get_parameter('get_agents_interfaces');
$id_agents = get_parameter('id_agents', []); $id_agents = get_parameter('id_agents', []);
$get_agents_group = (bool) get_parameter('get_agents_group', false); $get_agents_group = (bool) get_parameter('get_agents_group', false);
$force_local = (bool) get_parameter('force_local', 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()) { if (https_is_running()) {
header('Content-type: application/json'); header('Content-type: application/json');
} }
@ -345,4 +354,656 @@ if ($search_agents && (!is_metaconsole() || $force_local)) {
return; 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; return;

View File

@ -92,6 +92,9 @@ $node_id = (int) get_parameter('node_id', 0);
if ($get_comments === true) { if ($get_comments === true) {
$event = get_parameter('event', false); $event = get_parameter('event', false);
$event_rep = (int) get_parameter('event_rep', 0); $event_rep = (int) get_parameter('event_rep', 0);
$event_rep = get_parameter_post('event')['event_rep'];
$group_rep = get_parameter_post('event')['group_rep'];
if ($event === false) { if ($event === false) {
return __('Failed to retrieve comments'); return __('Failed to retrieve comments');
} }
@ -99,7 +102,7 @@ if ($get_comments === true) {
$eventsGrouped = []; $eventsGrouped = [];
// Consider if the event is grouped. // Consider if the event is grouped.
$whereGrouped = '1=1'; $whereGrouped = '1=1';
if ($event_rep === EVENT_GROUP_REP_EVENTS) { if ($group_rep === EVENT_GROUP_REP_EVENTS && $event_rep > 1) {
// Default grouped message filtering (evento and estado). // Default grouped message filtering (evento and estado).
$whereGrouped = sprintf( $whereGrouped = sprintf(
'`evento` = "%s"', '`evento` = "%s"',
@ -120,7 +123,7 @@ if ($get_comments === true) {
(int) $event['id_agentmodule'] (int) $event['id_agentmodule']
); );
} }
} else if ($event_rep === EVENT_GROUP_REP_EXTRAIDS) { } else if ($group_rep === EVENT_GROUP_REP_EXTRAIDS) {
$whereGrouped = sprintf( $whereGrouped = sprintf(
'`id_extra` = "%s"', '`id_extra` = "%s"',
$event['id_extra'] $event['id_extra']
@ -1639,6 +1642,7 @@ if ($get_extended_event) {
$comments = $event['comments']; $comments = $event['comments'];
$event['similar_ids'] = $similar_ids; $event['similar_ids'] = $similar_ids;
$event['group_rep'] = $group_rep;
if (isset($comments) === false) { if (isset($comments) === false) {
$comments = $event['user_comment']; $comments = $event['user_comment'];
@ -2348,6 +2352,11 @@ if ($drawConsoleSound === true) {
'Star_Trek_emergency_simulation.wav' => 'StarTrek emergency simulation', '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[] = [ $inputs[] = [
'class' => 'test-sounds', 'class' => 'test-sounds',
'direct' => 1, 'direct' => 1,
@ -2407,6 +2416,18 @@ if ($drawConsoleSound === true) {
$output .= '</span>'; $output .= '</span>';
$output .= '</div>'; $output .= '</div>';
$output .= '<div class="elements-discovered-alerts"><ul></ul></div>'; $output .= '<div class="elements-discovered-alerts"><ul></ul></div>';
$output .= html_print_input_hidden(
'ajax_file_sound_console',
ui_get_full_url('ajax.php', false, false, false),
true
);
$output .= html_print_input_hidden(
'meta',
is_metaconsole(),
true
);
$output .= '<div id="sound_event_details_window"></div>';
$output .= '<div id="sound_event_response_window"></div>';
$output .= '</div>'; $output .= '</div>';
$output .= '</div>'; $output .= '</div>';
@ -2493,6 +2514,37 @@ if ($get_events_fired) {
$filter = events_get_event_filter($filter_id); $filter = events_get_event_filter($filter_id);
} }
if (is_metaconsole() === true) {
$servers = metaconsole_get_servers();
if (is_array($servers) === true) {
$servers = array_reduce(
$servers,
function ($carry, $item) {
$carry[$item['id']] = $item['server_name'];
return $carry;
}
);
} else {
$servers = [];
}
if ($filter['server_id'] === '') {
$filter['server_id'] = array_keys($servers);
} else {
if (is_array($filter['server_id']) === false) {
if (is_numeric($filter['server_id']) === true) {
if ($filter['server_id'] !== 0) {
$filter['server_id'] = [$filter['server_id']];
} else {
$filter['server_id'] = array_keys($servers);
}
} else {
$filter['server_id'] = explode(',', $filter['server_id']);
}
}
}
}
// Set time. // Set time.
$filter['event_view_hr'] = 0; $filter['event_view_hr'] = 0;
@ -2511,29 +2563,32 @@ if ($get_events_fired) {
$return = []; $return = [];
if (empty($data) === false) { if (empty($data) === false) {
foreach ($data as $event) { foreach ($data as $event) {
$return[] = [ $return[] = array_merge(
'fired' => $event['id_evento'], $event,
'message' => ui_print_string_substr( [
strip_tags(io_safe_output($event['evento'])), 'fired' => $event['id_evento'],
75, 'message' => ui_print_string_substr(
true, strip_tags(io_safe_output($event['evento'])),
'9' 75,
), true,
'priority' => ui_print_event_priority($event['criticity'], true, true), '9'
'type' => events_print_type_img( ),
$event['event_type'], 'priority' => ui_print_event_priority($event['criticity'], true, true),
true 'type' => events_print_type_img(
), $event['event_type'],
'timestamp' => ui_print_timestamp( true
$event['timestamp'], ),
true, 'timestamp' => ui_print_timestamp(
['style' => 'font-size: 9pt; letter-spacing: 0.3pt;'] $event['timestamp'],
), true,
]; ['style' => 'font-size: 9pt; letter-spacing: 0.3pt;']
),
]
);
} }
} }
echo io_json_mb_encode($return); echo io_safe_output(io_json_mb_encode($return));
return; return;
} }

View File

@ -68,6 +68,13 @@ if (check_login()) {
0 0
); );
$load_filter_modal = get_parameter('load_filter_modal', 0);
$save_filter_modal = get_parameter('save_filter_modal', 0);
$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) { if ($get_agent_modules_json_by_name === true) {
$agent_name = get_parameter('agent_name'); $agent_name = get_parameter('agent_name');
@ -1661,6 +1668,632 @@ if (check_login()) {
} }
echo json_encode($children_selected); echo json_encode($children_selected);
return;
}
// Saves an event filter.
if ($save_monitor_filter) {
$values = [];
$values['id_name'] = get_parameter('id_name');
$values['id_group_filter'] = get_parameter('id_group_filter');
$values['ag_group'] = get_parameter('ag_group');
$values['modulegroup'] = get_parameter('modulegroup');
$values['recursion'] = get_parameter('recursion');
$values['status'] = get_parameter('status');
$values['ag_modulename'] = get_parameter('ag_modulename');
$values['ag_freestring'] = get_parameter('ag_freestring');
$values['tag_filter'] = json_encode(get_parameter('tag_filter'));
$values['moduletype'] = get_parameter('moduletype');
$values['module_option'] = get_parameter('module_option');
$values['min_hours_status'] = get_parameter('min_hours_status');
$values['datatype'] = get_parameter('datatype');
$values['not_condition'] = get_parameter('not_condition');
$values['ag_custom_fields'] = get_parameter('ag_custom_fields');
$exists = (bool) db_get_value_filter(
'id_filter',
'tmonitor_filter',
$values
);
if ($exists === true) {
echo 'duplicate';
} else {
$result = db_process_sql_insert('tmonitor_filter', $values);
if ($result === false) {
echo 'error';
} else {
echo $result;
}
}
}
if ($update_monitor_filter) {
$values = [];
$id = get_parameter('id');
$values['ag_group'] = get_parameter('ag_group');
$values['modulegroup'] = get_parameter('modulegroup');
$values['recursion'] = get_parameter('recursion');
$values['status'] = get_parameter('status');
$values['ag_modulename'] = get_parameter('ag_modulename');
$values['ag_freestring'] = get_parameter('ag_freestring');
$values['tag_filter'] = json_encode(get_parameter('tag_filter'));
$values['moduletype'] = get_parameter('moduletype');
$values['module_option'] = get_parameter('module_option');
$values['min_hours_status'] = get_parameter('min_hours_status');
$values['datatype'] = get_parameter('datatype');
$values['not_condition'] = get_parameter('not_condition');
$values['ag_custom_fields'] = get_parameter('ag_custom_fields');
$result = db_process_sql_update(
'tmonitor_filter',
$values,
['id_filter' => $id]
);
if ($result === false) {
echo 'error';
} else {
echo 'ok';
}
}
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';
$monitor_filters = db_get_all_rows_sql($sql);
$result = [];
if ($monitor_filters !== false) {
foreach ($monitor_filters as $monitor_filter) {
$result[$monitor_filter['id_filter']] = $monitor_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 tmonitor_filter
WHERE id_group_filter IN ('.implode(',', array_keys($user_groups)).')';
$event_filters = db_get_all_rows_sql($sql);
$filters = [];
foreach ($event_filters as $event_filter) {
$filters[$event_filter['id_filter']] = $event_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/status_monitor&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()) {
$table->class = 'databox filters';
$table->cellspacing = 0;
$table->cellpadding = 0;
}
$table->styleTable = 'font-weight: bold; text-align:left;';
if (!is_metaconsole()) {
$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()) {
$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] = __('Overwrite filter').$jump;
$sql = 'SELECT id_filter, id_name FROM tmonitor_filter';
$monitor_filters = db_get_all_rows_sql($sql);
$_filters_update = [];
if ($monitor_filters !== false) {
foreach ($monitor_filters as $monitor_filter) {
$_filters_update[$monitor_filter['id_filter']] = $monitor_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/module",
"save_monitor_filter" : 1,
"id_name": $("#text-id_name").val(),
"id_group_filter": $("#id_group_filter_dialog").val(),
"ag_group" : $("#ag_group").val(),
"modulegroup" : $("#modulegroup").val(),
"recursion" : $("#checkbox-recursion").is(':checked'),
"status" : $("#status").val(),
"severity" : $("#severity").val(),
"ag_modulename" : $("#text-ag_modulename").val(),
"ag_freestring" : $("#text-ag_freestring").val(),
"tag_filter" : $("#tag_filter").val(),
"moduletype" : $("#moduletype").val(),
"module_option" : $('#module_option').val(),
"min_hours_status" : $('#text-min_hours_status').val(),
"datatype" : $("#datatype").val(),
"not_condition" : $("#not_condition_switch").is(':checked'),
"ag_custom_fields": JSON.stringify(ag_custom_fields),
},
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();
}
// 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/module",
"update_monitor_filter" : 1,
"id" : $("#overwrite_filter").val(),
"ag_group" : $("#ag_group").val(),
"modulegroup" : $("#modulegroup").val(),
"recursion" : $("#checkbox-recursion").is(':checked'),
"status" : $("#status").val(),
"severity" : $("#severity").val(),
"ag_modulename" : $("#text-ag_modulename").val(),
"ag_freestring" : $("#text-ag_freestring").val(),
"tag_filter" : $("#tag_filter").val(),
"moduletype" : $("#moduletype").val(),
"module_option" : $('#module_option').val(),
"min_hours_status" : $('#text-min_hours_status').val(),
"datatype" : $("#datatype").val(),
"not_condition" : $("#not_condition_switch").is(':checked'),
"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 the first
$('#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');
// 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/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();
});
</script>
<?php
return; return;
} }
} }

View File

@ -360,7 +360,7 @@ function process_user_login_remote($login, $pass, $api=false)
} }
$user_info = [ $user_info = [
'fullname' => $login, 'fullname' => db_escape_string_sql($login),
'comments' => 'Imported from '.$config['auth'], 'comments' => 'Imported from '.$config['auth'],
]; ];
@ -402,7 +402,7 @@ function process_user_login_remote($login, $pass, $api=false)
$config['auth_error'] = __('User not found in database or incorrect password'); $config['auth_error'] = __('User not found in database or incorrect password');
return false; return false;
} else { } else {
$user_info['fullname'] = $sr['cn'][0]; $user_info['fullname'] = db_escape_string_sql($sr['cn'][0]);
$user_info['email'] = $sr['mail'][0]; $user_info['email'] = $sr['mail'][0];
// Create the user. // Create the user.
@ -1569,7 +1569,7 @@ function local_ldap_search(
$filter = ''; $filter = '';
if (!empty($access_attr) && !empty($user)) { if (!empty($access_attr) && !empty($user)) {
$filter = " -s sub '(".$access_attr.'='.$user.")' "; $filter = ' -s sub '.escapeshellarg('('.$access_attr.'='.$user.')');
} }
$tls = ''; $tls = '';
@ -1595,7 +1595,7 @@ function local_ldap_search(
$ldap_admin_pass = ' -w '.escapeshellarg($ldap_admin_pass); $ldap_admin_pass = ' -w '.escapeshellarg($ldap_admin_pass);
} }
$dn = " -b '".$dn."'"; $dn = ' -b '.escapeshellarg($dn);
$ldapsearch_command = 'ldapsearch -LLL -o ldif-wrap=no -o nettimeout='.$ldap_search_time.' -x'.$ldap_host.$ldap_version.' -E pr=10000/noprompt '.$ldap_admin_user.$ldap_admin_pass.$dn.$filter.$tls.' | grep -v "^#\|^$" | sed "s/:\+ /=>/g"'; $ldapsearch_command = 'ldapsearch -LLL -o ldif-wrap=no -o nettimeout='.$ldap_search_time.' -x'.$ldap_host.$ldap_version.' -E pr=10000/noprompt '.$ldap_admin_user.$ldap_admin_pass.$dn.$filter.$tls.' | grep -v "^#\|^$" | sed "s/:\+ /=>/g"';
$shell_ldap_search = explode("\n", shell_exec($ldapsearch_command)); $shell_ldap_search = explode("\n", shell_exec($ldapsearch_command));
foreach ($shell_ldap_search as $line) { foreach ($shell_ldap_search as $line) {

View File

@ -96,7 +96,10 @@ class AuditLog extends HTML
// Datatables list. // Datatables list.
try { try {
$columns = [ $columns = [
'id_usuario', [
'text' => 'id_usuario',
'class' => 'w50px',
],
'accion', 'accion',
'fecha', 'fecha',
'ip_origen', 'ip_origen',
@ -116,11 +119,11 @@ class AuditLog extends HTML
$columns, $columns,
[ [
'text' => 'security', 'text' => 'security',
'class' => 'w80px action_buttons show_security_info', 'class' => 'w50px action_buttons show_security_info',
], ],
[ [
'text' => 'action', '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), 'label' => __('Free search').ui_print_help_tip(__('Search filter by User, Action, Date, Source IP or Comments fields content'), true),
'type' => 'text', 'type' => 'text',
'class' => 'w200px', 'class' => 'w150px',
'id' => 'filter_text', 'id' => 'filter_text',
'name' => 'filter_text', 'name' => 'filter_text',
], ],
[ [
'label' => __('Max. hours old'), 'label' => __('Max. hours old'),
'type' => 'text', 'type' => 'select',
'class' => 'w100px', 'class' => 'w20px',
'id' => 'filter_period', 'select2_enable' => true,
'name' => 'filter_period', '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'), 'label' => __('IP'),
@ -223,7 +238,7 @@ class AuditLog extends HTML
'nothing' => __('All'), 'nothing' => __('All'),
'nothing_value' => '-1', 'nothing_value' => '-1',
'sql' => 'SELECT DISTINCT(accion), accion AS text FROM tsesion', 'sql' => 'SELECT DISTINCT(accion), accion AS text FROM tsesion',
'class' => 'mw250px', 'class' => 'mw200px',
'id' => 'filter_type', 'id' => 'filter_type',
'name' => '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" '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, "SYSTEM" AS text UNION SELECT "N/A"
AS id_user, "N/A" AS text', AS id_user, "N/A" AS text',
'class' => 'mw250px', 'class' => 'mw200px',
'id' => 'filter_user', 'id' => 'filter_user',
'name' => 'filter_user', 'name' => 'filter_user',
], ],
@ -346,9 +361,12 @@ class AuditLog extends HTML
).ui_print_timestamp($tmp->utimestamp, true); ).ui_print_timestamp($tmp->utimestamp, true);
if (enterprise_installed() === true) { if (enterprise_installed() === true) {
$tmp->security = enterprise_hook('cell1EntepriseAudit', [$tmp->id_sesion]); $extendedInfo = enterprise_hook('rowEnterpriseAudit', [$tmp->id_sesion]);
$tmp->action = enterprise_hook('cell2EntepriseAudit', []); if (empty($extendedInfo) === false) {
$tmp->extendedInfo = enterprise_hook('rowEnterpriseAudit', [$tmp->id_sesion]); $tmp->security = enterprise_hook('cell1EntepriseAudit', [$tmp->id_sesion]);
$tmp->action = enterprise_hook('cell2EntepriseAudit', []);
$tmp->extendedInfo = $extendedInfo;
}
} }
$carry[] = $tmp; $carry[] = $tmp;

View File

@ -900,7 +900,7 @@ class CalendarManager
$id_group = get_parameter('id_group', null); $id_group = get_parameter('id_group', null);
$day_code = get_parameter('day_code', null); $day_code = get_parameter('day_code', null);
$id_calendar = get_parameter('id_calendar', null); $id_calendar = get_parameter('id_calendar', null);
$description = get_parameter('description', null); $description = io_safe_input(get_parameter('description', null));
$change = true; $change = true;
if ($new === false if ($new === false
&& ($date === $specialDay->date() && ($date === $specialDay->date()

View File

@ -248,6 +248,11 @@ class ConsoleSupervisor
$this->checkAuditLogOldLocation(); $this->checkAuditLogOldLocation();
/*
* Check if performance variables are corrects
*/
$this->checkPerformanceVariables();
/* /*
* Checks if sync queue is longer than limits. * Checks if sync queue is longer than limits.
* NOTIF.SYNCQUEUE.LENGTH * NOTIF.SYNCQUEUE.LENGTH
@ -258,6 +263,21 @@ class ConsoleSupervisor
$this->checkSyncQueueStatus(); $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();
}
} }
@ -509,6 +529,11 @@ class ConsoleSupervisor
$this->checkAuditLogOldLocation(); $this->checkAuditLogOldLocation();
/*
* Check if performance variables are corrects
*/
$this->checkPerformanceVariables();
/* /*
* Checks if sync queue is longer than limits. * Checks if sync queue is longer than limits.
* NOTIF.SYNCQUEUE.LENGTH * NOTIF.SYNCQUEUE.LENGTH
@ -518,6 +543,108 @@ class ConsoleSupervisor
$this->checkSyncQueueLength(); $this->checkSyncQueueLength();
$this->checkSyncQueueStatus(); $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',
]
);
}
}
}
} }
@ -532,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&section=perf',
]
);
} else {
$this->cleanNotifications('NOTIF.ACCESSSTASTICS.PERFORMANCE');
}
}
/** /**
* Update targets for given notification using object targets. * Update targets for given notification using object targets.
* *
@ -2379,7 +2534,7 @@ class ConsoleSupervisor
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
$message_conf_cron .= __('Discovery relies on an appropriate cron setup.'); $message_conf_cron .= __('Discovery relies on an appropriate cron setup.');
$message_conf_cron .= '. '.__('Please, add the following line to your crontab file:'); $message_conf_cron .= '. '.__('Please, add the following line to your crontab file:');
$message_conf_cron .= '<b><pre class=""ui-dialog>* * * * * &lt;user&gt; wget -q -O - --no-check-certificate '; $message_conf_cron .= '<b><pre class=""ui-dialog>* * * * * &lt;user&gt; wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies ';
$message_conf_cron .= str_replace( $message_conf_cron .= str_replace(
ENTERPRISE_DIR.'/meta/', ENTERPRISE_DIR.'/meta/',
'', '',
@ -2806,4 +2961,30 @@ class ConsoleSupervisor
} }
/**
* Chechs if an agent has a dependency eror on omnishell
*
* @return void
*/
public function checkLibaryError()
{
$sql = 'SELECT COUNT(errorlevel) from tremote_command_target WHERE errorlevel = 2';
$error_dependecies = db_get_sql($sql);
if ($error_dependecies > 0) {
$this->notify(
[
'type' => 'NOTIF.AGENT.LIBRARY',
'title' => __('Agent dependency error'),
'message' => __(
'There are omnishell agents with dependency errors',
),
'url' => '__url__/index.php?sec=gextensions&sec2=enterprise/tools/omnishell',
]
);
}
}
} }

View File

@ -104,6 +104,7 @@ class Diagnostics extends Wizard
'getChartAjax', 'getChartAjax',
'formFeedback', 'formFeedback',
'createdScheduleFeedbackTask', 'createdScheduleFeedbackTask',
'getSystemDate',
]; ];
@ -209,6 +210,7 @@ class Diagnostics extends Wizard
'getAttachmentFolder', 'getAttachmentFolder',
'getInfoTagenteDatos', 'getInfoTagenteDatos',
'getServerThreads', 'getServerThreads',
'getSystemDate',
]; ];
if ($this->pdf === true) { if ($this->pdf === true) {
@ -278,6 +280,10 @@ class Diagnostics extends Wizard
$title = __('SQL show engine innodb status'); $title = __('SQL show engine innodb status');
break; break;
case 'getSystemDate':
$title = __('Date system');
break;
default: default:
// Not possible. // Not possible.
$title = ''; $title = '';
@ -516,6 +522,27 @@ class Diagnostics extends Wizard
} }
/**
* Date system
*
* @return string
*/
public function getSystemDate(): string
{
$result = [
'error' => false,
'data' => [
'date' => [
'name' => __('System Date (Console)'),
'value' => date('H:i:s Y-m-d'),
],
],
];
return json_encode($result);
}
/** /**
* Database size stats. * Database size stats.
* *
@ -619,7 +646,7 @@ class Diagnostics extends Wizard
$currentTime = time(); $currentTime = time();
$pandoraDbLastRun = __('Pandora DB has never been executed'); $pandoraDbLastRun = __('Pandora DB has never been executed');
if ($dateDbMantenaince !== false) { if ($dateDbMantenaince !== false && empty($dateDbMantenaince) === false) {
$difference = ($currentTime - $dateDbMantenaince); $difference = ($currentTime - $dateDbMantenaince);
$pandoraDbLastRun = human_time_description_raw( $pandoraDbLastRun = human_time_description_raw(
$difference, $difference,
@ -659,15 +686,6 @@ class Diagnostics extends Wizard
{ {
global $config; global $config;
// Size BBDD.
$dbSizeSql = db_get_value_sql(
'SELECT ROUND(SUM(data_length+index_length)/1024/1024,3)
FROM information_schema.TABLES'
);
// Add unit size.
$dbSize = $dbSizeSql.' M';
$result = [ $result = [
'error' => false, 'error' => false,
'data' => [ 'data' => [
@ -683,10 +701,6 @@ class Diagnostics extends Wizard
'name' => __('DB Schema Build'), 'name' => __('DB Schema Build'),
'value' => $config['db_scheme_build'], 'value' => $config['db_scheme_build'],
], ],
'dbSize' => [
'name' => __('DB Size'),
'value' => $dbSize,
],
], ],
]; ];

View 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();
}
}

View File

@ -782,7 +782,9 @@ class NetworkMap
if ($this->network) { if ($this->network) {
// Network map, based on direct network. // Network map, based on direct network.
$nodes = networkmap_get_nodes_from_ip_mask( $nodes = networkmap_get_nodes_from_ip_mask(
$this->network $this->network,
false,
'&#x0d;&#x0a;'
); );
} else if ($this->mapOptions['map_filter']['empty_map']) { } else if ($this->mapOptions['map_filter']['empty_map']) {
// Empty map returns no data. // Empty map returns no data.
@ -792,17 +794,22 @@ class NetworkMap
|| $this->mapOptions['map_filter']['dont_show_subgroups'] == 1 || $this->mapOptions['map_filter']['dont_show_subgroups'] == 1
) { ) {
// Show only current selected group. // Show only current selected group.
$filter['id_grupo'] = $this->idGroup; $filter['id_grupo'] = explode(',', $this->idGroup);
} else { } else {
// Show current group and children. // Show current group and children.
$childrens = groups_get_children($this->idGroup, null, true); foreach (explode(',', $this->idGroup) as $key => $group) {
if (!empty($childrens)) { $childrens = groups_get_children($group, null, true);
$childrens = array_keys($childrens); if (!empty($childrens)) {
$childrens = array_keys($childrens);
$filter['id_grupo'] = $childrens; if (empty($filter['id_grupo']) === false) {
$filter['id_grupo'][] = $this->idGroup; $filter['id_grupo'] = array_merge($filter['id_grupo'], $childrens);
} else { } else {
$filter['id_grupo'] = $this->idGroup; $filter['id_grupo'] = $childrens;
}
} else {
$filter['id_grupo'][] = $group;
}
} }
} }
@ -1189,6 +1196,10 @@ class NetworkMap
$head .= 'overlap="scalexy";'; $head .= 'overlap="scalexy";';
} }
if ($layout == 'spring1' || $layout == 'spring2') {
$head .= 'sep="'.$node_sep.'";';
}
if ($layout == 'flat') { if ($layout == 'flat') {
$head .= 'ranksep="'.$rank_sep.'";'; $head .= 'ranksep="'.$rank_sep.'";';
} }
@ -3498,6 +3509,7 @@ class NetworkMap
url_background_grid: url_background_grid, url_background_grid: url_background_grid,
refresh_time: '.$this->mapOptions['refresh_time'].', refresh_time: '.$this->mapOptions['refresh_time'].',
font_size: '.$this->mapOptions['font_size'].', font_size: '.$this->mapOptions['font_size'].',
method: '.$this->map['generation_method'].',
base_url_homedir: "'.ui_get_full_url(false).'" base_url_homedir: "'.ui_get_full_url(false).'"
}); });
init_drag_and_drop(); init_drag_and_drop();

View File

@ -84,6 +84,15 @@ class SatelliteCollection extends HTML
return; return;
} }
if ((int) $config['license_nms'] === 0) {
db_pandora_audit(
AUDIT_LOG_NMS_VIOLATION,
'Trying to access satellite collections'
);
include $config['homedir'].'/general/noaccess.php';
return;
}
// Set the ajax controller. // Set the ajax controller.
$this->ajaxController = $ajaxController; $this->ajaxController = $ajaxController;
// Capture all parameters before start. // Capture all parameters before start.

View File

@ -413,73 +413,74 @@ class SnmpConsole extends HTML
'class' => 'flex-row', 'class' => 'flex-row',
'inputs' => [ 'inputs' => [
[ [
'label' => __('Alert'), 'label' => __('Alert'),
'type' => 'select', 'type' => 'select',
'id' => 'filter_alert', 'id' => 'filter_alert',
'name' => 'filter_alert', 'input_class' => 'filter_input_datatable',
'class' => 'w200px', 'name' => 'filter_alert',
'fields' => $show_alerts, 'fields' => $show_alerts,
'return' => true, 'return' => true,
'selected' => $this->filter_alert, 'selected' => $this->filter_alert,
], ],
[ [
'label' => __('Severity'), 'label' => __('Severity'),
'type' => 'select', 'type' => 'select',
'id' => 'filter_severity', 'id' => 'filter_severity',
'name' => 'filter_severity', 'input_class' => 'filter_input_datatable',
'class' => 'w200px', 'name' => 'filter_severity',
'fields' => $severities, 'fields' => $severities,
'return' => true, 'return' => true,
'selected' => $this->filter_severity, 'selected' => $this->filter_severity,
], ],
[ [
'label' => __('Free search'), 'label' => __('Free search'),
'type' => 'text', 'type' => 'text',
'class' => 'w400px', 'id' => 'filter_free_search',
'id' => 'filter_free_search', 'input_class' => 'filter_input_datatable',
'name' => 'filter_free_search', 'name' => 'filter_free_search',
'value' => $this->filter_free_search, 'value' => $this->filter_free_search,
], ],
[ [
'label' => __('Status'), 'label' => __('Status'),
'type' => 'select', 'type' => 'select',
'id' => 'filter_status', 'id' => 'filter_status',
'name' => 'filter_status', 'input_class' => 'filter_input_datatable',
'class' => 'w200px', 'name' => 'filter_status',
'fields' => $status_array, 'fields' => $status_array,
'return' => true, 'return' => true,
'selected' => $this->filter_status, 'selected' => $this->filter_status,
], ],
[ [
'label' => __('Group by Enterprise String/IP'), 'label' => __('Group by Enterprise String/IP'),
'type' => 'select', 'type' => 'select',
'name' => 'filter_group_by', 'name' => 'filter_group_by',
'selected' => $this->filter_group_by, 'selected' => $this->filter_group_by,
'disabled' => false, 'disabled' => false,
'return' => true, 'return' => true,
'id' => 'filter_group_by', 'id' => 'filter_group_by',
'fields' => [ 'input_class' => 'filter_input_datatable',
'fields' => [
0 => __('No'), 0 => __('No'),
1 => __('Yes'), 1 => __('Yes'),
], ],
], ],
[ [
'label' => __('Max. hours old'), 'label' => __('Max. hours old'),
'type' => 'text', 'type' => 'text',
'class' => 'w200px', 'id' => 'filter_hours_ago',
'id' => 'filter_hours_ago', 'input_class' => 'filter_input_datatable',
'name' => 'filter_hours_ago', 'name' => 'filter_hours_ago',
'value' => $this->filter_hours_ago, 'value' => $this->filter_hours_ago,
], ],
[ [
'label' => __('Trap type'), 'label' => __('Trap type'),
'type' => 'select', 'type' => 'select',
'id' => 'filter_trap_type', 'id' => 'filter_trap_type',
'name' => 'filter_trap_type', 'input_class' => 'filter_input_datatable',
'class' => 'w200px', 'name' => 'filter_trap_type',
'fields' => $trap_types, 'fields' => $trap_types,
'return' => true, 'return' => true,
'selected' => $this->filter_trap_type, 'selected' => $this->filter_trap_type,
], ],
], ],
], ],
@ -926,7 +927,10 @@ class SnmpConsole extends HTML
'class' => 'invert_filter', 'class' => 'invert_filter',
] ]
).'</a>'; ).'</a>';
$tmp->action .= '<a href="index.php?sec=snmpconsole&sec2=enterprise/godmode/snmpconsole/snmp_trap_editor_form&oid='.$tmp->oid.'&custom_oid='.urlencode($tmp->oid_custom).'&severity='.$tmp->severity.'&text='.io_safe_input($tmp->text).'&description='.io_safe_input($tmp->description, ENT_QUOTES).'" title="'.io_safe_input($tmp->description, ENT_QUOTES).'">'.html_print_image('images/edit.png', true, ['alt' => __('SNMP trap editor'), 'title' => __('SNMP trap editor')]).'</a>';
if ($config['enterprise_installed']) {
$tmp->action .= '<a href="index.php?sec=snmpconsole&sec2=enterprise/godmode/snmpconsole/snmp_trap_editor_form&oid='.$tmp->oid.'&custom_oid='.urlencode($tmp->oid_custom).'&severity='.$tmp->severity.'&text='.io_safe_input($tmp->text).'&description='.io_safe_input($tmp->description, ENT_QUOTES).'" title="'.io_safe_input($tmp->description, ENT_QUOTES).'">'.html_print_image('images/edit.png', true, ['alt' => __('SNMP trap editor'), 'title' => __('SNMP trap editor')]).'</a>';
}
$tmp->m = html_print_checkbox_extended('snmptrapid[]', $tmp->id_trap, false, false, '', 'class="chk"', true); $tmp->m = html_print_checkbox_extended('snmptrapid[]', $tmp->id_trap, false, false, '', 'class="chk"', true);

View File

@ -214,6 +214,11 @@ class Tree
AND ta.unknown_count = 0 AND ta.unknown_count = 0
AND ta.normal_count > 0) '; AND ta.normal_count > 0) ';
break; break;
case AGENT_STATUS_NOT_NORMAL:
$agent_status_filter = ' AND (ta.critical_count > 0
OR ta.warning_count > 0) ';
break;
} }
return $agent_status_filter; return $agent_status_filter;
@ -285,6 +290,10 @@ class Tree
return $show_init_condition; return $show_init_condition;
} }
if ((int) $this->filter['statusModule'] === 6) {
return ' AND (ta.warning_count > 0 OR ta.critical_count > 0)';
}
$field_filter = modules_get_counter_by_states($this->filter['statusModule']); $field_filter = modules_get_counter_by_states($this->filter['statusModule']);
if ($field_filter === false) { if ($field_filter === false) {
return ' AND 1=0'; return ' AND 1=0';
@ -894,6 +903,18 @@ class Tree
$agent['counters']['ok'] = $agent['normal_count']; $agent['counters']['ok'] = $agent['normal_count'];
$agent['counters']['total'] = $agent['normal_count']; $agent['counters']['total'] = $agent['normal_count'];
break; break;
case AGENT_MODULE_STATUS_NOT_NORMAL:
if (empty($agent['critical_count']) === false) {
$agent['counters']['critical'] = $agent['critical_count'];
}
if (empty($agent['warning_count']) === false) {
$agent['counters']['warning'] = $agent['warning_count'];
}
$agent['counters']['total'] = ($agent['warning_count'] + $agent['critical_count']);
break;
} }
} }

View File

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

View File

@ -6397,3 +6397,42 @@ function getBearerToken()
return false; return false;
} }
/**
* 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.
* */
function nms_check_api()
{
global $config;
if ((int) $config['license_nms'] === 1) {
returnError('license_error');
return true;
}
}

View File

@ -519,6 +519,27 @@ function agents_get_agents(
$search_custom = ''; $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'])) { if (isset($filter['offset'])) {
$offset = $filter['offset']; $offset = $filter['offset'];
unset($filter['offset']); unset($filter['offset']);
@ -692,25 +713,38 @@ function agents_get_agents(
$where_nogroup = '1 = 1'; $where_nogroup = '1 = 1';
} }
$policy_join = '';
if ($policies !== '') {
$policy_join = 'INNER JOIN tpolicy_agents
ON tpolicy_agents.id_agent=tagente.id_agente';
}
if ($extra) { if ($extra) {
$where = sprintf( $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, $sql_extra,
$where, $where,
$where_nogroup, $where_nogroup,
$status_sql, $status_sql,
$search, $search,
$disabled $disabled,
$id_os,
$policies,
$other_condition
); );
} else { } else {
$where = sprintf( $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,
$where_nogroup, $where_nogroup,
$status_sql, $status_sql,
$search, $search,
$disabled, $disabled,
$search_custom $search_custom,
$id_os,
$policies,
$other_condition
); );
} }
@ -720,9 +754,11 @@ function agents_get_agents(
FROM `%s` tagente FROM `%s` tagente
LEFT JOIN tagent_secondary_group LEFT JOIN tagent_secondary_group
ON tagent_secondary_group.id_agent=tagente.id_agente ON tagent_secondary_group.id_agent=tagente.id_agente
%s
WHERE %s %s', WHERE %s %s',
implode(',', $fields), implode(',', $fields),
$table_name, $table_name,
$policy_join,
$where, $where,
$order $order
); );

View File

@ -198,6 +198,16 @@ function returnError($typeError, $returnType='string')
); );
break; break;
case 'license_error':
returnData(
$returnType,
[
'type' => 'string',
'data' => __('License not allowed for this operation.'),
]
);
break;
default: default:
returnData( returnData(
$returnType, $returnType,
@ -11061,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) 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 try {
$event = events_get_event($id_event); if (is_metaconsole() === true
alerts_agent_module_standby($event['id_alert_am'], 0); && (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)) { if (!empty($text)) {
// Set the comment for the validation // Set the comment for the validation
events_comment($id_event, $text); 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( returnData(
'string', 'string',
[ [

View File

@ -463,10 +463,6 @@ function config_update_config()
if (config_update_value('ipam_ocuppied_warning_treshold', get_parameter('ipam_ocuppied_warning_treshold'), true) === false) { if (config_update_value('ipam_ocuppied_warning_treshold', get_parameter('ipam_ocuppied_warning_treshold'), true) === false) {
$error_update[] = __('Ipam Ocuppied Manager Warning'); $error_update[] = __('Ipam Ocuppied Manager Warning');
} }
if (config_update_value('sap_license', get_parameter('sap_license'), true) === false) {
$error_update[] = __('SAP/R3 Plugin Licence');
}
} }
break; break;
@ -852,6 +848,10 @@ function config_update_config()
$error_update[] = __('Item limit for realtime reports)'); $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) { if (config_update_value('step_compact', (int) get_parameter('step_compact'), true) === false) {
$error_update[] = __('Compact interpolation in hours (1 Fine-20 bad)'); $error_update[] = __('Compact interpolation in hours (1 Fine-20 bad)');
} }
@ -1990,6 +1990,10 @@ function config_process_config()
config_update_value('report_limit', 100); config_update_value('report_limit', 100);
} }
if (!isset($config['events_per_query'])) {
config_update_value('events_per_query', 5000);
}
if (!isset($config['loginhash_pwd'])) { if (!isset($config['loginhash_pwd'])) {
config_update_value('loginhash_pwd', io_input_password((rand(0, 1000) * rand(0, 1000)).'pandorahash')); config_update_value('loginhash_pwd', io_input_password((rand(0, 1000) * rand(0, 1000)).'pandorahash'));
} }
@ -2297,6 +2301,96 @@ function config_process_config()
config_update_value('2Fa_auth', ''); 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) { if (isset($config['agent_wizard_defaults']) === false) {
config_update_value( config_update_value(
'agent_wizard_defaults', 'agent_wizard_defaults',

View File

@ -2018,7 +2018,7 @@ function events_change_status(
// Update ack info if the new status is validated. // Update ack info if the new status is validated.
$ack_utimestamp = 0; $ack_utimestamp = 0;
$ack_user = $config['id_user']; $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(); $ack_utimestamp = time();
} }
@ -2412,14 +2412,17 @@ function events_create_event(
$source = get_product_name(); $source = get_product_name();
} }
// Get Timestamp.
$timestamp = time();
$values = [ $values = [
'id_agente' => $id_agent, 'id_agente' => $id_agent,
'id_usuario' => $id_user, 'id_usuario' => $id_user,
'id_grupo' => $id_group, 'id_grupo' => $id_group,
'estado' => $status, 'estado' => $status,
'timestamp' => date('Y-m-d H:i:s'), 'timestamp' => date('Y-m-d H:i:s', $timestamp),
'evento' => $event, 'evento' => $event,
'utimestamp' => time(), 'utimestamp' => $timestamp,
'event_type' => $event_type, 'event_type' => $event_type,
'id_agentmodule' => $id_agent_module, 'id_agentmodule' => $id_agent_module,
'id_alert_am' => $id_aam, 'id_alert_am' => $id_aam,
@ -4862,7 +4865,7 @@ function events_page_general($event)
$data = []; $data = [];
$data[0] = __('Acknowledged by'); $data[0] = __('Acknowledged by');
if ($event['estado'] == 1) { if ($event['estado'] == 1 || $event['estado'] == 2) {
if (empty($event['id_usuario']) === true) { if (empty($event['id_usuario']) === true) {
$user_ack = __('Autovalidated'); $user_ack = __('Autovalidated');
} else { } else {
@ -4996,8 +4999,7 @@ function events_page_general_acknowledged($event_id)
global $config; global $config;
$Acknowledged = ''; $Acknowledged = '';
$event = db_get_row('tevento', 'id_evento', $event_id); $event = db_get_row('tevento', 'id_evento', $event_id);
hd($event['ack_utimestamp'], true); if ($event !== false && ($event['estado'] == 1 || $event['estado'] == 2)) {
if ($event !== false && $event['estado'] == 1) {
$user_ack = db_get_value( $user_ack = db_get_value(
'fullname', 'fullname',
'tusuario', 'tusuario',
@ -5875,3 +5877,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);
}

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Images File Manager functions. * Images File Manager functions.
* *
@ -96,7 +97,7 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AW')) { if (!check_acl($config['id_user'], 0, 'AW')) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,
'Trying to access File manager' 'Trying to access File manager'
@ -223,7 +224,7 @@ function create_text_file($default_real_directory, $destination_directory)
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AW')) { if (!check_acl($config['id_user'], 0, 'AW')) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,
'Trying to access File manager' 'Trying to access File manager'
@ -293,7 +294,7 @@ if ($create_dir === true) {
$testHash = md5($directory.$config['server_unique_identifier']); $testHash = md5($directory.$config['server_unique_identifier']);
if ($hash !== $testHash) { if ($hash !== $testHash) {
ui_print_error_message(__('Security error.')); ui_print_error_message(__('Security error.'));
} else { } else {
$dirname = filemanager_safe_directory((string) get_parameter('dirname')); $dirname = filemanager_safe_directory((string) get_parameter('dirname'));
@ -349,7 +350,7 @@ if ($delete_file === true) {
} }
} else { } else {
if (unlink($filename) === true) { if (unlink($filename) === true) {
$config['filemanager']['delete'] = 1; $config['filemanager']['delete'] = 1;
} else { } else {
$config['filemanager']['delete'] = 0; $config['filemanager']['delete'] = 0;
} }
@ -499,77 +500,116 @@ function filemanager_file_explorer(
check_opened_dialog('create_folder'); check_opened_dialog('create_folder');
} }
<?php if ($allowCreateText === true) : ?> <?php if ($allowCreateText === true) : ?>
function show_create_text_file() { function show_create_text_file() {
actions_dialog('create_text_file'); actions_dialog('create_text_file');
$("#create_text_file").css("display", "block"); $("#create_text_file").css("display", "block");
check_opened_dialog('create_text_file'); check_opened_dialog('create_text_file');
} }
<?php endif ?> <?php endif ?>
function show_upload_file() { function show_upload_file() {
actions_dialog('upload_file'); actions_dialog('upload_file');
$("#upload_file").css("display", "block"); $("#upload_file").css("display", "block");
check_opened_dialog('upload_file'); check_opened_dialog('upload_file');
} }
function check_opened_dialog(check_opened){ function check_opened_dialog(check_opened) {
if(check_opened !== 'create_folder'){ if (check_opened !== 'create_folder') {
if (($("#create_folder").hasClass("ui-dialog-content") && $('#create_folder').dialog('isOpen') === true)) { if (($("#create_folder").hasClass("ui-dialog-content") && $('#create_folder').dialog('isOpen') === true)) {
$('#create_folder').dialog('close'); $('#create_folder').dialog('close');
} }
} }
<?php if ($allowCreateText === true) : ?> <?php if ($allowCreateText === true) : ?>
if(check_opened !== 'create_text_file'){ if (check_opened !== 'create_text_file') {
if (($("#create_text_file").hasClass("ui-dialog-content") && $('#create_text_file').dialog('isOpen') === true)) { if (($("#create_text_file").hasClass("ui-dialog-content") && $('#create_text_file').dialog('isOpen') === true)) {
$('#create_text_file').dialog('close'); $('#create_text_file').dialog('close');
}
} }
}
<?php endif ?> <?php endif ?>
if(check_opened !== 'upload_file'){ if (check_opened !== 'upload_file') {
if (($("#upload_file").hasClass("ui-dialog-content") && $('#upload_file').dialog('isOpen')) === true) { if (($("#upload_file").hasClass("ui-dialog-content") && $('#upload_file').dialog('isOpen')) === true) {
$('#upload_file').dialog('close'); $('#upload_file').dialog('close');
} }
} }
} }
function actions_dialog(action){ function actions_dialog(action) {
$('.'+action).addClass('file_table_modal_active'); $('.' + action).addClass('file_table_modal_active');
var title_action =''; var title_action = '';
switch (action) { switch (action) {
case 'create_folder': case 'create_folder':
title_action = "<?php echo __('Create a Directory'); ?>"; title_action = "<?php echo __('Create a Directory'); ?>";
break; break;
<?php if ($allowCreateText === true) : ?> <?php if ($allowCreateText === true) : ?>
case 'create_text_file': case 'create_text_file':
title_action = "<?php echo __('Create a Text'); ?>"; title_action = "<?php echo __('Create a Text'); ?>";
break; break;
<?php endif ?> <?php endif ?>
case 'upload_file': case 'upload_file':
title_action = "<?php echo __('Upload Files'); ?>"; title_action = "<?php echo __('Upload Files'); ?>";
break; break;
default: default:
break; break;
} }
$('#'+action) $('#' + action)
.dialog({ .dialog({
title: title_action, title: title_action,
resizable: true, resizable: true,
draggable: true, draggable: true,
modal: true, modal: true,
overlay: { overlay: {
opacity: 0.5, opacity: 0.5,
background: "black" background: "black"
}, },
width: 500, width: 500,
minWidth: 500, minWidth: 500,
minHeight: 210, minHeight: 210,
maxWidth: 800, maxWidth: 800,
maxHeight: 300, maxHeight: 300,
close: function () { close: function() {
$('.'+action).removeClass('file_table_modal_active'); $('.' + action).removeClass('file_table_modal_active');
} }
}).show(); }).show();
}
function show_modal_real_path(path) {
if (navigator.clipboard && window.isSecureContext) <?php $secure_con = true; ?>;
else <?php $secure_con = false; ?>;
$('#modal_real_path').addClass('file_table_modal_active');
$('#real_path').empty();
$('#real_path').html(path);
title_action = "<?php echo __('Real path'); ?>";
$('#modal_real_path')
.dialog({
title: title_action,
resizable: true,
draggable: true,
modal: true,
overlay: {
opacity: 0.5,
background: "black"
},
width: 448,
minWidth: 448,
minHeight: 213,
maxWidth: 800,
maxHeight: 300,
close: function() {
$('#modal_real_path').removeClass('file_table_modal_active');
}
}).show();
$("#submit-submit").on("click", copyToClipboard);
}
function copyToClipboard() {
if (navigator.clipboard && window.isSecureContext) {
window.navigator.clipboard.writeText($("#real_path").text()).then(function() {
$('#modal_real_path').dialog('close');
});
}
} }
</script> </script>
<?php <?php
@ -686,9 +726,9 @@ function filemanager_file_explorer(
if (pathinfo($fileinfo['realpath'], PATHINFO_EXTENSION) === 'php' if (pathinfo($fileinfo['realpath'], PATHINFO_EXTENSION) === 'php'
&& (is_readable($fileinfo['realpath']) === true || is_executable($fileinfo['realpath']) === true) && (is_readable($fileinfo['realpath']) === true || is_executable($fileinfo['realpath']) === true)
) { ) {
$error_message = __('This file could be executed by any user'); $error_message = __('This file could be executed by any user');
$error_message .= '. '.__('Make sure it can\'t perform dangerous tasks'); $error_message .= '. '.__('Make sure it can\'t perform dangerous tasks');
$data[1] = '<span class="error forced_title" data-title="'.$error_message.'" data-use_title_for_force_title="1">'.$data[1].'</span>'; $data[1] = '<span class="error forced_title" data-title="'.$error_message.'" data-use_title_for_force_title="1">'.$data[1].'</span>';
} }
$data[2] = ui_print_timestamp( $data[2] = ui_print_timestamp(
@ -702,11 +742,11 @@ function filemanager_file_explorer(
$data[3] = ui_format_filesize($fileinfo['size']); $data[3] = ui_format_filesize($fileinfo['size']);
} }
// Actions buttons // Actions buttons
// Delete button. // Delete button.
$data[4] = ''; $data[4] = '';
$data[4] .= '<span style="display: flex">'; $data[4] .= '<span style="display: flex">';
$typefile = array_pop(explode('.', $fileinfo['name'])); $typefile = array_pop(explode('.', $fileinfo['name']));
if (is_writable($fileinfo['realpath']) === true if (is_writable($fileinfo['realpath']) === true
&& (is_dir($fileinfo['realpath']) === false || count(scandir($fileinfo['realpath'])) < 3) && (is_dir($fileinfo['realpath']) === false || count(scandir($fileinfo['realpath'])) < 3)
&& ($readOnly === false) && ($readOnly === false)
@ -747,9 +787,16 @@ function filemanager_file_explorer(
$data[4] .= '</a>'; $data[4] .= '</a>';
} }
$data[4] .= '</span>'; if (is_writable($fileinfo['realpath']) === true
&& (is_dir($fileinfo['realpath']) === false || count(scandir($fileinfo['realpath'])) < 3)
&& ($readOnly === false)
) {
$data[4] .= '<a href="javascript: show_modal_real_path(`'.$fileinfo['realpath'].'`);">'.html_print_image('images/book_edit.png', true, ['style' => 'margin-top: 2px;', 'title' => __('Real path'), 'class' => 'invert_filter']).'</a>';
}
array_push($table->data, $data); $data[4] .= '</span>';
array_push($table->data, $data);
} }
} else { } else {
ui_print_info_message( ui_print_info_message(
@ -842,7 +889,7 @@ function filemanager_file_explorer(
'content' => html_print_input_file( 'content' => html_print_input_file(
'file', 'file',
true, true,
[ 'style' => 'border:0; padding:0; width:100%' ] ['style' => 'border:0; padding:0; width:100%']
), ),
], ],
true true
@ -925,6 +972,22 @@ function filemanager_file_explorer(
); );
echo '</a>'; echo '</a>';
// Show Modal Real Path
$modal_real_path = "<div><b>Real path to plugin execution is:</b></div>
<div id='real_path'></div>";
if (isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'on' || $_SERVER['SERVER_NAME'] == 'localhost' || $_SERVER['SERVER_NAME'] == '127.0.0.1') {
$modal_real_path .= "<div style='float:right;margin: 5em 0 0 auto';>".html_print_submit_button(__('Copy'), 'submit', false, 'class="sub next"', true).'</div>';
}
html_print_div(
[
'id' => 'modal_real_path',
'class' => 'invisible',
'content' => $modal_real_path,
]
);
echo '</div>'; echo '</div>';
} else { } else {
echo "<div style='text-align: right; width: ".$table->width."; color:#AC4444; margin-bottom:10px;'>"; echo "<div style='text-align: right; width: ".$table->width."; color:#AC4444; margin-bottom:10px;'>";
@ -1071,4 +1134,4 @@ function filemanager_safe_directory(
} }
return $directory; return $directory;
} }

View File

@ -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" // Alias for "html_debug_print"
function html_debug($var, $file='', $oneline=false) function html_debug($var, $file='', $oneline=false)
{ {

View File

@ -797,6 +797,7 @@ if (is_ajax()) {
$db_fragmentation = json_decode($d->getTablesFragmentation()); $db_fragmentation = json_decode($d->getTablesFragmentation());
$sys_info = json_decode($d->getSystemInfo()); $sys_info = json_decode($d->getSystemInfo());
$php_sys = json_decode($d->getPHPSetup()); $php_sys = json_decode($d->getPHPSetup());
$system_date = json_decode($d->getSystemDate());
$fragmentation_status = ''; $fragmentation_status = '';
if ($db_fragmentation->data->tablesFragmentationStatus->status === 1) { if ($db_fragmentation->data->tablesFragmentationStatus->status === 1) {
@ -1030,6 +1031,14 @@ if (is_ajax()) {
<p>'.$sys_info->data->ipInfo->value.'</p> <p>'.$sys_info->data->ipInfo->value.'</p>
</th> </th>
</tr> </tr>
<tr>
<th style="width: 15%;">
<p><span>'.$system_date->data->date->name.'</span></p>
</th>
<th style="width: 85%;">
<p>'.$system_date->data->date->value.'</p>
</th>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>

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