Merge remote-tracking branch 'origin/develop' into ent-8791-base-de-datos-historica-para-metaconsola

This commit is contained in:
Daniel Barbero 2022-09-21 15:20:30 +02:00
commit 2343456113
130 changed files with 150220 additions and 100321 deletions

View File

@ -1,62 +0,0 @@
# Dockerfile for the Pandora FMS image.
FROM debian:jessie
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mysql && useradd -r -g mysql mysql
RUN mkdir /docker-entrypoint-initdb.d
# FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
# File::Basename
# File::Copy
# Sys::Hostname
# Data::Dumper
RUN apt-get update && apt-get install -y perl pwgen git openssh-client --no-install-recommends && rm -rf /var/lib/apt/lists/*
# gpg: key 5072E1F5: public key "MySQL Release Engineering <mysql-build@oss.oracle.com>" imported
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5
ENV MYSQL_MAJOR 5.6
ENV MYSQL_VERSION 5.6.29-1debian8
RUN echo "deb http://repo.mysql.com/apt/debian/ jessie mysql-${MYSQL_MAJOR}" > /etc/apt/sources.list.d/mysql.list
# the "/var/lib/mysql" stuff here is because the mysql-server postinst doesn't have an explicit way to disable the mysql_install_db codepath besides having a database already "configured" (ie, stuff in /var/lib/mysql/mysql)
# also, we set debconf keys to make APT a little quieter
RUN { \
echo mysql-community-server mysql-community-server/data-dir select ''; \
echo mysql-community-server mysql-community-server/root-pass password ''; \
echo mysql-community-server mysql-community-server/re-root-pass password ''; \
echo mysql-community-server mysql-community-server/remove-test-db select false; \
} | debconf-set-selections \
&& apt-get update && apt-get install -y mysql-server="${MYSQL_VERSION}" && rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql
# comment out a few problematic configuration values
# don't reverse lookup hostnames, they are usually another container
RUN sed -Ei 's/^(bind-address|log)/#&/' /etc/mysql/my.cnf \
&& echo 'skip-host-cache\nskip-name-resolve' | awk '{ print } $1 == "[mysqld]" && c == 0 { c = 1; system("cat") }' /etc/mysql/my.cnf > /tmp/my.cnf \
&& mv /tmp/my.cnf /etc/mysql/my.cnf
VOLUME /var/lib/mysql
COPY docker-entrypoint.sh /entrypoint.sh
COPY pandora.cnf /etc/mysql/conf.d
COPY pandora_initdb.sh /docker-entrypoint-initdb.d
ENTRYPOINT ["/entrypoint.sh"]
# Make ssh dir
RUN mkdir /root/.ssh/
# Copy over private key, and set permissions
RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
RUN chown -R root:root /root/.ssh
#Clone the repo
RUN git config --global http.sslVerify false
RUN git clone -b develop --single-branch https://github.com/pandorafms/pandorafms.git /tmp/pandorafms
#RUN mv -f /tmp/pandorafms/pandora_console/pandoradb.sql /docker-entrypoint-initdb.d
#RUN mv -f /tmp/pandorafms/pandora_console/pandoradb_data.sql /docker-entrypoint-initdb.d
EXPOSE 3306
CMD ["mysqld"]

View File

@ -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='2022052501' S_VERSION='202209231'
LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables # define default variables
@ -26,6 +26,7 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
[ "$DBUSER" ] || DBUSER=pandora [ "$DBUSER" ] || DBUSER=pandora
[ "$DBPASS" ] || DBPASS=pandora [ "$DBPASS" ] || DBPASS=pandora
[ "$DBPORT" ] || DBPORT=3306 [ "$DBPORT" ] || DBPORT=3306
[ "$DBROOTUSER" ] || DBROOTUSER=root
[ "$DBROOTPASS" ] || DBROOTPASS=pandora [ "$DBROOTPASS" ] || DBROOTPASS=pandora
[ "$SKIP_PRECHECK" ] || SKIP_PRECHECK=0 [ "$SKIP_PRECHECK" ] || SKIP_PRECHECK=0
[ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0 [ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0
@ -73,13 +74,16 @@ check_cmd_status () {
} }
check_pre_pandora () { check_pre_pandora () {
export MYSQL_PWD=$DBPASS
echo -en "${cyan}Checking environment ... ${reset}" echo -en "${cyan}Checking environment ... ${reset}"
rpm -qa | grep 'pandorafms_' &>> /dev/null && local fail=true rpm -qa | grep 'pandorafms_' &>> /dev/null && local fail=true
[ -d "$PANDORA_CONSOLE" ] && local fail=true [ -d "$PANDORA_CONSOLE" ] && local fail=true
[ -f /usr/bin/pandora_server ] && local fail=true [ -f /usr/bin/pandora_server ] && local fail=true
echo "use $DBNAME" | mysql -uroot -P$DBPORT -h$DBHOST &>> /dev/null && local fail=true
if [ "$SKIP_DATABASE_INSTALL" -eq '0' ]; then
export MYSQL_PWD=$DBPASS
echo "use $DBNAME" | mysql -u$DBUSER -P$DBPORT -h$DBHOST &>> /dev/null && local fail=true
fi
[ ! $fail ] [ ! $fail ]
check_cmd_status 'Error there is a current Pandora FMS installation on this node, please remove it to execute a clean install' check_cmd_status 'Error there is a current Pandora FMS installation on this node, please remove it to execute a clean install'
@ -214,7 +218,7 @@ if [ "$PHPVER" -eq '8' ] ; then
execute_cmd "dnf module install -y php:remi-8.0" "Configuring PHP 8" execute_cmd "dnf module install -y php:remi-8.0" "Configuring PHP 8"
fi fi
# Install percona Database # Install percona Database
execute_cmd "dnf module disable -y mysql" "Disabiling mysql module" execute_cmd "dnf module disable -y mysql" "Disabiling mysql module"
if [ "$MYVER" -eq '80' ] ; then if [ "$MYVER" -eq '80' ] ; then
@ -226,7 +230,6 @@ if [ "$MYVER" -ne '80' ] ; then
execute_cmd "dnf install -y Percona-Server-server-57 percona-xtrabackup-24" "Installing Percona Server 57" execute_cmd "dnf install -y Percona-Server-server-57 percona-xtrabackup-24" "Installing Percona Server 57"
fi fi
# Console dependencies # Console dependencies
console_dependencies=" \ console_dependencies=" \
php \ php \
@ -401,30 +404,28 @@ if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then
export MYSQL_PWD=$(grep "temporary password" /var/log/mysqld.log | rev | cut -d' ' -f1 | rev) export MYSQL_PWD=$(grep "temporary password" /var/log/mysqld.log | rev | cut -d' ' -f1 | rev)
if [ "$MYVER" -eq '80' ] ; then if [ "$MYVER" -eq '80' ] ; then
echo """ echo """
SET PASSWORD FOR 'root'@'localhost' = 'Pandor4!'; SET PASSWORD FOR '$DBROOTUSER'@'localhost' = 'Pandor4!';
UNINSTALL COMPONENT 'file://component_validate_password'; UNINSTALL COMPONENT 'file://component_validate_password';
SET PASSWORD FOR 'root'@'localhost' = '$DBROOTPASS'; SET PASSWORD FOR '$DBROOTUSER'@'localhost' = '$DBROOTPASS';
""" | mysql --connect-expired-password -uroot &>> "$LOGFILE" """ | mysql --connect-expired-password -u$DBROOTUSER &>> "$LOGFILE"
fi fi
if [ "$MYVER" -ne '80' ] ; then if [ "$MYVER" -ne '80' ] ; then
echo """ echo """
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('Pandor4!'); SET PASSWORD FOR '$DBROOTUSER'@'localhost' = PASSWORD('Pandor4!');
UNINSTALL PLUGIN validate_password; UNINSTALL PLUGIN validate_password;
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('$DBROOTPASS'); SET PASSWORD FOR '$DBROOTUSER'@'localhost' = PASSWORD('$DBROOTPASS');
""" | mysql --connect-expired-password -uroot &>> "$LOGFILE"fi """ | mysql --connect-expired-password -u$DBROOTUSER &>> "$LOGFILE"fi
fi fi
fi
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 export MYSQL_PWD=$DBROOTPASS
echo "ALTER USER \"$DBUSER\"@'%' IDENTIFIED WITH mysql_native_password BY \"$DBPASS\"" | mysql -uroot -P$DBPORT -h$DBHOST echo -en "${cyan}Creating Pandora FMS database...${reset}"
echo "GRANT ALL PRIVILEGES ON $DBNAME.* TO \"$DBUSER\"@'%'" | mysql -uroot -P$DBPORT -h$DBHOST 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."
export MYSQL_PWD=$DBPASS 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 #Generating my.cnf
cat > /etc/my.cnf << EO_CONFIG_F cat > /etc/my.cnf << EO_CONFIG_F
@ -471,12 +472,14 @@ pid-file=/var/run/mysqld/mysqld.pid
EO_CONFIG_F 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
fi
execute_cmd "systemctl restart mysqld" "Configuring database engine"
execute_cmd "systemctl enable mysqld --now" "Enabling Database service"
fi fi
export MYSQL_PWD=$DBPASS
execute_cmd "systemctl restart mysqld" "Configuring database engine"
#Define packages #Define packages
if [ "$PANDORA_BETA" -eq '0' ] ; then if [ "$PANDORA_BETA" -eq '0' ] ; then
@ -503,7 +506,6 @@ 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'
# Enable Services # Enable Services
execute_cmd "systemctl enable mysqld --now" "Enabling Database service"
execute_cmd "systemctl enable httpd --now" "Enabling HTTPD service" execute_cmd "systemctl enable httpd --now" "Enabling HTTPD service"
execute_cmd "systemctl enable php-fpm --now" "Enabling PHP-FPM service" execute_cmd "systemctl enable php-fpm --now" "Enabling PHP-FPM service"

View File

@ -0,0 +1,743 @@
#!/bin/bash
##############################################################################################################
# PandoraFMS Community online installation script for Ubuntu 22.04
##############################################################################################################
## Tested versions ##
# Ubuntu 22.04.1
#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='2022052501'
LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables
[ "$TZ" ] || TZ="Europe/Madrid"
[ "$PHPVER" ] || PHPVER=7.4
[ "$DBHOST" ] || DBHOST=127.0.0.1
[ "$DBNAME" ] || DBNAME=pandora
[ "$DBUSER" ] || DBUSER=pandora
[ "$DBPASS" ] || DBPASS=pandora
[ "$DBPORT" ] || DBPORT=3306
[ "$DBROOTPASS" ] || DBROOTPASS=pandora
[ "$SKIP_PRECHECK" ] || SKIP_PRECHECK=0
[ "$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")
[ "$PANDORA_BETA" ] || PANDORA_BETA=0
# 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_pre_pandora () {
export MYSQL_PWD=$DBPASS
echo -en "${cyan}Checking environment ... ${reset}"
[ -d "$PANDORA_CONSOLE" ] && local fail=true
[ -f /usr/bin/pandora_server ] && local fail=true
echo "use $DBNAME" | mysql -u$DBUSER -P$DBPORT -h$DBHOST &>> /dev/null && local fail=true
[ ! $fail ]
check_cmd_status 'Error there is a current Pandora FMS installation on this node, please remove it to execute a clean install'
}
check_repo_connection () {
execute_cmd "ping -c 2 firefly.artica.es" "Checking Community repo"
execute_cmd "ping -c 2 support.pandorafms.com" "Checking Enterprise repo"
}
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 Community 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
# Pre installed pandora
[ "$SKIP_PRECHECK" == 1 ] || check_pre_pandora
#advicing BETA PROGRAM
[ "$PANDORA_BETA" -ne '0' ] && echo -e "${red}BETA version enable using nightly PandoraFMS packages${reset}"
# Connectivity
check_repo_connection
# 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: dnf'
# 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"
#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"
execute_cmd "apt update" "Updating repos"
execute_cmd "apt install -y php$PHPVER-fpm php$PHPVER-common libapache2-mod-fcgid php$PHPVER-cli apache2" "Installing apache and php-fpm"
#execute_cmd "a2enmod proxy_fcgi setenvif && a2enconf php$PHPVER-fpm" "Enabling php-fpm"
echo -en "${cyan}Enabling php$PHPVER-fpm...${reset}"
a2enmod proxy_fcgi setenvif &>> "$LOGFILE" && a2enconf php$PHPVER-fpm &>> "$LOGFILE"
check_cmd_status "Error enabling php$PHPVER-fpm "
systemctl restart php$PHPVER-fpm &>> "$LOGFILE"
# Console dependencies
console_dependencies=" \
ldap-utils \
postfix \
wget \
graphviz \
xfonts-75dpi \
xfonts-100dpi \
xfonts-ayu \
xfonts-intl-arabic \
xfonts-intl-asian \
xfonts-intl-phonetic \
xfonts-intl-japanese-big \
xfonts-intl-european \
xfonts-intl-chinese \
xfonts-intl-japanese \
xfonts-intl-chinese-big \
libzstd1 \
gir1.2-atk-1.0 \
libavahi-common-data \
cairo-perf-utils \
libfribidi-bin \
php$PHPVER-mcrypt \
php$PHPVER-gd \
php$PHPVER-curl \
php$PHPVER-mysql \
php$PHPVER-ldap \
php$PHPVER-fileinfo \
php$PHPVER-gettext \
php$PHPVER-snmp \
php$PHPVER-mbstring \
php$PHPVER-zip \
php$PHPVER-xmlrpc \
php$PHPVER-xml \
php$PHPVER-yaml \
libnet-telnet-perl \
whois"
execute_cmd "apt install -y $console_dependencies" "Installing Pandora FMS Console dependencies"
# Server dependencies
server_dependencies=" \
perl \
nmap \
fping \
sudo \
net-tools \
nfdump \
expect \
openssh-client \
postfix \
unzip \
xprobe \
coreutils \
libio-compress-perl \
libmoosex-role-timer-perl \
libdbd-mysql-perl \
libcrypt-mysql-perl \
libhttp-request-ascgi-perl \
liblwp-useragent-chicaching-perl \
liblwp-protocol-https-perl \
snmp \
libnetaddr-ip-perl \
libio-socket-ssl-perl \
libio-socket-socks-perl \
libio-socket-ip-perl \
libio-socket-inet6-perl \
libnet-telnet-perl \
libjson-perl \
libencode-perl \
libgeo-ip-perl \
openjdk-8-jdk "
execute_cmd "apt install -y $server_dependencies" "Installing Pandora FMS Server dependencies"
# wmic and pandorawmic
execute_cmd "curl -O https://firefly.artica.es/pandorafms/utils/bin/wmic" "Downloading wmic"
execute_cmd "curl -O https://firefly.artica.es/pandorafms/utils/bin/pandorawmic" "Downloading pandorawmic"
echo -en "${cyan}Installing wmic and pandorawmic...${reset}"
chmod +x pandorawmic wmic &>> "$LOGFILE" && \
cp -a wmic /usr/bin/ &>> "$LOGFILE" && \
cp -a pandorawmic /usr/bin/ &>> "$LOGFILE"
check_cmd_status "Error Installing phanromjs"
# phantomjs
echo -en "${cyan}Installing phantomjs...${reset}"
export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64"
export OPENSSL_CONF=/etc/ssl
curl -LSs -O "https://firefly.artica.es/pandorafms/utils/$PHANTOM_JS.tar.bz2" &>> "$LOGFILE" && \
tar xvjf "$PHANTOM_JS.tar.bz2" &>> "$LOGFILE" && \
mv $PHANTOM_JS/bin/phantomjs /usr/bin &>> "$LOGFILE" && \
/usr/bin/phantomjs --version &>> "$LOGFILE"
check_cmd_status "Error Installing phanromjs"
# SDK VMware perl dependencies
vmware_dependencies=" \
lib32z1 \
lib32z1 \
build-essential \
uuid uuid-dev \
libssl-dev \
perl-doc \
libxml-libxml-perl \
libcrypt-ssleay-perl \
libsoap-lite-perl \
libmodule-build-perl"
execute_cmd "apt install -y $vmware_dependencies" "Installing VMware SDK dependencies"
execute_cmd "wget https://firefly.artica.es/pandorafms/utils/VMware-vSphere-Perl-SDK-7.0.0-16453907.x86_64.tar.gz" "Downloading VMware SDK"
echo -en "${cyan}Installing VMware SDK...${reset}"
tar xvzf VMware-vSphere-Perl-SDK-7.0.0-16453907.x86_64.tar.gz &>> "$LOGFILE"
cd vmware-vsphere-cli-distrib/ &>> "$LOGFILE"
sed --follow-symlinks -i -e "s/[^#].*show_EULA().*/ #show_EULA();/g" vmware-install.pl &>> "$LOGFILE"
./vmware-install.pl --default &>> "$LOGFILE"
check_cmd_status "Error Installing VMware SDK"
execute_cmd "cpan Crypt::OpenSSL::AES" "Installing extra vmware dependencie"
cd $WORKDIR &>> "$LOGFILE"
# Instant client Oracle
execute_cmd "mkdir -p /opt/oracle" "Creating Oracle instant client directory /opt/oracle"
execute_cmd "wget https://download.oracle.com/otn_software/linux/instantclient/19800/instantclient-basic-linux.x64-19.8.0.0.0dbru.zip" "Downloading Oracle instant client"
execute_cmd "wget https://download.oracle.com/otn_software/linux/instantclient/19800/instantclient-sqlplus-linux.x64-19.8.0.0.0dbru.zip" "Downloading Oracle sqlplus"
echo -en "${cyan}Installing Oracle instant client...${reset}"
rm -fr /opt/oracle/* &>> "$LOGFILE"
unzip instantclient-basic-linux.x64-19.8.0.0.0dbru.zip -d /opt/oracle/ &>> "$LOGFILE"
unzip instantclient-sqlplus-linux.x64-19.8.0.0.0dbru.zip -d /opt/oracle/ &>> "$LOGFILE"
check_cmd_status "Error Installing Oracle instant client"
#Configuring env variables
cat >> /root/.profile << 'EOF_ENV'
#!/bin/bash
VERSION=19.8
export PATH=$PATH:/opt/oracle/instantclient_19_8
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/oracle/instantclient_19_8
export ORACLE_HOME=/opt/oracle/instantclient_19_8
EOF_ENV
source '/root/.profile' &>> "$LOGFILE"
#ipam dependencies
ipam_dependencies=" \
xprobe \
libnetaddr-ip-perl \
coreutils \
libdbd-mysql-perl \
libxml-simple-perl \
libgeo-ip-perl \
libio-socket-inet6-perl \
libxml-twig-perl \
libnetaddr-ip-perl"
execute_cmd "apt install -y $ipam_dependencies" "Installing IPAM Dependencies"
# MSSQL dependencies el8
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.asc &>> "$LOGFILE"
curl -sSL https://packages.microsoft.com/config/ubuntu/20.04/prod.list | tee /etc/apt/sources.list.d/microsoft-prod.list &>> "$LOGFILE"
apt update &>> "$LOGFILE"
execute_cmd "env ACCEPT_EULA=Y apt install -y msodbcsql17" "Installing ODBC Driver for Microsoft(R) SQL Server(R)"
MS_ID=$(head -1 /etc/odbcinst.ini | tr -d '[]') &>> "$LOGFILE"
# Disabling apparmor and ufw
systemctl stop ufw.service &>> "$LOGFILE"
systemctl disable ufw &>> "$LOGFILE"
systemctl stop apparmor &>> "$LOGFILE"
systemctl disable apparmor &>> "$LOGFILE"
#install mysql
debconf-set-selections <<< $(echo -n "mysql-server mysql-server/root_password password $DBROOTPASS") &>> "$LOGFILE"
debconf-set-selections <<< $(echo -n "mysql-server mysql-server/root_password_again password $DBROOTPASS") &>> "$LOGFILE"
echo -en "${cyan}Installing MySql Server...${reset}"
env DEBIAN_FRONTEND=noninteractive apt install -y mysql-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"
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=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
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"
#Define packages
if [ "$PANDORA_BETA" -eq '0' ] ; then
[ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandorafms/latest/Tarball/pandorafms_server-7.0NG.tar.gz"
[ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.artica.es/pandorafms/latest/Tarball/pandorafms_console-7.0NG.tar.gz"
[ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/Tarball/pandorafms_agent_unix-7.0NG.tar.gz"
elif [ "$PANDORA_BETA" -ne '0' ] ; then
[ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandora_enterprise_nightlies/pandorafms_server-latest_x86_64.tar.gz"
[ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.artica.es/pandora_enterprise_nightlies/pandorafms_console-latest.tar.gz"
[ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/Tarball/pandorafms_agent_unix-7.0NG.tar.gz"
fi
# Downloading Pandora Packages
cd $WORKDIR &>> "$LOGFILE"
curl -LSs --output pandorafms_console-7.0NG.tar.gz "${PANDORA_CONSOLE_PACKAGE}" &>> "$LOGFILE"
curl -LSs --output pandorafms_server-7.0NG.tar.gz "${PANDORA_SERVER_PACKAGE}" &>> "$LOGFILE"
curl -LSs --output pandorafms_agent_unix-7.0NG.tar.gz "${PANDORA_AGENT_PACKAGE}" &>> "$LOGFILE"
# Install PandoraFMS Console
echo -en "${cyan}Installing PandoraFMS Console...${reset}"
tar xvzf pandorafms_console-7.0NG.tar.gz &>> "$LOGFILE" && cp -Ra pandora_console /var/www/html/ &>> "$LOGFILE"
check_cmd_status "Error installing PandoraFMS Console"
rm -f $PANDORA_CONSOLE/*.spec &>> "$LOGFILE"
# Install Pandora FMS Server
echo -en "${cyan}Installing PandoraFMS Server...${reset}"
useradd pandora &>> "$LOGFILE"
tar xvfz $WORKDIR/pandorafms_server-7.0NG.tar.gz &>> $LOGFILE && cd pandora_server && ./pandora_server_installer --install &>> $LOGFILE && cd $WORKDIR &>> $LOGFILE
check_cmd_status "Error installing PandoraFMS Server"
#Install agent:
execute_cmd "apt install -y libyaml-tiny-perl perl coreutils wget curl unzip procps python3 python3-pip" "Installing PandoraFMS Agent Dependencies"
echo -en "${cyan}Installing PandoraFMS Agent...${reset}"
tar xvzf $WORKDIR/pandorafms_agent_unix-7.0NG.tar.gz &>> "$LOGFILE" && cd unix && ./pandora_agent_installer --install &>> $LOGFILE && cp -a tentacle_client /usr/local/bin/ &>> $LOGFILE && cd $WORKDIR
check_cmd_status "Error installing PandoraFMS Agent"
# Copy gotty utility
cd $WORKDIR &>> "$LOGFILE"
execute_cmd "wget https://pandorafms.com/library/wp-content/uploads/2019/11/gotty_linux_amd64.tar.gz" 'Dowloading gotty util'
tar xvzf gotty_linux_amd64.tar.gz &>> $LOGFILE
execute_cmd "mv gotty /usr/bin/" 'Installing gotty util'
# Config servicesa
#Configure apache2
#Enable SSL connections
cat > /etc/apache2/conf-available/ssl-params.conf << EOF_PARAM
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLHonorCipherOrder On
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff
# Requires Apache >= 2.4
SSLCompression off
SSLUseStapling on
SSLStaplingCache "shmcb:logs/stapling-cache(150000)"
# Requires Apache >= 2.4.11
SSLSessionTickets Off
EOF_PARAM
a2enmod ssl &>> "$LOGFILE"
a2enmod headers &>> "$LOGFILE"
a2enconf ssl-params &>> "$LOGFILE"
a2ensite default-ssl &>> "$LOGFILE"
a2enconf ssl-params &>> "$LOGFILE"
apache2ctl configtest &>> "$LOGFILE"
execute_cmd "systemctl restart apache2" "Enable SSL mod and Restarting Apache2"
execute_cmd "systemctl enable mysql --now" "Enabling Database service"
execute_cmd "systemctl enable apache2 --now" "Enabling Apache2 service"
execute_cmd "systemctl enable php$PHPVER-fpm --now" "Enabling php$PHPVER-fpm service"
# Populate Database
echo -en "${cyan}Loading pandoradb.sql to $DBNAME database...${reset}"
mysql -u$DBUSER -P$DBPORT -h$DBHOST $DBNAME < $PANDORA_CONSOLE/pandoradb.sql &>> "$LOGFILE"
check_cmd_status 'Error Loading database schema'
echo -en "${cyan}Loading pandoradb_data.sql to $DBNAME database...${reset}"
mysql -u$DBUSER -P$DBPORT -h$DBHOST $DBNAME < $PANDORA_CONSOLE/pandoradb_data.sql &>> "$LOGFILE"
check_cmd_status 'Error Loading database schema data'
# Configure console
# Set console config file
cat > $PANDORA_CONSOLE/include/config.php << EO_CONFIG_F
<?php
\$config["dbtype"] = "mysql";
\$config["dbname"]="$DBNAME";
\$config["dbuser"]="$DBUSER";
\$config["dbpass"]="$DBPASS";
\$config["dbhost"]="$DBHOST";
\$config["homedir"]="$PANDORA_CONSOLE";
\$config["homeurl"]="/pandora_console";
error_reporting(0);
\$ownDir = dirname(__FILE__) . '/';
include (\$ownDir . "config_process.php");
EO_CONFIG_F
#Enable allow Override
cat > /etc/apache2/conf-enabled/pandora_security.conf << EO_CONFIG_F
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
EO_CONFIG_F
#Enable quickshell proxy
cat >> /etc/apache2/mods-enabled/00-proxy.conf << 'EO_HTTPD_WSTUNNEL'
ProxyRequests Off
<Proxy *>
Require all granted
</Proxy>
ProxyPass /ws ws://127.0.0.1:8080
ProxyPassReverse /ws ws://127.0.0.1:8080
EO_HTTPD_WSTUNNEL
# Fixing console permissions
chmod 600 $PANDORA_CONSOLE/include/config.php &>> "$LOGFILE"
chown -R www-data:www-data $PANDORA_CONSOLE &>> "$LOGFILE"
mv $PANDORA_CONSOLE/install.php $PANDORA_CONSOLE/install.done &>> "$LOGFILE"
# Prepare php.ini
## Prepare php config
ln -s /etc/php/$PHPVER/fpm/php.ini /etc/
sed --follow-symlinks -i -e "s/^max_input_time.*/max_input_time = -1/g" /etc/php.ini
sed --follow-symlinks -i -e "s/^max_execution_time.*/max_execution_time = 0/g" /etc/php.ini
sed --follow-symlinks -i -e "s/^upload_max_filesize.*/upload_max_filesize = 800M/g" /etc/php.ini
sed --follow-symlinks -i -e "s/^memory_limit.*/memory_limit = 800M/g" /etc/php.ini
sed --follow-symlinks -i -e "s/.*post_max_size =.*/post_max_size = 800M/" /etc/php.ini
sed --follow-symlinks -i -e "s/^disable_functions/;disable_functions/" /etc/php.ini
#adding 900s to httpd timeout
#echo 'TimeOut 900' > /etc/httpd/conf.d/timeout.conf
cat > /var/www/html/index.html << EOF_INDEX
<meta HTTP-EQUIV="REFRESH" content="0; url=/pandora_console/">
EOF_INDEX
execute_cmd "systemctl restart apache2" "Restarting apache2 after configuration"
execute_cmd "systemctl restart php$PHPVER-fpm" "Restarting php$PHPVER-fpm after configuration"
# prepare snmptrapd
cat > /etc/snmp/snmptrapd.conf << EOF
authCommunity log public
disableAuthorization yes
EOF
# Prepare Server conf
sed -i -e "s/^dbhost.*/dbhost $DBHOST/g" $PANDORA_SERVER_CONF
sed -i -e "s/^dbname.*/dbname $DBNAME/g" $PANDORA_SERVER_CONF
sed -i -e "s/^dbuser.*/dbuser $DBUSER/g" $PANDORA_SERVER_CONF
sed -i -e "s|^dbpass.*|dbpass $DBPASS|g" $PANDORA_SERVER_CONF
sed -i -e "s/^dbport.*/dbport $DBPORT/g" $PANDORA_SERVER_CONF
sed -i -e "s/^#.mssql_driver.*/mssql_driver $MS_ID/g" $PANDORA_SERVER_CONF
# Adding group www-data to pandora server conf.
grep -q "group www-data" $PANDORA_SERVER_CONF || \
cat >> $PANDORA_SERVER_CONF << EOF_G
#Adding group www-data to assing remote-config permission correctly for ubuntu 22.04
group www-data
EOF_G
# Enable agent remote config
sed -i "s/^remote_config.*$/remote_config 1/g" $PANDORA_AGENT_CONF
# Set Oracle environment for pandora_server
cat > /etc/pandora/pandora_server.env << 'EOF_ENV'
#!/bin/bash
VERSION=19.8
export PATH=$PATH:/opt/oracle/instantclient_19_8
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/oracle/instantclient_19_8
export ORACLE_HOME=/opt/oracle/instantclient_19_8
export OPENSSL_CONF=/etc/ssl
EOF_ENV
# 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
# Fix pandora_server.{log,error} permissions to allow Console check them
chown pandora:www-data /var/log/pandora
chmod g+s /var/log/pandora
cat > /etc/logrotate.d/pandora_server <<EO_LR
/var/log/pandora/pandora_server.log
/var/log/pandora/web_socket.log
/var/log/pandora/pandora_server.error {
su root apache
weekly
missingok
size 300000
rotate 3
maxage 90
compress
notifempty
copytruncate
create 660 pandora apache
}
/var/log/pandora/pandora_snmptrap.log {
su root apache
weekly
missingok
size 500000
rotate 1
maxage 30
notifempty
copytruncate
create 660 pandora apache
}
EO_LR
cat > /etc/logrotate.d/pandora_agent <<EO_LRA
/var/log/pandora/pandora_agent.log {
su root apache
weekly
missingok
size 300000
rotate 3
maxage 90
compress
notifempty
copytruncate
}
EO_LRA
chmod 0644 /etc/logrotate.d/pandora_server
chmod 0644 /etc/logrotate.d/pandora_agent
# Add websocket engine start script.
mv /var/www/html/pandora_console/pandora_websocket_engine /etc/init.d/ &>> "$LOGFILE"
chmod +x /etc/init.d/pandora_websocket_engine
# Start Websocket engine
/etc/init.d/pandora_websocket_engine start &>> "$LOGFILE"
# Configure websocket to be started at start.
systemctl enable pandora_websocket_engine &>> "$LOGFILE"
# Enable pandora ha service
execute_cmd "/etc/init.d/pandora_server start" "Starting Pandora FMS Server"
systemctl enable pandora_server &>> "$LOGFILE"
# starting tentacle server
execute_cmd "service tentacle_serverd start" "Starting Tentacle Server"
systemctl enable tentacle_serverd &>> "$LOGFILE"
# 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"
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 agent adn configuring Agente
sed -i "s/^remote_config.*$/remote_config 1/g" $PANDORA_AGENT_CONF &>> "$LOGFILE"
execute_cmd "/etc/init.d/pandora_agent_daemon start" "Starting PandoraFSM Agent"
systemctl enable pandora_agent_daemon &>> "$LOGFILE"
#fix path phantomjs
sed --follow-symlinks -i -e "s/^openssl_conf = openssl_init/#openssl_conf = openssl_init/g" /etc/ssl/openssl.cnf &>> "$LOGFILE"
#SSH banner
[ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me)
cat > /etc/issue.net << EOF_banner
Welcome to Pandora FMS appliance on CentOS
------------------------------------------
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"}')
You can find more information at http://pandorafms.com
EOF_banner
rm -f /etc/issue
ln -s /etc/issue.net /etc/issue
echo 'Banner /etc/issue.net' >> /etc/ssh/sshd_config
# Remove temporary files
execute_cmd "echo done" "Pandora FMS Community installed"
cd "$HOME"
execute_cmd "rm -rf $WORKDIR" "Removing temporary files"
# Print nice finish message
GREEN='\033[01;32m'
NONE='\033[0m'
printf " -> Go to Public ${green}http://"$ipplublic"/pandora_console${reset} to manage this server"
ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v -e "172.1[0-9].0.1" | awk '{print $2}' | awk -v g=$GREEN -v n=$NONE -F '/' '{printf "\n -> Go to Local "g"http://"$1"/pandora_console"n" to manage this server \n -> Use these credentials to log in Pandora Console "g"[ User: admin / Password: pandora ]"n" \n"}'

View File

@ -1,113 +0,0 @@
#!/bin/bash
set -eo pipefail
# if command starts with an option, prepend mysqld
if [ "${1:0:1}" = '-' ]; then
set -- mysqld "$@"
fi
if [ "$1" = 'mysqld' ]; then
# Get config
DATADIR="$("$@" --verbose --help --log-bin-index=`mktemp -u` 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')"
if [ ! -d "$DATADIR/mysql" ]; then
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
echo >&2 'error: database is uninitialized and password option is not specified '
echo >&2 ' You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD'
exit 1
fi
mkdir -p "$DATADIR"
chown -R mysql:mysql "$DATADIR"
echo 'Initializing database'
mysql_install_db --user=mysql --datadir="$DATADIR" --rpm --keep-my-cnf
echo 'Database initialized'
"$@" --skip-networking &
pid="$!"
mysql=( mysql --protocol=socket -uroot )
for i in {30..0}; do
if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then
break
fi
echo 'MySQL init process in progress...'
sleep 1
done
if [ "$i" = 0 ]; then
echo >&2 'MySQL init process failed.'
exit 1
fi
if [ -z "$MYSQL_INITDB_SKIP_TZINFO" ]; then
# sed is for https://bugs.mysql.com/bug.php?id=20545
mysql_tzinfo_to_sql /usr/share/zoneinfo | sed 's/Local time zone must be set--see zic manual page/FCTY/' | "${mysql[@]}" mysql
fi
if [ ! -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
MYSQL_ROOT_PASSWORD="$(pwgen -1 32)"
echo "GENERATED ROOT PASSWORD: $MYSQL_ROOT_PASSWORD"
fi
"${mysql[@]}" <<-EOSQL
-- What's done in this file shouldn't be replicated
-- or products like mysql-fabric won't work
SET @@SESSION.SQL_LOG_BIN=0;
DELETE FROM mysql.user ;
CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ;
DROP DATABASE IF EXISTS test ;
FLUSH PRIVILEGES ;
EOSQL
if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then
mysql+=( -p"${MYSQL_ROOT_PASSWORD}" )
fi
if [ "$MYSQL_DATABASE" ]; then
echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;" | "${mysql[@]}"
mysql+=( "$MYSQL_DATABASE" )
fi
if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then
echo "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;" | "${mysql[@]}"
if [ "$MYSQL_DATABASE" ]; then
echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* TO '$MYSQL_USER'@'%' ;" | "${mysql[@]}"
fi
echo 'FLUSH PRIVILEGES ;' | "${mysql[@]}"
fi
echo
for f in /docker-entrypoint-initdb.d/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;;
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo
done
if [ ! -z "$MYSQL_ONETIME_PASSWORD" ]; then
"${mysql[@]}" <<-EOSQL
ALTER USER 'root'@'%' PASSWORD EXPIRE;
EOSQL
fi
if ! kill -s TERM "$pid" || ! wait "$pid"; then
echo >&2 'MySQL init process failed.'
exit 1
fi
echo
echo 'MySQL init process done. Ready for start up.'
echo
fi
chown -R mysql:mysql "$DATADIR"
fi
exec "$@"

View File

@ -1,57 +0,0 @@
FROM pandorafms/pandorafms-base:centos7
# Build variables.
ARG BRANCH=develop
ARG DB_PASS=pandora
# Clone the Pandora FMS repo.
RUN git clone --depth 1 -b "$BRANCH" https://github.com/pandorafms/pandorafms.git /tmp/pandorafms || \
git clone --depth 1 -b develop https://github.com/pandorafms/pandorafms.git /tmp/pandorafms
# Install the Pandora FMS Server.
RUN cd /tmp/pandorafms/pandora_server && \
yes | ./pandora_server_installer --install && \
sed -i "s/^dbuser.*/dbuser root/" /etc/pandora/pandora_server.conf && \
sed -i "s/^dbpass.*/dbpass $DB_PASS/" /etc/pandora/pandora_server.conf
# Install the Pandora FMS Agent.
RUN cd /tmp/pandorafms/pandora_agents/unix && \
./pandora_agent_installer --install
# Set the server's name in Apache's configuration file to avoid warnings.
RUN sed -i "s/#ServerName.*/ServerName localhost:80/" /etc/httpd/conf/httpd.conf
# Install the Pandora FMS Console.
RUN rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql && \
mkdir -p /var/log/mysql/ && chown mysql. /var/log/mysql && \
chown mysql. -R /var/lib/mysql && \
sudo -u mysql mysqld --initialize --explicit_defaults_for_timestamp && \
sudo -u mysql mysqld --daemonize & \
sleep 50 && \
mysql_default_pass=$(cat /var/log/mysqld.log | grep "temporary password" | awk '{print $NF}') && \
mysqladmin -u root -p"$mysql_default_pass" --user=root password 'pandora' && \
httpd -k start && \
cp -r /tmp/pandorafms/pandora_console /var/www/html && \
chown -R apache.apache /var/www/html/pandora_console/ && \
python /tmp/pandorafms/tests/install_console.py
# Redirect HTTP requests to / to the Pandora FMS Console.
RUN echo '<meta http-equiv="refresh" content="0;url=/pandora_console">' > /var/www/html/index.html
# Create the entrypoint script.
RUN echo -e '#/bin/bash\n \
sudo -u mysql mysqld --daemonize &&\n \
httpd -k start &&\n \
/usr/sbin/crond &&\n \
/etc/init.d/pandora_agent_daemon start && \
/etc/init.d/pandora_server start && \
tail -f /var/log/pandora/pandora_server.log' \
>> /entrypoint.sh && \
chmod +x /entrypoint.sh
# Clean-up.
RUN rm -rf /tmp/pandorafms
RUN yum clean all
EXPOSE 80 3306 41121
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

View File

@ -1,4 +0,0 @@
#!/bin/bash
docker build --rm=true --pull --no-cache --build-arg BRANCH="develop" --build-arg DB_PASS="pandora" -t pandorafms/pandorafms:7 . && \
[ "$QA_ENV" == "" ] && \
docker push pandorafms/pandorafms:7

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.763, AIX version # Version 7.0NG.764, 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.763, FreeBSD Version # Version 7.0NG.764, 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.763, HP-UX Version # Version 7.0NG.764, 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.763, GNU/Linux # Version 7.0NG.764, 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.763, GNU/Linux # Version 7.0NG.764, 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.763, Solaris Version # Version 7.0NG.764, 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.763 # Version 7.0NG.764
# 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,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.763, AIX version # Version 7.0NG.764, 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.763 # Version 7.0NG.764
# 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.763, HPUX Version # Version 7.0NG.764, 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.763 # Version 7.0NG.764
# 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.763 # Version 7.0NG.764
# 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.763 # Version 7.0NG.764
# 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.763, Solaris version # Version 7.0NG.764, 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.763, AIX version # Version 7.0NG.764, 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.763-220810 Version: 7.0NG.764-220921
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.763-220810" pandora_version="7.0NG.764-220921"
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.763" VERSION="7.0NG.764"
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.763" onConclusion="none">pandorafms_src.pdk</pkg-ref> <pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.764" 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.763" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref> <pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.764" 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.763</string> <key>CFBundleVersion</key> <string>7.0NG.764</string>
<key>CFBundleGetInfoString</key> <string>7.0NG.763 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string> <key>CFBundleGetInfoString</key> <string>7.0NG.764 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
<key>CFBundleShortVersionString</key> <string>7.0NG.763</string> <key>CFBundleShortVersionString</key> <string>7.0NG.764</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.763, GNU/Linux # Version 7.0NG.764, 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.763, FreeBSD Version # Version 7.0NG.764, 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.763, HP-UX Version # Version 7.0NG.764, 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.763, GNU/Linux # Version 7.0NG.764, 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.763, GNU/Linux # Version 7.0NG.764, 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.763, NetBSD Version # Version 7.0NG.764, 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.763, Solaris Version # Version 7.0NG.764, 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

@ -1014,8 +1014,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.763'; use constant AGENT_VERSION => '7.0NG.764';
use constant AGENT_BUILD => '220810'; use constant AGENT_BUILD => '220921';
# 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

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.763 %define version 7.0NG.764
%define release 220810 %define release 220921
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.763 %define version 7.0NG.764
%define release 220810 %define release 220921
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

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.763" PI_VERSION="7.0NG.764"
PI_BUILD="220810" PI_BUILD="220921"
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.763 # Version 7.0NG.764
# 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.763} {Pandora FMS Windows Agent v7.0NG.764}
ApplicationID ApplicationID
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F} {17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{220810} {220921}
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.763 Build 220810") #define PANDORA_VERSION ("7.0NG.764 Build 220921")
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.763(Build 220810))" VALUE "ProductVersion", "(7.0NG.764(Build 220921))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,15 +0,0 @@
FROM mysql:5.5
MAINTAINER Pandora FMS Team <info@pandorafms.com>
WORKDIR /pandorafms/pandora_console
ADD pandoradb.sql /docker-entrypoint-initdb.d
ADD pandoradb_data.sql /docker-entrypoint-initdb.d
RUN chown mysql /docker-entrypoint-initdb.d
ENV MYSQL_DATABASE=pandora
RUN echo " \n\
sed -i \"1iUSE \$MYSQL_DATABASE\" /docker-entrypoint-initdb.d/pandoradb.sql \n\
sed -i \"1iUSE \$MYSQL_DATABASE\" /docker-entrypoint-initdb.d/pandoradb_data.sql \n\
" >> /docker-entrypoint-initdb.d/create_pandoradb.sh

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.763-220810 Version: 7.0NG.764-220921
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.763-220810" pandora_version="7.0NG.764-220921"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -1,62 +0,0 @@
FROM centos:centos6
MAINTAINER Pandora FMS Team <info@pandorafms.com>
RUN { \
echo '[EPEL]'; \
echo 'name = CentOS Epel'; \
echo 'baseurl = http://dl.fedoraproject.org/pub/epel/6/x86_64'; \
echo 'enabled=1'; \
echo 'gpgcheck=0'; \
} > /etc/yum.repos.d/extra_repos.repo
RUN { \
echo '[artica_pandorafms]'; \
echo 'name=CentOS6 - PandoraFMS official repo'; \
echo 'baseurl=http://artica.es/centos6'; \
echo 'gpgcheck=0'; \
echo 'enabled=1'; \
} > /etc/yum.repos.d/pandorafms.repo
RUN yum -y update; yum clean all;
RUN yum install -y \
git \
httpd \
cronie \
ntp \
openldap \
nfdump \
wget \
curl \
openldap \
plymouth \
xterm \
php \
php-gd \
graphviz \
php-mysql \
php-pear-DB \
php-pear \
php-pdo \
php-mbstring \
php-ldap \
php-snmp \
php-ldap \
php-common \
php-zip \
nmap \
net-snmp-utils \
mod_ssl \
xprobe2
#Clone the repo
RUN git clone -b develop https://github.com/pandorafms/pandorafms.git /tmp/pandorafms
#Exposing ports for: HTTP, SNMP Traps, Tentacle protocol
EXPOSE 80 162/udp 443 41121
# Simple startup script to avoid some issues observed with container restart
ADD docker_entrypoint.sh /entrypoint.sh
RUN chmod -v +x /entrypoint.sh
CMD ["/entrypoint.sh"]

View File

@ -1,80 +0,0 @@
#!/bin/bash
set -e
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$PANDORA_DB_HOST" ]; then
PANDORA_DB_HOST='mysql'
else
echo >&2 'warning: both PANDORA_DB_HOST and MYSQL_PORT_3306_TCP found'
echo >&2 " Connecting to PANDORA_DB_HOST ($PANDORA_DB_HOST)"
echo >&2 ' instead of the linked mysql container'
fi
fi
if [ -z "$PANDORA_DB_HOST" ]; then
echo >&2 'error: missing PANDORA_DB_HOST and MYSQL_PORT_3306_TCP environment variables'
echo >&2 ' Did you forget to --link some_mysql_container:mysql or set an external db'
echo >&2 ' with -e PANDORA_DB_HOST=hostname:port?'
exit 1
fi
# if we're linked to MySQL and thus have credentials already, let's use them
: ${PANDORA_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}
if [ "$PANDORA_DB_USER" = 'root' ]; then
: ${PANDORA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
fi
: ${PANDORA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_PASSWORD}
if [ -z "$PANDORA_DB_NAME" ]; then
: ${PANDORA_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-pandora}}
fi
if [ -z "$PANDORA_DB_PASSWORD" ]; then
echo >&2 'error: missing required PANDORA_DB_PASSWORD environment variable'
echo >&2 ' Did you forget to -e PANDORA_DB_PASSWORD=... ?'
echo >&2
echo >&2 ' (Also of interest might be PANDORA_DB_USER and PANDORA_DB_NAME.)'
exit 1
fi
mv -f /tmp/pandorafms/pandora_console /var/www/html
cd /var/www/html/pandora_console/include
cat > config.php <<- 'EOF'
<?php
$config["dbtype"] = "mysql";
$config["homedir"]="/var/www/html/pandora_console"; // Config homedir
$config["homeurl"]="/pandora_console"; // Base URL
$config["homeurl_static"]="/pandora_console"; // Don't delete
error_reporting(E_ALL);
$ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
EOF
echo "\$config[\"dbname\"]=\"$PANDORA_DB_NAME\";" >> config.php
echo "\$config[\"dbuser\"]=\"$PANDORA_DB_USER\";" >> config.php
echo "\$config[\"dbpass\"]=\"$PANDORA_DB_PASSWORD\";" >> config.php
echo "\$config[\"dbhost\"]=\"$PANDORA_DB_HOST\";" >> config.php
echo "include (\$ownDir . \"config_process.php\");" >> config.php
echo "?>" >> config.php
echo "Granting apache permissions to the console directory"
chown -R apache:apache /var/www/html/pandora_console
chmod 600 /var/www/html/pandora_console/include/config.php
# Customize php.iniA
echo "Configuring Pandora FMS elements and depending services"
sed "s/.*error_reporting =.*/error_reporting = E_ALL \& \~E_DEPRECATED \& \~E_NOTICE \& \~E_USER_WARNING/" /etc/php.ini > /tmp/php.ini && mv /tmp/php.ini /etc/php.ini
sed "s/.*max_execution_time =.*/max_execution_time = 0/" /etc/php.ini > /tmp/php.ini && mv /tmp/php.ini /etc/php.ini
sed "s/.*max_input_time =.*/max_input_time = -1/" /etc/php.ini > /tmp/php.ini && mv /tmp/php.ini /etc/php.ini
sed "s/.*upload_max_filesize =.*/upload_max_filesize = 800M/" /etc/php.ini > /tmp/php.ini && mv /tmp/php.ini /etc/php.ini
sed "s/.*memory_limit =.*/memory_limit = 800M/" /etc/php.ini > /tmp/php.ini && mv /tmp/php.ini /etc/php.ini
sed "s/.*post_max_size =.*/post_max_size = 100M/" /etc/php.ini > /tmp/php.ini && mv /tmp/php.ini /etc/php.ini
cd /var/www/html/pandora_console && mv -f install.php install.php.done
#Create the pandora user
/usr/sbin/useradd -d /home/pandora -s /bin/false -M -g 0 pandora
#Rock n' roll!
/etc/init.d/crond start &
/etc/init.d/ntpd start &
rm -rf /run/httpd/*
exec /usr/sbin/apachectl -D FOREGROUND

View File

@ -43,20 +43,11 @@ function dbmanager_query($sql, &$error, $dbconnection)
$error = mysqli_error($dbconnection); $error = mysqli_error($dbconnection);
return false; return false;
} }
} else {
$result = mysql_query($sql, $dbconnection);
if ($result === false) {
$backtrace = debug_backtrace();
$error = mysql_error();
return false;
}
} }
if ($result === true) { if ($result === true) {
if ($config['mysqli']) { if ($config['mysqli']) {
return mysqli_affected_rows($dbconnection); return mysqli_affected_rows($dbconnection);
} else {
return mysql_affected_rows();
} }
} }
@ -64,23 +55,17 @@ function dbmanager_query($sql, &$error, $dbconnection)
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
array_push($retval, $row); array_push($retval, $row);
} }
} else {
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
array_push($retval, $row);
}
} }
if ($config['mysqli']) { if ($config['mysqli']) {
mysqli_free_result($result); mysqli_free_result($result);
} else {
mysql_free_result($result);
} }
if (! empty($retval)) { if (! empty($retval)) {
return $retval; return $retval;
} }
// Return false, check with === or !== // Return false, check with === or !== .
return 'Empty'; return 'Empty';
} }
@ -171,20 +156,6 @@ function dbmgr_extension_main()
$data[1][0] = "Some samples of usage: <blockquote><em>SHOW STATUS;<br />DESCRIBE tagente<br />SELECT * FROM tserver<br />UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'</em></blockquote>"; $data[1][0] = "Some samples of usage: <blockquote><em>SHOW STATUS;<br />DESCRIBE tagente<br />SELECT * FROM tserver<br />UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'</em></blockquote>";
\enterprise_include_once('include/functions_metaconsole.php');
$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 = [];
}
$data[2][0] = html_print_textarea( $data[2][0] = html_print_textarea(
'sql', 'sql',
5, 5,
@ -195,6 +166,21 @@ function dbmgr_extension_main()
); );
if (is_metaconsole() === true) { if (is_metaconsole() === true) {
// Get the servers.
\enterprise_include_once('include/functions_metaconsole.php');
$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 = [];
}
$data[3][2] = html_print_input( $data[3][2] = html_print_input(
[ [
'name' => 'node_id', 'name' => 'node_id',
@ -223,7 +209,7 @@ function dbmgr_extension_main()
html_print_table($table); html_print_table($table);
echo '</form>'; echo '</form>';
// Processing SQL Code // Processing SQL Code.
if ($sql == '') { if ($sql == '') {
return; return;
} }
@ -271,7 +257,7 @@ function dbmgr_extension_main()
return; return;
} }
if (! is_array($result)) { if (is_array($result) === false) {
echo '<strong>Output: <strong>'.$result; echo '<strong>Output: <strong>'.$result;
db_pandora_audit( db_pandora_audit(
@ -315,11 +301,10 @@ if (is_metaconsole() === true) {
); );
extensions_add_meta_function('dbmgr_extension_main'); extensions_add_meta_function('dbmgr_extension_main');
} else {
} }
// This adds a option in the operation menu // This adds a option in the operation menu.
extensions_add_godmode_menu_option(__('DB interface'), 'PM', 'gextensions', 'dbmanager/icon.png', 'v1r1', 'gdbman'); extensions_add_godmode_menu_option(__('DB interface'), 'PM', 'gextensions', 'dbmanager/icon.png', 'v1r1', 'gdbman');
// This sets the function to be called when the extension is selected in the operation menu // This sets the function to be called when the extension is selected in the operation menu.
extensions_add_godmode_function('dbmgr_extension_main'); extensions_add_godmode_function('dbmgr_extension_main');

View File

@ -38,6 +38,8 @@ ALTER TABLE `tautoconfig` ADD COLUMN `executed` TINYINT UNSIGNED NOT NULL DEFAUL
ALTER TABLE `tusuario` DROP COLUMN `metaconsole_assigned_server`; ALTER TABLE `tusuario` DROP COLUMN `metaconsole_assigned_server`;
ALTER TABLE `tagente` ADD COLUMN `fixed_ip` TINYINT UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE `tmetaconsole_agent` ADD COLUMN `fixed_ip` TINYINT UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE `tipam_network` DROP FOREIGN KEY `tipam_network_ibfk_1`; ALTER TABLE `tipam_network` DROP FOREIGN KEY `tipam_network_ibfk_1`;
ALTER TABLE `tipam_network` MODIFY COLUMN `id_recon_task` INT UNSIGNED DEFAULT 0; ALTER TABLE `tipam_network` MODIFY COLUMN `id_recon_task` INT UNSIGNED DEFAULT 0;
ALTER TABLE `tipam_network` ADD CONSTRAINT `tipam_network_ibfk_1` FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE SET NULL ON UPDATE CASCADE; ALTER TABLE `tipam_network` ADD CONSTRAINT `tipam_network_ibfk_1` FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -0,0 +1,9 @@
START TRANSACTION;
ALTER TABLE `tplanned_downtime` ADD COLUMN `cron_interval_from` VARCHAR(100) DEFAULT '';
ALTER TABLE `tplanned_downtime` ADD COLUMN `cron_interval_to` VARCHAR(100) DEFAULT '';
SET @id_config := (SELECT id_config FROM tconfig WHERE `token` = 'metaconsole_node_id' AND `value` IS NOT NULL ORDER BY id_config DESC LIMIT 1);
DELETE FROM tconfig WHERE `token` = 'metaconsole_node_id' AND (id_config < @id_config OR `value` IS NULL);
COMMIT;

View File

@ -137,7 +137,16 @@ $table->data[] = $tdata;
// Modules by status. // Modules by status.
$tdata = []; $tdata = [];
$tdata[0] = reporting_get_stats_modules_status($data, 180, 100);
$data_agents = [
__('Critical') => $data['monitor_critical'],
__('Warning') => $data['monitor_warning'],
__('Normal') => $data['monitor_ok'],
__('Unknown') => $data['monitor_unknown'],
__('Not init') => $data['monitor_not_init'],
];
$tdata[0] = reporting_get_stats_modules_status($data, 180, 100, false, $data_agents);
$table->rowclass[] = ''; $table->rowclass[] = '';
$table->data[] = $tdata; $table->data[] = $tdata;

View File

@ -302,6 +302,15 @@ $table_ip = '<div class="label_select"><p class="input_label">'.__('IP Address')
$table_ip .= '<div class="label_select_parent">'; $table_ip .= '<div class="label_select_parent">';
$table_ip .= '<div class="label_select_child_left">'.html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).'</div>'; $table_ip .= '<div class="label_select_child_left">'.html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).'</div>';
$table_ip .= '<div class="label_select_child_right">'.html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').'</div>'; $table_ip .= '<div class="label_select_child_right">'.html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').'</div>';
$table_ip .= '<div class="label_select_child_right">'.html_print_input(
[
'type' => 'switch',
'id' => 'fixed_ip',
'name' => 'fixed_ip',
'value' => $fixed_ip,
]
).__('Fix IP address').ui_print_help_tip(__('Avoid automatic IP address update when agent IP changes.'), true).'</div>';
$table_ip .= '</div></div>'; $table_ip .= '</div></div>';
if ($id_agente) { if ($id_agente) {
@ -310,7 +319,7 @@ if ($id_agente) {
$table_ip .= '<div class="label_select">'; $table_ip .= '<div class="label_select">';
$table_ip .= '<div class="label_select_parent">'; $table_ip .= '<div class="label_select_parent">';
$table_ip .= '<div class="label_select_child_left">'.html_print_select($ip_all, 'address_list', $direccion_agente, '', '', 0, true).'</div>'; $table_ip .= '<div class="label_select_child_left">'.html_print_select($ip_all, 'address_list', $direccion_agente, '', '', 0, true).'</div>';
$table_ip .= '<div class="label_select_child_right">'.html_print_checkbox_switch('delete_ip', 1, false, true).__('Delete selected').'</div>'; $table_ip .= '<div class="label_select_child_right">'.html_print_checkbox_switch('delete_ip', 1, false, true).__('Delete selected IPs').'</div>';
$table_ip .= '</div></div>'; $table_ip .= '</div></div>';
} }
@ -1114,5 +1123,19 @@ ui_require_jquery_file('bgiframe');
} }
$("#text-agente").prop('readonly', true); $("#text-agente").prop('readonly', true);
// Disable fixed ip button if empty.
if($("#text-direccion").val() == '') {
$("#fixed_ip").prop('disabled',true);
}
$("#text-direccion").on('input',function(e){
if($("#text-direccion").val() == '') {
$("#fixed_ip").prop('disabled',true);
} else {
$("#fixed_ip").prop('disabled',false);
}
});
}); });
</script> </script>

View File

@ -173,6 +173,7 @@ $url_description = '';
$quiet = 0; $quiet = 0;
$macros = ''; $macros = '';
$cps = 0; $cps = 0;
$fixed_ip = 0;
$create_agent = (bool) get_parameter('create_agent'); $create_agent = (bool) get_parameter('create_agent');
$module_macros = []; $module_macros = [];
@ -225,6 +226,7 @@ if ($create_agent) {
$url_description = (string) get_parameter('url_description'); $url_description = (string) get_parameter('url_description');
$quiet = (int) get_parameter('quiet', 0); $quiet = (int) get_parameter('quiet', 0);
$cps = (int) get_parameter_switch('cps', -1); $cps = (int) get_parameter_switch('cps', -1);
$fixed_ip = (int) get_parameter_switch('fixed_ip', 0);
$secondary_groups = (string) get_parameter('secondary_hidden', ''); $secondary_groups = (string) get_parameter('secondary_hidden', '');
$fields = db_get_all_fields_in_table('tagent_custom_fields'); $fields = db_get_all_fields_in_table('tagent_custom_fields');
@ -282,6 +284,7 @@ if ($create_agent) {
'url_address' => $url_description, 'url_address' => $url_description,
'quiet' => $quiet, 'quiet' => $quiet,
'cps' => $cps, 'cps' => $cps,
'fixed_ip' => $fixed_ip,
] ]
); );
enterprise_hook('update_agent', [$id_agente]); enterprise_hook('update_agent', [$id_agente]);
@ -326,7 +329,7 @@ if ($create_agent) {
"Update GIS data":"'.$update_gis_data.'", "Update GIS data":"'.$update_gis_data.'",
"Url description":"'.$url_description.'", "Url description":"'.$url_description.'",
"Quiet":"'.(int) $quiet.'", "Quiet":"'.(int) $quiet.'",
"Cps":"'.(int) $cps.'"}'; "Cps":"'.(int) $cps.'",}';
// Create the secondary groups. // Create the secondary groups.
enterprise_hook( enterprise_hook(
@ -987,6 +990,7 @@ if ($update_agent) {
$fields = db_get_all_fields_in_table('tagent_custom_fields'); $fields = db_get_all_fields_in_table('tagent_custom_fields');
$secondary_groups = (string) get_parameter('secondary_hidden', ''); $secondary_groups = (string) get_parameter('secondary_hidden', '');
$satellite_server = (int) get_parameter('satellite_server', 0); $satellite_server = (int) get_parameter('satellite_server', 0);
$fixed_ip = (int) get_parameter_switch('fixed_ip', 0);
if ($fields === false) { if ($fields === false) {
$fields = []; $fields = [];
@ -1048,9 +1052,10 @@ if ($update_agent) {
$exists_ip = db_get_row_sql($sql); $exists_ip = db_get_row_sql($sql);
} }
$old_group = agents_get_agent_group($id_agente);
if ($grupo <= 0) { if ($grupo <= 0) {
ui_print_error_message(__('The group id %d is incorrect.', $grupo)); ui_print_error_message(__('The group id %d is incorrect.', $grupo));
} else if (group_allow_more_agents($grupo, true, 'update') === false) { } else if ($old_group !== $grupo && group_allow_more_agents($grupo, true, 'update') === false) {
ui_print_error_message(__('Agent cannot be updated due to the maximum agent limit for this group')); ui_print_error_message(__('Agent cannot be updated due to the maximum agent limit for this group'));
} else if ($exists_ip) { } else if ($exists_ip) {
ui_print_error_message(__('Duplicate main IP address')); ui_print_error_message(__('Duplicate main IP address'));
@ -1095,6 +1100,7 @@ if ($update_agent) {
'cps' => $cps, 'cps' => $cps,
'safe_mode_module' => $safe_mode_module, 'safe_mode_module' => $safe_mode_module,
'satellite_server' => $satellite_server, 'satellite_server' => $satellite_server,
'fixed_ip' => $fixed_ip,
]; ];
if ($config['metaconsole_agent_cache'] == 1) { if ($config['metaconsole_agent_cache'] == 1) {
@ -1234,6 +1240,7 @@ if ($id_agente) {
$safe_mode_module = $agent['safe_mode_module']; $safe_mode_module = $agent['safe_mode_module'];
$safe_mode = ($safe_mode_module) ? 1 : 0; $safe_mode = ($safe_mode_module) ? 1 : 0;
$satellite_server = (int) $agent['satellite_server']; $satellite_server = (int) $agent['satellite_server'];
$fixed_ip = (int) $agent['fixed_ip'];
} }
$update_module = (bool) get_parameter('update_module'); $update_module = (bool) get_parameter('update_module');

View File

@ -754,7 +754,8 @@ if ($agents !== false) {
$in_planned_downtime = db_get_sql( $in_planned_downtime = db_get_sql(
'SELECT executed FROM tplanned_downtime 'SELECT executed FROM tplanned_downtime
INNER JOIN tplanned_downtime_agents ON tplanned_downtime.id = tplanned_downtime_agents.id_downtime INNER JOIN tplanned_downtime_agents ON tplanned_downtime.id = tplanned_downtime_agents.id_downtime
WHERE tplanned_downtime_agents.id_agent = '.$agent['id_agente'].' AND tplanned_downtime.executed = 1' WHERE tplanned_downtime_agents.id_agent = '.$agent['id_agente'].' AND tplanned_downtime.executed = 1
AND tplanned_downtime.type_downtime <> "disable_agent_modules"'
); );
if ($agent['disabled']) { if ($agent['disabled']) {

View File

@ -466,7 +466,14 @@ if ($module_action === 'delete') {
$id_agent_module_disable $id_agent_module_disable
); );
if (db_process_sql($sql)) { $id_agent_changed[] = modules_get_agentmodule_agent($id_agent_module_disable);
$agent_update_result = db_process_sql_update(
'tagente',
['update_module_count' => 1],
['id_agente' => $id_agent_changed]
);
if (db_process_sql($sql) !== false && $agent_update_result !== false) {
$updated_count++; $updated_count++;
} }
} }
@ -993,6 +1000,24 @@ foreach ($modules as $module) {
} }
if ($module['disabled']) { if ($module['disabled']) {
$dt_disabled_icon = '';
$in_planned_downtime = db_get_sql(
'SELECT executed FROM tplanned_downtime
INNER JOIN tplanned_downtime_modules ON tplanned_downtime.id = tplanned_downtime_modules.id_downtime
WHERE tplanned_downtime.executed = 1
AND tplanned_downtime.type_downtime = "disable_agent_modules"
AND tplanned_downtime_modules.id_agent_module = '.$module['id_agente_modulo']
);
if ($in_planned_downtime !== false) {
$dt_disabled_icon = ui_print_help_tip(
__('Module in scheduled downtime'),
true,
'images/minireloj-16.png'
);
}
$data[0] .= '<em class="disabled_module">'.ui_print_truncate_text( $data[0] .= '<em class="disabled_module">'.ui_print_truncate_text(
$module['nombre'], $module['nombre'],
'module_medium', 'module_medium',
@ -1001,7 +1026,7 @@ foreach ($modules as $module) {
true, true,
'[&hellip;]', '[&hellip;]',
'font-size: 7.2pt' 'font-size: 7.2pt'
).'</em>'; ).$dt_disabled_icon.'</em>';
} else { } else {
$data[0] .= ui_print_truncate_text( $data[0] .= ui_print_truncate_text(
$module['nombre'], $module['nombre'],

View File

@ -49,6 +49,7 @@ if (!$agent_d && !$agent_w) {
set_unless_defined($config['past_planned_downtimes'], 1); set_unless_defined($config['past_planned_downtimes'], 1);
require_once 'include/functions_users.php'; require_once 'include/functions_users.php';
require_once $config['homedir'].'/include/functions_cron.php';
// Buttons. // Buttons.
$buttons = [ $buttons = [
@ -123,6 +124,18 @@ $periodically_time_to = (string) get_parameter(
date(TIME_FORMAT, ($system_time + SECONDS_1HOUR)) date(TIME_FORMAT, ($system_time + SECONDS_1HOUR))
); );
$hour_from = get_parameter('cron_hour_from', '*');
$minute_from = get_parameter('cron_minute_from', '*');
$mday_from = get_parameter('cron_mday_from', '*');
$month_from = get_parameter('cron_month_from', '*');
$wday_from = get_parameter('cron_wday_from', '*');
$hour_to = get_parameter('cron_hour_to', '*');
$minute_to = get_parameter('cron_minute_to', '*');
$mday_to = get_parameter('cron_mday_to', '*');
$month_to = get_parameter('cron_month_to', '*');
$wday_to = get_parameter('cron_wday_to', '*');
$monday = (bool) get_parameter('monday'); $monday = (bool) get_parameter('monday');
$tuesday = (bool) get_parameter('tuesday'); $tuesday = (bool) get_parameter('tuesday');
$wednesday = (bool) get_parameter('wednesday'); $wednesday = (bool) get_parameter('wednesday');
@ -262,6 +275,193 @@ if ($create_downtime || $update_downtime) {
); );
} else { } else {
$sql = ''; $sql = '';
$error_cron_from = false;
$error_cron_to = false;
$error_field = '';
if ($type_execution === 'cron') {
// Validate 'from' cron values.
$hour_from = io_safe_output(trim($hour_from));
if (preg_match('/^((?:([0-1]?[0-9]|2[0-3])|\*)\s*(?:(?:[\/-]([0-1]?[0-9]|2[0-3])))?\s*)$/', $hour_from, $matches) !== 1) {
$error_cron_from = true;
$error_field = __('hour (from)');
} else {
$interval_values = explode('-', $hour_from);
if (count($interval_values) > 1) {
$interval_from = $interval_values[0];
$interval_to = $interval_values[1];
if ((int) $interval_to < (int) $interval_from) {
$error_cron_from = true;
}
}
}
$minute_from = io_safe_output(trim($minute_from));
if (preg_match('/^((?:(5[0-9]|[0-5]?[0-9])|\*)\s*(?:(?:[\/-](5[0-9]|[0-5]?[0-9])))?\s*)$/', $minute_from, $matches) !== 1) {
$error_cron_from = true;
$error_field = __('minute (from)');
} else {
$interval_values = explode('-', $minute_from);
if (count($interval_values) > 1) {
$interval_from = $interval_values[0];
$interval_to = $interval_values[1];
if ((int) $interval_to < (int) $interval_from) {
$error_cron_from = true;
}
}
}
$mday_from = io_safe_output(trim($mday_from));
if (preg_match('/^((?:(0?[1-9]|[12][0-9]|3[01])|\*)\s*(?:(?:[\/-](0?[1-9]|[12][0-9]|3[01])))?\s*)$/', $mday_from, $matches) !== 1) {
$error_cron_from = true;
$error_field = __('month day (from)');
} else {
$interval_values = explode('-', $mday_from);
if (count($interval_values) > 1) {
$interval_from = $interval_values[0];
$interval_to = $interval_values[1];
if ((int) $interval_to < (int) $interval_from) {
$error_cron_from = true;
}
}
}
$month_from = io_safe_output(trim($month_from));
if (preg_match('/^((?:([1-9]|1[012])|\*)\s*(?:(?:[\/-]([1-9]|1[012])))?\s*)$/', $month_from, $matches) !== 1) {
$error_cron_from = true;
$error_field = __('month (from)');
} else {
$interval_values = explode('-', $month_from);
if (count($interval_values) > 1) {
$interval_from = $interval_values[0];
$interval_to = $interval_values[1];
if ((int) $interval_to < (int) $interval_from) {
$error_cron_from = true;
}
}
}
$wday_from = io_safe_output(trim($wday_from));
if (preg_match('/^((?:[0-6]|\*)\s*(?:(?:[\/-][0-6]))?\s*)$/', $wday_from, $matches) !== 1) {
$error_cron_from = true;
$error_field = __('week day (from)');
} else {
$interval_values = explode('-', $wday_from);
if (count($interval_values) > 1) {
$interval_from = $interval_values[0];
$interval_to = $interval_values[1];
if ((int) $interval_to < (int) $interval_from) {
$error_cron_from = true;
}
}
}
// Validate 'to' cron values.
$hour_to = io_safe_output(trim($hour_to));
if (preg_match('/^((?:([0-1]?[0-9]|2[0-3])|\*)\s*(?:(?:[\/-]([0-1]?[0-9]|2[0-3])))?\s*)$/', $hour_to, $matches) !== 1) {
$error_cron_to = true;
$error_field = __('hour (to)');
} else {
$interval_values = explode('-', $hour_to);
if (count($interval_values) > 1) {
$interval_from = $interval_values[0];
$interval_to = $interval_values[1];
if ((int) $interval_to < (int) $interval_from) {
$error_cron_to = true;
}
}
}
$minute_to = io_safe_output(trim($minute_to));
if (preg_match('/^((?:(5[0-9]|[0-5]?[0-9])|\*)\s*(?:(?:[\/-](5[0-9]|[0-5]?[0-9])))?\s*)$/', $minute_to, $matches) !== 1) {
$error_cron_to = true;
$error_field = __('minute (to)');
} else {
$interval_values = explode('-', $minute_to);
if (count($interval_values) > 1) {
$interval_from = $interval_values[0];
$interval_to = $interval_values[1];
if ((int) $interval_to < (int) $interval_from) {
$error_cron_to = true;
}
}
}
$mday_to = io_safe_output(trim($mday_to));
if (preg_match('/^((?:(0?[1-9]|[12][0-9]|3[01])|\*)\s*(?:(?:[\/-](0?[1-9]|[12][0-9]|3[01])))?\s*)$/', $mday_to, $matches) !== 1) {
$error_cron_to = true;
$error_field = __('month day (to)');
} else {
$interval_values = explode('-', $mday_to);
if (count($interval_values) > 1) {
$interval_from = $interval_values[0];
$interval_to = $interval_values[1];
if ((int) $interval_to < (int) $interval_from) {
$error_cron_to = true;
}
}
}
$month_to = io_safe_output(trim($month_to));
if (preg_match('/^((?:([1-9]|1[012])|\*)\s*(?:(?:[\/-]([1-9]|1[012])))?\s*)$/', $month_to, $matches) !== 1) {
$error_cron_to = true;
$error_field = __('month (to)');
} else {
$interval_values = explode('-', $month_to);
if (count($interval_values) > 1) {
$interval_from = $interval_values[0];
$interval_to = $interval_values[1];
if ((int) $interval_to < (int) $interval_from) {
$error_cron_to = true;
}
}
}
$wday_to = io_safe_output(trim($wday_to));
if (preg_match('/^((?:[0-6]|\*)\s*(?:(?:[\/-][0-6]))?\s*)$/', $wday_to, $matches) !== 1) {
$error_cron_to = true;
$error_field = __('week day (to)');
} else {
$interval_values = explode('-', $wday_to);
if (count($interval_values) > 1) {
$interval_from = $interval_values[0];
$interval_to = $interval_values[1];
if ((int) $interval_to < (int) $interval_from) {
$error_cron_to = true;
}
}
}
$cron_interval_from = io_safe_output($minute_from.' '.$hour_from.' '.$mday_from.' '.$month_from.' '.$wday_from);
$cron_interval_to = io_safe_output($minute_to.' '.$hour_to.' '.$mday_to.' '.$month_to.' '.$wday_to);
}
if (cron_check_syntax($cron_interval_from) !== 1) {
$cron_interval_from = '';
}
if (cron_check_syntax($cron_interval_to) !== 1) {
$cron_interval_to = '';
}
if ($create_downtime) { if ($create_downtime) {
// Check AD permission on new downtime. // Check AD permission on new downtime.
if (!in_array($id_group, $user_groups_ad)) { if (!in_array($id_group, $user_groups_ad)) {
@ -273,50 +473,68 @@ if ($create_downtime || $update_downtime) {
return; return;
} }
if (trim(io_safe_output($name)) != '') { if ($error_cron_to === true || $error_cron_from === true) {
if (!$check) { if ($error_cron_from === true) {
$values = [
'name' => $name,
'description' => $description,
'date_from' => $datetime_from,
'date_to' => $datetime_to,
'executed' => 0,
'id_group' => $id_group,
'only_alerts' => 0,
'monday' => $monday,
'tuesday' => $tuesday,
'wednesday' => $wednesday,
'thursday' => $thursday,
'friday' => $friday,
'saturday' => $saturday,
'sunday' => $sunday,
'periodically_time_from' => $periodically_time_from,
'periodically_time_to' => $periodically_time_to,
'periodically_day_from' => $periodically_day_from,
'periodically_day_to' => $periodically_day_to,
'type_downtime' => $type_downtime,
'type_execution' => $type_execution,
'type_periodicity' => $type_periodicity,
'id_user' => $config['id_user'],
];
if ($config['dbtype'] == 'oracle') {
$values['periodically_time_from'] = '1970/01/01 '.$values['periodically_time_from'];
$values['periodically_time_to'] = '1970/01/01 '.$values['periodically_time_to'];
}
$result = db_process_sql_insert(
'tplanned_downtime',
$values
);
} else {
ui_print_error_message( ui_print_error_message(
__('Each scheduled downtime must have a different name') __('Downtime start cron expression is not correct').': '.$error_field
); );
} }
if ($error_cron_to === true) {
ui_print_error_message(
__('Downtime stop cron expression is not correct').': '.$error_field
);
}
$result = false;
} else { } else {
ui_print_error_message( if (trim(io_safe_output($name)) != '') {
__('Scheduled downtime must have a name') if (!$check) {
); $values = [
'name' => $name,
'description' => $description,
'date_from' => $datetime_from,
'date_to' => $datetime_to,
'executed' => 0,
'id_group' => $id_group,
'only_alerts' => 0,
'monday' => $monday,
'tuesday' => $tuesday,
'wednesday' => $wednesday,
'thursday' => $thursday,
'friday' => $friday,
'saturday' => $saturday,
'sunday' => $sunday,
'periodically_time_from' => $periodically_time_from,
'periodically_time_to' => $periodically_time_to,
'periodically_day_from' => $periodically_day_from,
'periodically_day_to' => $periodically_day_to,
'type_downtime' => $type_downtime,
'type_execution' => $type_execution,
'type_periodicity' => $type_periodicity,
'id_user' => $config['id_user'],
'cron_interval_from' => $cron_interval_from,
'cron_interval_to' => $cron_interval_to,
];
if ($config['dbtype'] == 'oracle') {
$values['periodically_time_from'] = '1970/01/01 '.$values['periodically_time_from'];
$values['periodically_time_to'] = '1970/01/01 '.$values['periodically_time_to'];
}
$result = db_process_sql_insert(
'tplanned_downtime',
$values
);
} else {
ui_print_error_message(
__('Each scheduled downtime must have a different name')
);
}
} else {
ui_print_error_message(
__('Scheduled downtime must have a name')
);
}
} }
} else if ($update_downtime) { } else if ($update_downtime) {
$old_downtime = db_get_row('tplanned_downtime', 'id', $id_downtime); $old_downtime = db_get_row('tplanned_downtime', 'id', $id_downtime);
@ -381,6 +599,8 @@ if ($create_downtime || $update_downtime) {
'type_execution' => $type_execution, 'type_execution' => $type_execution,
'type_periodicity' => $type_periodicity, 'type_periodicity' => $type_periodicity,
'id_user' => $config['id_user'], 'id_user' => $config['id_user'],
'cron_interval_from' => $cron_interval_from,
'cron_interval_to' => $cron_interval_to,
]; ];
if ($config['dbtype'] == 'oracle') { if ($config['dbtype'] == 'oracle') {
$values['periodically_time_from'] = '1970/01/01 '.$values['periodically_time_from']; $values['periodically_time_from'] = '1970/01/01 '.$values['periodically_time_from'];
@ -388,15 +608,31 @@ if ($create_downtime || $update_downtime) {
} }
} }
if ($is_running) { if ($error_cron_to === true || $error_cron_from === true) {
if ($error_cron_from === true) {
ui_print_error_message(
__('Downtime start cron expression is not correct').': '.$error_field
);
}
if ($error_cron_to === true) {
ui_print_error_message(
__('Downtime stop cron expression is not correct').': '.$error_field
);
}
$result = false; $result = false;
} else { } else {
if (!empty($values)) { if ($is_running) {
$result = db_process_sql_update( $result = false;
'tplanned_downtime', } else {
$values, if (!empty($values)) {
['id' => $id_downtime] $result = db_process_sql_update(
); 'tplanned_downtime',
$values,
['id' => $id_downtime]
);
}
} }
} }
} }
@ -458,6 +694,8 @@ if ($id_downtime > 0) {
'type_execution', 'type_execution',
'type_periodicity', 'type_periodicity',
'id_user', 'id_user',
'cron_interval_from',
'cron_interval_to',
]; ];
switch ($config['dbtype']) { switch ($config['dbtype']) {
@ -532,6 +770,36 @@ if ($id_downtime > 0) {
$saturday = (bool) $result['saturday']; $saturday = (bool) $result['saturday'];
$sunday = (bool) $result['sunday']; $sunday = (bool) $result['sunday'];
$cron_interval_from = explode(' ', $result['cron_interval_from']);
if (isset($cron_interval_from[4]) === true) {
$minute_from = $cron_interval_from[0];
$hour_from = $cron_interval_from[1];
$mday_from = $cron_interval_from[2];
$month_from = $cron_interval_from[3];
$wday_from = $cron_interval_from[4];
} else {
$minute_from = '*';
$hour_from = '*';
$mday_from = '*';
$month_from = '*';
$wday_from = '*';
}
$cron_interval_to = explode(' ', $result['cron_interval_to']);
if (isset($cron_interval_to[4]) === true) {
$minute_to = $cron_interval_to[0];
$hour_to = $cron_interval_to[1];
$mday_to = $cron_interval_to[2];
$month_to = $cron_interval_to[3];
$wday_to = $cron_interval_to[4];
} else {
$minute_to = '*';
$hour_to = '*';
$mday_to = '*';
$month_to = '*';
$wday_to = '*';
}
$running = (bool) $result['executed']; $running = (bool) $result['executed'];
} }
@ -593,6 +861,7 @@ $table->data[3][1] = html_print_select(
[ [
'quiet' => __('Quiet'), 'quiet' => __('Quiet'),
'disable_agents' => __('Disabled Agents'), 'disable_agents' => __('Disabled Agents'),
'disable_agent_modules' => __('Disable Modules'),
'disable_agents_alerts' => __('Disabled only Alerts'), 'disable_agents_alerts' => __('Disabled only Alerts'),
], ],
'type_downtime', 'type_downtime',
@ -611,6 +880,7 @@ $table->data[4][1] = html_print_select(
[ [
'once' => __('Once'), 'once' => __('Once'),
'periodically' => __('Periodically'), 'periodically' => __('Periodically'),
'cron' => __('Cron from/to'),
], ],
'type_execution', 'type_execution',
$type_execution, $type_execution,
@ -740,6 +1010,18 @@ $table->data[5][1] = "
</td> </td>
</tr> </tr>
</table> </table>
</div>
<div id="cron_time" style="display: none;">
<table class="w100p">
<tr>
<td>'.__('Cron from:').'</td>
<td>'.html_print_extended_select_for_cron($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, false, false, true, 'from').'</td>
</tr>
<tr>
<td>'.__('Cron to:').'</td>
<td>'.html_print_extended_select_for_cron($hour_to, $minute_to, $mday_to, $month_to, $wday_to, true, false, true, true, 'to').'</td>
</tr>
</table>
</div>'; </div>';
if ($id_downtime > 0) { if ($id_downtime > 0) {
@ -797,13 +1079,29 @@ $table = new StdClass();
$table->class = 'databox filters'; $table->class = 'databox filters';
$table->width = '100%'; $table->width = '100%';
$table->data = []; $table->data = [];
$table->size[0] = '25%';
$table->data[0][0] = __('Group filter'); $table->data[0][0] = __('Group filter');
$table->data[0][1] = html_print_select_groups(false, $access, $return_all_group, 'filter_group', $filter_group, '', '', '', true, false, true, '', false, 'min-width:180px;margin-right:15px;'); $table->data[0][1] = html_print_select_groups(
false,
$access,
$return_all_group,
'filter_group',
$filter_group,
'',
'',
'',
true,
false,
true,
'',
false,
'min-width:180px;margin-right:15px;'
);
$table->data[0][2] = __('Recursion').'&nbsp&nbsp'.html_print_checkbox('recursion', 1, $recursion, true, false, ''); $table->data[0][2] = __('Recursion').'&nbsp&nbsp'.html_print_checkbox('recursion', 1, $recursion, true, false, '');
$table->data[1][0] = __('Available agents'); $table->data[1][0] = __('Available agents');
$table->data[1][1] = html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, true, true, true, '', false, 'width: 180px;'); $table->data[1][1] = html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, true, true, true, '', false, 'min-width: 250px;width: 70%;');
if ($type_downtime != 'quiet') { if ($type_downtime != 'quiet') {
@ -855,7 +1153,7 @@ $table->data[3][1] = html_print_select(
true, true,
'', '',
false, false,
'width: 180px;' 'min-width: 250px;width: 70%;'
); );
echo '</div>'; echo '</div>';
@ -1238,12 +1536,19 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
switch ($("#type_execution").val()) { switch ($("#type_execution").val()) {
case 'once': case 'once':
$("#periodically_time").hide(); $("#periodically_time").hide();
$("#cron_time").hide();
$("#once_time").show(); $("#once_time").show();
break; break;
case 'periodically': case 'periodically':
$("#once_time").hide(); $("#once_time").hide();
$("#cron_time").hide();
$("#periodically_time").show(); $("#periodically_time").show();
break; break;
case 'cron':
$("#once_time").hide();
$("#periodically_time").hide();
$("#cron_time").show();
break;
} }
} }

View File

@ -317,6 +317,7 @@ $row = [];
$execution_type_fields = [ $execution_type_fields = [
'once' => __('Once'), 'once' => __('Once'),
'periodically' => __('Periodically'), 'periodically' => __('Periodically'),
'cron' => __('Cron'),
]; ];
$row[] = __('Execution type').'&nbsp;'.html_print_select( $row[] = __('Execution type').'&nbsp;'.html_print_select(
$execution_type_fields, $execution_type_fields,
@ -460,10 +461,15 @@ if (empty($groups) === false) {
strtotime($date_to.' 23:59:59') strtotime($date_to.' 23:59:59')
); );
$cron = sprintf(
'type_execution = "cron"'
);
$where_values .= sprintf( $where_values .= sprintf(
' AND ((%s) OR (%s))', ' AND ((%s) OR (%s) OR (%s))',
$periodically_w, $periodically_w,
$once_w $once_w,
$cron
); );
} }
@ -471,6 +477,7 @@ if (empty($groups) === false) {
$filter_performed = true; $filter_performed = true;
$where_values .= sprintf( $where_values .= sprintf(
' AND (type_execution = "periodically" ' AND (type_execution = "periodically"
OR type_execution = "cron"
OR (type_execution = "once" OR (type_execution = "once"
AND date_to >= "%s"))', AND date_to >= "%s"))',
time() time()
@ -530,6 +537,8 @@ if (empty($groups) === false) {
'type_execution', 'type_execution',
'type_periodicity', 'type_periodicity',
'id_user', 'id_user',
'cron_interval_from',
'cron_interval_to',
]; ];
$columns_str = implode(',', $columns); $columns_str = implode(',', $columns);
@ -660,8 +669,9 @@ if ($downtimes === false && $filter_performed === false) {
$data['type'] = $type_text[$downtime['type_downtime']]; $data['type'] = $type_text[$downtime['type_downtime']];
$execution_text = [ $execution_text = [
'once' => __('once'), 'once' => __('Once'),
'periodically' => __('Periodically'), 'periodically' => __('Periodically'),
'cron' => __('Cron'),
]; ];
$data['execution'] = $execution_text[$downtime['type_execution']]; $data['execution'] = $execution_text[$downtime['type_execution']];

View File

@ -195,56 +195,55 @@ $simple_alerts = [];
$total = 0; $total = 0;
$where = ''; $where = '';
if ($searchFlag) {
if ($status_alert === 'fired') {
$where .= ' AND talert_template_modules.times_fired > 0';
}
if ($status_alert === 'notfired') { if ($status_alert === 'fired') {
$where .= ' AND talert_template_modules.times_fired = 0'; $where .= ' AND talert_template_modules.times_fired > 0';
} }
if ($priority != -1 && $priority != '') { if ($status_alert === 'notfired') {
$where .= ' AND id_alert_template IN (SELECT id FROM talert_templates WHERE priority = '.$priority.')'; $where .= ' AND talert_template_modules.times_fired = 0';
} }
if (strlen(trim($templateName)) > 0) { if ($priority != -1 && $priority != '') {
$where .= " AND id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE '%".trim($templateName)."%')"; $where .= ' AND id_alert_template IN (SELECT id FROM talert_templates WHERE priority = '.$priority.')';
} }
if (strlen(trim($fieldContent)) > 0) { if (strlen(trim($templateName)) > 0) {
$where .= " AND id_alert_template IN (SELECT id FROM talert_templates $where .= " AND id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE '%".trim($templateName)."%')";
}
if (strlen(trim($fieldContent)) > 0) {
$where .= " AND id_alert_template IN (SELECT id FROM talert_templates
WHERE field1 LIKE '%".trim($fieldContent)."%' OR field2 LIKE '%".trim($fieldContent)."%' OR WHERE field1 LIKE '%".trim($fieldContent)."%' OR field2 LIKE '%".trim($fieldContent)."%' OR
field3 LIKE '%".trim($fieldContent)."%' OR field3 LIKE '%".trim($fieldContent)."%' OR
field2_recovery LIKE '%".trim($fieldContent)."%' OR field2_recovery LIKE '%".trim($fieldContent)."%' OR
field3_recovery LIKE '%".trim($fieldContent)."%')"; field3_recovery LIKE '%".trim($fieldContent)."%')";
} }
if (strlen(trim($moduleName)) > 0) { if (strlen(trim($moduleName)) > 0) {
$where .= " AND id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE '%".trim($moduleName)."%')"; $where .= " AND id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE '%".trim($moduleName)."%')";
} }
if (strlen(trim($agentName)) > 0) { if (strlen(trim($agentName)) > 0) {
$where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo $where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo
FROM tagente t1 INNER JOIN tagente_modulo t2 ON t1.id_agente = t2.id_agente FROM tagente t1 INNER JOIN tagente_modulo t2 ON t1.id_agente = t2.id_agente
WHERE t1.alias LIKE '".trim($agentName)."')"; WHERE t1.alias LIKE '".trim($agentName)."')";
} }
if ($actionID != -1 && $actionID != '') { if ($actionID != -1 && $actionID != '') {
$where .= ' AND talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action = '.$actionID.') OR talert_template_modules.id IN (SELECT id FROM talert_template_modules ttm WHERE ttm.id_alert_template IN (SELECT tat.id FROM talert_templates tat WHERE tat.id_alert_action = '.$actionID.'))'; $where .= ' AND talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action = '.$actionID.') OR talert_template_modules.id IN (SELECT id FROM talert_template_modules ttm WHERE ttm.id_alert_template IN (SELECT tat.id FROM talert_templates tat WHERE tat.id_alert_action = '.$actionID.'))';
} }
if ($status_alert === 'disabled') { if ($status_alert === 'disabled') {
$where .= ' AND talert_template_modules.disabled = 1'; $where .= ' AND talert_template_modules.disabled = 1';
} }
if ($status_alert === 'all_enabled') { if ($status_alert === 'all_enabled') {
$where .= ' AND talert_template_modules.disabled = 0'; $where .= ' AND talert_template_modules.disabled = 0';
} }
if ($standby != -1 && $standby != '') { if ($standby != -1 && $standby != '') {
$where .= ' AND talert_template_modules.standby = '.$standby; $where .= ' AND talert_template_modules.standby = '.$standby;
}
} }
$id_agents = array_keys($agents); $id_agents = array_keys($agents);

View File

@ -169,154 +169,6 @@ if ($delete === true) {
} }
} }
$table = new stdClass;
$table->id = 'delete_table';
$table->class = 'databox filters';
$table->width = '100%';
$table->data = [];
$table->style = [];
$table->style[0] = 'font-weight: bold;';
$table->style[2] = 'font-weight: bold';
$table->size = [];
$table->size[0] = '15%';
$table->size[1] = '35%';
$table->size[2] = '15%';
$table->size[3] = '35%';
$table->data = [];
$table->data[0][0] = __('Group');
$table->data[0][1] = html_print_select_groups(
false,
'AW',
true,
'id_group',
$id_group,
false,
'',
'',
true
);
$table->data[0][2] = __('Group recursion');
$table->data[0][3] = html_print_checkbox(
'recursion',
1,
$recursion,
true,
false
);
$status_list = [];
$status_list[AGENT_STATUS_NORMAL] = __('Normal');
$status_list[AGENT_STATUS_WARNING] = __('Warning');
$status_list[AGENT_STATUS_CRITICAL] = __('Critical');
$status_list[AGENT_STATUS_UNKNOWN] = __('Unknown');
$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
$status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
$table->data[1][0] = __('Status');
$table->data[1][1] = html_print_select(
$status_list,
'status_agents',
'selected',
'',
__('All'),
AGENT_STATUS_ALL,
true
);
$table->data[1][2] = __('Show agents');
$table->data[1][3] = html_print_select(
[
0 => 'Only enabled',
1 => 'Only disabled',
],
'disabled',
2,
'',
__('All'),
2,
true,
false,
true,
'',
false,
'width:30%;'
);
if (is_metaconsole() === true) {
$servers = metaconsole_get_servers();
$server_fields = [];
foreach ($servers as $key => $server) {
$server_fields[$key] = $server['server_name'];
}
$table->data[2][2] = __('Node');
$table->data[2][3] = html_print_select(
$server_fields,
'nodes[]',
0,
false,
'',
'',
true,
true,
true,
'',
false,
'min-width: 500px; max-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true
);
}
$table->data[3][0] = __('Agents');
$table->data[3][0] .= '<span id="agent_loading" class="invisible">';
$table->data[3][0] .= html_print_image('images/spinner.png', true);
$table->data[3][0] .= '</span>';
$agents = [];
if (is_metaconsole() === false) {
$agents = agents_get_group_agents(
array_keys(users_get_groups($config['id_user'], 'AW', false)),
['disabled' => 2],
'none'
);
}
$table->data[3][1] = html_print_select(
$agents,
'id_agents[]',
0,
false,
'',
'',
true,
true,
true,
'',
false,
'min-width: 500px; max-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true
);
$url = 'index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents'; $url = 'index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents';
if (is_metaconsole() === true) { if (is_metaconsole() === true) {
@ -324,10 +176,15 @@ if (is_metaconsole() === true) {
} }
echo '<form method="post" id="form_agent" action="'.$url.'">'; echo '<form method="post" id="form_agent" action="'.$url.'">';
html_print_table($table);
$params = [
'id_group' => $id_group,
'recursion' => $recursion,
];
echo get_table_inputs_masive_agents($params);
if (is_metaconsole() === true || is_management_allowed() === true) { if (is_metaconsole() === true || is_management_allowed() === true) {
attachActionButton('delete', 'delete', $table->width); attachActionButton('delete', 'delete', '100%');
} }
echo '</form>'; echo '</form>';
@ -342,54 +199,6 @@ ui_require_jquery_file('pandora.controls');
$(document).ready (function () { $(document).ready (function () {
// Check Metaconsole. // Check Metaconsole.
var metaconsole = '<?php echo (is_metaconsole() === true) ? 1 : 0; ?>'; var metaconsole = '<?php echo (is_metaconsole() === true) ? 1 : 0; ?>';
form_controls_massive_operations_agents(metaconsole);
// Listeners.
var recursion;
$("#checkbox-recursion").click(function () {
recursion = this.checked ? 1 : 0;
$("#id_group").trigger("change");
});
var disabled;
$("#disabled").change(function () {
disabled = this.value;
$("#id_group").trigger("change");
});
var nodes;
$("#nodes").change(function () {
nodes = $("#nodes").val();
$("#id_group").trigger("change");
});
$("#status_agents").change(function() {
$("#id_group").trigger("change");
});
// Build data.
var data = {
status_agents: function () {
return $("#status_agents").val();
},
agentSelect: "select#id_agents",
privilege: "AW",
recursion: function() {
return recursion;
},
disabled: function() {
return disabled;
},
}
if (metaconsole == 1) {
data.serialized = true;
data.serialized_separator = '|';
data.nodes = function() {
return nodes;
};
}
// Change agents.
$("#id_group").pandoraSelectGroupAgent(data);
}); });
</script> </script>

File diff suppressed because it is too large Load Diff

View File

@ -68,11 +68,6 @@ $options_agents = [
'edit_agents' => __('Bulk agent edit'), 'edit_agents' => __('Bulk agent edit'),
'delete_agents' => __('Bulk agent delete'), 'delete_agents' => __('Bulk agent delete'),
]; ];
if (is_metaconsole() === true) {
$options_agents = [
'delete_agents' => __('Bulk agent delete'),
];
}
if (check_acl($config['id_user'], 0, 'UM')) { if (check_acl($config['id_user'], 0, 'UM')) {
$options_users = [ $options_users = [
@ -119,11 +114,6 @@ if ($satellite_options != ENTERPRISE_NOT_HOOK) {
$options_satellite = array_merge($options_satellite, $satellite_options); $options_satellite = array_merge($options_satellite, $satellite_options);
} }
$options_services = enterprise_hook('massive_services_options');
if ($options_services === ENTERPRISE_NOT_HOOK) {
$options_services = [];
}
if (in_array($option, array_keys($options_alerts)) === true) { if (in_array($option, array_keys($options_alerts)) === true) {
$tab = 'massive_alerts'; $tab = 'massive_alerts';
@ -141,8 +131,6 @@ if (in_array($option, array_keys($options_alerts)) === true) {
$tab = 'massive_satellite'; $tab = 'massive_satellite';
} else if (in_array($option, array_keys($options_plugins)) === true) { } else if (in_array($option, array_keys($options_plugins)) === true) {
$tab = 'massive_plugins'; $tab = 'massive_plugins';
} else if (in_array($option, array_keys($options_services)) === true) {
$tab = 'massive_services';
} }
if ($tab === 'massive_agents' && empty($option) === true) { if ($tab === 'massive_agents' && empty($option) === true) {
@ -211,10 +199,6 @@ switch ($tab) {
$options = $options_plugins; $options = $options_plugins;
break; break;
case 'massive_services':
$options = $options_services;
break;
default: default:
// Default. // Default.
break; break;
@ -303,12 +287,6 @@ if ($satellitetab == ENTERPRISE_NOT_HOOK) {
$satellitetab = ''; $satellitetab = '';
} }
$servicestab = enterprise_hook('massive_services_tab');
if ($servicestab == ENTERPRISE_NOT_HOOK) {
$servicestab = '';
}
$onheader = []; $onheader = [];
$onheader['massive_agents'] = $agentstab; $onheader['massive_agents'] = $agentstab;
$onheader['massive_modules'] = $modulestab; $onheader['massive_modules'] = $modulestab;

View File

@ -111,6 +111,9 @@ if ($access_console_node === true) {
$sub['godmode/groups/modu_group_list']['text'] = __('Module groups'); $sub['godmode/groups/modu_group_list']['text'] = __('Module groups');
$sub['godmode/groups/modu_group_list']['id'] = 'Module groups'; $sub['godmode/groups/modu_group_list']['id'] = 'Module groups';
$sub['godmode/setup/os']['text'] = __('Operating systems');
$sub['godmode/setup/os']['id'] = 'Edit OS';
} }
if ((bool) check_acl($config['id_user'], 0, 'AW') === true) { if ((bool) check_acl($config['id_user'], 0, 'AW') === true) {
@ -208,7 +211,6 @@ if ($access_console_node === true) {
enterprise_hook('massivepolicies_submenu'); enterprise_hook('massivepolicies_submenu');
enterprise_hook('massivesnmp_submenu'); enterprise_hook('massivesnmp_submenu');
enterprise_hook('massivesatellite_submenu'); enterprise_hook('massivesatellite_submenu');
enterprise_hook('massiveservices_submenu');
$sub['gmassive']['sub2'] = $sub2; $sub['gmassive']['sub2'] = $sub2;
$sub2 = []; $sub2 = [];
@ -380,8 +382,6 @@ if ($access_console_node === true) {
} }
$sub['general']['sub2'] = $sub2; $sub['general']['sub2'] = $sub2;
$sub['godmode/setup/os']['text'] = __('Edit OS');
$sub['godmode/setup/os']['id'] = 'Edit OS';
$sub['godmode/setup/license']['text'] = __('License'); $sub['godmode/setup/license']['text'] = __('License');
$sub['godmode/setup/license']['id'] = 'License'; $sub['godmode/setup/license']['id'] = 'License';

View File

@ -78,6 +78,14 @@ $agents_inventory_display_options['estado'] = __('Status');
$agents_inventory_display_options['agent_version'] = __('Version'); $agents_inventory_display_options['agent_version'] = __('Version');
$agents_inventory_display_options['remote'] = __('Remote configuration'); $agents_inventory_display_options['remote'] = __('Remote configuration');
// Modules inventory display options.
$modules_inventory_display_options = [];
$modules_inventory_display_options['alias'] = __('Name');
$modules_inventory_display_options['direccion'] = __('Description');
$modules_inventory_display_options['id_os'] = __('Tags');
$modules_inventory_display_options['id_grupo'] = __('Module groups');
$modules_inventory_display_options['secondary_groups'] = __('Group');
enterprise_include('/godmode/reporting/reporting_builder.item_editor.php'); enterprise_include('/godmode/reporting/reporting_builder.item_editor.php');
require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_agents.php';
if (enterprise_include_once('include/functions_metaconsole.php')) { if (enterprise_include_once('include/functions_metaconsole.php')) {
@ -901,6 +909,14 @@ switch ($action) {
$idAgentModule = $inventory_modules; $idAgentModule = $inventory_modules;
break; break;
case 'modules_inventory':
$description = $item['description'];
$es = json_decode($item['external_source'], true);
$selected_agent_group_filter = $es['agent_group_filter'];
$selected_module_group = $es['module_group'];
break;
case 'inventory': case 'inventory':
$description = $item['description']; $description = $item['description'];
$es = json_decode($item['external_source'], true); $es = json_decode($item['external_source'], true);
@ -3644,7 +3660,22 @@ $class = 'databox filters';
true, true,
'agent_group_filter', 'agent_group_filter',
$selected_agent_group_filter, $selected_agent_group_filter,
'' '',
'',
0,
false,
false,
false,
'',
false,
false,
false,
false,
'id_grupo',
false,
false,
false,
120
); );
?> ?>
</td> </td>
@ -3820,6 +3851,48 @@ $class = 'databox filters';
</td> </td>
</tr> </tr>
<tr id="row_module_group_filter" class="datos">
<td class="bolder">
<?php
echo __('Module group filter');
?>
</td>
<td>
<?php
$rows_select = [];
$rows_select[0] = __('Not assigned');
if ($is_metaconsole === false) {
$rows = db_get_all_rows_sql(
'SELECT * FROM tmodule_group ORDER BY name'
);
$rows = io_safe_output($rows);
if (empty($rows) === false) {
foreach ($rows as $module_group) {
$rows_select[$module_group['id_mg']] = $module_group['name'];
}
}
} else {
$rows_select = modules_get_modulegroups();
}
html_print_select($rows_select, 'modulegroup', $modulegroup, '', __($is_none), -1, true, false, true, '', false, 'width: 120px;');
html_print_select(
$rows_select,
'module_group',
$selected_module_group,
'',
__('All'),
-1,
false,
false,
true,
'',
false,
'width: 120px;'
);
?>
</td>
</tr>
</tbody> </tbody>
</table> </table>
@ -6139,6 +6212,8 @@ function chooseType() {
$("#row_agents_inventory_display_options").hide(); $("#row_agents_inventory_display_options").hide();
$("#row_agent_server_filter").hide(); $("#row_agent_server_filter").hide();
$("#row_agent_group_filter").hide(); $("#row_agent_group_filter").hide();
$("#row_module_group_filter").hide();
$("#row_module_group_filter").hide();
$("#row_os").hide(); $("#row_os").hide();
$("#row_custom_field_filter").hide(); $("#row_custom_field_filter").hide();
$("#row_custom_field").hide(); $("#row_custom_field").hide();
@ -6768,6 +6843,14 @@ function chooseType() {
break; break;
case 'modules_inventory':
$("#row_group").show();
$("#row_agent_server_filter").show();
$("#row_agent_group_filter").show();
$("#row_module_group_filter").show();
break;
case 'inventory': case 'inventory':
$("#row_description").show(); $("#row_description").show();
$("#row_group").show(); $("#row_group").show();

View File

@ -2313,6 +2313,14 @@ switch ($action) {
$values['external_source'] = json_encode($es); $values['external_source'] = json_encode($es);
break; break;
case 'modules_inventory':
$es['agent_server_filter'] = get_parameter('agent_server_filter');
$es['module_group'] = get_parameter('module_group');
$es['agent_group_filter'] = get_parameter('agent_group_filter');
$values['external_source'] = json_encode($es);
break;
case 'IPAM_network': case 'IPAM_network':
$es['network_filter'] = get_parameter('network_filter'); $es['network_filter'] = get_parameter('network_filter');
$es['alive_ip'] = get_parameter('alive_ip'); $es['alive_ip'] = get_parameter('alive_ip');
@ -3081,6 +3089,14 @@ switch ($action) {
$values['external_source'] = json_encode($es); $values['external_source'] = json_encode($es);
break; break;
case 'modules_inventory':
$es['agent_server_filter'] = get_parameter('agent_server_filter');
$es['module_group'] = get_parameter('module_group');
$es['agent_group_filter'] = get_parameter('agent_group_filter');
$values['external_source'] = json_encode($es);
break;
case 'IPAM_network': case 'IPAM_network':
$es['network_filter'] = get_parameter('network_filter'); $es['network_filter'] = get_parameter('network_filter');
$es['alive_ip'] = get_parameter('alive_ip'); $es['alive_ip'] = get_parameter('alive_ip');

View File

@ -833,23 +833,21 @@ ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
var added_config = { var added_config = {
"selector": "#tinyMCE_editor", "selector": "#tinyMCE_editor",
"elements": "text-label", "elements": "tinyMCE_editor",
"plugins": "noneditable", "plugins": "noneditable",
"theme_advanced_buttons1": "theme_advanced_buttons1": "bold,italic,|,justifyleft,justifycenter,justifyright,|,undo,redo,|,image,link,|,fontselect,|,forecolor,fontsizeselect,|,code",
"bold,italic,|,justifyleft,justifycenter,justifyright,|,undo,redo,|,image,link,|,fontselect,|,forecolor,fontsizeselect,|,code",
"valid_children": "+body[style]", "valid_children": "+body[style]",
"theme_advanced_font_sizes": "true", "theme_advanced_font_sizes": "true",
"content_css": "content_css": <?php echo '"'.ui_get_full_url('include/styles/pandora.css', false, false, false).'"'; ?>,
<?php echo '"'.ui_get_full_url('include/styles/pandora.css', false, false, false).'"'; ?>,
"editor_deselector": "noselected", "editor_deselector": "noselected",
"inline_styles": true, "inline_styles": true,
"nowrap": true, "nowrap": true,
"width": "400", "width": "400",
"height": "200", "height": "200",
} "body_class": "tinyMCEBody",
}
defineTinyMCE(added_config);
defineTinyMCE(added_config);
$("#dialog_label_editor").hide () $("#dialog_label_editor").hide ()
.dialog ({ .dialog ({
title: "<?php echo __('Edit label'); ?>", title: "<?php echo __('Edit label'); ?>",
@ -860,26 +858,22 @@ ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
opacity: 0.5, opacity: 0.5,
background: "black" background: "black"
}, },
width: 450, width: 530,
height: 300, height: 300,
autoOpen: false, autoOpen: false,
beforeClose: function() { beforeClose: function() {
var id_layout_data = $("#active_id_layout_data").val(); var id_layout_data = $("#active_id_layout_data").val();
var label = tinyMCE.activeEditor.getContent(); var label = tinyMCE.activeEditor.getContent();
$("#hidden-label_" + id_layout_data).val(label); $("#hidden-label_" + id_layout_data).val(label);
} }
}); });
});
var idText = $("#ip_text").html(); var idText = $("#ip_text").html();
});
function show_dialog_label_editor(id_layout_data) { function show_dialog_label_editor(id_layout_data) {
var label = $("#hidden-label_" + id_layout_data).val(); var label = $("#hidden-label_" + id_layout_data).val();
$("#active_id_layout_data").val(id_layout_data); $("#active_id_layout_data").val(id_layout_data);
$("#tinyMCE_editor").val(label);
tinyMCE.activeEditor.setContent(label); tinyMCE.activeEditor.setContent(label);
$("#dialog_label_editor").dialog("open"); $("#dialog_label_editor").dialog("open");
} }
@ -887,7 +881,6 @@ ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
function toggle_checkbox_multiple_delete() { function toggle_checkbox_multiple_delete() {
checked_head_multiple = $("input[name='head_multiple_delete']") checked_head_multiple = $("input[name='head_multiple_delete']")
.is(":checked"); .is(":checked");
$("input[name='multiple_delete_items']") $("input[name='multiple_delete_items']")
.prop("checked", checked_head_multiple); .prop("checked", checked_head_multiple);
} }
@ -900,7 +893,6 @@ ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
} }
); );
$("input[name='id_item_json']").val(JSON.stringify(delete_items)); $("input[name='id_item_json']").val(JSON.stringify(delete_items));
$("#form_multiple_delete").submit(); $("#form_multiple_delete").submit();
} }

View File

@ -208,7 +208,7 @@ if ($is_management_allowed === true) {
$buttons[$tab]['active'] = true; $buttons[$tab]['active'] = true;
$headerTitle = ($tab === 'builder') ? __('Edit OS') : __('List of OS'); $headerTitle = ($tab === 'builder') ? __('Edit OS') : __('List of Operating Systems');
if (is_metaconsole() === false) { if (is_metaconsole() === false) {
// Header. // Header.

View File

@ -340,8 +340,19 @@ $table->data[8][1] = html_print_input_text(
true true
); );
$table->data[9][0] = __('Max. days before delete autodisabled agents');
$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_text(
'days_delete_not_initialized',
$config['days_delete_not_initialized'],
'',
5,
5,
true
);
$table->data[10][0] = __('Max. days before delete autodisabled agents');
$table->data[10][1] = html_print_input_text(
'days_autodisable_deletion', 'days_autodisable_deletion',
$config['days_autodisable_deletion'], $config['days_autodisable_deletion'],
'', '',
@ -350,8 +361,8 @@ $table->data[9][1] = html_print_input_text(
true true
); );
$table->data[10][0] = __('Retention period of past special days'); $table->data[11][0] = __('Retention period of past special days');
$table->data[10][1] = html_print_input_text( $table->data[11][1] = html_print_input_text(
'num_past_special_days', 'num_past_special_days',
$config['num_past_special_days'], $config['num_past_special_days'],
'', '',
@ -360,8 +371,8 @@ $table->data[10][1] = html_print_input_text(
true true
); );
$table->data[11][0] = __('Max. macro data fields'); $table->data[12][0] = __('Max. macro data fields');
$table->data[11][1] = html_print_input_text( $table->data[12][1] = html_print_input_text(
'max_macro_fields', 'max_macro_fields',
$config['max_macro_fields'], $config['max_macro_fields'],
'', '',
@ -374,8 +385,8 @@ $table->data[11][1] = html_print_input_text(
); );
if (enterprise_installed()) { if (enterprise_installed()) {
$table->data[12][0] = __('Max. days before delete inventory data'); $table->data[13][0] = __('Max. days before delete inventory data');
$table->data[12][1] = html_print_input_text( $table->data[13][1] = html_print_input_text(
'inventory_purge', 'inventory_purge',
$config['inventory_purge'], $config['inventory_purge'],
'', '',

View File

@ -324,7 +324,7 @@ switch ($section) {
} }
// Put header inside div for special sizing.(No right margin). // Put header inside div for special sizing.(No right margin).
echo '<div id="header_configuration" style="width: calc(100% + 3em);">'; echo '<div id="header_configuration" style="width: calc(100%);">';
// Header. // Header.
ui_print_page_header( ui_print_page_header(
__('Configuration').$subpage, __('Configuration').$subpage,

View File

@ -34,7 +34,7 @@ check_login();
if (is_ajax()) { if (is_ajax()) {
$test_address = get_parameter('test_address', ''); $test_address = get_parameter('test_address', '');
$params = get_parameter('params', ''); $params = io_safe_output(get_parameter('params', ''));
$res = send_test_email( $res = send_test_email(
$test_address, $test_address,

View File

@ -914,7 +914,7 @@ class HostDevices extends Wizard
'hidden' => (($this->task['subnet_csv'] == '1') ? 1 : 0), 'hidden' => (($this->task['subnet_csv'] == '1') ? 1 : 0),
'id' => 'std_subnet', 'id' => 'std_subnet',
'label' => '<b>'.__('Network').':</b>'.ui_print_help_tip( 'label' => '<b>'.__('Network').':</b>'.ui_print_help_tip(
__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), __('You can specify networks or fully qualified domain names of a specific host, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24, hostname.artica.es'),
true true
), ),
'arguments' => [ 'arguments' => [

View File

@ -777,7 +777,7 @@ if ($save_filter_modal) {
$data[1] .= html_print_select( $data[1] .= html_print_select(
$user_groups_array, $user_groups_array,
'id_group_filter', 'id_group_filter_dialog',
$id_group_filter, $id_group_filter,
'', '',
'', '',
@ -884,7 +884,7 @@ function save_new_filter() {
"page" : "include/ajax/events", "page" : "include/ajax/events",
"save_event_filter" : 1, "save_event_filter" : 1,
"id_name" : $("#text-id_name").val(), "id_name" : $("#text-id_name").val(),
"id_group" : $("select#id_group").val(), "id_group" : $("#id_group_filter").val(),
"event_type" : $("#event_type").val(), "event_type" : $("#event_type").val(),
"severity" : $("#severity").val(), "severity" : $("#severity").val(),
"status" : $("#status").val(), "status" : $("#status").val(),
@ -900,7 +900,7 @@ function save_new_filter() {
"tag_without": Base64.decode($("#hidden-tag_without").val()), "tag_without": Base64.decode($("#hidden-tag_without").val()),
"filter_only_alert" : $("#filter_only_alert").val(), "filter_only_alert" : $("#filter_only_alert").val(),
"search_secondary_groups" : $("#checkbox-search_secondary_groups").val(), "search_secondary_groups" : $("#checkbox-search_secondary_groups").val(),
"id_group_filter": $("#id_group_filter").val(), "id_group_filter": $("#id_group_filter_dialog").val(),
"date_from": $("#text-date_from").val(), "date_from": $("#text-date_from").val(),
"time_from": $("#text-time_from").val(), "time_from": $("#text-time_from").val(),
"date_to": $("#text-date_to").val(), "date_to": $("#text-date_to").val(),
@ -960,7 +960,7 @@ function save_update_filter() {
{"page" : "include/ajax/events", {"page" : "include/ajax/events",
"update_event_filter" : 1, "update_event_filter" : 1,
"id" : $("#overwrite_filter").val(), "id" : $("#overwrite_filter").val(),
"id_group" : $("select#id_group").val(), "id_group" : $("#id_group_filter").val(),
"event_type" : $("#event_type").val(), "event_type" : $("#event_type").val(),
"severity" : $("#severity").val(), "severity" : $("#severity").val(),
"status" : $("#status").val(), "status" : $("#status").val(),
@ -976,7 +976,7 @@ function save_update_filter() {
"tag_without" : Base64.decode($("#hidden-tag_without").val()), "tag_without" : Base64.decode($("#hidden-tag_without").val()),
"filter_only_alert" : $("#filter_only_alert").val(), "filter_only_alert" : $("#filter_only_alert").val(),
"search_secondary_groups" : $("#checkbox-search_secondary_groups").val(), "search_secondary_groups" : $("#checkbox-search_secondary_groups").val(),
"id_group_filter": $("#id_group_filter").val(), "id_group_filter": $("#id_group_filter_dialog").val(),
"date_from": $("#text-date_from").val(), "date_from": $("#text-date_from").val(),
"time_from": $("#text-time_from").val(), "time_from": $("#text-time_from").val(),
"date_to": $("#text-date_to").val(), "date_to": $("#text-date_to").val(),

View File

@ -2215,7 +2215,9 @@ class ConsoleSupervisor
'type' => 'NOTIF.MISC.FONTPATH', 'type' => 'NOTIF.MISC.FONTPATH',
'title' => __('Default font doesn\'t exist'), 'title' => __('Default font doesn\'t exist'),
'message' => __('Your defined font doesn\'t exist or is not defined. Please, check font parameters in your config'), 'message' => __('Your defined font doesn\'t exist or is not defined. Please, check font parameters in your config'),
'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/setup&section=vis', 'url' => is_metaconsole() === false
? '__url__/index.php?sec=gsetup&sec2=godmode/setup/setup&section=vis'
: '__url__/index.php?sec=advanced&sec2=advanced/metasetup&tab=visual',
] ]
); );
} else { } else {

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Configuraton sample file. * Configuraton sample file.
* *
@ -38,6 +39,11 @@
* $config["homedir"]="/var/www/pandora_console/"; * $config["homedir"]="/var/www/pandora_console/";
* $config["homeurl"]="/pandora_console/"; * $config["homeurl"]="/pandora_console/";
* $config["auth"]["scheme"] = "mysql"; * $config["auth"]["scheme"] = "mysql";
*
* This is used to configure MySQL SSL console connection
* $config["dbssl"]=0;
* $config["dbsslcafile"]="/path/ca-cert.pem";
* $config["sslverifyservercert"]=1;
*/ */
// By default report any error but notices. // By default report any error but notices.

View File

@ -20,8 +20,8 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC220810'; $build_version = 'PC220921';
$pandora_version = 'v7.0NG.763'; $pandora_version = 'v7.0NG.764';
// 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

@ -31,7 +31,9 @@ function mysql_connect_db(
$user=null, $user=null,
$pass=null, $pass=null,
$port=null, $port=null,
$charset=null $charset=null,
$ssl=null,
$verify=null
) { ) {
global $config; global $config;
@ -55,6 +57,14 @@ function mysql_connect_db(
$port = $config['dbport']; $port = $config['dbport'];
} }
if ($ssl === null && (bool) $config['dbssl'] === true) {
$ssl = $config['dbsslcafile'];
}
if ($verify === null && (bool) $config['sslverifyservercert'] === true) {
$verify = 'verified';
}
// Check if mysqli is available // Check if mysqli is available
if (!isset($config['mysqli'])) { if (!isset($config['mysqli'])) {
$config['mysqli'] = extension_loaded(mysqli); $config['mysqli'] = extension_loaded(mysqli);
@ -63,22 +73,39 @@ function mysql_connect_db(
// Non-persistent connection: This will help to avoid mysql errors like "has gone away" or locking problems // Non-persistent connection: This will help to avoid mysql errors like "has gone away" or locking problems
// If you want persistent connections change it to mysql_pconnect(). // If you want persistent connections change it to mysql_pconnect().
if ($config['mysqli']) { if ($config['mysqli']) {
$connect_id = mysqli_connect($host, $user, $pass, $db, $port); if (empty($ssl)) {
if (mysqli_connect_errno() > 0) { $connect_id = mysqli_connect($host, $user, $pass, $db, $port);
include 'general/mysqlerr.php'; if (mysqli_connect_errno() > 0) {
return false; include 'general/mysqlerr.php';
return false;
}
db_change_cache_id($db, $host);
if (isset($charset)) {
mysqli_set_charset($connect_id, $charset);
}
mysqli_select_db($connect_id, $db);
} else {
$connect_id = mysqli_init();
mysqli_ssl_set($connect_id, null, null, $ssl, null, null);
if ($verify === 'verified') {
mysqli_real_connect($connect_id, $host, $user, $pass, $db, $port, null, MYSQLI_CLIENT_SSL);
} else {
mysqli_real_connect($connect_id, $host, $user, $pass, $db, $port, null, MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT);
}
if (mysqli_connect_errno() > 0) {
include 'general/mysqlerr.php';
return false;
}
} }
db_change_cache_id($db, $host);
if (isset($charset)) {
mysqli_set_charset($connect_id, $charset);
}
mysqli_select_db($connect_id, $db);
} else { } else {
$connect_id = @mysql_connect($host.':'.$port, $user, $pass, true); $connect_id = @mysql_connect($host.':'.$port, $user, $pass, true);
if (! $connect_id) { if (!$connect_id) {
return false; return false;
} }
@ -117,7 +144,7 @@ function mysql_db_get_all_rows_sql($sql, $search_history_db=false, $cache=true,
$history = false; $history = false;
// Connect to the history DB // Connect to the history DB
if (! isset($config['history_db_connection']) || $config['history_db_connection'] === false) { if (!isset($config['history_db_connection']) || $config['history_db_connection'] === false) {
$config['history_db_connection'] = db_connect($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], io_output_password($config['history_db_pass']), $config['history_db_port'], false); $config['history_db_connection'] = db_connect($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], io_output_password($config['history_db_pass']), $config['history_db_port'], false);
} }
@ -142,13 +169,13 @@ function mysql_db_get_all_rows_sql($sql, $search_history_db=false, $cache=true,
} }
// Append result to the history DB data // Append result to the history DB data
if (! empty($return)) { if (!empty($return)) {
foreach ($return as $row) { foreach ($return as $row) {
array_push($history, $row); array_push($history, $row);
} }
} }
if (! empty($history)) { if (!empty($history)) {
return $history; return $history;
} }
@ -240,7 +267,7 @@ function mysql_db_get_row($table, $field_search, $condition, $fields=false, $cac
} else { } else {
if (is_array($fields)) { if (is_array($fields)) {
$fields = implode(',', $fields); $fields = implode(',', $fields);
} else if (! is_string($fields)) { } else if (!is_string($fields)) {
return false; return false;
} }
} }
@ -403,7 +430,7 @@ function mysql_db_process_sql($sql, $rettype='affected_rows', $dbconnection='',
$cache = $config['dbcache']; $cache = $config['dbcache'];
} }
if ($cache && ! empty($sql_cache[$sql_cache['id']][$sql])) { if ($cache && !empty($sql_cache[$sql_cache['id']][$sql])) {
$retval = $sql_cache[$sql_cache['id']][$sql]; $retval = $sql_cache[$sql_cache['id']][$sql];
$sql_cache['saved'][$sql_cache['id']]++; $sql_cache['saved'][$sql_cache['id']]++;
db_add_database_debug_trace($sql); db_add_database_debug_trace($sql);
@ -518,7 +545,7 @@ function mysql_db_process_sql($sql, $rettype='affected_rows', $dbconnection='',
} }
} }
if (! empty($retval)) { if (!empty($retval)) {
return $retval; return $retval;
} }
@ -594,7 +621,7 @@ function mysql_encapsule_fields_with_same_name_to_instructions($field)
*/ */
function mysql_db_get_value_filter($field, $table, $filter, $where_join='AND', $search_history_db=false) function mysql_db_get_value_filter($field, $table, $filter, $where_join='AND', $search_history_db=false)
{ {
if (! is_array($filter) || empty($filter)) { if (!is_array($filter) || empty($filter)) {
return false; return false;
} }
@ -693,7 +720,7 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
{ {
$fields = []; $fields = [];
if (! is_array($values)) { if (!is_array($values)) {
return ''; return '';
} }
@ -863,7 +890,7 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
$i++; $i++;
} }
return (! empty($query) ? $prefix : '').$query.$group.$order.$limit.$offset; return (!empty($query) ? $prefix : '').$query.$group.$order.$limit.$offset;
} }
@ -945,7 +972,7 @@ function mysql_db_get_row_filter($table, $filter, $fields=false, $where_join='AN
} else { } else {
if (is_array($fields)) { if (is_array($fields)) {
$fields = implode(',', $fields); $fields = implode(',', $fields);
} else if (! is_string($fields)) { } else if (!is_string($fields)) {
return false; return false;
} }
} }
@ -995,7 +1022,7 @@ function mysql_db_get_all_rows_filter($table, $filter=[], $fields=false, $where_
$fields = '*'; $fields = '*';
} else if (is_array($fields)) { } else if (is_array($fields)) {
$fields = implode(',', $fields); $fields = implode(',', $fields);
} else if (! is_string($fields)) { } else if (!is_string($fields)) {
return false; return false;
} }

View File

@ -789,7 +789,7 @@ function agents_get_agents_selected($group)
); );
$all = array_reduce( $all = array_reduce(
$all, (empty($all) === true) ? [] : $all,
function ($carry, $item) { function ($carry, $item) {
$carry[$item['id_agente']] = $item['alias']; $carry[$item['id_agente']] = $item['alias'];
return $carry; return $carry;

View File

@ -45,6 +45,7 @@ require_once $config['homedir'].'/include/functions_servers.php';
require_once $config['homedir'].'/include/functions_planned_downtimes.php'; require_once $config['homedir'].'/include/functions_planned_downtimes.php';
require_once $config['homedir'].'/include/functions_db.php'; require_once $config['homedir'].'/include/functions_db.php';
require_once $config['homedir'].'/include/functions_event_responses.php'; require_once $config['homedir'].'/include/functions_event_responses.php';
require_once $config['homedir'].'/include/functions_tactical.php';
enterprise_include_once('include/functions_local_components.php'); enterprise_include_once('include/functions_local_components.php');
enterprise_include_once('include/functions_events.php'); enterprise_include_once('include/functions_events.php');
enterprise_include_once('include/functions_agents.php'); enterprise_include_once('include/functions_agents.php');
@ -12706,7 +12707,7 @@ function api_get_total_modules($id_group, $trash1, $trash2, $returnType)
{ {
global $config; global $config;
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
return; return;
} }
@ -12715,20 +12716,9 @@ function api_get_total_modules($id_group, $trash1, $trash2, $returnType)
return; return;
} }
$groups_clause = '1 = 1'; $partial = tactical_status_modules_agents($config['id_user'], false, 'AR');
if (!users_is_admin($config['id_user'])) {
$user_groups = implode(',', array_keys(users_get_groups()));
$groups_clause = "(ta.id_grupo IN ($user_groups) OR tasg.id_group IN ($user_groups))";
}
$sql = "SELECT COUNT(DISTINCT(id_agente_modulo)) $total = (int) $partial['_monitor_total_'];
FROM tagente_modulo tam, tagente ta
LEFT JOIN tagent_secondary_group tasg
ON ta.id_agente = tasg.id_agent
WHERE tam.id_agente = ta.id_agente AND id_module_group = $id_group
AND delete_pending = 0 AND $groups_clause";
$total = db_get_value_sql($sql);
$data = [ $data = [
'type' => 'string', 'type' => 'string',

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Main configuration of Pandora FMS * Main configuration of Pandora FMS
* *
@ -30,6 +31,7 @@
require_once __DIR__.'/../vendor/autoload.php'; require_once __DIR__.'/../vendor/autoload.php';
require_once __DIR__.'/functions.php'; require_once __DIR__.'/functions.php';
enterprise_include_once('include/functions_config.php'); enterprise_include_once('include/functions_config.php');
use PandoraFMS\Core\DBMaintainer; use PandoraFMS\Core\DBMaintainer;
use PandoraFMS\Core\Config; use PandoraFMS\Core\Config;
@ -146,7 +148,7 @@ function config_update_config()
return false; return false;
} }
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) { if (!check_acl($config['id_user'], 0, 'PM') && !is_user_admin($config['id_user'])) {
$config['error_config_update_config'] = []; $config['error_config_update_config'] = [];
$config['error_config_update_config']['correct'] = false; $config['error_config_update_config']['correct'] = false;
$config['error_config_update_config']['message'] = __('Failed updated: User is not admin.'); $config['error_config_update_config']['message'] = __('Failed updated: User is not admin.');
@ -816,6 +818,10 @@ function config_update_config()
$error_update[] = __('Max. days before delete unknown modules'); $error_update[] = __('Max. days before delete unknown modules');
} }
if (config_update_value('days_delete_not_initialized', (int) get_parameter('days_delete_not_initialized'), true) === false) {
$error_update[] = __('Max. days before delete not initialized modules');
}
if (config_update_value('days_compact', (int) get_parameter('days_compact'), true) === false) { if (config_update_value('days_compact', (int) get_parameter('days_compact'), true) === false) {
$error_update[] = __('Max. days before compact data'); $error_update[] = __('Max. days before compact data');
} }
@ -2237,9 +2243,9 @@ function config_process_config()
config_update_value('2Fa_auth', ''); config_update_value('2Fa_auth', '');
} }
/* /*
* Parse the ACL IP list for access API * Parse the ACL IP list for access API
*/ */
$temp_list_ACL_IPs_for_API = []; $temp_list_ACL_IPs_for_API = [];
if (isset($config['list_ACL_IPs_for_API'])) { if (isset($config['list_ACL_IPs_for_API'])) {
@ -2795,7 +2801,7 @@ function config_process_config()
$temp_ad_adv_perms = $config['ad_adv_perms']; $temp_ad_adv_perms = $config['ad_adv_perms'];
} }
config_update_value('ad_adv_perms', $temp_ad_adv_perms); config_update_value('ad_adv_perms', $temp_ad_adv_perms);
} }
if (!isset($config['ldap_adv_perms'])) { if (!isset($config['ldap_adv_perms'])) {
@ -3395,7 +3401,6 @@ function config_check()
$supervisor = new ConsoleSupervisor(false); $supervisor = new ConsoleSupervisor(false);
$supervisor->runBasic(); $supervisor->runBasic();
} }
} }
@ -3420,7 +3425,6 @@ function get_um_url()
} }
return $url; return $url;
} }
@ -3436,7 +3440,7 @@ function config_return_in_bytes($val)
$last = strtolower($val[(strlen($val) - 1)]); $last = strtolower($val[(strlen($val) - 1)]);
$val = (int) trim($val); $val = (int) trim($val);
switch ($last) { switch ($last) {
// The 'G' modifier is available since PHP 5.1.0. // The 'G' modifier is available since PHP 5.1.0.
case 'g': case 'g':
$val *= 1024; $val *= 1024;
case 'm': case 'm':

View File

@ -1205,7 +1205,12 @@ function events_get_all(
$tags = json_decode($tag_without, true); $tags = json_decode($tag_without, true);
if (is_array($tags) === true && in_array('0', $tags) === false) { if (is_array($tags) === true && in_array('0', $tags) === false) {
if (!$user_is_admin) { if (!$user_is_admin) {
$user_tags = array_flip(tags_get_tags_for_module_search()); $tags_module_search = tags_get_tags_for_module_search();
if ($tags_module_search === false) {
$tags_module_search = [];
}
$user_tags = array_flip($tags_module_search);
if ($user_tags != null) { if ($user_tags != null) {
foreach ($tags as $key_tag => $id_tag) { foreach ($tags as $key_tag => $id_tag) {
// User cannot filter with those tags. // User cannot filter with those tags.
@ -1279,7 +1284,8 @@ function events_get_all(
// Table tag for id_grupo. // Table tag for id_grupo.
'te.', 'te.',
// Alt table tag for id_grupo. // Alt table tag for id_grupo.
$user_admin_group_all $user_admin_group_all,
(bool) $filter['search_secondary_groups']
); );
// FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)". // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
} else if (check_acl($config['id_user'], 0, 'EW')) { } else if (check_acl($config['id_user'], 0, 'EW')) {
@ -1305,7 +1311,8 @@ function events_get_all(
// Table tag for id_grupo. // Table tag for id_grupo.
'te.', 'te.',
// Alt table tag for id_grupo. // Alt table tag for id_grupo.
$user_admin_group_all $user_admin_group_all,
(bool) $filter['search_secondary_groups']
); );
// FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)". // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
} else if (check_acl($config['id_user'], 0, 'EM')) { } else if (check_acl($config['id_user'], 0, 'EM')) {
@ -1331,7 +1338,8 @@ function events_get_all(
// Table tag for id_grupo. // Table tag for id_grupo.
'te.', 'te.',
// Alt table tag for id_grupo. // Alt table tag for id_grupo.
$user_admin_group_all $user_admin_group_all,
(bool) $filter['search_secondary_groups']
); );
// FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)". // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
} }
@ -4945,6 +4953,8 @@ function events_clean_tags($tags)
} }
$event_tags = tags_get_tags_formatted($tags, false); $event_tags = tags_get_tags_formatted($tags, false);
$event_tags = io_safe_input($event_tags);
return explode(',', str_replace(' ', '', $event_tags)); return explode(',', str_replace(' ', '', $event_tags));
} }

View File

@ -2237,7 +2237,7 @@ function html_print_extended_select_for_time(
* *
* @return string HTML code if return parameter is true. * @return string HTML code if return parameter is true.
*/ */
function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*', $month='*', $wday='*', $return=false, $disabled=false, $to=false) function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*', $month='*', $wday='*', $return=false, $disabled=false, $to=false, $advanced=false, $adv_mode_name='')
{ {
// Hours // Hours
for ($i = 0; $i < 24; $i++) { for ($i = 0; $i < 24; $i++) {
@ -2286,18 +2286,104 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
$table->head[3] = __('Month'); $table->head[3] = __('Month');
$table->head[4] = __('Week day'); $table->head[4] = __('Week day');
if ($to) { if ($advanced === false) {
$table->data[0][0] = html_print_select($hours, 'hour_to', $hour, '', __('Any'), '*', true, false, false, '', $disabled); if ($to) {
$table->data[0][1] = html_print_select($minutes, 'minute_to', $minute, '', __('Any'), '*', true, false, false, '', $disabled, false, $minutes_hidden_options); $table->data[0][0] = html_print_select($hours, 'hour_to', $hour, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[0][2] = html_print_select($mdays, 'mday_to', $mday, '', __('Any'), '*', true, false, false, '', $disabled); $table->data[0][1] = html_print_select($minutes, 'minute_to', $minute, '', __('Any'), '*', true, false, false, '', $disabled, false, $minutes_hidden_options);
$table->data[0][3] = html_print_select($months, 'month_to', $month, '', __('Any'), '*', true, false, false, '', $disabled); $table->data[0][2] = html_print_select($mdays, 'mday_to', $mday, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[0][4] = html_print_select($wdays, 'wday_to', $wday, '', __('Any'), '*', true, false, false, '', $disabled); $table->data[0][3] = html_print_select($months, 'month_to', $month, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[0][4] = html_print_select($wdays, 'wday_to', $wday, '', __('Any'), '*', true, false, false, '', $disabled);
} else {
$table->data[0][0] = html_print_select($hours, 'hour_from', $hour, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[0][1] = html_print_select($minutes, 'minute_from', $minute, '', __('Any'), '*', true, false, false, '', $disabled, false, $minutes_hidden_options);
$table->data[0][2] = html_print_select($mdays, 'mday_from', $mday, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[0][3] = html_print_select($months, 'month_from', $month, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[0][4] = html_print_select($wdays, 'wday_from', $wday, '', __('Any'), '*', true, false, false, '', $disabled);
}
} else { } else {
$table->data[0][0] = html_print_select($hours, 'hour_from', $hour, '', __('Any'), '*', true, false, false, '', $disabled); if ($adv_mode_name !== '') {
$table->data[0][1] = html_print_select($minutes, 'minute_from', $minute, '', __('Any'), '*', true, false, false, '', $disabled, false, $minutes_hidden_options); $adv_mode_name = '_'.$adv_mode_name;
$table->data[0][2] = html_print_select($mdays, 'mday_from', $mday, '', __('Any'), '*', true, false, false, '', $disabled); }
$table->data[0][3] = html_print_select($months, 'month_from', $month, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[0][4] = html_print_select($wdays, 'wday_from', $wday, '', __('Any'), '*', true, false, false, '', $disabled); $table->data[0][0] = html_print_extended_select_for_downtime_cron(
'cron_hour'.$adv_mode_name,
$hours,
$hour,
'',
__('Any'),
'*',
false,
true,
false,
false,
false,
0,
'Valid values: [0-23], [0-23]-[0-23], *, or step value (example: */3, 10/5)'
);
$table->data[0][1] = html_print_extended_select_for_downtime_cron(
'cron_minute'.$adv_mode_name,
$minutes,
$minute,
'',
__('Any'),
'*',
false,
true,
false,
false,
false,
0,
'Valid values: [0-59], [0-59]-[0-59], *, or step value (example: */5, 10/1)'
);
$table->data[0][2] = html_print_extended_select_for_downtime_cron(
'cron_mday'.$adv_mode_name,
$mdays,
$mday,
'',
__('Any'),
'*',
false,
true,
false,
false,
false,
0,
'Valid values: [1-31], [1-31]-[1-31], *, or step value (example: */5, 7/2)'
);
$table->data[0][3] = html_print_extended_select_for_downtime_cron(
'cron_month'.$adv_mode_name,
$months,
$month,
'',
__('Any'),
'*',
false,
true,
false,
false,
false,
0,
'Valid values: [1-12], [1-12]-[1-12], *, or step value (example: */3, 9/1)'
);
$table->data[0][4] = html_print_extended_select_for_downtime_cron(
'cron_wday'.$adv_mode_name,
$wdays,
$wday,
'',
__('Any'),
'*',
false,
true,
false,
false,
false,
0,
'Valid values: [0-6], [0-6]-[0-6], *, or step value (example: */2, 3/1)'
);
} }
return html_print_table($table, $return); return html_print_table($table, $return);
@ -6171,3 +6257,112 @@ function html_print_go_back_button(string $url, array $options=[], bool $return=
return $output; return $output;
} }
/**
* Render select box for numeric values and text box for complex values.
*
* @param string $name Select form name.
* @param string $fields Fields to populate select box.
* @param mixed $selected Current selected value. It can be a single value or an array of selected values (in combination with multiple).
* @param string $script Javascript onChange (select) code.
* @param string $nothing Label when nothing is selected.
* @param mixed $nothing_value Value when nothing is selected.
* @param integer $size Size of the input.
* @param boolean $return Whether to return an output string or echo now (optional, echo by default).
* @param boolean $select_style Wherter to assign to combo a unique name (to have more than one on same page, like dashboard).
* @param boolean $unique_name Uunique name value.
* @param boolean $disabled Input renders as disabled.
* @param boolean $no_change No change value.
* @param boolean $text_help Tooltip.
* @return string HTML code if return parameter is true.
*/
function html_print_extended_select_for_downtime_cron(
$name,
$fields,
$selected='',
$script='',
$nothing='',
$nothing_value='0',
$size=false,
$return=false,
$select_style=false,
$unique_name=true,
$disabled=false,
$no_change=0,
$text_help=''
) {
global $config;
if ($unique_name === true) {
$uniq_name = uniqid($name);
} else {
$uniq_name = $name;
}
ob_start();
echo '<div id="'.$uniq_name.'_default" class="w100p inline_line">';
html_print_select(
$fields,
$uniq_name.'_select',
$selected,
''.$script,
$nothing,
$nothing_value,
false,
false,
false,
'',
$disabled,
'font-size: xx-small;'.$select_style
);
echo ' <a href="javascript:">'.html_print_image(
'images/pencil.png',
true,
[
'class' => $uniq_name.'_toggler',
'alt' => __('Custom'),
'title' => __('Custom'),
'style' => 'width: 18px;',
]
).'</a>';
echo '</div>';
$help_tooltip = ($text_help !== '') ? ui_print_help_tip(__($text_help), true) : '';
echo '<div id="'.$uniq_name.'_manual" class="w100p inline_line">';
html_print_input_text($uniq_name.'_text', $selected, '', 20);
html_print_input_hidden($name, $selected, false, $uniq_name);
echo ' <a href="javascript:">'.$help_tooltip.'&nbsp'.html_print_image(
'images/default_list.png',
true,
[
'class' => $uniq_name.'_toggler',
'alt' => __('List'),
'title' => __('List'),
'style' => 'width: 18px;',
]
).'</a>';
echo '</div>';
$select_init_func = (is_numeric($selected) === true || $selected === '*') ? 'post_process_select_init' : 'post_process_select_init_inv';
echo "<script type='text/javascript'>
$(document).ready (function () {
".$select_init_func."('$uniq_name','$selected');
post_process_select_events_unit('$uniq_name','$selected');
});
</script>";
$returnString = ob_get_clean();
if ($return) {
return $returnString;
} else {
echo $returnString;
}
}

View File

@ -95,3 +95,168 @@ function attachActionButton(
$return $return
); );
} }
/**
* Get table inputs for massive operation agents edit and delete.
*
* @param array $params Params.
*
* @return string Output.
*/
function get_table_inputs_masive_agents($params)
{
global $config;
$table = new stdClass;
$table->id = 'delete_table';
$table->class = 'databox filters';
$table->width = '100%';
$table->data = [];
$table->style = [];
$table->style[0] = 'font-weight: bold;';
$table->style[2] = 'font-weight: bold';
$table->size = [];
$table->size[0] = '15%';
$table->size[1] = '35%';
$table->size[2] = '15%';
$table->size[3] = '35%';
$table->data = [];
$table->data[0][0] = __('Group');
$table->data[0][1] = html_print_select_groups(
false,
'AW',
true,
'id_group',
$params['id_group'],
false,
'',
'',
true
);
$table->data[0][2] = __('Group recursion');
$table->data[0][3] = html_print_checkbox(
'recursion',
1,
$params['recursion'],
true,
false
);
$status_list = [];
$status_list[AGENT_STATUS_NORMAL] = __('Normal');
$status_list[AGENT_STATUS_WARNING] = __('Warning');
$status_list[AGENT_STATUS_CRITICAL] = __('Critical');
$status_list[AGENT_STATUS_UNKNOWN] = __('Unknown');
$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
$status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
$table->data[1][0] = __('Status');
$table->data[1][1] = html_print_select(
$status_list,
'status_agents',
'selected',
'',
__('All'),
AGENT_STATUS_ALL,
true
);
$table->data[1][2] = __('Show agents');
$table->data[1][3] = html_print_select(
[
0 => 'Only enabled',
1 => 'Only disabled',
],
'disabled',
2,
'',
__('All'),
2,
true,
false,
true,
'',
false,
'width:30%;'
);
if (is_metaconsole() === true) {
$servers = metaconsole_get_servers();
$server_fields = [];
foreach ($servers as $key => $server) {
$server_fields[$key] = $server['server_name'];
}
$table->data[2][2] = __('Node');
$table->data[2][3] = html_print_select(
$server_fields,
'nodes[]',
0,
false,
'',
'',
true,
true,
true,
'',
false,
'min-width: 500px; max-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true
);
}
$table->data[3][0] = __('Agents');
$table->data[3][0] .= '<span id="agent_loading" class="invisible">';
$table->data[3][0] .= html_print_image('images/spinner.png', true);
$table->data[3][0] .= '</span>';
$agents = [];
if (is_metaconsole() === false) {
$agents = agents_get_group_agents(
array_keys(users_get_groups($config['id_user'], 'AW', false)),
['disabled' => 2],
'none'
);
}
$table->data[3][1] = html_print_select(
$agents,
'id_agents[]',
0,
false,
'',
'',
true,
true,
true,
'',
false,
'min-width: 500px; max-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true
);
$output = html_print_table($table, true);
return $output;
}

View File

@ -656,7 +656,7 @@ function menu_get_sec_pages($sec, $menu_hash=false)
foreach ($menu[$sec]['sub'] as $k => $v) { foreach ($menu[$sec]['sub'] as $k => $v) {
// Avoid special cases of standalone windows. // Avoid special cases of standalone windows.
if (preg_match('/^javascript:/', $k) || preg_match('/\.php/', $k)) { if (preg_match('/^javascript:/', $k) || preg_match('/\.php/', $k)) {
if ($sec !== 'links') { if ($sec !== 'links' && $sec !== 'eventos') {
continue; continue;
} }
} }

View File

@ -539,6 +539,8 @@ function planned_downtimes_migrate_malformed_downtimes_copy_items($original_down
*/ */
function planned_downtimes_stop($downtime) function planned_downtimes_stop($downtime)
{ {
global $config;
$result = false; $result = false;
$message = ''; $message = '';
@ -672,6 +674,21 @@ function planned_downtimes_stop($downtime)
} }
break; break;
case 'disable_agent_modules':
$update_sql = sprintf(
'UPDATE tagente_modulo tam, tagente ta, tplanned_downtime_modules tpdm
SET tam.disabled = 0, ta.update_module_count = 1
WHERE tpdm.id_agent_module = tam.id_agente_modulo AND
ta.id_agente = tam.id_agente AND
tpdm.id_downtime = %d',
$id_downtime
);
db_process_sql($update_sql);
$count = '';
break;
case 'disable_agents_alerts': case 'disable_agents_alerts':
$agents = db_get_all_rows_filter( $agents = db_get_all_rows_filter(
'tplanned_downtime_agents', 'tplanned_downtime_agents',

View File

@ -774,6 +774,13 @@ function reporting_make_reporting_data(
); );
break; break;
case 'modules_inventory':
$report['contents'][] = reporting_modules_inventory(
$report,
$content
);
break;
case 'inventory': case 'inventory':
$report['contents'][] = reporting_inventory( $report['contents'][] = reporting_inventory(
$report, $report,
@ -2438,6 +2445,14 @@ function reporting_event_report_module(
} }
/**
* Generate agents inventory report.
*
* @param array $report Report info.
* @param array $content Content info.
*
* @return array
*/
function reporting_agents_inventory($report, $content) function reporting_agents_inventory($report, $content)
{ {
global $config; global $config;
@ -2470,7 +2485,7 @@ function reporting_agents_inventory($report, $content)
$custom_field_sql = ''; $custom_field_sql = '';
$search_sql = ''; $search_sql = '';
if (!empty($es_agent_custom_fields)) { if (empty(array_filter($es_agent_custom_fields)) === false) {
$custom_field_sql = 'INNER JOIN tagent_custom_data tacd ON tacd.id_agent = tagente.id_agente'; $custom_field_sql = 'INNER JOIN tagent_custom_data tacd ON tacd.id_agent = tagente.id_agente';
if ($es_agent_custom_fields[0] != 0) { if ($es_agent_custom_fields[0] != 0) {
$custom_field_sql .= ' AND tacd.id_field IN ('.implode(',', $es_agent_custom_fields).')'; $custom_field_sql .= ' AND tacd.id_field IN ('.implode(',', $es_agent_custom_fields).')';
@ -2629,6 +2644,146 @@ function reporting_agents_inventory($report, $content)
} }
/**
* Generate modules inventory report.
*
* @param array $report Report info.
* @param array $content Content info.
*
* @return array
*/
function reporting_modules_inventory($report, $content)
{
global $config;
$return['name'] = $content['name'];
$return['type'] = 'modules_inventory';
$return['title'] = $content['name'];
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['description'] = $content['description'];
$return['date'] = reporting_get_date_text($report, $content);
$external_source = io_safe_input(json_decode($content['external_source'], true));
$es_agent_group_filter = $external_source['agent_group_filter'];
$module_group = $external_source['module_group'];
$es_agent_server_filter = $external_source['agent_server_filter'];
$search_sql = '';
if (empty($es_agent_group_filter) === false) {
$search_sql .= ' AND (ta.id_grupo = '.$es_agent_group_filter.' OR tasg.id_group = '.$es_agent_group_filter.')';
}
if (empty($module_group) === false && $module_group > -1) {
$search_sql .= ' AND tam.id_module_group = '.$module_group;
}
$user_groups_to_sql = '';
$user_groupsAR = users_get_groups($config['id_user'], 'AR');
$user_groups = $user_groupsAR;
$user_groups_to_sql = implode(',', array_keys($user_groups));
$sql = sprintf(
'SELECT tam.id_agente_modulo,
tam.nombre,
tam.descripcion,
tam.id_module_group,
ttm.id_tag,
ta.id_grupo AS group_id,
tasg.id_group AS sec_group_id
FROM tagente_modulo tam
INNER JOIN tagente ta
ON tam.id_agente = ta.id_agente
LEFT JOIN tagent_secondary_group tasg
ON ta.id_agente = tasg.id_agent
LEFT JOIN ttag_module ttm
ON ttm.id_agente_modulo = tam.id_agente_modulo
WHERE (ta.id_grupo IN (%s) OR tasg.id_group IN (%s)) %s',
$user_groups_to_sql,
$user_groups_to_sql,
$search_sql
);
if (is_metaconsole()) {
$servers_ids = array_column(metaconsole_get_servers(), 'id');
} else {
$servers_ids = [0];
}
$return_data = [];
foreach ($servers_ids as $server_id) {
if (is_metaconsole()) {
$server = metaconsole_get_connection_by_id($server_id);
if ((int) $es_agent_server_filter !== 0
&& (int) $es_agent_server_filter !== (int) $server_id
) {
continue;
}
metaconsole_connect($server);
}
$agents = db_get_all_rows_sql($sql);
$return_data[$server_id] = $agents;
if (is_metaconsole()) {
metaconsole_restore_db();
}
}
$all_data = [];
foreach ($return_data as $server_agents) {
foreach ($server_agents as $agent) {
$all_data[] = $agent;
}
}
$return['data'] = $all_data;
$module_row_data = [];
foreach ($return['data'] as $row) {
if (is_array($module_row_data[$row['id_agente_modulo']]) === false) {
$module_row_data[$row['id_agente_modulo']]['nombre'] = $row['nombre'];
$module_row_data[$row['id_agente_modulo']]['descripcion'] = $row['descripcion'];
$module_row_data[$row['id_agente_modulo']]['id_module_group'] = $row['id_module_group'];
$module_row_data[$row['id_agente_modulo']]['id_tag'] = [];
$module_row_data[$row['id_agente_modulo']]['group_id'] = [];
$module_row_data[$row['id_agente_modulo']]['sec_group_id'] = [];
}
if (in_array($row['id_tag'], $module_row_data[$row['id_agente_modulo']]['id_tag']) === false
&& $row['id_tag'] !== null
) {
$module_row_data[$row['id_agente_modulo']]['id_tag'][] = $row['id_tag'];
}
if (in_array($row['group_id'], $module_row_data[$row['id_agente_modulo']]['group_id']) === false
&& $row['group_id'] !== null
) {
$module_row_data[$row['id_agente_modulo']]['group_id'][] = $row['group_id'];
}
if (in_array($row['sec_group_id'], $module_row_data[$row['id_agente_modulo']]['sec_group_id']) === false
&& $row['sec_group_id'] !== null
) {
$module_row_data[$row['id_agente_modulo']]['sec_group_id'][] = $row['sec_group_id'];
}
}
$return['data'] = $module_row_data;
return reporting_check_structure_content($return);
}
function reporting_inventory_changes($report, $content, $type) function reporting_inventory_changes($report, $content, $type)
{ {
global $config; global $config;
@ -7591,15 +7746,7 @@ function reporting_advanced_sla(
} }
if (isset($max_value) === false || (int) $max_value === 0) { if (isset($max_value) === false || (int) $max_value === 0) {
if ($max_value === '0' $max_value = null;
&& $max_value < $min_value
&& isset($min_value_warning) === true
&& $min_value_warning > $max_value
) {
$max_value = $min_value_warning;
} else {
$max_value = null;
}
} }
if (isset($max_value) === false && isset($min_value) === false) { if (isset($max_value) === false && isset($min_value) === false) {
@ -8154,18 +8301,21 @@ function reporting_advanced_sla(
$inverse_interval $inverse_interval
); );
// Warning SLA check. $sla_check_value_warning = false;
$sla_check_value_warning = sla_check_value( if ($sla_check_value === true) {
$current_data['datos'], // Warning SLA check.
$min_value_warning, $sla_check_value_warning = sla_check_value(
$max_value_warning, $current_data['datos'],
$inverse_interval_warning, $min_value_warning,
1 $max_value_warning,
); $inverse_interval_warning,
1
);
}
} }
// Not unknown nor not init values. // Not unknown nor not init values.
if ($sla_check_value_warning && $sla_check_warning === true) { if ($sla_check_value_warning === true && $sla_check_warning === true) {
if (isset($current_data['type']) === false if (isset($current_data['type']) === false
|| ((int) $current_data['type'] === 0 || ((int) $current_data['type'] === 0
&& $i !== 0) && $i !== 0)
@ -11466,7 +11616,7 @@ function reporting_get_stats_alerts($data, $links=false)
{ {
global $config; global $config;
// Link URLS // Link URLS.
$mobile = false; $mobile = false;
if (isset($data['mobile'])) { if (isset($data['mobile'])) {
if ($data['mobile']) { if ($data['mobile']) {
@ -11482,14 +11632,14 @@ function reporting_get_stats_alerts($data, $links=false)
$urls = []; $urls = [];
if ($links) { if ($links) {
$urls['monitor_alerts'] = 'index.php?sec=estado&sec2=operation/agentes/alerts_status&pure='.$config['pure']; $urls['monitor_alerts'] = 'index.php?sec=estado&sec2=operation/agentes/alerts_status&pure='.$config['pure'];
$urls['monitor_alerts_fired'] = 'index.php?sec=estado&sec2=operation/agentes/alerts_status&filter=fired&pure='.$config['pure']; $urls['monitor_alerts_fired'] = 'index.php?sec=estado&sec2=operation/agentes/alerts_status&disabled=fired&pure='.$config['pure'];
} else { } else {
$urls['monitor_alerts'] = $config['homeurl'].'index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;refr=60'; $urls['monitor_alerts'] = $config['homeurl'].'index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;refr=60';
$urls['monitor_alerts_fired'] = $config['homeurl'].'index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;refr=60&filter=fired'; $urls['monitor_alerts_fired'] = $config['homeurl'].'index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;refr=60&disabled=fired';
} }
} }
// Alerts table // Alerts table.
$table_al = html_get_predefined_table(); $table_al = html_get_predefined_table();
$tdata = []; $tdata = [];
@ -11528,7 +11678,7 @@ function reporting_get_stats_alerts($data, $links=false)
$output = '<fieldset class="databox tactical_set"> $output = '<fieldset class="databox tactical_set">
<legend>'.__('Defined and fired alerts').'</legend>'.html_print_table($table_al, true).'</fieldset>'; <legend>'.__('Defined and fired alerts').'</legend>'.html_print_table($table_al, true).'</fieldset>';
} else { } else {
// Remove the defined alerts cause with the new cache table is difficult to retrieve them // Remove the defined alerts cause with the new cache table is difficult to retrieve them.
unset($table_al->data[0][0], $table_al->data[0][1]); unset($table_al->data[0][0], $table_al->data[0][1]);
$table_al->class = 'tactical_view'; $table_al->class = 'tactical_view';
@ -14211,6 +14361,10 @@ function reporting_format_planned_downtime_dates($planned_downtime)
$dates = date('Y-m-d H:i', $planned_downtime['date_from']).'&nbsp;'.__('to').'&nbsp;'.date('Y-m-d H:i', $planned_downtime['date_to']); $dates = date('Y-m-d H:i', $planned_downtime['date_from']).'&nbsp;'.__('to').'&nbsp;'.date('Y-m-d H:i', $planned_downtime['date_to']);
break; break;
case 'cron':
$dates = __('Start condition').': <span class="italic">'.$planned_downtime['cron_interval_from'].'</span> - '.__('Stop condition').': <span class="italic">'.$planned_downtime['cron_interval_to'].'</span>';
break;
case 'periodically': case 'periodically':
if (!isset($planned_downtime['type_periodicity'])) { if (!isset($planned_downtime['type_periodicity'])) {
return ''; return '';

View File

@ -394,6 +394,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
reporting_html_agents_inventory($table, $item); reporting_html_agents_inventory($table, $item);
break; break;
case 'modules_inventory':
reporting_html_modules_inventory($table, $item);
break;
case 'inventory': case 'inventory':
reporting_html_inventory($table, $item); reporting_html_inventory($table, $item);
break; break;
@ -1677,6 +1681,117 @@ function reporting_html_agents_inventory($table, $item, $pdf=0)
} }
/**
* Print html modules inventory
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param boolean $pdf Print pdf true or false.
*
* @return string HTML code.
*/
function reporting_html_modules_inventory($table, $item, $pdf=0)
{
global $config;
$table1 = new stdClass();
$table1->width = '100%';
$table1->style[0] = 'text-align: left;vertical-align: top;min-width: 100px;';
$table1->class = 'databox data';
$table1->cellpadding = 1;
$table1->cellspacing = 1;
$table1->styleTable = 'overflow: wrap; table-layout: fixed;';
$table1->style[0] = 'text-align: left;vertical-align: top;min-width: 100px;';
$table1->style[1] = 'text-align: left;vertical-align: top;min-width: 100px;';
$table1->style[2] = 'text-align: left;vertical-align: top; min-width: 100px';
$table1->style[3] = 'text-align: left;vertical-align: top;min-width: 100px;';
$table1->style[4] = 'text-align: left;vertical-align: top;min-width: 100px;';
$table1->style[5] = 'text-align: left;vertical-align: top; min-width: 100px';
$table1->head = [];
$table1->head[] = __('Name');
$table1->head[] = __('Description');
$table1->head[] = __('Module group');
$table1->head[] = __('Tags');
$table1->head[] = __('Agent group');
$table1->head[] = __('Agent secondary groups');
$table1->headstyle[0] = 'text-align: left';
$table1->headstyle[1] = 'text-align: left';
$table1->headstyle[2] = 'text-align: left';
$table1->headstyle[3] = 'text-align: left';
$table1->headstyle[4] = 'text-align: left';
$table1->headstyle[5] = 'text-align: left';
$table1->data = [];
foreach ($item['data'] as $module_id => $module_data) {
$row = [];
$first_item = array_pop(array_reverse($module_data));
foreach ($module_data as $data_field_key => $data_field_value) {
if ($data_field_key === 'nombre') {
$column_value = $data_field_value;
} else if ($data_field_key === 'descripcion') {
$column_value = $data_field_value;
} else if ($data_field_key === 'id_module_group') {
$module_group_name = modules_get_modulegroup_name($data_field_value);
if ($module_group_name === '') {
$module_group_name = '-';
}
$column_value = $module_group_name;
} else if ($data_field_key === 'id_tag') {
$tags_names = array_map(
function ($tag_id) {
return db_get_value('name', 'ttag', 'id_tag', $tag_id);
},
$data_field_value
);
$column_value = implode('<br>', $tags_names);
} else if ($data_field_key === 'group_id') {
$column_value = groups_get_name($data_field_value[0]);
} else if ($data_field_key === 'sec_group_id') {
$sec_groups_names = array_map(
function ($group_id) {
return groups_get_name($group_id);
},
$data_field_value
);
$column_value = implode('<br>', $sec_groups_names);
}
$row[] = $column_value;
}
$table1->data[] = $row;
if ($pdf !== 0) {
$table1->data[] = '<br />';
}
}
if ($pdf === 0) {
$table->colspan['permissions']['cell'] = 3;
$table->cellstyle['permissions']['cell'] = 'text-align: center;';
$table->data['permissions']['cell'] = html_print_table(
$table1,
true
);
} else {
return html_print_table(
$table1,
true
);
}
}
/** /**
* Print in html inventory changes reports * Print in html inventory changes reports
* *
@ -4110,7 +4225,7 @@ function reporting_html_availability($table, $item, $pdf=0)
} else { } else {
$table_row[] = $row['agent']; $table_row[] = $row['agent'];
$item_name = $row['availability_item']; $item_name = $row['availability_item'];
if ((bool) $row['compare'] === true) { if ((bool) $row['compare'] === false) {
$item_name .= ' ('.__('24 x 7').')'; $item_name .= ' ('.__('24 x 7').')';
} }

View File

@ -880,6 +880,13 @@ function reports_get_report_types($template=false, $not_editor=false)
]; ];
} }
if (!$template) {
$types['modules_inventory'] = [
'optgroup' => __('Inventory'),
'name' => __('Modules inventory'),
];
}
if ($config['enterprise_installed']) { if ($config['enterprise_installed']) {
$types['inventory'] = [ $types['inventory'] = [
'optgroup' => __('Inventory'), 'optgroup' => __('Inventory'),

View File

@ -416,7 +416,7 @@ function tactical_get_data(
} else { } else {
$result_list = db_get_all_rows_sql( $result_list = db_get_all_rows_sql(
sprintf( sprintf(
'SELECT COUNT(*) as contado, estado 'SELECT COUNT(DISTINCT(tam.id_agente_modulo)) as contado, estado
FROM tagente_estado tae FROM tagente_estado tae
INNER JOIN tagente ta INNER JOIN tagente ta
ON tae.id_agente = ta.id_agente ON tae.id_agente = ta.id_agente

View File

@ -751,7 +751,8 @@ function tags_get_acl_tags(
$childrens_ids=[], $childrens_ids=[],
$force_group_and_tag=false, $force_group_and_tag=false,
$id_grupo_table_pretag='', $id_grupo_table_pretag='',
$alt_id_grupo_table_pretag='' $alt_id_grupo_table_pretag='',
$search_secondary_group=true
) { ) {
global $config; global $config;
@ -831,7 +832,8 @@ function tags_get_acl_tags(
$force_group_and_tag, $force_group_and_tag,
false, false,
$id_grupo_table_pretag, $id_grupo_table_pretag,
$alt_id_grupo_table_pretag $alt_id_grupo_table_pretag,
$search_secondary_group
); );
if (!empty($condition)) { if (!empty($condition)) {
@ -933,7 +935,8 @@ function tags_get_acl_tags_event_condition(
$force_group_and_tag=false, $force_group_and_tag=false,
$force_equal=false, $force_equal=false,
$id_grupo_table_pretag='', $id_grupo_table_pretag='',
$alt_id_grupo_table_pretag='' $alt_id_grupo_table_pretag='',
$search_secondary_group=true
) { ) {
global $config; global $config;
$condition = []; $condition = [];
@ -951,7 +954,13 @@ function tags_get_acl_tags_event_condition(
// Group condition (The module belongs to an agent of the group X) // Group condition (The module belongs to an agent of the group X)
// $group_condition = sprintf('id_grupo IN (%s)', implode(',', array_values(groups_get_children_ids($group_id, true))));. // $group_condition = sprintf('id_grupo IN (%s)', implode(',', array_values(groups_get_children_ids($group_id, true))));.
$group_condition = '('.$id_grupo_table_pretag.'id_grupo = '.$group_id.' OR '.$alt_id_grupo_table_pretag.'id_group = '.$group_id.')'; $group_condition = '('.$id_grupo_table_pretag.'id_grupo = '.$group_id;
if ($search_secondary_group === true) {
$group_condition .= ' OR '.$alt_id_grupo_table_pretag.'id_group = '.$group_id;
}
$group_condition .= ')';
// Tags condition (The module has at least one of the restricted tags). // Tags condition (The module has at least one of the restricted tags).
$tags_condition = ''; $tags_condition = '';
@ -987,7 +996,13 @@ function tags_get_acl_tags_event_condition(
} }
$in_group = implode(',', $without_tags); $in_group = implode(',', $without_tags);
$condition .= sprintf('('.$id_grupo_table_pretag.'id_grupo IN (%s) OR '.$alt_id_grupo_table_pretag.'id_group IN (%s))', $in_group, $in_group); $condition .= sprintf('('.$id_grupo_table_pretag.'id_grupo IN (%s)', $in_group);
if ($search_secondary_group === true) {
$condition .= sprintf(' OR '.$alt_id_grupo_table_pretag.'id_group IN (%s)', $in_group);
}
$condition .= ')';
} }
$condition = !empty($condition) ? "($condition)" : ''; $condition = !empty($condition) ? "($condition)" : '';
@ -1319,7 +1334,7 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags=[], $children
WHERE ".get_acl_column($access).' = 1)'; WHERE ".get_acl_column($access).' = 1)';
if (isset($id_group)) { if (isset($id_group)) {
$sql .= 'AND id_grupo = '.$id_group; $sql .= ' AND id_grupo = '.$id_group;
} }
$user_has_perm_without_tags = db_get_all_rows_sql($sql); $user_has_perm_without_tags = db_get_all_rows_sql($sql);
@ -1328,6 +1343,7 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags=[], $children
return true; return true;
} }
$tags_aux = [];
$tags_str = ''; $tags_str = '';
if (!empty($tags)) { if (!empty($tags)) {
foreach ($tags as $tag) { foreach ($tags as $tag) {

View File

@ -473,9 +473,9 @@ function treeview_printAlertsTable($id_module, $server_data=[], $no_head=false)
if ($user_access_node && check_acl($config['id_user'], $id_group, 'LW')) { if ($user_access_node && check_acl($config['id_user'], $id_group, 'LW')) {
// Actions table // Actions table
echo '<div class="w100p right mw300px right_align">'; echo '<div class="w100p right_align">';
echo '<a target=_blank href="'.$console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&search=1&module_name='.$module_name.'&id_agente='.$agent_id.$url_hash.'" target="_blank">'; echo '<a target=_blank href="'.$console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&search=1&module_name='.$module_name.'&id_agente='.$agent_id.$url_hash.'" target="_blank">';
html_print_submit_button(__('Go to alerts edition'), 'upd_button', false, 'class="sub search"'); html_print_submit_button(__('Go to alerts edition'), 'upd_button', false, 'class="sub search" style="margin-right: 20px"');
echo '</a>'; echo '</a>';
echo '</div>'; echo '</div>';
} }

View File

@ -94,3 +94,55 @@ function showMassiveOperationMessage(message) {
}); });
} }
*/ */
// eslint-disable-next-line no-unused-vars
function form_controls_massive_operations_agents(metaconsole) {
// Listeners.
var recursion;
$("#checkbox-recursion").click(function() {
recursion = this.checked ? 1 : 0;
$("#id_group").trigger("change");
});
var disabled;
$("#disabled").change(function() {
disabled = this.value;
$("#id_group").trigger("change");
});
var nodes;
$("#nodes").change(function() {
nodes = $("#nodes").val();
$("#id_group").trigger("change");
});
$("#status_agents").change(function() {
$("#id_group").trigger("change");
});
// Build data.
var data = {
status_agents: function() {
return $("#status_agents").val();
},
agentSelect: "select#id_agents",
privilege: "AW",
recursion: function() {
return recursion;
},
disabled: function() {
return disabled;
}
};
if (metaconsole == 1) {
data.serialized = true;
data.serialized_separator = "|";
data.nodes = function() {
return nodes;
};
}
// Change agents.
$("#id_group").pandoraSelectGroupAgent(data);
}

View File

@ -737,6 +737,11 @@ function post_process_select_init(name) {
$("#" + name + "_default").show(); $("#" + name + "_default").show();
} }
function post_process_select_init_inv(name) {
$("#" + name + "_manual").show();
$("#" + name + "_default").hide();
}
function post_process_select_init_unit(name, selected) { function post_process_select_init_unit(name, selected) {
// Manual mode is hidden by default // Manual mode is hidden by default

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -539,7 +539,7 @@ class BlockHistogram extends Widget
25, 25,
false, false,
true, true,
true, true
); );
break; break;

View File

@ -239,6 +239,10 @@ class SystemGroupStatusWidget extends Widget
$values['groupId'] = $decoder['groupId']; $values['groupId'] = $decoder['groupId'];
} }
if (isset($decoder['groupRecursion']) === true) {
$values['groupRecursion'] = $decoder['groupRecursion'];
}
return $values; return $values;
} }
@ -326,6 +330,16 @@ class SystemGroupStatusWidget extends Widget
], ],
]; ];
$inputs[] = [
'label' => __('Group recursion'),
'arguments' => [
'name' => 'groupRecursion',
'id' => 'groupRecursion',
'type' => 'switch',
'value' => $values['groupRecursion'],
],
];
return $inputs; return $inputs;
} }
@ -342,6 +356,7 @@ class SystemGroupStatusWidget extends Widget
$values['groupId'] = \get_parameter('groupId', []); $values['groupId'] = \get_parameter('groupId', []);
$values['status'] = \get_parameter('status', []); $values['status'] = \get_parameter('status', []);
$values['groupRecursion'] = (bool) \get_parameter_switch('groupRecursion', 0);
return $values; return $values;
} }
@ -381,6 +396,14 @@ class SystemGroupStatusWidget extends Widget
$selected_groups = explode(',', $this->values['groupId'][0]); $selected_groups = explode(',', $this->values['groupId'][0]);
// Recursion.
if ($this->values['groupRecursion'] === true) {
foreach ($selected_groups as $father) {
$children = \groups_get_children_ids($father);
$selected_groups = ($selected_groups + $children);
}
}
if ($selected_groups[0] === '') { if ($selected_groups[0] === '') {
return false; return false;
} }
@ -450,7 +473,7 @@ class SystemGroupStatusWidget extends Widget
$result_groups[0] = $all_counters; $result_groups[0] = $all_counters;
} }
$this->values['groupId'] = explode(',', $this->values['groupId'][0]); $this->values['groupId'] = $selected_groups;
$this->values['status'] = explode(',', $this->values['status'][0]); $this->values['status'] = explode(',', $this->values['status'][0]);
$style = 'font-size: 12px; text-align: center;'; $style = 'font-size: 12px; text-align: center;';

View File

@ -437,7 +437,7 @@ div#dashboard-controls {
z-index: 1; z-index: 1;
top: 10px; top: 10px;
right: 10px; right: 10px;
width: 600px; width: 800px;
height: 70px; height: 70px;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -446,7 +446,7 @@ div#dashboard-controls {
align-items: center; align-items: center;
background-color: #f2f6f7; background-color: #f2f6f7;
border-radius: 15px; border-radius: 15px;
padding: 10px; padding: 0px 10px;
} }
div#dashboard-controls div { div#dashboard-controls div {
@ -455,13 +455,24 @@ div#dashboard-controls div {
} }
div#dashboard-controls div#dashboard-slides-form-countdown { div#dashboard-controls div#dashboard-slides-form-countdown {
flex: 4; flex: 7;
} }
div#dashboard-controls div#dashboard-slides-name { div#dashboard-controls div#dashboard-slides-name {
flex: 3; flex: 3;
} }
div#dashboard-controls div.dashboard-mode {
flex: 1;
display: flex;
flex-direction: row;
justify-content: center;
}
div#dashboard-controls div.dashboard-mode a {
margin: 0px;
}
div#view-slides-cell-mode { div#view-slides-cell-mode {
min-height: 100vh; min-height: 100vh;
width: 100vw; width: 100vw;
@ -490,6 +501,13 @@ div#main_pure {
margin: 0 auto; margin: 0 auto;
margin-top: 30px; margin-top: 30px;
} }
.dashboard-refr {
display: flex;
flex-direction: row-reverse;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
}
#form-config-widget .info_box, #form-config-widget .info_box,
.content-widget .info_box { .content-widget .info_box {

View File

@ -201,7 +201,7 @@ ol.steps li.visited a {
} }
/* White text */ /* White text */
a, a:not(.visual-console-item),
label, label,
#menu_tab_left li a, #menu_tab_left li a,
#menu_tab_left li span, #menu_tab_left li span,

50532
pandora_console/index.pot Normal file

File diff suppressed because it is too large Load Diff

View File

@ -128,8 +128,8 @@
</div> </div>
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.763'; $version = '7.0NG.764';
$build = '220810'; $build = '220921';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

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