diff --git a/extras/deploy-scripts/deploy_ext_database_el8.sh b/extras/deploy-scripts/deploy_ext_database_el8.sh index 3ff86cc56b..4417265599 100644 --- a/extras/deploy-scripts/deploy_ext_database_el8.sh +++ b/extras/deploy-scripts/deploy_ext_database_el8.sh @@ -19,10 +19,10 @@ LOGFILE="/tmp/deploy-ext-db-$(date +%F).log" [ "$DBHOST" ] || DBHOST=127.0.0.1 [ "$DBNAME" ] || DBNAME=pandora [ "$DBUSER" ] || DBUSER=pandora -[ "$DBPASS" ] || DBPASS=pandora +[ "$DBPASS" ] || DBPASS='Pandor4!' [ "$DBPORT" ] || DBPORT=3306 [ "$DBROOTUSER" ] || DBROOTUSER=root -[ "$DBROOTPASS" ] || DBROOTPASS=pandora +[ "$DBROOTPASS" ] || DBROOTPASS='Pandor4!' [ "$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") @@ -79,6 +79,53 @@ check_root_permissions () { fi } +# Function to check if a password meets the MySQL secure password requirements +is_mysql_secure_password() { + local password=$1 + + # Check password length (at least 8 characters) + if [[ ${#password} -lt 8 ]]; then + echo "Password length should be at least 8 characters." + return 1 + fi + + # Check if password contains at least one uppercase letter + if [[ $password == ${password,,} ]]; then + echo "Password should contain at least one uppercase letter." + return 1 + fi + + # Check if password contains at least one lowercase letter + if [[ $password == ${password^^} ]]; then + echo "Password should contain at least one lowercase letter." + return 1 + fi + + # Check if password contains at least one digit + if ! [[ $password =~ [0-9] ]]; then + echo "Password should contain at least one digit." + return 1 + fi + + # Check if password contains at least one special character + if ! [[ $password =~ [[:punct:]] ]]; then + echo "Password should contain at least one special character." + return 1 + fi + + # Check if password is not a common pattern (e.g., "password", "123456") + local common_patterns=("password" "123456" "qwerty") + for pattern in "${common_patterns[@]}"; do + if [[ $password == *"$pattern"* ]]; then + echo "Password should not contain common patterns." + return 1 + fi + done + + # If all checks pass, the password is MySQL secure compliant + return 0 +} + ## Main echo "Starting PandoraFMS External DB deployment EL8 ver. $S_VERSION" @@ -128,6 +175,10 @@ execute_cmd "grep --version" 'Checking needed tools: grep' execute_cmd "sed --version" 'Checking needed tools: sed' execute_cmd "dnf --version" 'Checking needed tools: dnf' +#Check mysql pass +execute_cmd "is_mysql_secure_password $DBROOTPASS" "Checking DBROOTPASS password match policy" 'This password do not match minimum MySQL policy requirements, more info in: https://dev.mysql.com/doc/refman/8.0/en/validate-password.html' +execute_cmd "is_mysql_secure_password $DBPASS" "Checking DBPASS password match policy" 'This password do not match minimum MySQL policy requirements, more info in: https://dev.mysql.com/doc/refman/8.0/en/validate-password.html' + # Creating working directory rm -rf "$HOME"/pandora_deploy_tmp/*.rpm* &>> "$LOGFILE" mkdir "$HOME"/pandora_deploy_tmp &>> "$LOGFILE" @@ -207,16 +258,12 @@ if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then export MYSQL_PWD=$(grep "temporary password" /var/log/mysqld.log | rev | cut -d' ' -f1 | rev) if [ "$MYVER" -eq '80' ] ; then echo """ - SET PASSWORD FOR '$DBROOTUSER'@'localhost' = 'Pandor4!'; - UNINSTALL COMPONENT 'file://component_validate_password'; SET PASSWORD FOR '$DBROOTUSER'@'localhost' = '$DBROOTPASS'; """ | mysql --connect-expired-password -u$DBROOTUSER &>> "$LOGFILE" fi if [ "$MYVER" -ne '80' ] ; then echo """ - SET PASSWORD FOR '$DBROOTUSER'@'localhost' = PASSWORD('Pandor4!'); - UNINSTALL PLUGIN validate_password; SET PASSWORD FOR '$DBROOTUSER'@'localhost' = PASSWORD('$DBROOTPASS'); """ | mysql --connect-expired-password -u$DBROOTUSER &>> "$LOGFILE"fi fi diff --git a/extras/deploy-scripts/deploy_ext_database_ubuntu_2204.sh b/extras/deploy-scripts/deploy_ext_database_ubuntu_2204.sh index 21f9b21fa0..767be5632f 100644 --- a/extras/deploy-scripts/deploy_ext_database_ubuntu_2204.sh +++ b/extras/deploy-scripts/deploy_ext_database_ubuntu_2204.sh @@ -26,9 +26,9 @@ rm -f $LOGFILE &> /dev/null # remove last log before start [ "$DBHOST" ] || DBHOST=127.0.0.1 [ "$DBNAME" ] || DBNAME=pandora [ "$DBUSER" ] || DBUSER=pandora -[ "$DBPASS" ] || DBPASS=pandora +[ "$DBPASS" ] || DBPASS='Pandor4!' [ "$DBPORT" ] || DBPORT=3306 -[ "$DBROOTPASS" ] || DBROOTPASS=pandora +[ "$DBROOTPASS" ] || DBROOTPASS='Pandor4!' [ "$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") @@ -86,6 +86,53 @@ check_root_permissions () { fi } +# Function to check if a password meets the MySQL secure password requirements +is_mysql_secure_password() { + local password=$1 + + # Check password length (at least 8 characters) + if [[ ${#password} -lt 8 ]]; then + echo "Password length should be at least 8 characters." + return 1 + fi + + # Check if password contains at least one uppercase letter + if [[ $password == ${password,,} ]]; then + echo "Password should contain at least one uppercase letter." + return 1 + fi + + # Check if password contains at least one lowercase letter + if [[ $password == ${password^^} ]]; then + echo "Password should contain at least one lowercase letter." + return 1 + fi + + # Check if password contains at least one digit + if ! [[ $password =~ [0-9] ]]; then + echo "Password should contain at least one digit." + return 1 + fi + + # Check if password contains at least one special character + if ! [[ $password =~ [[:punct:]] ]]; then + echo "Password should contain at least one special character." + return 1 + fi + + # Check if password is not a common pattern (e.g., "password", "123456") + local common_patterns=("password" "123456" "qwerty") + for pattern in "${common_patterns[@]}"; do + if [[ $password == *"$pattern"* ]]; then + echo "Password should not contain common patterns." + return 1 + fi + done + + # If all checks pass, the password is MySQL secure compliant + return 0 +} + ## Main echo "Starting PandoraFMS External DB deployment Ubuntu 22.04 ver. $S_VERSION" @@ -137,6 +184,10 @@ execute_cmd "grep --version" 'Checking needed tools: grep' execute_cmd "sed --version" 'Checking needed tools: sed' execute_cmd "apt --version" 'Checking needed tools: apt' +#Check mysql pass +execute_cmd "is_mysql_secure_password $DBROOTPASS" "Checking DBROOTPASS password match policy" 'This password do not match minimum MySQL policy requirements, more info in: https://dev.mysql.com/doc/refman/8.0/en/validate-password.html' +execute_cmd "is_mysql_secure_password $DBPASS" "Checking DBPASS password match policy" 'This password do not match minimum MySQL policy requirements, more info in: https://dev.mysql.com/doc/refman/8.0/en/validate-password.html' + # Creating working directory rm -rf "$WORKDIR" &>> "$LOGFILE" mkdir -p "$WORKDIR" &>> "$LOGFILE" @@ -170,6 +221,7 @@ if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then """ | mysql -uroot &>> "$LOGFILE" export MYSQL_PWD=$DBROOTPASS + echo "INSTALL COMPONENT 'file://component_validate_password';" | mysql -uroot -P$DBPORT -h$DBHOST &>> "$LOGFILE" 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." diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index 2e40524588..c16729bca0 100644 --- a/extras/deploy-scripts/pandora_deploy_community.sh +++ b/extras/deploy-scripts/pandora_deploy_community.sh @@ -11,7 +11,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf -S_VERSION='2023050901' +S_VERSION='2023062901' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" # define default variables @@ -285,8 +285,7 @@ console_dependencies=" \ mod_ssl \ libzstd \ openldap-clients \ - chromium \ - http://firefly.pandorafms.com/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm" + chromium" execute_cmd "yum install -y $console_dependencies" "Installing Pandora FMS Console dependencies" # Server dependencies @@ -313,7 +312,6 @@ server_dependencies=" \ bind-utils \ whois \ cpanminus \ - http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \ http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \ https://firefly.pandorafms.com/centos7/pandorawmic-1.0.0-1.x86_64.rpm" execute_cmd "yum install -y $server_dependencies" "Installing Pandora FMS Server dependencies" @@ -341,7 +339,6 @@ execute_cmd "yum install -y $oracle_dependencies || yum reinstall -y $oracle_dep #ipam dependencies ipam_dependencies=" \ - http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \ perl(NetAddr::IP) \ perl(Sys::Syslog) \ perl(DBI) \ @@ -719,6 +716,9 @@ echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cro systemctl enable pandora_agent_daemon &>> $LOGFILE execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent" +# Enable postrix +systemctl enable postfix --now &>> "$LOGFILE" + #SSH banner [ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me) diff --git a/extras/deploy-scripts/pandora_deploy_community_el8.sh b/extras/deploy-scripts/pandora_deploy_community_el8.sh index 972a094c95..32422ab98b 100644 --- a/extras/deploy-scripts/pandora_deploy_community_el8.sh +++ b/extras/deploy-scripts/pandora_deploy_community_el8.sh @@ -14,7 +14,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf -S_VERSION='2023050901' +S_VERSION='2023062901' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" # define default variables @@ -24,10 +24,10 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" [ "$DBHOST" ] || DBHOST=127.0.0.1 [ "$DBNAME" ] || DBNAME=pandora [ "$DBUSER" ] || DBUSER=pandora -[ "$DBPASS" ] || DBPASS=pandora +[ "$DBPASS" ] || DBPASS='Pandor4!' [ "$DBPORT" ] || DBPORT=3306 [ "$DBROOTUSER" ] || DBROOTUSER=root -[ "$DBROOTPASS" ] || DBROOTPASS=pandora +[ "$DBROOTPASS" ] || DBROOTPASS='Pandor4!' [ "$SKIP_PRECHECK" ] || SKIP_PRECHECK=0 [ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0 [ "$SKIP_KERNEL_OPTIMIZATIONS" ] || SKIP_KERNEL_OPTIMIZATIONS=0 @@ -125,6 +125,52 @@ installing_docker () { echo "End installig docker" &>> "$LOGFILE" } +# Function to check if a password meets the MySQL secure password requirements +is_mysql_secure_password() { + local password=$1 + + # Check password length (at least 8 characters) + if [[ ${#password} -lt 8 ]]; then + echo "Password length should be at least 8 characters." + return 1 + fi + + # Check if password contains at least one uppercase letter + if [[ $password == ${password,,} ]]; then + echo "Password should contain at least one uppercase letter." + return 1 + fi + + # Check if password contains at least one lowercase letter + if [[ $password == ${password^^} ]]; then + echo "Password should contain at least one lowercase letter." + return 1 + fi + + # Check if password contains at least one digit + if ! [[ $password =~ [0-9] ]]; then + echo "Password should contain at least one digit." + return 1 + fi + + # Check if password contains at least one special character + if ! [[ $password =~ [[:punct:]] ]]; then + echo "Password should contain at least one special character." + return 1 + fi + + # Check if password is not a common pattern (e.g., "password", "123456") + local common_patterns=("password" "123456" "qwerty") + for pattern in "${common_patterns[@]}"; do + if [[ $password == *"$pattern"* ]]; then + echo "Password should not contain common patterns." + return 1 + fi + done + + # If all checks pass, the password is MySQL secure compliant + return 0 +} ## Main echo "Starting PandoraFMS Community deployment EL8 ver. $S_VERSION" @@ -189,6 +235,10 @@ execute_cmd "grep --version" 'Checking needed tools: grep' execute_cmd "sed --version" 'Checking needed tools: sed' execute_cmd "dnf --version" 'Checking needed tools: dnf' +#Check mysql pass +execute_cmd "is_mysql_secure_password $DBROOTPASS" "Checking DBROOTPASS password match policy" 'This password do not match minimum MySQL policy requirements, more info in: https://dev.mysql.com/doc/refman/8.0/en/validate-password.html' +execute_cmd "is_mysql_secure_password $DBPASS" "Checking DBPASS password match policy" 'This password do not match minimum MySQL policy requirements, more info in: https://dev.mysql.com/doc/refman/8.0/en/validate-password.html' + # Creating working directory rm -rf "$HOME"/pandora_deploy_tmp/*.rpm* &>> "$LOGFILE" mkdir "$HOME"/pandora_deploy_tmp &>> "$LOGFILE" @@ -344,8 +394,7 @@ console_dependencies=" \ http://firefly.pandorafms.com/centos8/chromium-110.0.5481.177-1.el7.x86_64.rpm \ http://firefly.pandorafms.com/centos8/chromium-common-110.0.5481.177-1.el7.x86_64.rpm \ http://firefly.pandorafms.com/centos8/perl-Net-Telnet-3.04-1.el8.noarch.rpm \ - http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \ - http://firefly.pandorafms.com/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm" + http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm" execute_cmd "dnf install -y $console_dependencies" "Installing Pandora FMS Console dependencies" # Server dependencies @@ -371,7 +420,7 @@ server_dependencies=" \ java \ bind-utils \ whois \ - http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \ + libnsl \ http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \ https://firefly.pandorafms.com/centos8/pandorawmic-1.0.0-1.x86_64.rpm" execute_cmd "dnf install -y $server_dependencies" "Installing Pandora FMS Server dependencies" @@ -399,7 +448,6 @@ execute_cmd "dnf install -y $oracle_dependencies" "Installing Oracle Instant cli #ipam dependencies ipam_dependencies=" \ - http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \ perl(NetAddr::IP) \ perl(Sys::Syslog) \ perl(DBI) \ @@ -439,7 +487,6 @@ if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then if [ "$MYVER" -eq '80' ] ; then echo """ SET PASSWORD FOR '$DBROOTUSER'@'localhost' = 'Pandor4!'; - UNINSTALL COMPONENT 'file://component_validate_password'; SET PASSWORD FOR '$DBROOTUSER'@'localhost' = '$DBROOTPASS'; """ | mysql --connect-expired-password -u$DBROOTUSER &>> "$LOGFILE" fi @@ -447,7 +494,6 @@ if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then if [ "$MYVER" -ne '80' ] ; then echo """ SET PASSWORD FOR '$DBROOTUSER'@'localhost' = PASSWORD('Pandor4!'); - UNINSTALL PLUGIN validate_password; SET PASSWORD FOR '$DBROOTUSER'@'localhost' = PASSWORD('$DBROOTPASS'); """ | mysql --connect-expired-password -u$DBROOTUSER &>> "$LOGFILE"fi fi @@ -622,8 +668,9 @@ sed -i -e "s/^upload_max_filesize.*/upload_max_filesize = 800M/g" /etc/php.ini sed -i -e "s/^memory_limit.*/memory_limit = 800M/g" /etc/php.ini sed -i -e "s/.*post_max_size =.*/post_max_size = 800M/" /etc/php.ini -#adding 900s to httpd timeout +#adding 900s to httpd timeout and 300 to ProxyTimeout echo 'TimeOut 900' > /etc/httpd/conf.d/timeout.conf +echo 'ProxyTimeout 300' >> /etc/httpd/conf.d/timeout.conf cat > /var/www/html/index.html << EOF_INDEX @@ -787,6 +834,9 @@ echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cro systemctl enable pandora_agent_daemon &>> "$LOGFILE" execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent" +# Enable postfix +systemctl enable postfix --now &>> "$LOGFILE" + #SSH banner [ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me) diff --git a/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh b/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh index 3d31ae10af..a215808d17 100644 --- a/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh +++ b/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh @@ -17,7 +17,7 @@ PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf WORKDIR=/opt/pandora/deploy -S_VERSION='2023050901' +S_VERSION='2023062901' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" rm -f $LOGFILE &> /dev/null # remove last log before start @@ -27,9 +27,9 @@ rm -f $LOGFILE &> /dev/null # remove last log before start [ "$DBHOST" ] || DBHOST=127.0.0.1 [ "$DBNAME" ] || DBNAME=pandora [ "$DBUSER" ] || DBUSER=pandora -[ "$DBPASS" ] || DBPASS=pandora +[ "$DBPASS" ] || DBPASS='Pandor4!' [ "$DBPORT" ] || DBPORT=3306 -[ "$DBROOTPASS" ] || DBROOTPASS=pandora +[ "$DBROOTPASS" ] || DBROOTPASS='Pandor4!' [ "$SKIP_PRECHECK" ] || SKIP_PRECHECK=0 [ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0 [ "$SKIP_KERNEL_OPTIMIZATIONS" ] || SKIP_KERNEL_OPTIMIZATIONS=0 @@ -113,6 +113,53 @@ check_root_permissions () { fi } +# Function to check if a password meets the MySQL secure password requirements +is_mysql_secure_password() { + local password=$1 + + # Check password length (at least 8 characters) + if [[ ${#password} -lt 8 ]]; then + echo "Password length should be at least 8 characters." + return 1 + fi + + # Check if password contains at least one uppercase letter + if [[ $password == ${password,,} ]]; then + echo "Password should contain at least one uppercase letter." + return 1 + fi + + # Check if password contains at least one lowercase letter + if [[ $password == ${password^^} ]]; then + echo "Password should contain at least one lowercase letter." + return 1 + fi + + # Check if password contains at least one digit + if ! [[ $password =~ [0-9] ]]; then + echo "Password should contain at least one digit." + return 1 + fi + + # Check if password contains at least one special character + if ! [[ $password =~ [[:punct:]] ]]; then + echo "Password should contain at least one special character." + return 1 + fi + + # Check if password is not a common pattern (e.g., "password", "123456") + local common_patterns=("password" "123456" "qwerty") + for pattern in "${common_patterns[@]}"; do + if [[ $password == *"$pattern"* ]]; then + echo "Password should not contain common patterns." + return 1 + fi + done + + # If all checks pass, the password is MySQL secure compliant + return 0 +} + installing_docker () { #Installing docker for debug echo "Start installig docker" &>> "$LOGFILE" @@ -194,6 +241,10 @@ execute_cmd "grep --version" 'Checking needed tools: grep' execute_cmd "sed --version" 'Checking needed tools: sed' execute_cmd "apt --version" 'Checking needed tools: apt' +#Check mysql pass +execute_cmd "is_mysql_secure_password $DBROOTPASS" "Checking DBROOTPASS password match policy" 'This password do not match minimum MySQL policy requirements, more info in: https://dev.mysql.com/doc/refman/8.0/en/validate-password.html' +execute_cmd "is_mysql_secure_password $DBPASS" "Checking DBPASS password match policy" 'This password do not match minimum MySQL policy requirements, more info in: https://dev.mysql.com/doc/refman/8.0/en/validate-password.html' + # Creating working directory rm -rf "$WORKDIR" &>> "$LOGFILE" mkdir -p "$WORKDIR" &>> "$LOGFILE" @@ -265,7 +316,6 @@ server_dependencies=" \ openssh-client \ postfix \ unzip \ - xprobe \ coreutils \ libio-compress-perl \ libmoosex-role-timer-perl \ @@ -287,6 +337,8 @@ server_dependencies=" \ libgeo-ip-perl \ arping \ snmp-mibs-downloader \ + snmptrapd \ + libnsl2 \ openjdk-8-jdk " execute_cmd "apt install -y $server_dependencies" "Installing Pandora FMS Server dependencies" @@ -299,17 +351,7 @@ 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.pandorafms.com/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" +check_cmd_status "Error Installing pandorawmic/wmic" # create symlink for fping rm -f /usr/sbin/fping &>> "$LOGFILE" @@ -370,7 +412,6 @@ source '/root/.profile' &>> "$LOGFILE" #ipam dependencies ipam_dependencies=" \ - xprobe \ libnetaddr-ip-perl \ coreutils \ libdbd-mysql-perl \ @@ -413,6 +454,7 @@ if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then """ | mysql -uroot &>> "$LOGFILE" export MYSQL_PWD=$DBROOTPASS + echo "INSTALL COMPONENT 'file://component_validate_password';" | mysql -uroot -P$DBPORT -h$DBHOST &>> "$LOGFILE" 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." @@ -619,8 +661,9 @@ sed --follow-symlinks -i -e "s/^memory_limit.*/memory_limit = 800M/g" /etc/php.i 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 +#adding 900s to httpd timeout and 300 to ProxyTimeout +echo 'TimeOut 900' > /etc/apache2/conf-enabled/timeout.conf +echo 'ProxyTimeout 300' >> /etc/apache2/conf-enabled/timeout.conf cat > /var/www/html/index.html << EOF_INDEX @@ -792,6 +835,13 @@ 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" +# Enable postfix +systemctl enable postfix --now &>> "$LOGFILE" + +# Disable snmptrapd +systemctl disable --now snmptrapd &>> "$LOGFILE" +systemctl disable --now snmptrapd.socket &>> "$LOGFILE" + #SSH banner [ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me) diff --git a/pandora_agents/pc/DEBIAN/control b/pandora_agents/pc/DEBIAN/control index cdbcc99cfe..ac23fd959f 100644 --- a/pandora_agents/pc/DEBIAN/control +++ b/pandora_agents/pc/DEBIAN/control @@ -4,7 +4,7 @@ Architecture: all Priority: optional Section: admin Installed-Size: 260 -Maintainer: ÁRTICA ST +Maintainer: Pandora FMS Homepage: https://pandorafms.org/ Depends: coreutils, perl, unzip Description: Pandora FMS agents are based on native languages in every platform: scripts that can be written in any language. It’s possible to reproduce any agent in any programming language and can be extended without difficulty the existing ones in order to cover aspects not taken into account up to the moment. These scripts are formed by modules that each one gathers a "chunk" of information. Thus, every agent gathers several "chunks" of information; this one is organized in a data set and stored in a single file, called data file. diff --git a/pandora_agents/shellscript/linux/DEBIAN/control b/pandora_agents/shellscript/linux/DEBIAN/control index 55a5168f93..2ffdee57df 100755 --- a/pandora_agents/shellscript/linux/DEBIAN/control +++ b/pandora_agents/shellscript/linux/DEBIAN/control @@ -4,7 +4,7 @@ Architecture: all Priority: optional Section: admin Installed-Size: 260 -Maintainer: ÁRTICA ST +Maintainer: Pandora FMS Homepage: http://pandorafms.org/ Depends: coreutils, perl Description: Pandora FMS agents are based on native languages in every platform: scripts that can be written in any language. It’s possible to reproduce any agent in any programming language and can be extended without difficulty the existing ones in order to cover aspects not taken into account up to the moment. These scripts are formed by modules that each one gathers a "chunk" of information. Thus, every agent gathers several "chunks" of information; this one is organized in a data set and stored in a single file, called data file. diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index f8e421c978..8d0edd2c56 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,10 +1,10 @@ package: pandorafms-agent-unix -Version: 7.0NG.772-230706 +Version: 7.0NG.772-230802 Architecture: all Priority: optional Section: admin Installed-Size: 260 -Maintainer: ÁRTICA ST +Maintainer: Pandora FMS Homepage: http://pandorafms.org/ Depends: coreutils, perl, unzip Description: Pandora FMS agents are based on native languages in every platform: scripts that can be written in any language. It’s possible to reproduce any agent in any programming language and can be extended without difficulty the existing ones in order to cover aspects not taken into account up to the moment. These scripts are formed by modules that each one gathers a "chunk" of information. Thus, every agent gathers several "chunks" of information; this one is organized in a data set and stored in a single file, called data file. diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 7f63f3afb1..77d941633b 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.772-230706" +pandora_version="7.0NG.772-230802" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/Darwin/dmg/files/pandorafms_uninstall/PandoraFMS agent uninstaller.app/Contents/Info.plist b/pandora_agents/unix/Darwin/dmg/files/pandorafms_uninstall/PandoraFMS agent uninstaller.app/Contents/Info.plist index 4ee8965fef..e7c5fa5a91 100644 --- a/pandora_agents/unix/Darwin/dmg/files/pandorafms_uninstall/PandoraFMS agent uninstaller.app/Contents/Info.plist +++ b/pandora_agents/unix/Darwin/dmg/files/pandorafms_uninstall/PandoraFMS agent uninstaller.app/Contents/Info.plist @@ -6,7 +6,7 @@ CFBundleIdentifier com.pandorafms.pandorafms_uninstall CFBundleVersion 7.0NG.772 - CFBundleGetInfoString 7.0NG.772 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020 + CFBundleGetInfoString 7.0NG.772 Pandora FMS on Aug 2020 CFBundleShortVersionString 7.0NG.772 NSPrincipalClassNSApplication diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index e439bfaaf2..7e7e637899 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -213,5 +213,5 @@ module_end module_plugin grep_log /var/adm/syslog Syslog . - - +#Inventory plugin +#module_plugin /usr/share/pandora_agent/plugins/inventory_solaris.pl diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 0ca3110733..041b43b1b8 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1031,7 +1031,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.772'; -use constant AGENT_BUILD => '230706'; +use constant AGENT_BUILD => '230802'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index e76cd7b4e3..5e397cd329 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.772 -%define release 230706 +%define release 230802 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.spec b/pandora_agents/unix/pandora_agent.redhat_bin.spec new file mode 100644 index 0000000000..226c73426b --- /dev/null +++ b/pandora_agents/unix/pandora_agent.redhat_bin.spec @@ -0,0 +1,168 @@ +# +#Pandora FMS Linux Agent +# +%global __os_install_post %{nil} +%define name pandorafms_agent_linux_bin +%define source_name pandorafms_agent_linux +%define version 7.0NG.772 +%define release 230725 + +Summary: Pandora FMS Linux agent, binary version +Name: %{name} +Version: %{version} +Release: %{release} +License: GPL +Vendor: ArticaST +Source0: %{source_name}-%{version}.tar.gz +URL: http://pandorafms.org +Group: System/Monitoring +Packager: Sancho Lerena +Prefix: /usr/share +BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot +BuildArch: noarch +Requires(pre): shadow-utils +Requires(post): chkconfig /bin/ln +Requires(preun): chkconfig /bin/rm /usr/sbin/userdel +Requires: coreutils unzip +Requires: util-linux procps grep +Requires: /sbin/ip /bin/awk +Requires: perl(Sys::Syslog) perl(IO::Compress::Zip) +# Required by plugins +#Requires: sh-utils sed passwd net-tools rpm +AutoReq: 0 +Provides: %{name}-%{version} + +%description +Pandora FMS agent for unix. Pandora FMS is an OpenSource full-featured monitoring software. + +%prep +rm -rf $RPM_BUILD_ROOT + +%setup -q -n unix + +%build + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT%{prefix}/pandora_agent/ +mkdir -p $RPM_BUILD_ROOT/usr/bin/ +mkdir -p $RPM_BUILD_ROOT/usr/sbin/ +mkdir -p $RPM_BUILD_ROOT/etc/pandora/ +mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d/ +mkdir -p $RPM_BUILD_ROOT/var/log/pandora/ +mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1/ +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/ +cp -aRf * $RPM_BUILD_ROOT%{prefix}/pandora_agent/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/tentacle_client $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_exec $RPM_BUILD_ROOT/usr/bin/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_daemon $RPM_BUILD_ROOT/etc/rc.d/init.d/pandora_agent_daemon +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/pandora_agent.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/tentacle_client.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ + +cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/Linux/pandora_agent.conf $RPM_BUILD_ROOT/usr/share/pandora_agent/pandora_agent.conf.rpmnew + +install -m 0644 pandora_agent_logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/pandora_agent + +if [ -f $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec ] ; then + rm $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec +fi + +%clean +rm -Rf $RPM_BUILD_ROOT + +%pre +getent passwd pandora >/dev/null || \ + /usr/sbin/useradd -d %{prefix}/pandora -s /bin/false -M -g 0 pandora +exit 0 +chown pandora:root /var/log/pandora + +%post +if [ ! -d /etc/pandora ] ; then + mkdir -p /etc/pandora +fi + +if [ ! -f /usr/share/pandora_agent/pandora_agent.conf ] ; then + cp /usr/share/pandora_agent/pandora_agent.conf.rpmnew /usr/share/pandora_agent/pandora_agent.conf +fi + +if [ ! -f /etc/pandora/pandora_agent.conf ] ; then + ln -s /usr/share/pandora_agent/pandora_agent.conf /etc/pandora/pandora_agent.conf +else + [[ ! -f /etc/pandora/pandora_agent.conf.rpmnew ]] && ln -s /usr/share/pandora_agent/pandora_agent.conf.rpmnew /etc/pandora/pandora_agent.conf.rpmnew +fi + +if [ ! -e /etc/pandora/plugins ]; then + ln -s /usr/share/pandora_agent/plugins /etc/pandora +fi + +if [ ! -e /etc/pandora/collections ]; then + mkdir -p /usr/share/pandora_agent/collections + ln -s /usr/share/pandora_agent/collections /etc/pandora +fi + +if [ ! -e /etc/pandora/commands ]; then + mkdir -p /usr/share/pandora_agent/commands + ln -s /usr/share/pandora_agent/commands /etc/pandora +fi + +mkdir -p /var/spool/pandora/data_out +if [ ! -d /var/log/pandora ]; then + mkdir -p /var/log/pandora +fi + +if [ `command -v systemctl` ]; +then + echo "Copying new version of pandora_agent_daemon service" + cp -f /usr/share/pandora_agent/pandora_agent_daemon.service /usr/lib/systemd/system/ + chmod -x /usr/lib/systemd/system/pandora_agent_daemon.service +# Enable the services on SystemD + systemctl enable pandora_agent_daemon.service +else + /sbin/chkconfig --add pandora_agent_daemon + /sbin/chkconfig pandora_agent_daemon on +fi + +if [ "$1" -gt 1 ] +then + + echo "If Pandora Agent daemon was running with init.d script," + echo "please stop it manually and start the service with systemctl" + +fi + + +%preun + +# Upgrading +if [ "$1" = "1" ]; then + exit 0 +fi + +/sbin/chkconfig --del pandora_agent_daemon +/etc/rc.d/init.d/pandora_agent_daemon stop >/dev/null 2>&1 || : + +# Remove symbolic links +pushd /etc/pandora +for f in pandora_agent.conf plugins collections +do + [ -L $f ] && rm -f $f +done +exit 0 + +%files +%defattr(750,root,root) +/usr/bin/pandora_agent + +%defattr(755,pandora,root) +%{prefix}/pandora_agent + +%defattr(755,root,root) +/usr/bin/pandora_agent_exec +/usr/bin/tentacle_client +/etc/rc.d/init.d/pandora_agent_daemon + +%defattr(644,root,root) +/usr/share/man/man1/pandora_agent.1.gz +/usr/share/man/man1/tentacle_client.1.gz +%config(noreplace) %{_sysconfdir}/logrotate.d/pandora_agent diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 4cd8604a73..7b10d52dba 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.772 -%define release 230706 +%define release 230802 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 977028b30a..7dd4c17020 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.772" -PI_BUILD="230706" +PI_BUILD="230802" OS_NAME=`uname -s` FORCE=0 @@ -541,8 +541,17 @@ install () { then echo "Define 'pandora_agent=\"YES\"' in /etc/rc.conf to enable the daemon." else - echo "Check your startup configuration to be sure Pandora FMS Agent is ready " - echo "to start automatically when system restarts": + # Enable startup service + if [ `command -v systemctl` ] + then + systemctl enable pandora_agent_daemon + elif [ `command -v chkconfig` ] + then + chkconfig pandora_agent_daemon on + else + echo "Check your startup configuration to be sure Pandora FMS Agent is ready " + echo "to start automatically when system restarts": + fi fi # Restore the daemon script diff --git a/pandora_agents/unix/plugins/inventory_solaris.pl b/pandora_agents/unix/plugins/inventory_solaris.pl new file mode 100644 index 0000000000..fa07650e39 --- /dev/null +++ b/pandora_agents/unix/plugins/inventory_solaris.pl @@ -0,0 +1,121 @@ +#!/usr/bin/perl -w +# + +use strict; +use Data::Dumper; + +#print header +print "\n"; + +#get pakahes +my @pkg_list = `/usr/bin/pkginfo -l 2> /dev/null`; + +print " \n"; +print " \n"; +print " \n"; + +my $pkg; +foreach my $line (@pkg_list) { + + chomp $line; + + my $match = ( $line =~ /PKGINST:/ .. $line =~ /^$/ ); + + if ( $match && $match !~ /E0/ ) { + + if ( $line =~ /^\s+([A-Z]+):\s+(.*)$/ ) { + my ($key, $val) = ($1, $2); + if ( $key eq 'FILES' ) { + if ( $val =~ /^(\d+) (.*)$/ ) { + $pkg->{FILES}->{$2} = $1; + } + } + else { + $pkg->{$1} = $2; + } + } + elsif ( $line =~ /^\s+([0-9]+) (.*)$/ ) { + $pkg->{FILES}->{$2} = $1; + } + else { + print "Unrecognized output: [$line]\n"; + } + + } + else { + + # + # Blank line between packages + # + print "{PKGINST} . ';'; + print $pkg->{VERSION} . ';'; + print $pkg->{NAME} . ';'; + print "]]>\n"; + + } +} +print " \n"; +print " \n"; +#close software module + + +#CPU module +print " \n"; +print " \n"; +print " \n"; + +my $cpu_model =`kstat cpu_info 2> /dev/null | grep brand | uniq | sed 's/.*brand//g' | tr -d ' '`; +my $cpu_clock = `kstat cpu_info 2> /dev/null | grep clock_MHz | uniq | awk '{print \$NF " Mhz"}'`; +my $cpu_brand = `kstat cpu_info 2> /dev/null | grep vendor_id | uniq | awk '{print \$NF}'`; + +chomp $cpu_brand; +chomp $cpu_clock; +chomp $cpu_model; + +print "\n"; + +print " \n"; +print " \n"; +#close cpu module + + +#RAM module +print " \n"; +print " \n"; +print " \n"; + +my $memory_size =`prtconf 2> /dev/null | grep Memory | cut -d ':' -f 2`; + +chomp $memory_size; + +print "\n"; + +print " \n"; +print " \n"; +#close RAM module + +#NIC module +print " \n"; +print " \n"; +print " \n"; + +my @nic =`dladm show-link 2> /dev/null| grep -v STATE | awk '{print \$1}'`; + +foreach my $nic (@nic){ + chomp $nic; + + my $nic_mac = `dladm show-linkprop $nic -p mac-address 2> /dev/null |grep -v LINK| awk '{print \$4}'`; + my $nic_speed = `dladm show-linkprop $nic -p speed 2> /dev/null |grep -v LINK| awk '{print \$4}'`; + + chomp $nic_mac; + chomp $nic_speed; + print "\n"; +} + +print " \n"; +print " \n"; +#close NIC module + +#close inventory +print "\n"; \ No newline at end of file diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 940527b010..66ab8026be 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230706} +{230802} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 8632de3531..87114ed2da 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.772 Build 230706") +#define PANDORA_VERSION ("7.0NG.772 Build 230802") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index bd0da3c4a2..3dd6c88730 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -6,12 +6,12 @@ BEGIN BEGIN BLOCK "080904E4" BEGIN - VALUE "CompanyName", "Artica ST" + VALUE "CompanyName", "Pandora FMS" VALUE "FileDescription", "Pandora FMS Agent for Windows Platform" - VALUE "LegalCopyright", "Artica ST" + VALUE "LegalCopyright", "Pandora FMS" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.772(Build 230706))" + VALUE "ProductVersion", "(7.0NG.772(Build 230802))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 0ee8c1801a..72bb6af9d9 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,10 +1,10 @@ package: pandorafms-console -Version: 7.0NG.772-230706 +Version: 7.0NG.772-230802 Architecture: all Priority: optional Section: admin Installed-Size: 42112 -Maintainer: Artica ST +Maintainer: Pandora FMS Homepage: https://pandorafms.com/ Depends: php, php-snmp, php-gd, php-mysqlnd, php-db, php-xmlrpc, php-curl, graphviz, dbconfig-common, php-ldap, mysql-client | virtual-mysql-client, php-xmlrpc, php-zip, php-mbstring Description: Pandora FMS is an Open Source monitoring tool. It monitor your systems and applications, and allows you to control the status of any element of them. The web console is the graphical user interface (GUI) to manage the pool and to generate reports and graphs from the Pandora FMS monitoring process. diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 1acafcf6ed..92678462df 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.772-230706" +pandora_version="7.0NG.772-230802" package_pear=0 package_pandora=1 @@ -163,7 +163,7 @@ if [ $package_pear -eq 1 ] then echo "Make the package \"php-xml-rpc\"." cd temp_package - dh-make-pear --maintainer "ÁRTICA ST " XML_RPC + dh-make-pear --maintainer "Pandora FMS " XML_RPC cd php-xml-rpc-* dpkg-buildpackage -rfakeroot cd .. diff --git a/pandora_console/composer.lock b/pandora_console/composer.lock index d7a05579a9..cf6f9f2502 100644 --- a/pandora_console/composer.lock +++ b/pandora_console/composer.lock @@ -609,7 +609,7 @@ } ], "description": "PHP library for ChartJS", - "homepage": "https://artica.es/", + "homepage": "https://pandorafms.com/", "keywords": [ "chartjs", "graph", diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt index 0c0e0bd7fc..5d603ac1f9 100644 --- a/pandora_console/extras/delete_files/delete_files.txt +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -1692,3 +1692,14 @@ enterprise/godmode/modules/manage_inventory_modules_form.php enterprise/operation/inventory/inventory.php include/test.js include/web2image.js +enterprise/meta/monitoring/wizard/wizard.agent.php +enterprise/meta/monitoring/wizard/wizard.create_agent.php +enterprise/meta/monitoring/wizard/wizard.create_module.php +enterprise/meta/monitoring/wizard/wizard.main.php +enterprise/meta/monitoring/wizard/wizard.manage_alert.php +enterprise/meta/monitoring/wizard/wizard.module.local.php +enterprise/meta/monitoring/wizard/wizard.module.network.php +enterprise/meta/monitoring/wizard/wizard.module.web.php +enterprise/meta/monitoring/wizard/wizard.php +enterprise/meta/monitoring/wizard/wizard.update_agent.php +enterprise/meta/monitoring/wizard/wizard.update_module.php \ No newline at end of file diff --git a/pandora_console/extras/mr/65.sql b/pandora_console/extras/mr/65.sql index 0b48fd1a01..31e221f3b0 100644 --- a/pandora_console/extras/mr/65.sql +++ b/pandora_console/extras/mr/65.sql @@ -1,5 +1,67 @@ START TRANSACTION; +CREATE TABLE IF NOT EXISTS `tdiscovery_apps` ( + `id_app` int(10) auto_increment, + `short_name` varchar(250) NOT NULL DEFAULT '', + `name` varchar(250) NOT NULL DEFAULT '', + `section` varchar(250) NOT NULL DEFAULT 'custom', + `description` varchar(250) NOT NULL DEFAULT '', + `version` varchar(250) NOT NULL DEFAULT '', + PRIMARY KEY (`id_app`), + UNIQUE (`short_name`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +CREATE TABLE IF NOT EXISTS `tdiscovery_apps_scripts` ( + `id_app` int(10), + `macro` varchar(250) NOT NULL DEFAULT '', + `value` text NOT NULL DEFAULT '', + PRIMARY KEY (`id_app`, `macro`), + FOREIGN KEY (`id_app`) REFERENCES tdiscovery_apps(`id_app`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +CREATE TABLE IF NOT EXISTS `tdiscovery_apps_executions` ( + `id` int(10) unsigned NOT NULL auto_increment, + `id_app` int(10), + `execution` text NOT NULL DEFAULT '', + PRIMARY KEY (`id`, `id_app`), + FOREIGN KEY (`id_app`) REFERENCES tdiscovery_apps(`id_app`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +CREATE TABLE IF NOT EXISTS `tdiscovery_apps_tasks_macros` ( + `id_task` int(10) unsigned NOT NULL, + `macro` varchar(250) NOT NULL DEFAULT '', + `type` varchar(250) NOT NULL DEFAULT 'custom', + `value` text NOT NULL DEFAULT '', + `temp_conf` tinyint unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (`id_task`, `macro`), + FOREIGN KEY (`id_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + + +ALTER TABLE `trecon_task` + ADD COLUMN `id_app` int(10), + ADD COLUMN `setup_complete` tinyint unsigned NOT NULL DEFAULT 0, + ADD COLUMN `executions_timeout` int unsigned NOT NULL DEFAULT 60, + ADD FOREIGN KEY (`id_app`) REFERENCES tdiscovery_apps(`id_app`) ON DELETE CASCADE ON UPDATE CASCADE; + +CREATE TABLE IF NOT EXISTS `tnetwork_explorer_filter` ( +`id` INT NOT NULL, +`filter_name` VARCHAR(45) NULL, +`top` VARCHAR(45) NULL, +`action` VARCHAR(45) NULL, +`advanced_filter` TEXT NULL, +PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +CREATE TABLE IF NOT EXISTS `tnetwork_usage_filter` ( +`id` INT NOT NULL auto_increment, +`filter_name` VARCHAR(45) NULL, +`top` VARCHAR(45) NULL, +`action` VARCHAR(45) NULL, +`advanced_filter` TEXT NULL, +PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + ALTER TABLE `tlayout` ADD COLUMN `grid_color` VARCHAR(45) NOT NULL DEFAULT '#cccccc' AFTER `maintenance_mode`, ADD COLUMN `grid_size` VARCHAR(45) NOT NULL DEFAULT '10' AFTER `grid_color`; @@ -8,6 +70,45 @@ ALTER TABLE `tlayout_template` ADD COLUMN `grid_color` VARCHAR(45) NOT NULL DEFAULT '#cccccc' AFTER `maintenance_mode`, ADD COLUMN `grid_size` VARCHAR(45) NOT NULL DEFAULT '10' AFTER `grid_color`; + DELETE FROM tconfig WHERE token = 'refr'; +INSERT INTO `tmodule_inventory` (`id_module_inventory`, `id_os`, `name`, `description`, `interpreter`, `data_format`, `code`, `block_mode`,`script_mode`) VALUES (37,2,'CPU','CPU','','Brand;Clock;Model','',0,2); + +INSERT INTO `tmodule_inventory` (`id_module_inventory`, `id_os`, `name`, `description`, `interpreter`, `data_format`, `code`, `block_mode`,`script_mode`) VALUES (38,2,'RAM','RAM','','Size','',0,2); + +INSERT INTO `tmodule_inventory` (`id_module_inventory`, `id_os`, `name`, `description`, `interpreter`, `data_format`, `code`, `block_mode`,`script_mode`) VALUES (39,2,'NIC','NIC','','NIC;Mac;Speed','',0,2); + +INSERT INTO `tmodule_inventory` (`id_module_inventory`, `id_os`, `name`, `description`, `interpreter`, `data_format`, `code`, `block_mode`,`script_mode`) VALUES (40,2,'Software','Software','','PKGINST;VERSION;NAME','',0,2); + +ALTER TABLE `treport_content` ADD COLUMN `period_range` INT NULL DEFAULT 0 AFTER `period`; + +CREATE TABLE IF NOT EXISTS `tevent_comment` ( + `id` serial PRIMARY KEY, + `id_event` BIGINT UNSIGNED NOT NULL, + `utimestamp` BIGINT NOT NULL DEFAULT 0, + `comment` TEXT, + `id_user` VARCHAR(255) DEFAULT NULL, + `action` TEXT, + FOREIGN KEY (`id_event`) REFERENCES `tevento`(`id_evento`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES tusuario(`id_user`) + ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +INSERT INTO `tevent_comment` (`id_event`, `utimestamp`, `comment`, `id_user`, `action`) +SELECT * FROM ( + SELECT tevento.id_evento AS `id_event`, + JSON_UNQUOTE(JSON_EXTRACT(tevento.user_comment, CONCAT('$[',n.num,'].utimestamp'))) AS `utimestamp`, + JSON_UNQUOTE(JSON_EXTRACT(tevento.user_comment, CONCAT('$[',n.num,'].comment'))) AS `comment`, + JSON_UNQUOTE(JSON_EXTRACT(tevento.user_comment, CONCAT('$[',n.num,'].id_user'))) AS `id_user`, + JSON_UNQUOTE(JSON_EXTRACT(tevento.user_comment, CONCAT('$[',n.num,'].action'))) AS `action` + FROM tevento + INNER JOIN (SELECT 0 num UNION ALL SELECT 1 UNION ALL SELECT 2) n + ON n.num < JSON_LENGTH(tevento.user_comment) + WHERE tevento.user_comment != "" +) t order by utimestamp DESC; + +ALTER TABLE tevento DROP COLUMN user_comment; + COMMIT; diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 646e40481e..36090b9446 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -34,6 +34,22 @@ echo sprintf('
', $menuTypeClass); $notifications_numbers['notifications'], $notifications_numbers['last_id'] ).'
'; + $header_welcome = ''; + if (check_acl($config['id_user'], $group, 'AW')) { + $header_welcome .= '
'; + $header_welcome .= html_print_image( + 'images/wizard@svg.svg', + true, + [ + 'class' => 'main_menu_icon invert_filter', + 'title' => __('Welcome dialog'), + 'id' => 'Welcome-dialog', + 'alt' => __('Welcome dialog'), + 'style' => 'cursor: pointer;', + ] + ); + $header_welcome .= '
'; + } // ======= Servers List =============================================== if ((bool) check_acl($config['id_user'], 0, 'AW') !== false) { @@ -217,11 +233,8 @@ echo sprintf('
', $menuTypeClass); $header_autorefresh = ''; $header_autorefresh_counter = ''; - if ($config['legacy_vc'] - || ($_GET['sec2'] !== 'operation/visual_console/render_view') - || (($_GET['sec2'] !== 'operation/visual_console/render_view') - && $config['legacy_vc']) - ) { + + if (($_GET['sec2'] !== 'operation/visual_console/render_view')) { if ($autorefresh_list !== null && array_search($_GET['sec2'], $autorefresh_list) !== false ) { @@ -461,7 +474,7 @@ echo sprintf('
', $menuTypeClass); } else { echo '
'.$config['custom_title_header'].''.$config['custom_subtitle_header'].'
'.$header_searchbar.'
-
'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'
'; +
'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $header_welcome, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'
'; } ?>
@@ -904,6 +917,44 @@ echo sprintf('
', $menuTypeClass); $("#agent_access").css("display",""); }); + $("#welcome-icon-header").click(function () { + if (!$('#welcome_modal_window').length){ + $(document.body).append('
'); + $(document.body).append( $('').attr('href', 'include/styles/new_installation_welcome_window.css') ); + } + // Clean DOM. + load_modal({ + target: $('#welcome_modal_window'), + url: '', + modal: { + title: "", + cancel: '', + ok: '' + }, + onshow: { + page: 'include/ajax/welcome_window', + method: 'loadWelcomeWindow', + }, + oncancel: { + page: 'include/ajax/welcome_window', + title: "", + method: 'cancelWelcome', + confirm: function (fn) { + confirmDialog({ + title: '', + message: '', + ok: '', + cancel: '', + onAccept: function() { + // Continue execution. + fn(); + } + }) + } + } + }); + }); + // Feedback. $("#feedback-header").click(function () { diff --git a/pandora_console/general/main_menu.php b/pandora_console/general/main_menu.php index 13e3f2c38c..92e5e2aff9 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -185,6 +185,10 @@ echo '
'; $(`#sub${this.id}`).hide(); }) } else if ($('#menu_full').hasClass('menu_full_collapsed')) { + $(".arrow_menu_right").each(function() { + $(this).removeClass('arrow_menu_right'); + $(this).addClass('arrow_menu_down'); + }); localStorage.setItem("menuType", "classic"); $('ul.submenu').css('left', '280px'); var menuType_val = localStorage.getItem("menuType"); @@ -273,6 +277,14 @@ echo '
'; $('.menu_icon').mouseenter(function() { var menuType_val = localStorage.getItem("menuType"); if (!click_display && menuType_val === 'collapsed') { + $(".arrow_menu_down").each(function() { + $(this).removeClass('arrow_menu_down'); + $(this).addClass('arrow_menu_right'); + }); + $(".arrow_menu_up").each(function() { + $(this).removeClass('arrow_menu_up'); + $(this).addClass('arrow_menu_right'); + }); table_hover = $(this); handsIn = 1; openTime = new Date().getTime(); @@ -305,6 +317,7 @@ echo ''; table_hover2 = $(this); handsIn2 = 1; openTime2 = new Date().getTime(); + $("#sub" + table_hover2[0].id).attr('style', 'display: none; position: fixed; left: 340px;'); $("#sub" + table_hover2[0].id).show(); if (typeof(table_noHover2) != 'undefined') { if ("ul#sub" + table_hover2[0].id != "ul#sub" + table_noHover2[0].id) { @@ -315,6 +328,7 @@ echo ''; }).mouseleave(function() { var menuType_val = localStorage.getItem("menuType"); if (!click_display && menuType_val === 'collapsed') { + $("#sub" + $(this)[0].id).attr('style', 'display: none;'); table_noHover2 = table_hover2; handsIn2 = 0; setTimeout(function() { @@ -349,7 +363,7 @@ echo ''; const id = table_hover[0].id; const classes = $(`#${id}`).attr('class'); - if (id === 'icon_about') { + if (id === 'icon_about' || id === 'icon_about_operation') { return; } diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php index 96f9232dab..759e319dbd 100644 --- a/pandora_console/general/register.php +++ b/pandora_console/general/register.php @@ -100,21 +100,23 @@ if ($initial && users_is_admin()) { ); } -$welcome = !$initial; -try { - $welcome_window = new WelcomeWindow($welcome); - if ($welcome_window !== null) { - $welcome_window->run(); +if (check_acl($config['id_user'], 0, 'AW')) { + $welcome = !$initial; + try { + $welcome_window = new WelcomeWindow($welcome); + if ($welcome_window !== null) { + $welcome_window->run(); + } + } catch (Exception $e) { + $welcome = false; } -} catch (Exception $e) { - $welcome = false; } try { if (isset($_SESSION['showed_tips_window']) === false) { $tips_window = new TipsWindow(); if ($tips_window !== null) { - $tips_window->run(); + $tips_window->run(); } } } catch (Exception $e) { diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index b161b7ff6d..cbe7858e9e 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -212,7 +212,7 @@ $groups = users_get_groups($config['id_user'], 'AR', false); // Get modules. $modules = db_get_all_rows_sql( 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo - WHERE id_agente = '.$id_parent + WHERE id_agente = '.$id_agente ); $modules_values = []; $modules_values[0] = __('Any'); @@ -300,7 +300,7 @@ if (enterprise_installed() === true) { // Parent agents. $paramsParentAgent = []; $paramsParentAgent['return'] = true; -$paramsParentAgent['show_helptip'] = false; +$paramsParentAgent['show_helptip'] = true; $paramsParentAgent['input_name'] = 'id_parent'; $paramsParentAgent['print_hidden_input_idagent'] = true; $paramsParentAgent['hidden_input_idagent_name'] = 'id_agent_parent'; @@ -646,7 +646,7 @@ if (enterprise_installed() === true) { // Parent agent. $tableAdvancedAgent->data['parent_agent'][] = html_print_label_input_block( - __('Parent'), + __('Agent parent'), ui_print_agent_autocomplete_input($paramsParentAgent) ); @@ -1205,15 +1205,30 @@ ui_require_jquery_file('bgiframe'); $("#cascade_protection_module").attr("disabled", 'disabled'); } - $("#checkbox-cascade_protection").change(function () { - var checked = $("#checkbox-cascade_protection").is(":checked"); - - if (checked) { + $("#text-id_parent").change(function(){ + const parent = $("#text-id_parent").val(); + if (parent != '') { + $("#checkbox-cascade_protection").prop('checked', true); $("#cascade_protection_module").removeAttr("disabled"); } else { $("#cascade_protection_module").val(0); $("#cascade_protection_module").attr("disabled", 'disabled'); + $("#text-id_parent").removeAttr("required"); + $("#cascade_protection_module").empty(); + $("#checkbox-cascade_protection").prop('checked', false); + } + }); + + $("#checkbox-cascade_protection").change(function () { + var checked = $("#checkbox-cascade_protection").is(":checked"); if (checked) { + $("#cascade_protection_module").removeAttr("disabled"); + $("#text-id_parent").attr("required", "required"); + } + else { + $("#cascade_protection_module").val(0); + $("#cascade_protection_module").attr("disabled", 'disabled'); + $("#text-id_parent").removeAttr("required"); } }); diff --git a/pandora_console/godmode/agentes/agent_template.php b/pandora_console/godmode/agentes/agent_template.php index 163fc16af8..9c080fcf3f 100644 --- a/pandora_console/godmode/agentes/agent_template.php +++ b/pandora_console/godmode/agentes/agent_template.php @@ -80,7 +80,7 @@ if (isset($_POST['template_id']) === true) { $values = [ 'id_agente' => $id_agente, 'id_tipo_modulo' => $row2['type'], - 'descripcion' => __('Created by template ').$name_template.' . '.$row2['description'], + 'descripcion' => $row2['description'], 'max' => $row2['max'], 'min' => $row2['min'], 'module_interval' => $row2['module_interval'], diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index c68d483eaf..b07fb5ca4f 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -460,6 +460,18 @@ if ($id_agente) { $templatetab['active'] = ($tab === 'template'); + // Policy tab. + $policyTab['text'] = html_print_menu_button( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=policy&id_agente='.$id_agente, + 'image' => 'images/policy@svg.svg', + 'title' => __('Manage policy'), + ], + true + ); + + $policyTab['active'] = ($tab === 'policy'); + // Inventory. $inventorytab['text'] = ''.html_print_image( 'images/hardware-software-component@svg.svg', @@ -638,6 +650,7 @@ if ($id_agente) { 'template' => $templatetab, 'inventory' => $inventorytab, 'pluginstab' => $pluginstab, + 'policy' => (enterprise_installed() === true) ? $policyTab : '', 'collection' => $collectiontab, 'group' => $grouptab, 'gis' => $gistab, @@ -654,11 +667,11 @@ if ($id_agente) { 'template' => $templatetab, 'inventory' => $inventorytab, 'pluginstab' => $pluginstab, + 'policy' => (enterprise_installed() === true) ? $policyTab : '', 'collection' => $collectiontab, 'group' => $grouptab, 'gis' => $gistab, 'agent_wizard' => $agent_wizard, - ]; } @@ -725,6 +738,11 @@ if ($id_agente) { $tab_name = __('Inventory'); break; + case 'policy': + $help_header = 'policy_tab'; + $tab_name = __('Policies'); + break; + case 'plugins': $help_header = 'plugins_tab'; $tab_name = __('Agent plugins'); @@ -2428,6 +2446,10 @@ switch ($tab) { include 'inventory_manager.php'; break; + case 'policy': + enterprise_include('operation/agentes/policy_manager.php'); + break; + default: if (enterprise_hook('switch_agent_tab', [$tab])) { // This will make sure that blank pages will have at least some diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 4f28d256cd..9021514178 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -1072,16 +1072,20 @@ if ((bool) check_acl($config['id_user'], 0, 'AW') === true) { function () { $(".actions", this).css ("visibility", "hidden"); }); - + $("#ag_group").click ( function () { $(this).css ("width", "auto"); $(this).css ("min-width", "100px"); }); - + $("#ag_group").blur (function () { $(this).css ("width", "100px"); }); - + + var show_deploy_agent = ""; + if (show_deploy_agent !== '0'){ + $('#button-modal_deploy_agent').click(); + } }); diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index 0744a5849e..970a2c4d9f 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -171,6 +171,8 @@ foreach ($password_fields as $k => $p) { } $(document).ready(function () { - changePluginSelect(); + if ($("#id_plugin").val() === 0) { + changePluginSelect(); + } }); diff --git a/pandora_console/godmode/agentes/module_manager_editor_web.php b/pandora_console/godmode/agentes/module_manager_editor_web.php index 281963108a..727e16d5bf 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_web.php +++ b/pandora_console/godmode/agentes/module_manager_editor_web.php @@ -113,7 +113,8 @@ if ($id_policy_module > 0) { $plugin_parameter_split = explode(' ', $plugin_parameter); $plugin_parameter_final_split = ''; -foreach ($plugin_parameter_split as $key => $value) { +$new_plugin_parameter_split = array_filter($plugin_parameter_split, 'strlen'); +foreach ($new_plugin_parameter_split as $key => $value) { if (strpos($value, 'http_auth_user') === false && strpos($value, 'http_auth_pass') === false) { $plugin_parameter_final_split .= $value.' '; } @@ -317,8 +318,7 @@ foreach ($texts as $code => $text) { return; } - $(plugin_parameter).val( - 'task_begin\ncookie 0\nresource 0\ntask_end'); + $(plugin_parameter).val('task_begin\ncookie 0\nresource 0\ntask_end'); $('#button-btn_loadbasic').attr('disabled', 'disabled'); diff --git a/pandora_console/godmode/agentes/planned_downtime.list.php b/pandora_console/godmode/agentes/planned_downtime.list.php index a9a65bc834..959db70ed6 100755 --- a/pandora_console/godmode/agentes/planned_downtime.list.php +++ b/pandora_console/godmode/agentes/planned_downtime.list.php @@ -89,7 +89,7 @@ if (is_ajax() === true) { [ 'id' => 'agent_modules_affected_planned_downtime', 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => 'godmode/agentes/planned_downtime.list', diff --git a/pandora_console/godmode/alerts/alert_list.builder.php b/pandora_console/godmode/alerts/alert_list.builder.php index de01a947ff..de07bce961 100644 --- a/pandora_console/godmode/alerts/alert_list.builder.php +++ b/pandora_console/godmode/alerts/alert_list.builder.php @@ -40,6 +40,8 @@ $table->size = []; $table->style[0] = 'width: 50%'; $table->style[1] = 'width: 50%'; +$modules = []; + if (is_metaconsole() === true) { $params = []; $params['return'] = true; @@ -79,8 +81,6 @@ if (is_metaconsole() === true) { } } -$modules = []; - $table->data[0][1] = html_print_label_input_block( __('Module'), html_print_select( diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index 3a71292aed..1a3e991fde 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -318,74 +318,59 @@ if (count($actions) == 1 && isset($actions[0])) { } else { foreach ($actions as $kaction => $action) { $table->data[$kaction][0] = $action['name']; - if ((int) $kaction === 0) { - $table->data[$kaction][0] .= ui_print_help_tip( - __('The default actions will be executed every time that the alert is fired and no other action is executed'), - true - ); - } - - foreach ($action['escalation'] as $k => $v) { - if ($v > 0) { - $table->data[$kaction][$k] .= html_print_image( - 'images/tick.png', - true, - ['class' => 'invert_filter'] - ); + if (count($action['escalation']) > 1) { + foreach ($action['escalation'] as $k => $v) { + $table->head[$k] = '#'.$k; + if ($v > 0) { + $table->data[$kaction][$k] .= html_print_image( + 'images/tick.png', + true, + ['class' => 'invert_filter'] + ); + } else { + $table->data[$kaction][$k] = html_print_image( + 'images/blade.png', + true + ); + } + } + } else { + $table->head[1] = __('Every time that the alert is fired'); + if (count($action['escalation']) > 0) { + if ($action['escalation'][0] > 0) { + $table->data[$kaction][1] .= html_print_image( + 'images/tick.png', + true, + ['class' => 'invert_filter'] + ); + } else { + $table->data[$kaction][1] = html_print_image( + 'images/blade.png', + true + ); + } } else { - $table->data[$kaction][$k] = html_print_image( + $table->data[$kaction][1] = html_print_image( 'images/blade.png', true ); } - - if (count($table->head) <= count($action['escalation'])) { - if ($k == count($action['escalation'])) { - if ($k == 1) { - $table->head[$kaction] = __('Every time that the alert is fired'); - } else { - $table->head[$kaction] = '>#'.($kaction - 1); - } - } else { - $table->head[$kaction] = '#'.($kaction); - if ($v > 0) { - $table->data[$kaction][($kaction + 1)] = html_print_image( - 'images/tick.png', - true, - ['class' => 'invert_filter'] - ); - } else { - $table->data[$kkaction][($kaction + 1)] = html_print_image( - 'images/blade.png', - true - ); - } - } - } - } - - $table->head[($kaction + 1)] = '#'.($kaction); - if (count($action['escalation']) === 0) { - $table->data[$kaction][($kaction + 2)] = html_print_image( - 'images/blade.png', - true - ); } $action_threshold = ($action['module_action_threshold'] > 0) ? $action['module_action_threshold'] : $action['action_threshold']; if ($action_threshold == 0) { - $table->data[$kaction][($k + 1)] = __('No'); + $table->data[$kaction][] = __('No'); } else { - $table->data[$kaction][($k + 1)] = human_time_description_raw( + $table->data[$kaction][] = human_time_description_raw( $action_threshold, true, 'tiny' ); } - - $table->head[($kaction + 1)] = __('Threshold'); } + + $table->head[] = __('Threshold'); } html_print_table($table); diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index 3324c92e9d..edaa003ce6 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -322,10 +322,18 @@ function update_template($step) if ($step == 1) { $name = (string) get_parameter('name'); + $name = trim(io_safe_output($name)); + if (strlen($name) === 0) { + ui_print_warning_message(__('You can\'t named a template with spaces')); + return false; + } + + $name = io_safe_input($name); $description = (string) get_parameter('description'); $wizard_level = (string) get_parameter('wizard_level'); $priority = (int) get_parameter('priority'); $id_group = get_parameter('id_group'); + $name_check = db_get_value('name', 'talert_templates', 'name', $name); // Only for Metaconsole. Save the previous name for synchronizing. if (is_metaconsole() === true) { $previous_name = db_get_value('name', 'talert_templates', 'id', $id); @@ -342,7 +350,12 @@ function update_template($step) 'previous_name' => $previous_name, ]; - $result = alerts_update_alert_template($id, $values); + if ($name_check === false) { + $result = alerts_update_alert_template($id, $values); + } else { + ui_print_warning_message(__('Another template with the same name already exists')); + $result = false; + } } else if ($step == 2) { $schedule = io_safe_output(get_parameter('schedule', [])); json_decode($schedule, true); @@ -487,6 +500,13 @@ $wizard_level = 'nowizard'; if ($create_template) { $name = (string) get_parameter('name'); + $name = trim(io_safe_output($name)); + if (strlen($name) === 0) { + ui_print_warning_message(__('You can\'t named a template with spaces')); + } + + $name = io_safe_input($name); + $description = (string) get_parameter('description'); $type = (string) get_parameter('type', 'critical'); $value = (string) get_parameter('value'); @@ -515,10 +535,11 @@ if ($create_template) { $values['field3_recovery'] = ' '; } - if (!$name_check) { + if ($name_check === false) { $result = alerts_create_alert_template($name, $type, $values); } else { - $result = ''; + ui_print_warning_message(__('Another template with the same name already exists')); + $result = false; } if ($result) { diff --git a/pandora_console/godmode/category/category.php b/pandora_console/godmode/category/category.php index 9872a002f5..46095b6efb 100755 --- a/pandora_console/godmode/category/category.php +++ b/pandora_console/godmode/category/category.php @@ -184,7 +184,7 @@ if (empty($result) === false) { ] ).'  '; $data[1] .= ''.html_print_image( - 'images/delet.svg', + 'images/delete.svg', true, [ 'title' => __('Delete'), diff --git a/pandora_console/godmode/groups/tactical.php b/pandora_console/godmode/groups/tactical.php index 067bed45be..0b09cbc789 100644 --- a/pandora_console/godmode/groups/tactical.php +++ b/pandora_console/godmode/groups/tactical.php @@ -187,7 +187,7 @@ try { [ 'id' => 'list_agents_tactical', 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $columnNames, 'return' => true, diff --git a/pandora_console/godmode/massive/massive_copy_modules.php b/pandora_console/godmode/massive/massive_copy_modules.php index 5d069a8e9b..ade7a7f69b 100755 --- a/pandora_console/godmode/massive/massive_copy_modules.php +++ b/pandora_console/godmode/massive/massive_copy_modules.php @@ -86,31 +86,39 @@ if ($do_operation) { $groups = users_get_groups(); $table = new stdClass(); -$table->class = 'databox filters'; -$table->width = '100%'; -$table->data = []; -$table->style = []; -$table->style[0] = 'font-weight: bold;'; -$table->style[2] = 'font-weight: bold'; -$table->style[4] = 'font-weight: bold'; -$table->style[6] = 'font-weight: bold'; - -// Source selection $table->id = 'source_table'; -$table->data[0][0] = __('Group'); -$table->data[0][1] = html_print_select_groups( - false, - 'AW', - true, - 'source_id_group', - $source_id_group, - false, - '', - '', - true +$table->class = 'databox filters filter-table-adv'; +$table->width = '100%'; +$table->size[0] = '50%'; +$table->size[1] = '50%'; +$table->data = []; + +// Source selection. +$table->data[0][0] = html_print_label_input_block( + __('Group'), + html_print_select_groups( + false, + 'AW', + true, + 'source_id_group', + $source_id_group, + false, + '', + '', + true, + false, + false, + 'w100p', + false, + 'width:100%' + ) ); -$table->data[0][2] = __('Group recursion'); -$table->data[0][3] = html_print_checkbox('source_recursion', 1, $source_recursion, true, false); + +$table->data[0][1] = html_print_label_input_block( + __('Group recursion'), + html_print_checkbox('source_recursion', 1, $source_recursion, true, false) +); + $status_list = []; $status_list[AGENT_STATUS_NORMAL] = __('Normal'); $status_list[AGENT_STATUS_WARNING] = __('Warning'); @@ -118,37 +126,52 @@ $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[0][4] = __('Status'); -$table->data[0][5] = html_print_select( - $status_list, - 'status_agents_source', - 'selected', - '', - __('All'), - AGENT_STATUS_ALL, - true + +$table->data[1][0] = html_print_label_input_block( + __('Status'), + html_print_select( + $status_list, + 'status_agents_source', + 'selected', + '', + __('All'), + AGENT_STATUS_ALL, + true, + false, + true, + 'w100p' + ) ); -$table->data[0][6] = __('Agent'); -$table->data[0][6] .= ' '; -// $table->data[0][7] = html_print_select (agents_get_group_agents ($source_id_group, false, "none"), -// 'source_id_agent', $source_id_agent, false, __('Select'), 0, true); + $agents = ( $source_id_group ? agents_get_group_agents($source_id_group, false, 'none') : agents_get_group_agents(array_keys(users_get_groups($config['id_user'], 'AW', false))) ); -$table->data[0][7] = html_print_select($agents, 'source_id_agent', $source_id_agent, false, __('Select'), 0, true); - -echo '
'; +$table->data[1][1] = html_print_label_input_block( + __('Agent').' ', + html_print_select( + $agents, + 'source_id_agent', + $source_id_agent, + false, + __('Select'), + 0, + true + ) +); +echo ''; echo '
'; -echo ''; -echo ''.__('Source'); -echo ''; +echo ''.__('Source').''; html_print_table($table); echo '
'; -// Target selection + +unset($table); +// Target selection. +$table = new stdClass(); $table->id = 'target_table'; -$table->class = 'databox filters'; +$table->class = 'databox filters filter-table-adv'; +$table->width = '100%'; +$table->size[0] = '50%'; +$table->size[1] = '50%'; $table->data = []; $modules = []; @@ -169,66 +192,64 @@ foreach ($agent_alerts as $alert) { } $tags = tags_get_user_tags(); -$table->data['tags'][0] = __('Tags'); -$table->data['tags'][1] = html_print_select( - $tags, - 'tags[]', - $tags_name, - false, - __('Any'), - -1, - true, - true, - true +$table->colspan[0][0] = 2; +$table->data[0][0] = html_print_label_input_block( + __('Tags'), + html_print_select( + $tags, + 'tags[]', + $tags_name, + false, + __('Any'), + -1, + true, + true, + true, + '', + false, + 'overflow-x: hidden;white-space: nowrap;max-width: 1136px;' + ) ); -$table->data['operations'][0] = __('Operations'); -$table->data['operations'][1] = ''; -$table->data['operations'][1] .= html_print_checkbox('copy_modules', 1, true, true); -$table->data['operations'][1] .= html_print_label(__('Copy modules'), 'checkbox-copy_modules', true); -$table->data['operations'][1] .= '
'; - -$table->data['operations'][1] .= ''; -$table->data['operations'][1] .= html_print_checkbox('copy_alerts', 1, true, true); -$table->data['operations'][1] .= html_print_label(__('Copy alerts'), 'checkbox-copy_alerts', true); -$table->data['operations'][1] .= ''; - -$table->data['form_modules_filter'][0] = __('Filter Modules'); -$table->data['form_modules_filter'][1] = html_print_input_text('filter_modules', '', '', 20, 255, true); - -$table->data[1][0] = __('Modules'); -$table->data[1][1] = ''; -$table->data[1][1] .= html_print_select( - $modules, - 'target_modules[]', - 0, - false, - '', - '', - true, - true +$table->data[1][0] = html_print_label_input_block( + __('Operations'), + ''.html_print_checkbox('copy_modules', 1, true, true).html_print_label(__('Copy modules'), 'checkbox-copy_modules', true).''.html_print_checkbox('copy_alerts', 1, true, true).html_print_label(__('Copy alerts'), 'checkbox-copy_alerts', true).'' ); -$table->data[1][1] .= ''; -$table->data[1][1] .= ''; -$table->data[1][1] .= ''.__('No modules for this agent').''; -$table->data[1][1] .= ''; -$table->data[2][0] = __('Alerts'); -$table->data[2][1] = ''; -$table->data[2][1] .= html_print_select( - $alerts, - 'target_alerts[]', - 0, - false, - '', - '', - true, - true +$table->data[1][1] = html_print_label_input_block( + __('Filter Modules'), + html_print_input_text('filter_modules', '', '', 20, 255, true) +); + +$table->colspan[2][0] = 2; +$table->data[2][0] = html_print_label_input_block( + __('Modules'), + ''.html_print_select( + $modules, + 'target_modules[]', + 0, + false, + '', + '', + true, + true + ).''.__('No modules for this agent').'' +); + +$table->colspan[3][0] = 2; +$table->data[3][0] = html_print_label_input_block( + __('Alerts'), + ''.html_print_select( + $alerts, + 'target_alerts[]', + 0, + false, + '', + '', + true, + true + ).''.__('No alerts for this agent').'' ); -$table->data[2][1] .= ''; -$table->data[2][1] .= ''; -$table->data[2][1] .= ''.__('No alerts for this agent').''; -$table->data[2][1] .= ''; echo '
@@ -1224,4 +1247,104 @@ if (is_ajax()) { echo $dialog; } + + if ($about_operation) { + global $config; + global $pandora_version; + global $build_version; + $product_name = io_safe_output(get_product_name()); + $license_expiry_date = substr($config['license_expiry_date'], 0, 4).'/'.substr($config['license_expiry_date'], 4, 2).'/'.substr($config['license_expiry_date'], 6, 2); + $license_expired = false; + $timestamp = strtotime($license_expiry_date); + if ($timestamp < time() || enterprise_installed() === false) { + $license_expired = true; + } + + $lts_name = ''; + if (empty($config['lts_name']) === false) { + $lts_name = ' '.$config['lts_name'].''; + } + + $image_about = ui_get_full_url('/images/custom_logo/logo-default-pandorafms.png', false, false, false); + if (enterprise_installed() === false) { + if ($config['style'] === 'pandora_black') { + $image_about = 'images/custom_logo/'.HEADER_LOGO_BLACK_CLASSIC; + } else if ($config['style'] === 'pandora') { + $image_about = 'images/custom_logo/'.HEADER_LOGO_DEFAULT_CLASSIC; + } + } else { + if ($config['style'] === 'pandora_black' && $config['custom_logo'] === HEADER_LOGO_DEFAULT_CLASSIC) { + $config['custom_logo'] = HEADER_LOGO_BLACK_CLASSIC; + } else if ($config['style'] === 'pandora' && $config['custom_logo'] === HEADER_LOGO_BLACK_CLASSIC) { + $config['custom_logo'] = HEADER_LOGO_DEFAULT_CLASSIC; + } + + $image_about = 'images/custom_logo/'.$config['custom_logo']; + + if (file_exists(ENTERPRISE_DIR.'/'.$image_about) === true) { + $image_about = ENTERPRISE_DIR.'/'.$image_about; + } + } + + if (is_metaconsole() === true) { + $image_about = ui_get_full_url('/enterprise/images/custom_logo/pandoraFMS_metaconsole_full.svg', false, false, false); + + if ($config['meta_custom_logo'] === 'pandoraFMS_metaconsole_full.svg') { + $image_about = 'images/custom_logo/'.$config['meta_custom_logo']; + } else { + $image_about = '../images/custom_logo/'.$config['meta_custom_logo']; + } + + if (file_exists(ENTERPRISE_DIR.'/'.$image_about) === true) { + $image_about = $image_about; + } + } + + + $dialog = ' +
+ + + + + + +
+ + logo + + +

'.$product_name.'

+

'.__('Version').' '.$pandora_version.$lts_name.' - '.(enterprise_installed() ? 'Enterprise' : 'Community').'

+

'.__('MR version').' MR'.$config['MR'].'

+

Build'.$build_version.'

'; + if (enterprise_installed() === true) { + $dialog .= '

'.__('Support expires').''.$license_expiry_date.'

'; + } + + if ($license_expired === false) { + $dialog .= '

'.__('This system has official support, warranty and official updates.').'

'; + } else if (enterprise_installed() === true) { + $dialog .= '

'.__('This system has no active support contract, and has no support, upgrades or warranty.').'

'; + $dialog .= '

'.__('Contact Pandora FMS for expand your support contract.').'

'; + } else { + $dialog .= '

'.__('The OpenSource version has no support or warranty of any kind.').'

'; + $dialog .= '

'.__('Contact Pandora FMS for official support contract.').'

'; + } + + $dialog .= '
+ +
+ + '; + + echo $dialog; + } } diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index b670088f85..a039fcbc07 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -743,7 +743,8 @@ function modules_create_agent_module( string $name, array $values=[], bool $disableACL=false, - $tags=false + $tags=false, + $use_agent_ip=false, ) { global $config; @@ -785,6 +786,10 @@ function modules_create_agent_module( return ERR_EXIST; } + if ($use_agent_ip === true) { + $values['ip_target'] = agents_get_address($id_agent); + } + // Encrypt passwords. if (isset($values['plugin_pass']) === true) { // Avoid two times encryption. diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 59d02ccb4f..79fcd9a0db 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1233,7 +1233,9 @@ function netflow_draw_item( $max_aggregates, $connection_name='', $output='HTML', - $address_resolution=false + $address_resolution=false, + $width_content=false, + $height_content=false ) { $aggregate = $filter['aggregate']; $interval = ($end_date - $start_date); @@ -1432,6 +1434,9 @@ function netflow_draw_item( netflow_aggregate_is_ip($aggregate) ); + $data_circular['width'] = $width_content; + $data_circular['height'] = $height_content; + $html = '
'; $html .= graph_netflow_circular_mesh($data_circular); $html .= '
'; @@ -1734,7 +1739,12 @@ function netflow_get_top_summary( switch ($top_action) { case 'listeners': if (empty(!$filter)) { - $netflow_filter['ip_src'] = $filter; + if (!is_array($filter)) { + $netflow_filter['ip_src'] = $filter; + } else { + $netflow_filter['ip_src'] = $filter['ip']; + $netflow_filter['advanced_filter'] = $filter['advanced_filter']; + } } $sort = 'dstip'; @@ -1742,7 +1752,12 @@ function netflow_get_top_summary( case 'talkers': if (empty(!$filter)) { - $netflow_filter['ip_dst'] = $filter; + if (!is_array($filter)) { + $netflow_filter['ip_dst'] = $filter; + } else { + $netflow_filter['ip_dst'] = $filter['ip']; + $netflow_filter['advanced_filter'] = $filter['advanced_filter']; + } } $sort = 'srcip'; @@ -2069,7 +2084,7 @@ function netflow_aggregate_is_ip($aggregate) * * @return array With map structure. */ -function netflow_build_map_data($start_date, $end_date, $top, $aggregate) +function netflow_build_map_data($start_date, $end_date, $top, $aggregate, $advanced_filter='') { // Pass an empty filter data structure. $data = netflow_get_relationships_raw_data( @@ -2083,7 +2098,7 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate) 'ip_src' => '', 'dst_port' => '', 'src_port' => '', - 'advanced_filter' => '', + 'advanced_filter' => $advanced_filter, 'router_ip' => '', ], $top, diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index c516ff2259..c01e44157a 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -412,6 +412,13 @@ function reporting_make_reporting_data( ); break; + case 'event_report_log_table': + $report['contents'][] = reporting_log_table( + $report, + $content + ); + break; + case 'increment': $report['contents'][] = reporting_increment( $report, diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 2f227e430c..91d8a9e5a5 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -259,6 +259,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) reporting_html_log($table, $item); break; + case 'event_report_log_table': + reporting_html_log_table($table, $item); + break; + case 'permissions_report': reporting_html_permissions($table, $item); break; diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 3be975fe2e..f13e935b6a 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -944,6 +944,11 @@ function reports_get_report_types($template=false, $not_editor=false) 'optgroup' => __('Log'), 'name' => __('Log report'), ]; + + $types['event_report_log_table'] = [ + 'optgroup' => __('Log'), + 'name' => __('Log report by period'), + ]; } if ($template === false) { diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index f42b791e8f..ebc2bb414d 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -1411,3 +1411,24 @@ function servers_get_master() return $result; } + + +/** + * Return true if all servers are up. + * + * @return boolean + */ +function check_all_servers_up() +{ + $status = true; + + $servers = servers_get_info(); + + foreach ($servers as $server) { + if ($server['status'] !== '1') { + return false; + } + } + + return $status; +} diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index f76e9e3ebc..38ecabb0e0 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -716,6 +716,13 @@ function snmp_browser_print_container( $table->size[0] = '30%'; $table->size[1] = '30%'; $table->size[2] = '30%'; + $target_ip = get_parameter('target_ip', ''); + if (str_contains($target_ip, '_')) { + $custom_field = explode('_', $target_ip)[2]; + $agent_alias = get_parameter('agent_alias', ''); + $id_agente = db_get_all_rows_sql('SELECT id_agente FROM tagente WHERE alias = "'.io_safe_output($agent_alias).'"')[0]['id_agente']; + $target_ip = db_get_all_rows_sql('SELECT description FROM tagent_custom_data WHERE id_field = '.$custom_field.' AND id_agent = '.$id_agente)[0]['description']; + } $table->data[0][0] = html_print_label_input_block( __('Target IP'), @@ -723,7 +730,7 @@ function snmp_browser_print_container( [ 'type' => 'text', 'name' => 'target_ip', - 'value' => get_parameter('target_ip', ''), + 'value' => $target_ip, 'required' => true, 'size' => 25, 'maxlength' => 0, @@ -1284,7 +1291,8 @@ function snmp_browser_create_modules_snmp( string $module_target, array $snmp_values, ?array $id_target, - ?string $server_to_exec=null + ?string $server_to_exec=null, + ?string $use_agent_ip='' ) { $target_ip = null; $target_port = null; @@ -1343,6 +1351,12 @@ function snmp_browser_create_modules_snmp( } } + if (empty($use_agent_ip) === false) { + $use_agent_ip = true; + } else { + $use_agent_ip = false; + } + $fail_modules = []; foreach ($targets_oids as $key => $target_oid) { @@ -1507,7 +1521,7 @@ function snmp_browser_create_modules_snmp( 'history_data' => 1, ]; foreach ($id_target as $agent) { - $ids[] = modules_create_agent_module($agent, $oid['oid'], $values); + $ids[] = modules_create_agent_module($agent, $oid['oid'], $values, false, false, $use_agent_ip); } } else if ($module_target == 'policy') { // Policies only in enterprise version. @@ -1796,6 +1810,16 @@ function snmp_browser_print_create_module_massive( true ); + $table->data[4][0] = html_print_label_input_block( + __('Use agent IP'), + html_print_checkbox( + 'use_agent_ip', + 1, + false, + true + ) + ); + $output .= html_print_table($table, true); // SNMP extradata. diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index b2341ff6c9..90213d96dd 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -795,8 +795,14 @@ function tags_get_acl_tags( $acltags = []; foreach ($raw_acltags as $group => $taglist) { - if (empty($id_group) === false && array_key_exists($group, $id_group) === false) { - continue; + if ($return_mode === 'module_condition') { + if (!empty($id_group) && !in_array($group, $id_group)) { + continue; + } + } else { + if (empty($id_group) === false && array_key_exists($group, $id_group) === false) { + continue; + } } if (!empty($taglist)) { diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 33b164a330..025276ecef 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -650,16 +650,28 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false) // Agent name. $row = []; $row['title'] = __('Agent name'); - $row['data'] = html_print_anchor( - [ - 'href' => 'javascript:void(0)', - 'title' => __('Click here for view this agent'), - 'class' => 'font_11', - 'content' => $cellName, - 'onClick' => "sendHash('".$urlAgent."')", - ], - true - ); + if (is_metaconsole() === true) { + $row['data'] = html_print_anchor( + [ + 'href' => 'javascript:void(0)', + 'title' => __('Click here for view this agent'), + 'class' => 'font_11', + 'content' => $cellName, + 'onClick' => "sendHash('".$urlAgent."')", + ], + true + ); + } else { + $row['data'] = html_print_anchor( + [ + 'href' => $urlAgent, + 'title' => __('Click here for view this agent'), + 'class' => 'font_11', + 'content' => $cellName, + ], + true + ); + } $table->data['name'] = $row; @@ -880,11 +892,13 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false) $table_advanced->head = []; $table_advanced->data = []; - // Agent version. - $row = []; + $row = []; + // Agent version. + if (!empty($agent['agent_version'])) { $row['title'] = __('Agent Version'); $row['data'] = $agent['agent_version']; $table_advanced->data['agent_version'] = $row; + } // Position Information. if ($config['activate_gis']) { @@ -964,7 +978,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false) '', '', true, - false, + empty($table_advanced->data), '', 'white-box-content mrgn_top_0 mrgn_btn_0px border-bottom-gray', 'white_table_flex' diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index f50f2d56e4..7b191d599a 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -88,8 +88,16 @@ function ui_bbcode_to_html($text, $allowed_tags=['[url]']) * * @return string Truncated text. */ -function ui_print_truncate_text($text, $numChars=GENERIC_SIZE_TEXT, $showTextInAToopTip=true, $return=true, $showTextInTitle=true, $suffix='…', $style=false) -{ +function ui_print_truncate_text( + $text, + $numChars=GENERIC_SIZE_TEXT, + $showTextInAToopTip=true, + $return=true, + $showTextInTitle=true, + $suffix='…', + $style=false, + $forced_title=false +) { global $config; if (is_string($numChars)) { @@ -190,6 +198,10 @@ function ui_print_truncate_text($text, $numChars=GENERIC_SIZE_TEXT, $showTextInA } } + if ($forced_title === true) { + $truncateText = ''.$div_content.''; + + if ($return === false) { + echo $output; + } + + return $output; +} + + /** * Get the shape of an image by assigning it a CSS class. Prints an image with CSS representing a status. * @@ -3716,28 +3754,71 @@ function ui_progress_extend( * Generate needed code to print a datatables jquery plugin. * * @param array $parameters All desired data using following format: - * [ - * 'print' => true (by default printed) - * 'id' => datatable id. - * 'class' => datatable class. - * 'style' => datatable style. - * 'order' => [ - * 'field' => column name - * 'direction' => asc or desc - * ], - * 'default_pagination' => integer, default pagination is set to block_size - * 'ajax_url' => 'include/ajax.php' ajax_url. - * 'ajax_data' => [ operation => 1 ] extra info to be sent. - * 'ajax_postprocess' => a javscript function to postprocess data received - * by ajax call. It is applied foreach row and must - * use following format: - * * [code] - * * function (item) { - * * // Process received item, for instance, name: - * * tmp = '' + item.name + ''; - * * item.name = tmp; - * * } - * * [/code] + * + * ```php + * $parameters = [ + * // JS Parameters + * 'serverside' => true, + * 'paging' => true, + * 'default_pagination' => $config['block_size'], + * 'searching' => false, + * 'dom_elements' => "plfrtiB", + * 'pagination_options' => [default_pagination, 5, 10, 20, 100, 200, 500, 1000, "All"], + * 'ordering' => true, + * 'order' => [[0, "asc"]], //['field' => 'column_name', 'direction' => 'asc/desc'] + * 'zeroRecords' => "No matching records found", + * 'emptyTable' => "No data available in table", + * 'no_sortable_columns' => [], //Allows the column name (db) from "columns" parameter + * 'csv_field_separator' => ",", + * 'csv_header' => true, + * 'mini_csv' => false, + * 'mini_pagination' => false, + * 'mini_search' => false, + * 'drawCallback' => undefined, //'console.log(123),' + * 'data_element' => undefined, //Rows processed + * 'ajax_postprocess' => undefined, //'process_datatables_item(item)' + * 'ajax_data' => undefined, //Extra data to be sent ['field1' => 1, 'field2 => 0] + * 'ajax_url' => undefined, + * 'caption' => undefined, + * + * // PHP Parameters + * 'id' => undefined, //Used for table and form id, + * 'columns' =>, + * 'column_names' =>, + * 'filter_main_class' =>, + * 'toggle_collapsed' =>true, + * 'search_button_class' => 'sub filter', + * 'csv' =>=1, + * 'form' => + * ..[ + * ....'id' => $form_id, + * ....'class' => 'flex-row', + * ....'style' => 'width: 100%,', + * ....'js' => '', + * ....'html' => $filter, + * ....'inputs' => [], + * ....'extra_buttons' => $buttons, + * ..], + * 'no_toggle' => false, + * 'form_html' => undefined, + * 'toggle_collapsed' => true, + * 'class' => "", //Datatable class. + * 'style' => "" ,//Datatable style. + * 'return' => false, + * 'print' => true, + * ] + * + * ``` + * + * ```php + * ajax_postprocess => a javscript function to postprocess data received + * by ajax call. It is applied foreach row and must + * use following format: + * function (item) { + * // Process received item, for instance, name: + * tmp = '' + item.name + ''; + * item.name = tmp; + * } * 'columns_names' => [ * 'column1' :: Used as th text. Direct text entry. It could be array: * OR @@ -3754,7 +3835,6 @@ function ui_progress_extend( * 'column2', * ... * ], - * 'no_sortable_columns' => [ indexes ] 1,2... -1 etc. Avoid sorting. * 'form' => [ * 'html' => 'html code' a directly defined inputs in HTML. * 'extra_buttons' => [ @@ -3786,12 +3866,7 @@ function ui_progress_extend( * ] * ], * 'extra_html' => HTML content to be placed after 'filter' section. - * 'drawCallback' => function to be called after draw. Sample in: - * https://datatables.net/examples/advanced_init/row_grouping.html - * ] - * 'zeroRecords' => Message when zero records obtained from filter.(Leave blank for default). - * 'emptyTable' => Message when table data empty.(Leave blank for default). - * End. + * ``` * * @return string HTML code with datatable. * @throws Exception On error. @@ -3808,6 +3883,9 @@ function ui_print_datatable(array $parameters) $form_id = uniqid('datatable_filter_'); } + $parameters['table_id'] = $table_id; + $parameters['form_id'] = $form_id; + if (!isset($parameters['columns']) || !is_array($parameters['columns'])) { throw new Exception('[ui_print_datatable]: You must define columns for datatable'); } @@ -3827,10 +3905,6 @@ function ui_print_datatable(array $parameters) $parameters['default_pagination'] = $config['block_size']; } - if (!isset($parameters['paging'])) { - $parameters['paging'] = true; - } - if (!isset($parameters['filter_main_class'])) { $parameters['filter_main_class'] = ''; } @@ -3839,13 +3913,9 @@ function ui_print_datatable(array $parameters) $parameters['toggle_collapsed'] = true; } - $no_sortable_columns = json_encode([]); - if (isset($parameters['no_sortable_columns'])) { - $no_sortable_columns = json_encode($parameters['no_sortable_columns']); - } - if (!is_array($parameters['order'])) { - $order = '0, "asc"'; + $order = 0; + $direction = 'asc'; } else { if (!isset($parameters['order']['direction'])) { $direction = 'asc'; @@ -3864,47 +3934,35 @@ function ui_print_datatable(array $parameters) } } - $order .= ', "'.$parameters['order']['direction'].'"'; + $direction = $parameters['order']['direction']; } - if (!isset($parameters['ajax_data'])) { - $parameters['ajax_data'] = ''; + $parameters['order']['order'] = $order; + $parameters['order']['direction'] = $direction; + + foreach ($parameters['no_sortable_columns'] as $key => $find) { + $found = array_search( + $parameters['no_sortable_columns'][$key], + $parameters['columns'] + ); + + if ($found !== false) { + unset($parameters['no_sortable_columns'][$key]); + array_push($parameters['no_sortable_columns'], $found); + } + + if (is_int($parameters['no_sortable_columns'][$key]) === false) { + unset($parameters['no_sortable_columns'][$key]); + } } - $search_button_class = 'sub filter'; + $parameters['csvTextInfo'] = __('Export current page to CSV'); + $parameters['csvFileTitle'] = sprintf(__('export_%s_current_page_%s'), $table_id, date('Y-m-d')); + if (isset($parameters['search_button_class'])) { $search_button_class = $parameters['search_button_class']; - } - - if (isset($parameters['pagination_options'])) { - $pagination_options = $parameters['pagination_options']; } else { - $pagination_options = [ - [ - // There is a limit of (2^32)^2 (18446744073709551615) rows in a MyISAM table, show for show all use max nrows. - // -1 Retun error or only 1 row. - $parameters['default_pagination'], - 5, - 10, - 25, - 100, - 200, - 500, - 1000, - 18446744073709551615, - ], - [ - $parameters['default_pagination'], - 5, - 10, - 25, - 100, - 200, - 500, - 1000, - 'All', - ], - ]; + $search_button_class = 'sub filter'; } if (isset($parameters['datacolumns']) === false @@ -3917,16 +3975,12 @@ function ui_print_datatable(array $parameters) $parameters['csv'] = 1; } - $dom_elements = '"plfrtiB"'; - if (isset($parameters['dom_elements'])) { - $dom_elements = '"'.$parameters['dom_elements'].'"'; - } - $filter = ''; // Datatable filter. if (isset($parameters['form']) && is_array($parameters['form'])) { if (isset($parameters['form']['id'])) { $form_id = $parameters['form']['id']; + $parameters['form_id'] = $form_id; } if (isset($parameters['form']['class'])) { @@ -4044,10 +4098,13 @@ function ui_print_datatable(array $parameters) ) ); $processing .= ''; + $parameters['processing'] = $processing; $zeroRecords = isset($parameters['zeroRecords']) === true ? $parameters['zeroRecords'] : __('No matching records found'); $emptyTable = isset($parameters['emptyTable']) === true ? $parameters['emptyTable'] : __('No data available in table'); + $parameters['zeroRecords'] = $zeroRecords; + $parameters['emptyTable'] = $emptyTable; // Extra html. $extra = ''; if (isset($parameters['extra_html']) && !empty($parameters['extra_html'])) { @@ -4056,8 +4113,8 @@ function ui_print_datatable(array $parameters) // Base table. $table = ''; + $table .= 'class="'.$parameters['class'].'"'; + $table .= 'style="box-sizing: border-box;'.$parameters['style'].'">'; $table .= ''; if (isset($parameters['column_names']) @@ -4084,335 +4141,60 @@ function ui_print_datatable(array $parameters) } $table .= ''; - - if (isset($parameters['data_element']) === true) { - $table .= ''; - foreach ($parameters['data_element'] as $row) { - $table .= ''; - foreach ($row as $td_data) { - $table .= ''; - } - - $table .= ''; - } - - $table .= ''; - - $js = ''; - } - $table .= '
'.$td_data.'
'; - $pagination_class = 'pandora_pagination'; - if (!empty($parameters['pagination_class'])) { - $pagination_class = $parameters['pagination_class']; + $parameters['ajax_url_full'] = ui_get_full_url('ajax.php', false, false, false); + + $parameters['spinnerLoading'] = html_print_image( + 'images/spinner.gif', + true, + [ + 'id' => $form_id.'_loading', + 'class' => 'loading-search-datatables-button', + ] + ); + + $language = substr(get_user_language(), 0, 2); + if (is_metaconsole() === false) { + $parameters['language'] = 'include/javascript/i18n/dataTables.'.$language.'.json'; + } else { + $parameters['language'] = '../../include/javascript/i18n/dataTables.'.$language.'.json'; } - $columns = ''; - for ($i = 1; $i <= (count($parameters['columns']) - 3); $i++) { - if ($i != (count($parameters['columns']) - 3)) { - $columns .= $i.','; - } else { - $columns .= $i; - } + $parameters['phpDate'] = date('Y-m-d'); + $parameters['dataElements'] = json_encode($parameters['data_element']); + + // * START JAVASCRIPT. + if (is_metaconsole() === false) { + $file_path = ui_get_full_url('include/javascript/datatablesFunction.js'); + } else { + $file_path = ui_get_full_url('../../include/javascript/datatablesFunction.js'); } - $export_columns = ''; - if (isset($parameters['csv_exclude_latest']) === true - && $parameters['csv_exclude_latest'] === true - ) { - $export_columns = ',columns: \'th:not(:last-child)\''; - } + $file_content = file_get_contents($file_path); + $json_data = json_encode($parameters); + $json_config = json_encode($config); - if (isset($parameters['data_element']) === false || isset($parameters['print_pagination_search_csv'])) { - if (isset($parameters['ajax_url'])) { - $type_data = 'ajax: { - url: "'.ui_get_full_url('ajax.php', false, false, false).'", - type: "POST", - dataSrc: function (json) { - if($("#'.$form_id.'_search_bt") != undefined) { - $("#'.$form_id.'_loading").remove(); - } + $js = ''; - if (json.error) { - console.error(json.error); - $("#error-'.$table_id.'").html(json.error); - $("#error-'.$table_id.'").dialog({ - title: "Filter failed", - width: 630, - resizable: true, - draggable: true, - modal: false, - closeOnEscape: true, - buttons: { - "Ok" : function () { - $(this).dialog("close"); - } - } - }).parent().addClass("ui-state-error"); - } else {'; - - if (isset($parameters['ajax_return_operation']) === true - && empty($parameters['ajax_return_operation']) === false - && isset($parameters['ajax_return_operation_function']) === true - && empty($parameters['ajax_return_operation_function']) === false - ) { - $type_data .= ' - if (json.'.$parameters['ajax_return_operation'].' !== undefined) { - '.$parameters['ajax_return_operation_function'].'(json.'.$parameters['ajax_return_operation'].'); - } - '; - } - - if (isset($parameters['ajax_postprocess'])) { - $type_data .= ' - if (json.data) { - json.data.forEach(function(item) { - '.$parameters['ajax_postprocess'].' - }); - } else { - json.data = {}; - }'; - } - - $type_data .= ' - return json.data; - } - }, - data: function (data) { - if($("#button-'.$form_id.'_search_bt") != undefined) { - var loading = \''.html_print_image( - 'images/spinner.gif', - true, - [ - 'id' => $form_id.'_loading', - 'class' => 'loading-search-datatables-button', - ] - ).'\'; - $("#button-'.$form_id.'_search_bt").parent().append(loading); - } - - inputs = $("#'.$form_id.' :input"); - - values = {}; - inputs.each(function() { - values[this.name] = $(this).val(); - }) - - $.extend(data, { - filter: values,'."\n"; - - if (is_array($parameters['ajax_data'])) { - foreach ($parameters['ajax_data'] as $k => $v) { - $type_data .= $k.':'.json_encode($v).",\n"; - } - } - - $type_data .= 'page: "'.$parameters['ajax_url'].'" - }); - - return data; - } - },'; - } else { - $type_data = 'data: '.json_encode($parameters['data_element']).','; - } - - $serverside = 'true'; - if (isset($parameters['data_element'])) { - $serverside = 'false'; - } - - // Javascript controller. - $js = ''; - } - - // Order. + $js .= ''; + // * END JAVASCRIPT. $info_msg_arr = []; $info_msg_arr['message'] = $emptyTable; $info_msg_arr['div_class'] = 'info_box_container invisible_important datatable-msg-info-'.$table_id; - $spinner = '
'; + $spinner = '
'; $info_msg = '
'.ui_print_info_message($info_msg_arr).'
'; + $err_msg = '
'; $output = $info_msg.$err_msg.$filter.$extra.$spinner.$table.$js; if (is_ajax() === false) { @@ -4436,7 +4218,7 @@ function ui_print_datatable(array $parameters) false, false ); - $output .= '?v='.$config['current_package'].'"/>'; + $output .= '"/>'; // Load tables.css. $output .= '', $comments); - if (is_array($comments)) { - foreach ($comments as $comm) { - if (empty($comm)) { - continue; - } - - $comments_array[] = io_safe_output(json_decode($comm, true)); - } - } - - $order_utimestamp = array_reduce( - $comments_array, - function ($carry, $item) { - foreach ($item as $k => $v) { - $carry[$v['utimestamp']] = $v; - } - - return $carry; - } - ); - - $key_max_utimestamp = max(array_keys($order_utimestamp)); - - $last_comment = $order_utimestamp[$key_max_utimestamp]; - - if (empty($last_comment) === true) { + if (empty($comment) === true) { return ''; } // Only show the last comment. If commment its too long,the comment will short with ... // If $config['prominent_time'] is timestamp the date show Month, day, hour and minutes. // Else show comments hours ago - if ($last_comment['action'] != 'Added comment') { - $last_comment['comment'] = $last_comment['action']; + if ($comment['action'] != 'Added comment') { + $comment['comment'] = $comment['action']; } - $short_comment = substr($last_comment['comment'], 0, 20); + $short_comment = substr($comment['comment'], 0, 20); if ($config['prominent_time'] == 'timestamp') { - $comentario = ''.date($config['date_format'], $last_comment['utimestamp']).' ('.$last_comment['id_user'].'): '.$last_comment['comment'].''; + $comentario = ''.date($config['date_format'], $comment['utimestamp']).' ('.$comment['id_user'].'): '.$comment['comment'].''; - if (strlen($comentario) > '200px') { - $comentario = ''.date($config['date_format'], $last_comment['utimestamp']).' ('.$last_comment['id_user'].'): '.$short_comment.'...'; + if (strlen($comentario) > '200px' && $truncate_limit >= 255) { + $comentario = ''.date($config['date_format'], $comment['utimestamp']).' ('.$comment['id_user'].'): '.$short_comment.'...'; } } else { - $rest_time = (time() - $last_comment['utimestamp']); + $rest_time = (time() - $comment['utimestamp']); $time_last = (($rest_time / 60) / 60); - $comentario = ''.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'  Hours  ('.$last_comment['id_user'].'): '.$last_comment['comment'].''; + $comentario = ''.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'  Hours  ('.$comment['id_user'].'): '.$comment['comment'].''; - if (strlen($comentario) > '200px') { - $comentario = ''.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'  Hours  ('.$last_comment['id_user'].'): '.$short_comment.'...'; + if (strlen($comentario) > '200px' && $truncate_limit >= 255) { + $comentario = ''.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'  Hours  ('.$comment['id_user'].'): '.$short_comment.'...'; } } - return io_safe_output($comentario); + $comentario = io_safe_output($comentario); + if (strlen($comentario) >= $truncate_limit) { + $comentario = ui_print_truncate_text( + $comentario, + $truncate_limit, + false, + true, + false, + '…', + true, + true, + ); + } + + return $comentario; } @@ -8205,6 +7977,133 @@ function ui_print_fav_menu($id_element, $url, $label, $section) } +function ui_print_tree( + $tree, + $id=0, + $depth=0, + $last=0, + $last_array=[], + $sufix=false, + $descriptive_ids=false, + $previous_id='' +) { + static $url = false; + $output = ''; + + // Get the base URL for images. + if ($url === false) { + $url = ui_get_full_url('operation/tree', false, false, false); + } + + // Leaf. + if (empty($tree['__LEAVES__'])) { + return ''; + } + + $count = 0; + $total = (count(array_keys($tree['__LEAVES__'])) - 1); + $last_array[$depth] = $last; + $class = 'item_'.$depth; + + if ($depth > 0) { + $output .= '