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 eae2a56807..80a3821568 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-230705 +Version: 7.0NG.772-230801 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 0e9751413d..6bea6f1f68 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-230705" +pandora_version="7.0NG.772-230801" 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 a1370e569c..2dfb967438 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 => '230705'; +use constant AGENT_BUILD => '230801'; # 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 5376afeb5d..4e1d5d73f4 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 230705 +%define release 230801 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 aa619d96fc..da2b6b7fa7 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 230705 +%define release 230801 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 19d56d9041..c2c04e866d 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="230705" +PI_BUILD="230801" 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 92f642b538..7a88382b36 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230705} +{230801} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 363e89008d..57d4e2a9fd 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 230705") +#define PANDORA_VERSION ("7.0NG.772 Build 230801") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 435bb08511..1f922a2123 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 230705))" + VALUE "ProductVersion", "(7.0NG.772(Build 230801))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index d165d8a1e3..66f3140f52 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,10 +1,10 @@ package: pandorafms-console -Version: 7.0NG.772-230705 +Version: 7.0NG.772-230801 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 622109247e..5211fe12bc 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-230705" +pandora_version="7.0NG.772-230801" 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..60bffeb27f 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -349,7 +349,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 6efd958c5f..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) ); @@ -965,7 +965,7 @@ foreach ($fields as $field) { true ); } else if ($field['is_link_enabled']) { - list($link_text, $link_url) = json_decode($custom_value, true); + list($link_text, $link_url) = json_decode(io_safe_output($custom_value), true); if (json_last_error() !== JSON_ERROR_NONE) { $link_text = ''; @@ -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_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 4669b98858..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', @@ -835,7 +835,7 @@ if ($downtimes === false && $filter_performed === false) { // If user have writting permissions. if (in_array($downtime['id_group'], $groupsAD) === true) { // Stop button. - if ($downtime['type_execution'] === 'once' + if (($downtime['type_execution'] === 'once' || $downtime['type_execution'] === 'periodically') && (int) $downtime['executed'] === 1 ) { if ((bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') === true diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index b972e1ff5a..97a492809e 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -333,7 +333,7 @@ $show_table_filter .= ui_toggle( __('Search'), 'search', true, - false, + true, '', 'white-box-content no_border', 'filter-datatable-main box-flat white_table_graph fixed_filter_bar ' diff --git a/pandora_console/godmode/alerts/alert_list.builder.php b/pandora_console/godmode/alerts/alert_list.builder.php index b68ae38162..de07bce961 100644 --- a/pandora_console/godmode/alerts/alert_list.builder.php +++ b/pandora_console/godmode/alerts/alert_list.builder.php @@ -40,27 +40,45 @@ $table->size = []; $table->style[0] = 'width: 50%'; $table->style[1] = 'width: 50%'; -// Add an agent selector -if (! $id_agente) { +$modules = []; + +if (is_metaconsole() === true) { $params = []; $params['return'] = true; $params['show_helptip'] = true; $params['input_name'] = 'id_agent'; $params['selectbox_id'] = 'id_agent_module'; $params['javascript_is_function_select'] = true; - $params['metaconsole_enabled'] = false; + $params['metaconsole_enabled'] = true; $params['use_hidden_input_idagent'] = true; $params['print_hidden_input_idagent'] = true; + $params['javascript_page'] = 'enterprise/meta/include/ajax/events.ajax'; + $table->data[0][0] = html_print_label_input_block( __('Agent'), - ui_print_agent_autocomplete_input($params) + '
'.ui_print_agent_autocomplete_input($params).'
' ); -} +} else { + // Add an agent selector. + if (! $id_agente) { + $params = []; + $params['return'] = true; + $params['show_helptip'] = true; + $params['input_name'] = 'id_agent'; + $params['selectbox_id'] = 'id_agent_module'; + $params['javascript_is_function_select'] = true; + $params['metaconsole_enabled'] = false; + $params['use_hidden_input_idagent'] = true; + $params['print_hidden_input_idagent'] = true; + $table->data[0][0] = html_print_label_input_block( + __('Agent'), + ui_print_agent_autocomplete_input($params) + ); + } -$modules = []; - -if ($id_agente) { - $modules = agents_get_modules($id_agente, false, ['delete_pending' => 0]); + if ($id_agente) { + $modules = agents_get_modules($id_agente, false, ['delete_pending' => 0]); + } } $table->data[0][1] = html_print_label_input_block( @@ -319,7 +337,8 @@ $(document).ready (function () { jQuery.post ( + "ajax.php", {"page" : "operation/agentes/estado_agente", "get_agent_module_last_value" : 1, - "id_agent_module" : this.value + "id_agent_module" : this.value, + "server_name" : $('#text-id_agent').val(), }, function (data, status) { if (data === false) { @@ -338,5 +357,4 @@ $(document).ready (function () { ); }); }); -/* ]]> */ diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index 828901f2bf..17669ab248 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -99,6 +99,19 @@ if ($update_alert) { } if ($create_alert) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $id_alert_template = (int) get_parameter('template'); $id_agent_module = (int) get_parameter('id_agent_module'); @@ -203,9 +216,28 @@ if ($create_alert) { } } } + + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($delete_alert) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $id_alert_agent_module = (int) get_parameter('id_alert'); $temp = db_get_row('talert_template_modules', 'id', $id_alert_agent_module); @@ -241,9 +273,27 @@ if ($delete_alert) { '', true ); + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($add_action) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $id_action = (int) get_parameter('action_select'); $id_alert_module = (int) get_parameter('id_alert_module'); $fires_min = (int) get_parameter('fires_min'); @@ -280,9 +330,28 @@ if ($add_action) { '', true ); + + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($update_action) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $alert_id = (int) get_parameter('alert_id'); $id_action = (int) get_parameter('action_select_ajax-'.$alert_id); $id_module_action = (int) get_parameter('id_module_action_ajax'); @@ -321,9 +390,28 @@ if ($update_action) { '', true ); + + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($delete_action) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $id_action = (int) get_parameter('id_action'); $id_alert = (int) get_parameter('id_alert'); @@ -348,6 +436,12 @@ if ($delete_action) { '', true ); + + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($enable_alert) { diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index cd5a271971..1a3e991fde 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -318,61 +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 (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); - } + 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->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->data[$kaction][$k] = 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 - ); + } 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][1] = 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/extensions.php b/pandora_console/godmode/extensions.php index baa3c2e6a5..5ec67b09a7 100644 --- a/pandora_console/godmode/extensions.php +++ b/pandora_console/godmode/extensions.php @@ -287,7 +287,7 @@ foreach ($extensions as $file => $extension) { [ 'href' => 'index.php?sec=godmode/extensions&sec2=godmode/extensions&enterprise='.(int) $extension['enterprise'].'&enabled='.$file, 'image' => 'images/lightbulb_off.png', - 'title' => __('Delete'), + 'title' => __('Enable'), ], true ); @@ -305,7 +305,7 @@ foreach ($extensions as $file => $extension) { [ 'href' => 'index.php?sec=godmode/extensions&sec2=godmode/extensions&enterprise='.(int) $extension['enterprise'].'&disabled='.$file, 'image' => 'images/lightbulb.png', - 'title' => __('Delete'), + 'title' => __('Disable'), ], true ); 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 '