diff --git a/extras/deploy-scripts/pandora_agent_deploy.sh b/extras/deploy-scripts/pandora_agent_deploy.sh index 88bfe4dd83..30bfc82632 100644 --- a/extras/deploy-scripts/pandora_agent_deploy.sh +++ b/extras/deploy-scripts/pandora_agent_deploy.sh @@ -184,14 +184,14 @@ if [[ $OS_RELEASE =~ 'rhel' ]] || [[ $OS_RELEASE =~ 'fedora' ]]; then echo -e "${cyan}Installing agent dependencies...${reset}" ${green}OK${reset} # Insatall pandora agent - [ "$PANDORA_AGENT_PACKAGE_EL" ] || PANDORA_AGENT_PACKAGE_EL="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_agent_linux_bin-7.0NG.x86_64.rpm " + [ "$PANDORA_AGENT_PACKAGE_EL" ] || PANDORA_AGENT_PACKAGE_EL="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_agent_linux_bin-7.0NG.x86_64.rpm" execute_cmd "$package_manager_cmd install -y ${PANDORA_AGENT_PACKAGE_EL}" 'Installing Pandora FMS agent package' #[[ $PANDORA_AGENT_SSL ]] && execute_cmd "$package_manager_cmd install -y perl-IO-Socket-SSL" "Installing SSL libraries for encrypted connection" fi if [[ $OS_RELEASE == 'debian' ]]; then - [ "$PANDORA_AGENT_PACKAGE_UBUNTU" ] || PANDORA_AGENT_PACKAGE_UBUNTU='https://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_agent_linux-7.0NG_x86_64.tar.gz' + [ "$PANDORA_AGENT_PACKAGE_UBUNTU" ] || PANDORA_AGENT_PACKAGE_UBUNTU='https://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_agent_linux-7.0NG.x86_64.tar.gz' execute_cmd "apt update" 'Updating repos' execute_cmd "apt install -y perl wget curl unzip procps python3 python3-pip" 'Installing agent dependencies' execute_cmd "curl --output pandorafms_agent_linux-7.0NG.tar.gz ${PANDORA_AGENT_PACKAGE_UBUNTU}" 'Downloading Pandora FMS agent package' diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index c16729bca0..44be2d8fb9 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='2023062901' +S_VERSION='2023101101' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" # define default variables @@ -185,7 +185,7 @@ extra_repos=" \ tar \ yum-utils \ https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \ -http://rpms.remirepo.net/enterprise/remi-release-7.rpm \ +https://rpms.remirepo.net/enterprise/remi-release-7.rpm \ https://repo.percona.com/yum/percona-release-latest.noarch.rpm" execute_cmd "yum install -y $extra_repos" "Installing extra repositories" @@ -285,6 +285,7 @@ console_dependencies=" \ mod_ssl \ libzstd \ openldap-clients \ + https://firefly.pandorafms.com/centos8/pandora_gotty-1.0-1.el8.x86_64.rpm \ chromium" execute_cmd "yum install -y $console_dependencies" "Installing Pandora FMS Console dependencies" @@ -312,7 +313,7 @@ server_dependencies=" \ bind-utils \ whois \ cpanminus \ - http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \ + https://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" @@ -322,13 +323,13 @@ execute_cmd "cpanm -i Thread::Semaphore" "Installing Thread::Semaphore" # SDK VMware perl dependencies vmware_dependencies=" \ - http://firefly.pandorafms.com/centos8/VMware-vSphere-Perl-SDK-6.5.0-4566394.x86_64.rpm \ + https://firefly.pandorafms.com/centos8/VMware-vSphere-Perl-SDK-6.5.0-4566394.x86_64.rpm \ perl-JSON \ perl-Archive-Zip \ openssl-devel \ perl-Crypt-CBC \ perl-Digest-SHA \ - http://firefly.pandorafms.com/centos7/perl-Crypt-OpenSSL-AES-0.02-1.el7.x86_64.rpm" + https://firefly.pandorafms.com/centos7/perl-Crypt-OpenSSL-AES-0.02-1.el7.x86_64.rpm" execute_cmd "yum install -y $vmware_dependencies" "Installing SDK VMware perl dependencies" # Instant client Oracle @@ -410,7 +411,7 @@ skip-character-set-client-handshake # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Mysql optimizations for Pandora FMS -# Please check the documentation in http://pandorafms.com for better results +# Please check the documentation in https://pandorafms.com for better results max_allowed_packet = 64M innodb_buffer_pool_size = $POOL_SIZE @@ -461,20 +462,20 @@ export MYSQL_PWD=$DBPASS #Define packages #Define packages if [ "$PANDORA_LTS" -eq '1' ] ; then - [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/LTS/pandorafms_server-7.0NG.noarch.rpm" - [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/LTS/pandorafms_console-7.0NG.noarch.rpm" - [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/LTS/pandorafms_agent_linux-7.0NG.noarch.rpm" + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/LTS/pandorafms_server-7.0NG.noarch.rpm" + [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/LTS/pandorafms_console-7.0NG.noarch.rpm" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/LTS/pandorafms_agent_linux-7.0NG.noarch.rpm" elif [ "$PANDORA_LTS" -ne '1' ] ; then - [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_server-7.0NG.noarch.rpm" - [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.noarch.rpm" - [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_agent_linux-7.0NG.noarch.rpm" + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_server-7.0NG.x86_64.rpm" + [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.x86_64.rpm" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_agent_linux-7.0NG.noarch.rpm" fi # if beta is enable if [ "$PANDORA_BETA" -eq '1' ] ; then - PANDORA_SERVER_PACKAGE="http://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_server-latest.x86_64.rpm" - PANDORA_CONSOLE_PACKAGE="http://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_console-latest.noarch.rpm" - PANDORA_AGENT_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_agent_linux-7.0NG.noarch.rpm" + PANDORA_SERVER_PACKAGE="https://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_server-latest.x86_64.rpm" + PANDORA_CONSOLE_PACKAGE="https://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_console-latest.x86_64.rpm" + PANDORA_AGENT_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_agent_linux-7.0NG.noarch.rpm" fi # Downloading Pandora Packages @@ -710,8 +711,8 @@ systemctl enable tentacle_serverd &>> $LOGFILE execute_cmd "service tentacle_serverd start" "Starting Tentacle Server" # Enabling condole cron -execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron" -echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab +execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron" +echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab ## Enabling agent systemctl enable pandora_agent_daemon &>> $LOGFILE execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent" @@ -729,7 +730,7 @@ Welcome to Pandora FMS appliance on CentOS Go to Public http://$ipplublic/pandora_console to login web console $(ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v "172.17.0.1" | awk '{print $2}' | awk -F '/' '{print "Go to Local http://"$1"/pandora_console to login web console"}') -You can find more information at http://pandorafms.com +You can find more information at https://pandorafms.com EOF_banner diff --git a/extras/deploy-scripts/pandora_deploy_community_el8.sh b/extras/deploy-scripts/pandora_deploy_community_el8.sh index 32422ab98b..7e2d2524c0 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='2023062901' +S_VERSION='2023101101' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" # define default variables @@ -264,7 +264,7 @@ if [ "$(grep -Ei 'Red Hat Enterprise' /etc/redhat-release)" ]; then tar \ dnf-utils \ https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \ - http://rpms.remirepo.net/enterprise/remi-release-8.rpm \ + https://rpms.remirepo.net/enterprise/remi-release-8.rpm \ https://repo.percona.com/yum/percona-release-latest.noarch.rpm" execute_cmd "dnf install -y $extra_repos" "Installing extra repositories" @@ -275,7 +275,7 @@ else tar \ dnf-utils \ epel-release \ - http://rpms.remirepo.net/enterprise/remi-release-8.rpm \ + https://rpms.remirepo.net/enterprise/remi-release-8.rpm \ https://repo.percona.com/yum/percona-release-latest.noarch.rpm" execute_cmd "dnf install -y $extra_repos" "Installing extra repositories" @@ -391,10 +391,12 @@ console_dependencies=" \ mod_ssl \ libzstd \ openldap-clients \ - 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" + https://firefly.pandorafms.com/centos8/chromium-110.0.5481.177-1.el7.x86_64.rpm \ + https://firefly.pandorafms.com/centos8/chromium-common-110.0.5481.177-1.el7.x86_64.rpm \ + https://firefly.pandorafms.com/centos8/perl-Net-Telnet-3.04-1.el8.noarch.rpm \ + https://firefly.pandorafms.com/centos8/pandora_gotty-1.0-1.el8.x86_64.rpm \ + https://firefly.pandorafms.com/centos8/pandorafms_made-0.1.0-1.el8.x86_64.rpm \ + https://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 @@ -421,7 +423,7 @@ server_dependencies=" \ bind-utils \ whois \ libnsl \ - http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \ + https://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" @@ -436,8 +438,8 @@ vmware_dependencies=" \ perl-Math-Random-ISAAC \ perl-JSON \ perl-Crypt-SSLeay \ - http://firefly.pandorafms.com/centos8/perl-Crypt-OpenSSL-AES-0.02-1.el8.x86_64.rpm \ - http://firefly.pandorafms.com/centos8/VMware-vSphere-Perl-SDK-6.5.0-4566394.x86_64.rpm" + https://firefly.pandorafms.com/centos8/perl-Crypt-OpenSSL-AES-0.02-1.el8.x86_64.rpm \ + https://firefly.pandorafms.com/centos8/VMware-vSphere-Perl-SDK-6.5.0-4566394.x86_64.rpm" execute_cmd "dnf install -y $vmware_dependencies" "Installing SDK VMware perl dependencies" # Instant client Oracle @@ -518,7 +520,7 @@ skip-character-set-client-handshake # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Mysql optimizations for Pandora FMS -# Please check the documentation in http://pandorafms.com for better results +# Please check the documentation in https://pandorafms.com for better results max_allowed_packet = 64M innodb_buffer_pool_size = $POOL_SIZE @@ -567,20 +569,20 @@ export MYSQL_PWD=$DBPASS #Define packages if [ "$PANDORA_LTS" -eq '1' ] ; then - [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/LTS/pandorafms_server-7.0NG.noarch.rpm" - [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/LTS/pandorafms_console-7.0NG.noarch.rpm" - [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/LTS/pandorafms_agent_linux-7.0NG.noarch.rpm" + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/LTS/pandorafms_server-7.0NG.noarch.rpm" + [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/LTS/pandorafms_console-7.0NG.noarch.rpm" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_agent_linux_bin-7.0NG.x86_64.rpm" elif [ "$PANDORA_LTS" -ne '1' ] ; then - [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_server-7.0NG.noarch.rpm" - [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.noarch.rpm" - [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_agent_linux-7.0NG.noarch.rpm" + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_server-7.0NG.x86_64.rpm" + [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.x86_64.rpm" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_agent_linux_bin-7.0NG.x86_64.rpm" fi # if beta is enable if [ "$PANDORA_BETA" -eq '1' ] ; then - PANDORA_SERVER_PACKAGE="http://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_server-latest.x86_64.rpm" - PANDORA_CONSOLE_PACKAGE="http://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_console-latest.noarch.rpm" - PANDORA_AGENT_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_agent_linux-7.0NG.noarch.rpm" + PANDORA_SERVER_PACKAGE="https://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_server-latest.x86_64.rpm" + PANDORA_CONSOLE_PACKAGE="https://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_console-latest.x86_64.rpm" + PANDORA_AGENT_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/RHEL_CentOS/pandorafms_agent_linux_bin-7.0NG.x86_64.rpm" fi # Downloading Pandora Packages @@ -828,8 +830,8 @@ systemctl enable tentacle_serverd &>> "$LOGFILE" execute_cmd "service tentacle_serverd start" "Starting Tentacle Server" # Enabling condole cron -execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron" -echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab +execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron" +echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab ## Enabling agent systemctl enable pandora_agent_daemon &>> "$LOGFILE" execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent" diff --git a/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh b/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh index a215808d17..5f240b0a41 100644 --- a/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh +++ b/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh @@ -344,6 +344,14 @@ execute_cmd "apt install -y $server_dependencies" "Installing Pandora FMS Server execute_cmd "installing_docker" "Installing Docker for debug" +# Installing pandora_gotty +execute_cmd "curl --output pandora_gotty.deb https://firefly.pandorafms.com/ubuntu/pandora_gotty_1.0.0.deb" "Downloading pandora_gotty" +execute_cmd "apt install -y ./pandora_gotty.deb" "Intalling pandora_gotty" + +# Installing MADE +execute_cmd "curl --output pandora_made.deb https://firefly.pandorafms.com/ubuntu/pandorafms-made_0.1.0-2_amd64.deb" "Downloading pandora MADE" +execute_cmd "apt install -y ./pandora_made.deb" "Intalling pandora MADE" + # wmic and pandorawmic execute_cmd "curl -O https://firefly.pandorafms.com/pandorafms/utils/bin/wmic" "Downloading wmic" execute_cmd "curl -O https://firefly.pandorafms.com/pandorafms/utils/bin/pandorawmic" "Downloading pandorawmic" @@ -514,17 +522,17 @@ execute_cmd "systemctl restart mysql" "Configuring and restarting database engin if [ "$PANDORA_LTS" -eq '1' ] ; then [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/Tarball/LTS/pandorafms_server-7.0NG.tar.gz" [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/Tarball/LTS/pandorafms_console-7.0NG.tar.gz" - [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/Tarball/LTS/pandorafms_agent_linux-7.0NG.tar.gz" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_agent_linux-7.0NG.x86_64.tar.gz" elif [ "$PANDORA_LTS" -ne '1' ] ; then [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_server-7.0NG.tar.gz" [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_console-7.0NG.tar.gz" - [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_agent_linux-7.0NG.tar.gz" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE=" https://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_agent_linux-7.0NG.x86_64.tar.gz" fi if [ "$PANDORA_BETA" -eq '1' ] ; then - PANDORA_SERVER_PACKAGE="http://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_server-latest_x86_64.tar.gz" + PANDORA_SERVER_PACKAGE="http://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_server-latest.tar.gz" PANDORA_CONSOLE_PACKAGE="http://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_console-latest.tar.gz" - PANDORA_AGENT_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_agent_linux-7.0NG.tar.gz" + PANDORA_AGENT_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_agent_linux-7.0NG.x86_64.tar.gz" fi # Downloading Pandora Packages @@ -819,8 +827,8 @@ execute_cmd "service tentacle_serverd start" "Starting Tentacle Server" systemctl enable tentacle_serverd &>> "$LOGFILE" # Enabling console cron -execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron" -echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab +execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron" +echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab # Enabling pandoradb cron execute_cmd "echo 'enabling pandoradb cron' >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS pandoradb cron" diff --git a/extras/pandora_gotty/deb/pandora_gotty/DEBIAN/control b/extras/pandora_gotty/deb/pandora_gotty/DEBIAN/control index f715ee1b49..fda06b3e36 100644 --- a/extras/pandora_gotty/deb/pandora_gotty/DEBIAN/control +++ b/extras/pandora_gotty/deb/pandora_gotty/DEBIAN/control @@ -1,6 +1,6 @@ Source: pandora_gotty Section: utils -Version: 1.0.0 +Version: 1.1.0 Priority: optional Maintainer: PandoraFMS Build-Depends: debhelper (>= 12) diff --git a/extras/pandora_gotty/pandora_gotty.spec b/extras/pandora_gotty/pandora_gotty.spec index 813c9726c9..d322fae653 100644 --- a/extras/pandora_gotty/pandora_gotty.spec +++ b/extras/pandora_gotty/pandora_gotty.spec @@ -1,5 +1,5 @@ %define name pandora_gotty -%define version 1.0 +%define version 1.1 %define release 1%{?dist} Summary: pandora_gptty for Pandora FMS Name: %{name} diff --git a/extras/pandora_gotty/src/pandora_gotty_exec.py b/extras/pandora_gotty/src/pandora_gotty_exec.py index 1f7756745f..2444d88363 100644 --- a/extras/pandora_gotty/src/pandora_gotty_exec.py +++ b/extras/pandora_gotty/src/pandora_gotty_exec.py @@ -74,7 +74,7 @@ def exec_ssh (user:str, add:str, port:int): try: print("> Starting SSH connection...") ssh_command = f"ssh {user}@{add} -p {port}" - subprocess.run(ssh_command, shell=True) + subprocess.run(ssh_command, shell=True, encoding='utf-8', text=True) except subprocess.CalledProcessError as e: raise SystemExit(e) @@ -88,7 +88,7 @@ def exec_telnet (add:str, port:int): try: print("> Starting Telnet connection...") ssh_command = f"telnet -E {add} {port}" - subprocess.run(ssh_command, shell=True) + subprocess.run(ssh_command, shell=True, encoding='utf-8', text=True) except subprocess.CalledProcessError as e: raise SystemExit(e) diff --git a/extras/pandora_update_version.sh b/extras/pandora_update_version.sh index 29dee8f0ce..06de8cc2b1 100755 --- a/extras/pandora_update_version.sh +++ b/extras/pandora_update_version.sh @@ -22,13 +22,16 @@ else fi SPEC_FILES="$CODEHOME/pandora_console/pandora_console.spec \ $CODEHOME/pandora_agents/unix/pandora_agent.spec \ +$CODEHOME/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec \ +$CODEHOME/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec \ +$CODEHOME/pandora_agents/unix/pandora_agent.redhat_bin.spec \ +$CODEHOME/pandora_agents/unix/pandora_agent.redhat.spec \ $CODEHOME/pandora_server/pandora_server.spec \ $PANDHOME_ENT/pandora_console/enterprise/pandora_console_enterprise.spec \ $PANDHOME_ENT/pandora_server/PandoraFMS-Enterprise/pandora_server_enterprise.spec \ $CODEHOME/pandora_console/pandora_console.redhat.spec \ $CODEHOME/pandora_console/pandora_console.rhel7.spec \ $CODEHOME/pandora_agents/unix/pandora_agent.redhat.spec \ -$CODEHOME/pandora_agents/unix/pandora_agent.redhat_bin.spec \ $CODEHOME/pandora_server/pandora_server.redhat.spec \ $PANDHOME_ENT/pandora_agents/pandora_agent.spec \ $PANDHOME_ENT/pandora_server/pandora_server_enterprise.redhat.spec \ diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index 5c5ec2d3b6..37fb9b0854 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.3, AIX version +# Version 7.0NG.774, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index ed33c06e4d..5a36cea140 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.3, FreeBSD Version +# Version 7.0NG.774, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index 784c729f73..52cd8e1774 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.3, HP-UX Version +# Version 7.0NG.774, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index 6284c748f9..4ad837f943 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.3, GNU/Linux +# Version 7.0NG.774, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index 28ee6bd21f..efa9d79f34 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.3, GNU/Linux +# Version 7.0NG.774, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index 3d17139780..3a97e4a011 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.3, Solaris Version +# Version 7.0NG.774, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index edf5a7847a..621c1d24ac 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2023 Pandora FMS -# Version 7.0NG.773.3 +# Version 7.0NG.774 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software # Foundation; either version 2 of the Licence or any later version diff --git a/pandora_agents/pc/pandora_agent b/pandora_agents/pc/pandora_agent index aa8208f5d0..67e603b225 100644 --- a/pandora_agents/pc/pandora_agent +++ b/pandora_agents/pc/pandora_agent @@ -54,7 +54,6 @@ if (!$@) { use constant AGENT_VERSION => '4.0.1'; use constant AGENT_BUILD => '111213'; - # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { linux => 'cat /proc/meminfo | grep MemTotal: | awk \'{ print $2 }\'', @@ -117,7 +116,6 @@ my $ConfDir = ''; # Pandora FMS agent configuration file my $ConfFile = 'pandora_agent.conf'; - # Broker agent configuration files my @BrokerPid; @@ -264,7 +262,6 @@ sub valid_regexp ($) { sub rmrf { my $path = shift; local *DIR; - if (-d $path) { opendir (DIR, $path) || return; while (defined (my $file_name = readdir(DIR))) { @@ -348,7 +345,6 @@ sub log_message ($$;$) { } } } - ################################################################################ # Add the given directory to the PATH. ################################################################################ @@ -582,7 +578,6 @@ sub write_broker_conf($){ } while (my $line = ){ - # Skip broker definitions if ($line =~ m/^\s*broker_agent/) { next; @@ -1810,7 +1805,6 @@ sub exec_plugin ($) { $Sem->down () if (defined ($Sem)); $Xml .= $output; $Sem->up () if (defined ($Sem)); - $ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1); } @@ -2287,4 +2281,4 @@ This is released under the GNU Lesser General Public License. Copyright (c) 2005-2023 Pandora FMS -=cut +=cut \ No newline at end of file diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index d2c1806dc0..74841e0515 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.773.3, AIX version +# Version 7.0NG.774, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index 69b39f6a25..7ba120ca70 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.773.3 +# Version 7.0NG.774 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index b27bfe9167..bcbd2dbb35 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.773.3, HPUX Version +# Version 7.0NG.774, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 23dff46fb5..98c137741e 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.3 +# Version 7.0NG.774 # Licensed under GPL license v2, # (c) 2003-2023 Pandora FMS # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index 3250232611..b4b3c35ac8 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.3 +# Version 7.0NG.774 # Licensed under GPL license v2, # (c) 2003-2023 Pandora FMS # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index 29fd1d64da..9ea0d9a2aa 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.3 +# Version 7.0NG.774 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index a4b43f1944..954c52853b 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.773.3, Solaris version +# Version 7.0NG.774, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index 29fb0051d5..c3bea470ac 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.773.3, AIX version +# Version 7.0NG.774, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2023 Pandora FMS # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index d6727545b4..516095201c 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.773.3-231023 +Version: 7.0NG.774-231205 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index bb9ca3f29b..db2417bcc0 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.773.3-231023" +pandora_version="7.0NG.774-231205" 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/build_darwin_dmg.sh b/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh index 91907dbd82..b1d0fea6db 100644 --- a/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh +++ b/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh @@ -31,7 +31,7 @@ fi if [ "$#" -ge 2 ]; then VERSION="$2" else - VERSION="7.0NG.773.3" + VERSION="7.0NG.774" fi # Path for the generated DMG file diff --git a/pandora_agents/unix/Darwin/dmg/extras/distribution.xml b/pandora_agents/unix/Darwin/dmg/extras/distribution.xml index 94266e09e4..708d31a47a 100644 --- a/pandora_agents/unix/Darwin/dmg/extras/distribution.xml +++ b/pandora_agents/unix/Darwin/dmg/extras/distribution.xml @@ -19,11 +19,11 @@ - pandorafms_src.pdk + pandorafms_src.pdk - pandorafms_uninstall.pdk + pandorafms_uninstall.pdk + + + \ No newline at end of file diff --git a/pandora_console/godmode/update_manager/update_manager.php b/pandora_console/godmode/update_manager/update_manager.php index e201bc14dd..3cb774c4d5 100644 --- a/pandora_console/godmode/update_manager/update_manager.php +++ b/pandora_console/godmode/update_manager/update_manager.php @@ -119,11 +119,13 @@ switch ($tab) { case 'setup': include $config['homedir'].'/godmode/update_manager/update_manager.setup.php'; + include $config['homedir'].'/godmode/update_manager/modal_lts_update.php'; break; case 'offline': $mode = \UpdateManager\UI\Manager::MODE_OFFLINE; include $config['homedir'].'/godmode/um_client/index.php'; + include $config['homedir'].'/godmode/update_manager/modal_lts_update.php'; break; case 'online': @@ -163,5 +165,6 @@ switch ($tab) { $mode = \UpdateManager\UI\Manager::MODE_ONLINE; include $config['homedir'].'/godmode/um_client/index.php'; + include $config['homedir'].'/godmode/update_manager/modal_lts_update.php'; break; } diff --git a/pandora_console/godmode/update_manager/update_manager.setup.php b/pandora_console/godmode/update_manager/update_manager.setup.php index ac5471f96a..6fb56aed15 100644 --- a/pandora_console/godmode/update_manager/update_manager.setup.php +++ b/pandora_console/godmode/update_manager/update_manager.setup.php @@ -63,6 +63,10 @@ if (users_is_admin()) { } } +if (isset($config['lts_updates']) === false) { + config_update_value('lts_updates', 1); +} + if (!$action_update_url_update_manager) { $url_update_manager = get_parameter( 'url_update_manager', diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 08040f839c..83e54f24c5 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -33,8 +33,6 @@ check_login(); require_once $config['homedir'].'/vendor/autoload.php'; -use PandoraFMS\Dashboard\Manager; - require_once $config['homedir'].'/include/functions_profile.php'; require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_groups.php'; @@ -157,14 +155,92 @@ if (is_ajax() === true) { return; } + + if ($delete_profile === true) { + // Get parameters. + $result = false; + $id_user = (string) get_parameter('id_user'); + $id_up = (int) get_parameter('id_user_profile'); + $delete_user = (bool) get_parameter('delete_user', false); + $user_is_global_admin = users_is_admin($id_user); + + $perfilUser = db_get_row('tusuario_perfil', 'id_up', $id_up); + $id_perfil = $perfilUser['id_perfil']; + + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + 'Deleted profile for user '.io_safe_output($id_user), + false, + false, + 'The profile with id '.$id_perfil.' in the group '.$perfilUser['id_grupo'] + ); + // Delete profile. + $profile_deleted = profile_delete_user_profile($id_user, $id_up); + // Check if exists more profiles. + $has_profile = db_get_row('tusuario_perfil', 'id_usuario', $id_user); + if ($profile_deleted === true) { + if ($has_profile === false && $user_is_global_admin === false && $delete_user === true) { + if (is_metaconsole() === true) { + $servers = metaconsole_get_servers(); + foreach ($servers as $server) { + // Connect to the remote console. + metaconsole_connect($server); + + // Delete the user. + $result = delete_user($id_user); + if ($result === true) { + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + __('Deleted user %s from metaconsole', io_safe_output($id_user)) + ); + } + + // Restore the db connection. + metaconsole_restore_db(); + + // Log to the metaconsole too. + if ($result === true) { + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + __( + 'Deleted user %s from %s', + io_safe_input($id_user), + io_safe_input($server['server_name']) + ) + ); + } + } + + $result = delete_user((string) $id_user); + + if ($result === true) { + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + __('Deleted user %s', io_safe_output($id_user)) + ); + } + } else { + $result = delete_user((string) $id_user); + if ($result === true) { + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + __('Deleted user %s', io_safe_output($id_user)) + ); + } + } + } else { + $result = $profile_deleted; + } + } + + return $result; + } } $tab = get_parameter('tab', 'user'); - // Save autorefresh list. $autorefresh_list = (array) get_parameter_post('autorefresh_list'); $autorefresh_white_list = (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) ? '' : json_encode($autorefresh_list); - // Header. if (is_metaconsole() === true) { user_meta_print_header(); @@ -197,11 +273,11 @@ if (is_metaconsole() === true) { ).'', ], ]; - $buttons[$tab]['active'] = true; } $edit_user = get_parameter('edit_user'); + ui_print_standard_header( ($edit_user) ? sprintf('%s [ %s ]', __('Update User'), $id) : __('Create User'), 'images/gm_users.png', @@ -224,11 +300,9 @@ if (is_metaconsole() === true) { ], ] ); - $sec = 'gusuarios'; } - if ((bool) $config['user_can_update_info'] === true) { $view_mode = false; } else { @@ -350,8 +424,10 @@ if ($create_user === true) { $values['data_section'] = $dashboard; } else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) { $values['data_section'] = $visual_console; - } else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section'); + } else if ($values['section'] === HOME_SCREEN_OTHER) { + $values['data_section'] = get_parameter('data_section_other'); + } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { + $values['data_section'] = get_parameter('data_section_external'); } // $values['section'] = $homeScreenValues[$values['section']]; @@ -598,8 +674,11 @@ if ($update_user) { $values['email'] = (string) get_parameter('email'); $values['phone'] = (string) get_parameter('phone'); $values['comments'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('comments')))); - $values['allowed_ip_active'] = ((int) get_parameter('allowed_ip_active', -1) === 0); - $values['allowed_ip_list'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('allowed_ip_list')))); + if (users_is_admin($config['id_user']) === true || (bool) check_acl($config['id_user'], 0, 'PM') === true) { + $values['allowed_ip_active'] = ((int) get_parameter('allowed_ip_active', -1) === 0); + $values['allowed_ip_list'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('allowed_ip_list')))); + } + $values['is_admin'] = (get_parameter('is_admin', 0) === 0) ? 0 : 1; $values['language'] = (string) get_parameter('language'); $values['timezone'] = (string) get_parameter('timezone'); @@ -645,8 +724,10 @@ if ($update_user) { $values['data_section'] = $dashboard; } else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) { $values['data_section'] = $visual_console; - } else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section'); + } else if ($values['section'] === HOME_SCREEN_OTHER) { + $values['data_section'] = get_parameter('data_section_other'); + } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { + $values['data_section'] = get_parameter('data_section_external'); } // $values['section'] = $homeScreenValues[$values['section']]; @@ -688,23 +769,55 @@ if ($update_user) { $id_user = (string) get_parameter('id_user', ''); if ($password_new != '') { - $correct_password = false; + if ($config['auth'] !== 'mysql') { + ui_print_error_message(__('It is not possible to change the password because external authentication is being used')); + } else { + $correct_password = false; - $user_credentials_check = process_user_login($id_user, $own_password_confirm, true); + $user_credentials_check = process_user_login($id_user, $own_password_confirm, true); - if ($user_credentials_check !== false) { - $correct_password = true; - } + if ($user_credentials_check !== false) { + $correct_password = true; + } - if ((string) $password_confirm === (string) $password_new) { - if ($correct_password === true || is_user_admin($config['id_user'])) { - if ((is_user_admin($config['id_user']) === false || $config['enable_pass_policy_admin']) && $config['enable_pass_policy']) { - $pass_ok = login_validate_pass($password_new, $id, true); - if ($pass_ok != 1) { - ui_print_error_message($pass_ok); + if ((string) $password_confirm === (string) $password_new) { + if ($correct_password === true || is_user_admin($config['id_user'])) { + if ((is_user_admin($config['id_user']) === false || $config['enable_pass_policy_admin']) && $config['enable_pass_policy']) { + $pass_ok = login_validate_pass($password_new, $id, true); + if ($pass_ok != 1) { + ui_print_error_message($pass_ok); + } else { + $res2 = update_user_password($id, $password_new); + if ($res2) { + db_process_sql_insert( + 'tsesion', + [ + 'id_sesion' => '', + 'id_usuario' => $id, + 'ip_origen' => $_SERVER['REMOTE_ADDR'], + 'accion' => 'Password change', + 'descripcion' => 'Access password updated', + 'fecha' => date('Y-m-d H:i:s'), + 'utimestamp' => time(), + ] + ); + $res3 = save_pass_history($id, $password_new); + + // Generate new API token. + $newToken = api_token_generate(); + $res4 = update_user($id, ['api_token' => $newToken]); + } + + ui_print_result_message( + $res1 || $res2, + __('User info successfully updated'), + __('Error updating user info (no change?)') + ); + } } else { $res2 = update_user_password($id, $password_new); if ($res2) { + $res3 = save_pass_history($id, $password_new); db_process_sql_insert( 'tsesion', [ @@ -717,7 +830,6 @@ if ($update_user) { 'utimestamp' => time(), ] ); - $res3 = save_pass_history($id, $password_new); // Generate new API token. $newToken = api_token_generate(); @@ -731,54 +843,27 @@ if ($update_user) { ); } } else { - $res2 = update_user_password($id, $password_new); - if ($res2) { - $res3 = save_pass_history($id, $password_new); - db_process_sql_insert( - 'tsesion', - [ - 'id_sesion' => '', - 'id_usuario' => $id, - 'ip_origen' => $_SERVER['REMOTE_ADDR'], - 'accion' => 'Password change', - 'descripcion' => 'Access password updated', - 'fecha' => date('Y-m-d H:i:s'), - 'utimestamp' => time(), - ] - ); - - // Generate new API token. - $newToken = api_token_generate(); - $res4 = update_user($id, ['api_token' => $newToken]); + if ($own_password_confirm === '') { + ui_print_error_message(__('Password of the active user is required to perform password change')); + } else { + ui_print_error_message(__('Password of active user is not correct')); } - - ui_print_result_message( - $res1 || $res2, - __('User info successfully updated'), - __('Error updating user info (no change?)') - ); } } else { - if ($own_password_confirm === '') { - ui_print_error_message(__('Password of the active user is required to perform password change')); - } else { - ui_print_error_message(__('Password of active user is not correct')); - } + db_process_sql_insert( + 'tsesion', + [ + 'id_sesion' => '', + 'id_usuario' => $id, + 'ip_origen' => $_SERVER['REMOTE_ADDR'], + 'accion' => 'Password change', + 'descripcion' => 'Access password update failed', + 'fecha' => date('Y-m-d H:i:s'), + 'utimestamp' => time(), + ] + ); + ui_print_error_message(__('Passwords does not match')); } - } else { - db_process_sql_insert( - 'tsesion', - [ - 'id_sesion' => '', - 'id_usuario' => $id, - 'ip_origen' => $_SERVER['REMOTE_ADDR'], - 'accion' => 'Password change', - 'descripcion' => 'Access password update failed', - 'fecha' => date('Y-m-d H:i:s'), - 'utimestamp' => time(), - ] - ); - ui_print_error_message(__('Passwords does not match')); } } else { $has_skin = false; @@ -864,89 +949,6 @@ if ($update_user) { $user_info = $values; } -if ($delete_profile) { - $id2 = (string) get_parameter('id_user'); - $id_up = (int) get_parameter('id_user_profile'); - $perfilUser = db_get_row('tusuario_perfil', 'id_up', $id_up); - $id_perfil = $perfilUser['id_perfil']; - $perfil = db_get_row('tperfil', 'id_perfil', $id_perfil); - - db_pandora_audit( - AUDIT_LOG_USER_MANAGEMENT, - 'Deleted profile for user '.io_safe_output($id2), - false, - false, - 'The profile with id '.$id_perfil.' in the group '.$perfilUser['id_grupo'] - ); - - $return = profile_delete_user_profile($id2, $id_up); - ui_print_result_message( - $return, - __('Successfully deleted'), - __('Could not be deleted') - ); - - - $has_profile = db_get_row('tusuario_perfil', 'id_usuario', $id2); - $user_is_global_admin = users_is_admin($id2); - - if ($has_profile === false && $user_is_global_admin === false) { - $result = delete_user($id2); - - if ($result === true) { - db_pandora_audit( - AUDIT_LOG_USER_MANAGEMENT, - __('Deleted user %s', io_safe_output($id_user)) - ); - } - - ui_print_result_message( - $result, - __('Successfully deleted'), - __('There was a problem deleting the user') - ); - - // Delete the user in all the consoles. - if (is_metaconsole() === true) { - $servers = metaconsole_get_servers(); - foreach ($servers as $server) { - // Connect to the remote console. - metaconsole_connect($server); - - // Delete the user. - $result = delete_user($id_user); - if ($result === true) { - db_pandora_audit( - AUDIT_LOG_USER_MANAGEMENT, - __('Deleted user %s from metaconsole', io_safe_output($id_user)) - ); - } - - // Restore the db connection. - metaconsole_restore_db(); - - // Log to the metaconsole too. - if ($result === true) { - db_pandora_audit( - AUDIT_LOG_USER_MANAGEMENT, - __( - 'Deleted user %s from %s', - io_safe_input($id_user), - io_safe_input($server['server_name']) - ) - ); - } - - ui_print_result_message( - $result, - __('Successfully deleted from %s', io_safe_input($server['server_name'])), - __('There was a problem deleting the user from %s', io_safe_input($server['server_name'])) - ); - } - } - } -} - if ((int) $status !== -1) { ui_print_result_message( $status, @@ -1157,6 +1159,13 @@ if (is_user_admin($id) === true) { ); } +html_print_div( + [ + 'id' => 'delete_profile_modal', + 'content' => '', + ] +); + $full_name = '
'.html_print_input_text_extended( 'fullname', $user_info['fullname'], @@ -1376,72 +1385,6 @@ if (is_metaconsole() === true) { ); } -$values = [ - -1 => __('Use global conf'), - 1 => __('Yes'), - 0 => __('No'), -]; - -$home_screen = '

'.__('Home screen').ui_print_help_tip( - __('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1 to show agent detail view'), - true -).'

'; - -$dashboards = Manager::getDashboards( - -1, - -1, - false, - false, - $id_usr -); - -$dashboards_aux = []; -if ($dashboards === false) { - $dashboards = ['None' => 'None']; -} else { - foreach ($dashboards as $key => $dashboard) { - $dashboards_aux[$dashboard['id']] = $dashboard['name']; - } -} - -$home_screen .= ''; - -$layouts = visual_map_get_user_layouts($config['id_user'], true); -$layouts_aux = []; -if ($layouts === false) { - $layouts_aux = ['None' => 'None']; -} else { - foreach ($layouts as $layout) { - $layouts_aux[$layout] = $layout; - } -} - -$home_screen .= ''; - -$home_screen .= html_print_input_text( - 'data_section', - $user_info['data_section'], - '', - 60, - 255, - true, - false -); - -$home_screen = ''; - $size_pagination = '

'.__('Block size for pagination').'

'; $size_pagination .= html_print_input_text( 'block_size', @@ -1995,24 +1938,87 @@ if (is_metaconsole() === false) { } }); }); - + $('input:image[name="del"]').click(function(e) { - if ($(json_profile).length > 0) return; - if (!confirm('Are you sure?')) return; - e.preventDefault(); - var rows = $("#table_profiles tr").length; - if (((is_metaconsole === '1' && rows <= 4) || (is_metaconsole === '' && rows <= 3)) && user_is_global_admin !== '1') { - if (!confirm('' + '. ' + '')) { - return; - } - } + + var rows = $("#table_profiles tr").length; + let deleteuser = 0; + e.preventDefault(); var id_user_profile = $(this).siblings(); id_user_profile = id_user_profile[1].value; var row = $(this).closest('tr'); + if (((is_metaconsole === '1' && rows <= 3) || (is_metaconsole !== '1' && rows <= 3)) && user_is_global_admin !== '1') { + $("#delete_profile_modal") + .empty() + .html(""); + // Set the title. + $("#delete_profile_modal").prop("title", ""); + // Build the dialog for show the mesage. + $("#delete_profile_modal").dialog({ + resizable: true, + draggable: true, + modal: true, + width: 500, + buttons: [ + { + text: "Cancel", + click: function() { + $(this).dialog("close"); + return false; + } + }, + { + text: "Delete", + click: function() { + $(this).dialog("close"); + deleteuser = 1; + delete_user_profile(id_user_profile, row, id_user, deleteuser); + } + }, + { + text: "Preserve", + click: function() { + $(this).dialog("close"); + deleteuser = 0; + delete_user_profile(id_user_profile, row, id_user, deleteuser) + } + } + ], + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: false, + open: function(event, ui) { + $(".ui-dialog-titlebar-close").hide(); + } + }); + } else { + if (((is_metaconsole === '1' && rows <= 3) || (is_metaconsole === '' && rows <= 3)) && user_is_global_admin !== '1') { + if (!confirm('' + '. ' + '')) { + return false; + } else { + delete_user_profile(id_user_profile, row, id_user, deleteuser); + } + } else { + if (!confirm('Are you sure?')) { + return false; + } else { + delete_user_profile(id_user_profile, row, id_user, deleteuser); + } + } + } + + if ($(json_profile).length > 0) return; + }); + + function delete_user_profile(id_user_profile, row, id_user, deleteuser){ var params = []; params.push("delete_profile=1"); + params.push("edit_user=1"); + params.push("delete_user=" + deleteuser); params.push("id_user=" + id_user); params.push("id_user_profile=" + id_user_profile); params.push("page=godmode/users/configure_user"); @@ -2023,15 +2029,14 @@ if (is_metaconsole() === false) { success: function(data) { row.remove(); var rows = $("#table_profiles tr").length; - - if (is_metaconsole === '' && rows <= 2 && user_is_global_admin !== '1') { + if (is_metaconsole === '' && rows <= 2 && user_is_global_admin !== '1' && deleteuser == '1') { window.location.replace(""); - } else if (is_metaconsole === '1' && rows <= 3 && user_is_global_admin !== '1') { + } else if (is_metaconsole === '1' && rows <= 2 && user_is_global_admin !== '1' && deleteuser == '1') { window.location.replace(""); } } }); - }); + } function checkProfiles(e) { e.preventDefault(); @@ -2078,17 +2083,20 @@ if (is_metaconsole() === false) { } function show_data_section() { - var $section = $("#section").val(); - var $allElements = $('div[id^="custom_home_screen_"]'); - var $elementSelected = $('div[id="custom_home_screen_' + $section + '"]'); + var section = $("#section").val(); + if(section === 'other'){ + section = 'external_link'; + } + var allElements = $('div[id^="custom_home_screen_"]'); + var elementSelected = $('div[id="custom_home_screen_' + section + '"]'); // Hide all elements. - $allElements.each(function() { + allElements.each(function() { $(this).addClass('invisible'); $(this).children().addClass('invisible'); }) // Show only the selected. - $elementSelected.removeClass('invisible'); - $elementSelected.children().removeClass('invisible'); + elementSelected.removeClass('invisible'); + elementSelected.children().removeClass('invisible'); } function switch_ehorus_conf() { diff --git a/pandora_console/godmode/users/user_management.php b/pandora_console/godmode/users/user_management.php index 6d5f9bf18b..b1212c11ec 100644 --- a/pandora_console/godmode/users/user_management.php +++ b/pandora_console/godmode/users/user_management.php @@ -26,6 +26,8 @@ * ============================================================================ */ +use PandoraFMS\Dashboard\Manager; + // Load global vars. global $config; @@ -45,16 +47,80 @@ $homeScreenValues = [ HOME_SCREEN_DASHBOARD => __('Dashboard'), ]; +$dashboards = Manager::getDashboards( + -1, + -1, + false, + false, + $id_usr +); + +$dashboards_aux = []; +if ($dashboards === false) { + $dashboards = ['None' => 'None']; +} else { + foreach ($dashboards as $key => $dashboard) { + $dashboards_aux[$dashboard['id']] = $dashboard['name']; + } +} + // Custom Home Screen controls. $customHomeScreenAddition = []; // Home screen. Dashboard. -$customHomeScreenAddition[HOME_SCREEN_DASHBOARD] = html_print_select($dashboards_aux, 'dashboard', $user_info['data_section'], '', '', '', true, false, true, 'w100p', false, 'width: 100%'); +$customHomeScreenAddition[HOME_SCREEN_DASHBOARD] = html_print_select( + $dashboards_aux, + 'dashboard', + $user_info['data_section'], + '', + '', + '', + true, + false, + true, + 'w100p', + false, + 'width: 100%' +); // Home screen. Visual consoles. $customHomeScreenAddition[HOME_SCREEN_VISUAL_CONSOLE] = html_print_select($layouts_aux, 'visual_console', $user_info['data_section'], '', '', '', true, false, true, 'w100p', false, 'width: 100%'); // Home screen. External link and Other. -$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text('data_section', $user_info['data_section'], '', 60, 255, true); -$customHomeScreenAddition[HOME_SCREEN_OTHER] = html_print_input_text('data_section', $user_info['data_section'], '', 60, 255, true); +$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text('data_section_external', $user_info['data_section'], '', 60, 255, true); +$customHomeScreenAddition[HOME_SCREEN_OTHER] = html_print_input_text('data_section_other', $user_info['data_section'], '', 60, 255, true); +$layouts = visual_map_get_user_layouts($config['id_user'], true); +$layouts_aux = []; +if ($layouts === false) { + $layouts_aux = ['None' => 'None']; +} else { + foreach ($layouts as $layout) { + $layouts_aux[$layout] = $layout; + } +} + +// Home screen. Visual consoles. +$customHomeScreenAddition[HOME_SCREEN_VISUAL_CONSOLE] = html_print_select( + $layouts_aux, + 'visual_console', + $user_info['data_section'], + '', + '', + '', + true, + false, + true, + 'w100p', + false, + 'width: 100%' +); +// Home screen. External link and Other. +$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text( + 'data_section', + $user_info['data_section'], + '', + 60, + 255, + true +); $customHomeScreenDataField = ''; foreach ($customHomeScreenAddition as $key => $customField) { $customHomeScreenDataField .= html_print_div( @@ -266,7 +332,7 @@ $passwordManageTable->data = []; $passwordManageTable->data['captions_newpassword'][0] = __('New password'); $passwordManageTable->rowclass['fields_newpassword'] = 'w540px'; -$passwordManageTable->data['fields_newpassword'][0] = html_print_input_text_extended( +$passwordManageTable->data['fields_newpassword'][0] = '
'.html_print_input_text_extended( 'password_new', '', 'password_new', @@ -276,16 +342,17 @@ $passwordManageTable->data['fields_newpassword'][0] = html_print_input_text_exte $view_mode, '', [ - 'class' => 'input w100p', + 'class' => 'input', 'placeholder' => __('Password'), + 'style' => 'width: 540px', ], true, true -); +).'
'; $passwordManageTable->data['captions_repeatpassword'][0] = __('Repeat new password'); $passwordManageTable->rowclass['fields_repeatpassword'] = 'w540px'; -$passwordManageTable->data['fields_repeatpassword'][0] = html_print_input_text_extended( +$passwordManageTable->data['fields_repeatpassword'][0] = '
'.html_print_input_text_extended( 'password_confirm', '', 'password_conf', @@ -297,10 +364,11 @@ $passwordManageTable->data['fields_repeatpassword'][0] = html_print_input_text_e [ 'class' => 'input w100p', 'placeholder' => __('Password confirmation'), + 'style' => 'width: 540px', ], true, true -); +).'
'; if ($new_user === false && users_is_admin() === false) { $passwordManageTable->data['captions_currentpassword'][0] = __('Current password'); @@ -576,7 +644,7 @@ $userManagementTable->data['fields_autorefreshTime'][0] .= ui_print_input_placeh true ); -// eHorus conf +// EHorus conf. if (isset($config['ehorus_user_level_conf']) === true && (bool) $config['ehorus_user_level_conf'] === true) { $userManagementTable->data['captions_ehorus_user_level_enabled'][1] = __('Pandora RC user access enabled'); $userManagementTable->data['fields_ehorus_user_level_enabled'][1] = html_print_checkbox_switch( @@ -791,55 +859,61 @@ $userManagementTable->data['fields_addSettings'][0] = html_print_textarea( 5, 65, $user_info['comments'], - ($view_mode ? 'readonly="readonly"' : ''), + ($view_mode) ? 'readonly="readonly"' : '', true, '' ); -$userManagementTable->data['captions_addSettings'][1] = __('Login allowed IP list'); -$userManagementTable->data['fields_addSettings'][1] = html_print_div( - [ - 'class' => 'edit_user_allowed_ip', - 'content' => html_print_textarea( - 'allowed_ip_list', - 5, - 65, - ($user_info['allowed_ip_list'] ?? ''), - (((bool) $view_mode === true) ? 'readonly="readonly"' : ''), - true - ), - ], - true -); +if (users_is_admin($config['id_user']) === true || (bool) check_acl($config['id_user'], 0, 'PM') === true) { + $allowAllIpsContent = []; + $allowAllIpsContent[] = ''.__('Enable IP allowlist').''; + $allowAllIpsContent[] = html_print_div( + [ + 'content' => html_print_checkbox_switch( + 'allowed_ip_active', + 0, + ($user_info['allowed_ip_active'] ?? 0), + true, + false, + 'handleIpAllowlist(this)' + ), + ], + true + ); -$userManagementTable->data['fields_addSettings'][1] .= ui_print_input_placeholder( - __('Add the source IPs that will allow console access. Each IP must be separated only by comma. * allows all.'), - true -); + $userManagementTable->data['captions_addSettings'][1] = html_print_div( + [ + 'class' => 'margin-top-10', + 'style' => 'display: flex; flex-direction: row-reverse; align-items: center;', + 'content' => implode('', $allowAllIpsContent), + ], + true + ); -$allowAllIpsContent = []; -$allowAllIpsContent[] = ''.__('Allow all IPs').''; -$allowAllIpsContent[] = html_print_div( - [ - 'content' => html_print_checkbox_switch( - 'allowed_ip_active', - 0, - ($user_info['allowed_ip_active'] ?? 0), - true - ), - ], - true -); - -$userManagementTable->data['fields_addSettings'][1] .= html_print_div( - [ - 'class' => 'margin-top-10', - 'style' => 'display: flex; flex-direction: row-reverse; align-items: center;', - 'content' => implode('', $allowAllIpsContent), - ], - true -); + $userManagementTable->data['fields_addSettings'][1] .= html_print_div( + [ + 'class' => 'edit_user_allowed_ip '.(((int) $user_info['allowed_ip_active'] === 1) ? '' : 'invisible'), + 'content' => html_print_textarea( + 'allowed_ip_list', + 5, + 65, + ($user_info['allowed_ip_list'] ?? ''), + (((bool) $view_mode === true) ? 'readonly="readonly"' : ''), + true + ), + ], + true + ); + $userManagementTable->data['fields_addSettings'][1] .= ui_print_input_placeholder( + __('Add the source IPs that will allow console access. Each IP must be separated only by comma. * allows all.'), + true, + [ + 'id' => 'info_allowed_ip', + 'class' => ((int) $user_info['allowed_ip_active'] === 1) ? 'input_sub_placeholder' : 'input_sub_placeholder invisible', + ] + ); +} if ($config['ITSM_enabled'] && $config['ITSM_user_level_conf']) { // Pandora ITSM user remote login. @@ -945,15 +1019,7 @@ $(document).ready(function () { $('#advanced-line1_looknfeel-1 > a').css('display', 'block'); }) - var ehorus_user_level_enabled = - - ; + var ehorus_user_level_enabled = ''; var chk_ehorus_user_level_enabled = ehorus_user_level_enabled; if (ehorus_user_level_enabled == 0) { @@ -985,4 +1051,14 @@ $(document).ready(function () { } }) }); + +function handleIpAllowlist(e){ + if(e.checked === true) { + $('.edit_user_allowed_ip').show(); + $('#info_allowed_ip').show(); + } else { + $('.edit_user_allowed_ip').hide(); + $('#info_allowed_ip').hide(); + } +} \ No newline at end of file diff --git a/pandora_console/images/Anomaly-detection.png b/pandora_console/images/Anomaly-detection.png new file mode 100644 index 0000000000..cf3c346138 Binary files /dev/null and b/pandora_console/images/Anomaly-detection.png differ diff --git a/pandora_console/images/Anomaly-detection@2x.png b/pandora_console/images/Anomaly-detection@2x.png new file mode 100644 index 0000000000..ba2352fbf1 Binary files /dev/null and b/pandora_console/images/Anomaly-detection@2x.png differ diff --git a/pandora_console/images/Anomaly-detection@svg.svg b/pandora_console/images/Anomaly-detection@svg.svg new file mode 100644 index 0000000000..45abb1db7a --- /dev/null +++ b/pandora_console/images/Anomaly-detection@svg.svg @@ -0,0 +1,14 @@ + + + Anomaly detection@svg + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/alert_recovered@svg.svg b/pandora_console/images/alert_recovered@svg.svg new file mode 100644 index 0000000000..09f84d6215 --- /dev/null +++ b/pandora_console/images/alert_recovered@svg.svg @@ -0,0 +1,9 @@ + + + + Dark / 20 / alert@svg + Created with Sketch. + + + + \ No newline at end of file diff --git a/pandora_console/images/desacoplar-ventana.svg b/pandora_console/images/desacoplar-ventana.svg new file mode 100644 index 0000000000..0b3cbca31d --- /dev/null +++ b/pandora_console/images/desacoplar-ventana.svg @@ -0,0 +1,14 @@ + + + Icons/Dark/20/desacoplar-ventana + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/minimizar.svg b/pandora_console/images/minimizar.svg new file mode 100644 index 0000000000..957268b4ea --- /dev/null +++ b/pandora_console/images/minimizar.svg @@ -0,0 +1,7 @@ + + + Icons/Dark/20/minimizar + + + + \ No newline at end of file diff --git a/pandora_console/images/vulnerability_scan@svg.svg b/pandora_console/images/vulnerability_scan@svg.svg new file mode 100644 index 0000000000..5eb67da9e0 --- /dev/null +++ b/pandora_console/images/vulnerability_scan@svg.svg @@ -0,0 +1,7 @@ + + + Vulnerability scanner@svg + + + + \ No newline at end of file diff --git a/pandora_console/include/ajax/alert_list.ajax.php b/pandora_console/include/ajax/alert_list.ajax.php index d742f952e8..fd00f2eaee 100644 --- a/pandora_console/include/ajax/alert_list.ajax.php +++ b/pandora_console/include/ajax/alert_list.ajax.php @@ -435,6 +435,7 @@ if ($get_agent_alerts_datatable === true) { } $idGroup = $filter_alert['ag_group']; + $search_sg = $filter_alert['search_sg']; $tag_filter = $filter_alert['tag']; $action_filter = $filter_alert['action']; @@ -658,10 +659,9 @@ if ($get_agent_alerts_datatable === true) { $id_groups = array_keys( users_get_groups($config['id_user'], 'AR', false) ); + $alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter, $search_sg); - $alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter); - - $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter); + $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter, $search_sg); } } else { if ($idAgent !== 0) { @@ -673,9 +673,9 @@ if ($get_agent_alerts_datatable === true) { users_get_groups($config['id_user'], $access, false) ); - $alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter, false); + $alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter, false, $search_sg); - $countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter, false); + $countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter, false, $search_sg); } } diff --git a/pandora_console/include/ajax/dashboard.ajax.php b/pandora_console/include/ajax/dashboard.ajax.php new file mode 100644 index 0000000000..50a0e0b7a1 --- /dev/null +++ b/pandora_console/include/ajax/dashboard.ajax.php @@ -0,0 +1,235 @@ +width = '100%'; + $table->class = 'info_table'; + $table->headstyle['name'] = 'text-align: left;'; + $table->headstyle['cells'] = 'text-align: center;'; + $table->headstyle['groups'] = 'text-align: center;'; + $table->headstyle['favorite'] = 'text-align: center;'; + $table->headstyle['full_screen'] = 'text-align: center;'; + + $table->style = []; + $table->style['name'] = 'text-align: left;'; + $table->style['cells'] = 'text-align: center;'; + $table->style['groups'] = 'text-align: center;'; + $table->style['favorite'] = 'text-align: center;'; + $table->style['full_screen'] = 'text-align: center;'; + + $table->size = []; + $table->size['name'] = '40%'; + $table->size['full_screen'] = '30px'; + + $table->head = []; + $table->head['name'] = __('Name'); + $table->head['cells'] = __('Cells'); + $table->head['groups'] = __('Group'); + $table->head['favorite'] = __('Favorite'); + $table->head['full_screen'] = __('Full screen'); + + if ($manageDashboards === 1) { + $table->head['copy'] = __('Copy'); + $table->head['delete'] = __('Delete'); + $table->headstyle['copy'] = 'text-align: center;'; + $table->headstyle['delete'] = 'text-align: center;'; + $table->style['copy'] = 'text-align: center;'; + $table->style['delete'] = 'text-align: center;'; + $table->size['cells'] = '30px'; + $table->size['groups'] = '30px'; + $table->size['favorite'] = '30px'; + $table->size['copy'] = '30px'; + $table->size['delete'] = '30px'; + } else { + $table->size['cells'] = '60px'; + $table->size['groups'] = '60px'; + $table->size['favorite'] = '60px'; + } + + $table->data = []; + + $where_name = ''; + if (strlen($filter['free_search']) > 0) { + $where_name = 'name LIKE "%'.$filter['free_search'].'%"'; + } + + $where_group = ''; + if (empty($filter['group']) === false && $filter['group'] !== '0') { + $where_group = sprintf('id_group = %s', $filter['group']); + if (empty($where_name) === false) { + $where_group = 'AND '.$where_group; + } + } + + $where = ''; + if (empty($where_name) === false || empty($where_group) === false) { + $where = sprintf( + 'WHERE %s %s', + $where_name, + $where_group + ); + } + + $sql = 'SELECT * FROM tdashboard '.$where.' ORDER BY id '.$pagination; + $dashboards = db_get_all_rows_sql($sql); + $count = db_get_value_sql('SELECT COUNT(*) FROM tdashboard '.$where); + foreach ($dashboards as $dashboard) { + $data = []; + + $dataQuery = ['dashboardId' => $dashboard['id']]; + + $url = $urlDashboard.'&'.http_build_query($dataQuery); + $data['name'] = ''; + $data['name'] .= $dashboard['name']; + $data['name'] .= ''; + + $data['cells'] = $dashboard['cells']; + + if (empty($dashboard['id_user']) === false) { + $data['groups'] = __( + 'Private for (%s)', + $dashboard['id_user'] + ); + } else { + $data['groups'] = ui_print_group_icon( + $dashboard['id_group'], + true + ); + } + + $data['favorite'] = $dashboard['active']; + + $dataQueryFull = [ + 'dashboardId' => $dashboard['id'], + 'pure' => 1, + ]; + + $urlFull = $urlDashboard; + $urlFull .= '&'.\http_build_query($dataQueryFull); + $data['full_screen'] = ''; + $data['full_screen'] .= \html_print_image( + 'images/fullscreen@svg.svg', + true, + ['class' => 'main_menu_icon invert_filter'] + ); + $data['full_screen'] .= ''; + + if ($manageDashboards === 1) { + $data['copy'] = ''; + $data['delete'] = ''; + } + + if (check_acl_restricted_all($config['id_user'], $dashboard['id_group'], 'RM')) { + $dataQueryCopy = [ + 'dashboardId' => $dashboard['id'], + 'copyDashboard' => 1, + ]; + $urlCopy = $urlDashboard.'&'.\http_build_query($dataQueryCopy); + $data['copy'] = ''; + $data['copy'] .= html_print_image('images/copy.svg', true, ['class' => 'main_menu_icon invert_filter']); + $data['copy'] .= ''; + + $dataQueryDelete = [ + 'dashboardId' => $dashboard['id'], + 'deleteDashboard' => 1, + ]; + $urlDelete = $urlDashboard; + $urlDelete .= '&'.\http_build_query($dataQueryDelete); + $data['delete'] = ''; + $data['delete'] .= \html_print_image( + 'images/delete.svg', + true, + ['class' => 'main_menu_icon invert_filter'] + ); + $data['delete'] .= ''; + } + + $table->cellclass[] = [ + 'full_screen' => 'table_action_buttons', + 'copy' => 'table_action_buttons', + 'delete' => 'table_action_buttons', + ]; + + $table->data[] = $data; + } + + // Datatables format: RecordsTotal && recordsfiltered. + echo json_encode( + [ + 'data' => $table->data, + 'recordsTotal' => $count, + 'recordsFiltered' => $count, + ] + ); + // Capture output. + $response = ob_get_clean(); + } catch (Exception $e) { + echo json_encode(['error' => $e->getMessage()]); + exit; + } + + // If not valid, show error with issue. + json_decode($response); + if (json_last_error() == JSON_ERROR_NONE) { + // If valid dump. + echo $response; + } else { + echo json_encode( + ['error' => $response] + ); + } + + exit; +} diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 593fa9a975..0aea4cf37f 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -92,6 +92,9 @@ $get_id_source_event = get_parameter('get_id_source_event'); $node_id = (int) get_parameter('node_id', 0); $settings_modal = get_parameter('settings', 0); $parameters_modal = get_parameter('parameters', 0); +$update_event_custom_id = get_parameter('update_event_custom_id', 0); +$draw_events_graph = get_parameter('drawEventsGraph', false); + // User private filter. $current_filter = get_parameter('current_filter', 0); $private_filter_event = get_parameter('private_filter_event', 0); @@ -311,6 +314,7 @@ if ($save_event_filter) { $values['severity'] = implode(',', get_parameter('severity', -1)); $values['status'] = get_parameter('status'); $values['search'] = get_parameter('search'); + $values['regex'] = get_parameter('regex'); $values['not_search'] = get_parameter('not_search'); $values['text_agent'] = get_parameter('text_agent'); $values['id_agent'] = get_parameter('id_agent'); @@ -379,6 +383,7 @@ if ($update_event_filter) { $values['severity'] = implode(',', get_parameter('severity', -1)); $values['status'] = get_parameter('status'); $values['search'] = get_parameter('search'); + $values['regex'] = get_parameter('regex'); $values['not_search'] = get_parameter('not_search'); $values['text_agent'] = get_parameter('text_agent'); $values['id_agent'] = get_parameter('id_agent'); @@ -638,6 +643,8 @@ function load_form_filter() { $("#status").val(val); if (i == 'search') $('#text-search').val(val); + if (i == 'regex') + $('#text-regex').val(val); if (i == 'not_search') $('#checkbox-not_search').val(val); if (i == 'text_agent') @@ -968,6 +975,7 @@ function save_new_filter() { "severity" : $("#severity").val(), "status" : $("#status").val(), "search" : $("#text-search").val(), + "regex" : $('#text-regex').val(), "not_search" : $("#checkbox-not_search").val(), "text_agent" : $("#text_id_agent").val(), "id_agent" : $('input:hidden[name=id_agent]').val(), @@ -1048,6 +1056,7 @@ function save_update_filter() { "severity" : $("#severity").val(), "status" : $("#status").val(), "search" : $("#text-search").val(), + "regex" : $('#text-regex').val(), "not_search" : $("#checkbox-not_search").val(), "text_agent" : $("#text_id_agent").val(), "id_agent" : $('input:hidden[name=id_agent]').val(), @@ -2065,14 +2074,6 @@ if ($table_events) { // (propagate ACL funct!). $groups = users_get_groups($config['id_user']); - $tags_condition = tags_get_acl_tags( - $config['id_user'], - array_keys($groups), - 'ER', - 'event_condition', - 'AND' - ); - $tableEvents24h = new stdClass(); $tableEvents24h->class = 'filter_table'; $tableEvents24h->styleTable = 'border: 0;padding: 0;margin: 0 0 10px;'; @@ -2107,7 +2108,7 @@ if ($table_events) { ); } else { events_print_event_table( - 'estado <> 1 '.$tags_condition, + 'estado <> 1', 200, '100%', false, @@ -2650,6 +2651,8 @@ if ($get_events_fired) { $filter['date_to'] = date('Y-m-d', $end); $filter['time_from'] = date('H:i:s', $start); $filter['time_to'] = date('H:i:s', $end); + $filter['severity'] = explode(',', $filter['severity']); + $data = events_get_all( ['te.*'], $filter @@ -2759,3 +2762,56 @@ if ($draw_row_response_info === true) { echo $output; return; } + +if ($update_event_custom_id) { + $event_custom_id = get_parameter('event_custom_id'); + $event_id = get_parameter('event_id'); + $server_id = 0; + if (is_metaconsole() === true) { + $server_id = (int) get_parameter('server_id'); + } + + // Safe custom fields for hacks. + if (preg_match('/script/i', io_safe_output($event_custom_id))) { + $return = false; + } else { + try { + if (is_metaconsole() === true + && $server_id > 0 + ) { + $node = new Node($server_id); + $node->connect(); + } + + $return = events_event_custom_id( + $event_id, + $event_custom_id + ); + } catch (\Exception $e) { + // Unexistent agent. + if (is_metaconsole() === true + && $server_id > 0 + ) { + $node->disconnect(); + } + + $return = false; + } finally { + if (is_metaconsole() === true + && $server_id > 0 + ) { + $node->disconnect(); + } + } + } + + echo ($return === true) ? 'update_ok' : 'update_error'; + return; +} + +if ((bool) $draw_events_graph === true) { + $filter = get_parameter('filter'); + $output = event_print_graph($filter); + echo $output; + return; +} \ No newline at end of file diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 92ab21b1bc..e4eba79858 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -35,6 +35,7 @@ if (check_login()) { include_once $config['homedir'].'/include/functions_agents.php'; include_once $config['homedir'].'/include/functions_modules.php'; include_once $config['homedir'].'/include/functions_ui.php'; + include_once $config['homedir'].'/include/functions_macros.php'; enterprise_include_once('include/functions_metaconsole.php'); $get_plugin_macros = get_parameter('get_plugin_macros'); @@ -483,6 +484,13 @@ if (check_login()) { 'tagente_modulo', ['id_agente_modulo' => $module_id] ); + + $made_enabled = db_get_value_filter( + 'made_enabled', + 'tagente_modulo', + ['id_agente_modulo' => $module_id] + ); + $unit = db_get_value_filter( 'unit', 'tagente_modulo', @@ -1161,7 +1169,9 @@ if (check_login()) { ); } + $data[2] .= ''; $data[2] .= ui_print_truncate_text($module['nombre'], 'module_medium', false, true, true, '…', 'font-size: 9pt;'); + $data[2] .= ''; if (empty($module['extended_info']) === false) { $data[2] .= ui_print_help_tip($module['extended_info'], true, '/images/default_list.png'); } @@ -1197,7 +1207,23 @@ if (check_login()) { ); if (strlen($module['ip_target']) !== 0) { - $title .= '
IP: '.$module['ip_target']; + // Check if value is custom field. + if ($module['ip_target'][0] == '_' && $module['ip_target'][(strlen($module['ip_target']) - 1)] == '_') { + $custom_field_name = substr($module['ip_target'], 1, -1); + $custom_value = agents_get_agent_custom_field($id_agente, $custom_field_name); + if (isset($custom_value) && $custom_value !== false) { + $title .= '
IP: '.$custom_value; + } else { + $array_macros = return_agent_macros($id_agente); + if (isset($array_macros[$module['ip_target']])) { + $title .= '
IP: '.$array_macros[$module['ip_target']]; + } else { + $title .= '
IP: '.$module['ip_target']; + } + } + } else { + $title .= '
IP: '.$module['ip_target']; + } } $last_status_change_text = __('Time elapsed since last status change: '); @@ -1354,10 +1380,12 @@ if (check_login()) { $additionalLinkAction = '&flag=1'; $linkCaption = __('Force checks'); $imgaction = 'images/force@svg.svg'; + $visibility = ''; } else { $additionalLinkAction = ''; $linkCaption = __('Refresh'); $imgaction = 'images/go-back@svg.svg'; + $visibility = 'visibility: initial;'; } $moduleActionButtons[] = html_print_anchor( @@ -1369,6 +1397,7 @@ if (check_login()) { [ 'title' => __('Force remote check'), 'class' => 'main_menu_icon forced_title', + 'style' => $visibility, ] ), ], diff --git a/pandora_console/include/ajax/notifications.ajax.php b/pandora_console/include/ajax/notifications.ajax.php index 36ea95900d..a69ad1b56e 100644 --- a/pandora_console/include/ajax/notifications.ajax.php +++ b/pandora_console/include/ajax/notifications.ajax.php @@ -38,6 +38,10 @@ if ($change_label === '1') { $source = get_parameter('source', 0); $user = get_parameter('user', ''); $value = get_parameter('value', 0) ? 1 : 0; + $user_info = get_user_info($config['id_user']); + if ((bool) $user_info['is_admin'] === false && $config['id_user'] !== $user) { + return false; + } // Update the label value. ob_clean(); diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 319b98e168..600b30e74d 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -59,6 +59,7 @@ if (is_ajax() === true) { $metaID = (int) get_parameter('metaID', 0); $childrenMethod = get_parameter('childrenMethod', 'on_demand'); + $default_filters = [ 'searchAgent' => '', 'statusAgent' => AGENT_STATUS_ALL, @@ -69,6 +70,7 @@ if (is_ajax() === true) { ]; $filter = get_parameter('filter', $default_filters); + $agent_a = check_acl($config['id_user'], 0, 'AR'); $agent_w = check_acl($config['id_user'], 0, 'AW'); $access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR'); diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index 0d105d5994..b29dd06bd3 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -70,8 +70,7 @@ $otherSerialize = get_parameter('other'); $otherMode = get_parameter('other_mode', 'url_encode'); $returnType = get_parameter('return_type', 'string'); $info = get_parameter('info', ''); -$raw_decode = (bool) get_parameter('raw_decode', false); - +$raw_decode = (bool) get_parameter('raw_decode', true); $other = parseOtherParameter($otherSerialize, $otherMode, $raw_decode); $apiPassword = io_output_password( db_get_value_filter( diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php deleted file mode 100644 index 529684569d..0000000000 --- a/pandora_console/include/chart_generator.php +++ /dev/null @@ -1,324 +0,0 @@ - 'api_password'] - ) - ); - - - if ($apiPassword === $data_decoded['apipass']) { - $bypassLogin = true; - } -} - -if (!isset($config[$slicebar])) { - $config[$slicebar] = $slicebar_value; -} - -// Try to initialize session using existing php session id. -$user = new PandoraFMS\User(['phpsessionid' => $session_id]); - -if (check_login(false) === false && $bypassLogin !== true) { - // Error handler. - ?> - - - - - Access denied - - - - - - - - - -

Access is not granted

- @@ -1179,7 +1178,7 @@ class WelcomeWindow extends Wizard } function configureEmail() { - window.location = ''; + window.location = ''; } function serversUp() { @@ -1323,14 +1322,18 @@ class WelcomeWindow extends Wizard }); }); - $('#button-create_conectivity').click(function(){ + $('#button-create_conectivity').click(function(e){ + if($("#text-ip_target")[0].checkValidity() == false) { + $("#text-ip_target")[0].reportValidity(); + return false; + } $.ajax({ async: false, type: "POST", url: "include/ajax/task_to_perform.php", data: { check_connectivity: 1, - id_group: $('#id_group :selected').val(), + id_group: $('#id_group1 option:selected').val(), ip_target: $('#text-ip_target').val(), agent_name: $('#text-agent_name').val(), }, diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 79acf1c08a..fe3237294c 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,8 +20,8 @@ /** * Pandora build version and version */ -$build_version = 'PC231023'; -$pandora_version = 'v7.0NG.773.3'; +$build_version = 'PC231205'; +$pandora_version = 'v7.0NG.774'; // Do not overwrite default timezone set if defined. $script_tz = @date_default_timezone_get(); diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 4a5063ccbf..b2ce8d88b4 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -45,6 +45,7 @@ define('EVENT_NEW', 0); define('EVENT_VALIDATE', 1); define('EVENT_PROCESS', 2); define('EVENT_NO_VALIDATED', 3); +define('EVENT_NO_PROCESS', 4); // Events group by constants. define('EVENT_GROUP_REP_ALL', 0); @@ -442,6 +443,7 @@ define('SERVER_TYPE_CORRELATION', 22); define('SERVER_TYPE_NCM', 23); define('SERVER_TYPE_NETFLOW', 24); define('SERVER_TYPE_LOG', 25); +define('SERVER_TYPE_MADE', 26); // REPORTS. define('REPORT_TOP_N_MAX', 1); diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index d03b8d7412..641a9f93f7 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -990,6 +990,70 @@ function get_parameter($name, $default='') } +function get_parameter_date($name, $default='', $date_format='Y/m/d') +{ + $date_end = get_parameter('date_end', 0); + $time_end = get_parameter('time_end'); + $datetime_end = strtotime($date_end.' '.$time_end); + + $custom_date = get_parameter('custom_date', 0); + $range = get_parameter('range', SECONDS_1DAY); + $date_text = get_parameter('range_text', SECONDS_1DAY); + $date_init_less = (strtotime(date('Y/m/d')) - SECONDS_1DAY); + $date_init = get_parameter('date_init', date(DATE_FORMAT, $date_init_less)); + $time_init = get_parameter('time_init', date(TIME_FORMAT, $date_init_less)); + $datetime_init = strtotime($date_init.' '.$time_init); + if ($custom_date === '1') { + if ($datetime_init >= $datetime_end) { + $datetime_init = $date_init_less; + } + + $date_init = date('Y/m/d H:i:s', $datetime_init); + $date_end = date('Y/m/d H:i:s', $datetime_end); + $period = ($datetime_end - $datetime_init); + } else if ($custom_date === '2') { + $date_units = get_parameter('range_units'); + $date_end = date('Y/m/d H:i:s'); + $date_init = date('Y/m/d H:i:s', (strtotime($date_end) - ((int) $date_text * (int) $date_units))); + $period = (strtotime($date_end) - strtotime($date_init)); + } else if (in_array($range, ['this_week', 'this_month', 'past_week', 'past_month'])) { + if ($range === 'this_week') { + $monday = date('Y/m/d', strtotime('last monday')); + + $sunday = date('Y/m/d', strtotime($monday.' +6 days')); + $period = (strtotime($sunday) - strtotime($monday)); + $date_init = $monday; + $date_end = $sunday; + } else if ($range === 'this_month') { + $date_end = date('Y/m/d', strtotime('last day of this month')); + $first_of_month = date('Y/m/d', strtotime('first day of this month')); + $date_init = $first_of_month; + $period = (strtotime($date_end) - strtotime($first_of_month)); + } else if ($range === 'past_month') { + $date_end = date('Y/m/d', strtotime('last day of previous month')); + $first_of_month = date('Y/m/d', strtotime('first day of previous month')); + $date_init = $first_of_month; + $period = (strtotime($date_end) - strtotime($first_of_month)); + } else if ($range === 'past_week') { + $date_end = date('Y/m/d', strtotime('sunday', strtotime('last week'))); + $first_of_week = date('Y/m/d', strtotime('monday', strtotime('last week'))); + $date_init = $first_of_week; + $period = (strtotime($date_end) - strtotime($first_of_week)); + } + } else { + $date_end = date('Y/m/d H:i:s'); + $date_init = date('Y/m/d H:i:s', (strtotime($date_end) - $range)); + $period = (strtotime($date_end) - strtotime($date_init)); + } + + return [ + 'date_init' => date($date_format, strtotime($date_init)), + 'date_end' => date($date_format, strtotime($date_end)), + 'period' => $period, + ]; +} + + /** * Get a parameter from a get request. * @@ -4310,48 +4374,22 @@ function generator_chart_to_pdf( $module_list=false ) { global $config; - - if (is_metaconsole()) { + $hack_metaconsole = ''; + if (is_metaconsole() === true) { $hack_metaconsole = '../..'; - } else { - $hack_metaconsole = ''; } - $url = ui_get_full_url(false).$hack_metaconsole.'/include/chart_generator.php'; - if (!$params['return_img_base_64']) { $img_file = 'img_'.uniqid().'.png'; $img_path = $config['homedir'].'/attachment/'.$img_file; $img_url = ui_get_full_url(false).$hack_metaconsole.'/attachment/'.$img_file; } - $session_id = session_id(); - if ($type_graph_pdf === 'combined') { - $data = [ - 'data' => $params, - 'session_id' => $session_id, - 'type_graph_pdf' => $type_graph_pdf, - 'data_module_list' => $module_list, - 'data_combined' => $params_combined, - 'id_user' => $config['id_user'], - 'slicebar' => $_SESSION['slicebar'], - 'slicebar_value' => $config[$_SESSION['slicebar']], - 'apipass' => get_parameter('apipass', null), - - ]; - } else { - $data = [ - 'data' => $params, - 'session_id' => $session_id, - 'type_graph_pdf' => $type_graph_pdf, - 'id_user' => $config['id_user'], - 'slicebar' => $_SESSION['slicebar'], - 'slicebar_value' => $config[$_SESSION['slicebar']], - 'apipass' => get_parameter('apipass', null), - ]; + if ($type_graph_pdf !== 'combined') { + $params_combined = []; + $module_list = []; } - unset($data['data']['graph_data']); // If not install chromium avoid 500 convert tu images no data to show. $chromium_dir = io_safe_output($config['chromium_path']); $result_ejecution = exec($chromium_dir.' --version'); @@ -4371,22 +4409,16 @@ function generator_chart_to_pdf( // Creates a new page. $page = $browser->createPage(); - $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, $url); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, ['data' => json_encode($data)]); + // Generate Html. + $html = chart_generator( + $type_graph_pdf, + $params, + $params_combined, + $module_list + ); - $response = curl_exec($curl); - - curl_close($curl); - - $page->setHtml($response); - /* - //For debug url with parameters. - $navigation = $page->navigate($url.'?data='.urlencode(json_encode($data))); - $navigation->waitForNavigation(Page::DOM_CONTENT_LOADED); - */ + $page->setHtml($html); // Dynamic. $dynamic_height = $page->evaluate('document.getElementById("container-chart-generator-item").clientHeight')->getReturnValue(); @@ -4433,6 +4465,211 @@ function generator_chart_to_pdf( } +/** + * Html print chart for chromium + * + * @param string $type_graph_pdf Chart mode. + * @param array $params Params. + * @param array $params_combined Params Combined charts. + * @param array $module_list Module list Combined charts. + * + * @return string Output Html. + */ +function chart_generator( + string $type_graph_pdf, + array $params, + array $params_combined=[], + array $module_list=[] +) : string { + global $config; + + include_once $config['homedir'].'/include/graphs/functions_d3.php'; + + if (isset($params['backgroundColor']) === false) { + $params['backgroundColor'] = 'inherit'; + } + + $hack_metaconsole = (is_metaconsole() === true) ? '../../' : ''; + + $output = ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= 'Pandora FMS Graph'; + $output .= ''; + + $css_files = [ + 'pandora' => 'include/styles/', + 'pandora_minimal' => 'include/styles/', + 'jquery-ui.min' => 'include/styles/js/', + 'jquery-ui_custom' => 'include/styles/js/', + ]; + + foreach ($css_files as $name => $path) { + $output .= ui_require_css_file($name, $path, true, true); + } + + $js_files = [ + 'pandora_ui' => 'include/javascript/', + 'jquery.current' => 'include/javascript/', + 'jquery.pandora' => 'include/javascript/', + 'jquery-ui.min' => 'include/javascript/', + 'date' => 'include/javascript/timezone/src/', + 'pandora' => 'include/javascript/', + 'jquery.flot' => 'include/graphs/flot/', + 'jquery.flot.min' => 'include/graphs/flot/', + 'jquery.flot.time' => 'include/graphs/flot/', + 'jquery.flot.pie' => 'include/graphs/flot/', + 'jquery.flot.crosshair.min' => 'include/graphs/flot/', + 'jquery.flot.stack.min' => 'include/graphs/flot/', + 'jquery.flot.selection.min' => 'include/graphs/flot/', + 'jquery.flot.resize.min' => 'include/graphs/flot/', + 'jquery.flot.threshold' => 'include/graphs/flot/', + 'jquery.flot.threshold.multiple' => 'include/graphs/flot/', + 'jquery.flot.symbol.min' => 'include/graphs/flot/', + 'jquery.flot.exportdata.pandora' => 'include/graphs/flot/', + 'jquery.flot.axislabels' => 'include/graphs/flot/', + 'pandora.flot' => 'include/graphs/flot/', + 'chart' => 'include/graphs/chartjs/', + 'chartjs-plugin-datalabels.min' => 'include/graphs/chartjs/', + ]; + + foreach ($js_files as $name => $path) { + $output .= ui_require_javascript_file($name, $path, true, true); + } + + $output .= include_javascript_d3(true, true); + + $output .= ''; + $output .= ''; + $params['only_image'] = false; + $params['menu'] = false; + $params['disable_black'] = true; + + $viewport = [ + 'width' => 0, + 'height' => 0, + ]; + + $style = 'width:100%;'; + if (isset($params['options']['viewport']) === true) { + $viewport = $params['options']['viewport']; + if (empty($viewport['width']) === false) { + $style .= 'width:'.$viewport['width'].'px;'; + } + + if (empty($viewport['height']) === false) { + $style .= 'height:'.$viewport['height'].'px;'; + } + } + + $output .= '
'; + switch ($type_graph_pdf) { + case 'combined': + $params['pdf'] = true; + $result = graphic_combined_module( + $module_list, + $params, + $params_combined + ); + + $output .= $result; + break; + + case 'sparse': + $params['pdf'] = true; + $output .= grafico_modulo_sparse($params); + break; + + case 'pie_graph': + $params['pdf'] = true; + $chart = get_build_setup_charts( + 'PIE', + $params['options'], + $params['chart_data'] + ); + + $output .= $chart->render(true); + break; + + case 'vbar_graph': + $params['pdf'] = true; + $chart = get_build_setup_charts( + 'BAR', + $params['options'], + $params['chart_data'] + ); + + $output .= $chart->render(true); + break; + + case 'ring_graph': + $params['pdf'] = true; + $params['options']['width'] = 500; + $params['options']['height'] = 500; + + $chart = get_build_setup_charts( + 'DOUGHNUT', + $params['options'], + $params['chart_data'] + ); + + $output .= $chart->render(true); + break; + + case 'line_graph': + $params['pdf'] = true; + $params['options']['width'] = '100%'; + $params['options']['height'] = 200; + $chart = get_build_setup_charts( + 'LINE', + $params['options'], + $params['chart_data'] + ); + $output .= $chart->render(true); + break; + + case 'slicebar': + $output .= flot_slicesbar_graph( + $params['graph_data'], + $params['period'], + $params['width'], + $params['height'], + $params['legend'], + $params['colors'], + $params['fontpath'], + $params['round_corner'], + $params['homeurl'], + $params['watermark'], + $params['adapt_key'], + $params['stat_winalse'], + $params['id_agent'], + $params['full_legend_daterray'], + $params['not_interactive'], + $params['ttl'], + $params['sizeForTicks'], + $params['show'], + $params['date_to'], + $params['server_id'] + ); + break; + + default: + // Code... + break; + } + + $output .= '
'; + $output .= ''; + $output .= ''; + + return $output; +} + + /** * Get the product name. * diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index e4fae13896..9a952cf125 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -4769,7 +4769,7 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) $secondary_groups = enterprise_hook('agents_get_secondary_groups', [$id_agente]); $secondaryLinks = []; if (empty($secondary_groups['for_select']) === true) { - $secondaryLinks[] = ''.__('N/A').''; + $secondaryLinks = []; } else { foreach ($secondary_groups['for_select'] as $id => $name) { $secondaryLinks[] = html_print_anchor( @@ -4828,22 +4828,22 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) 'content' => groups_get_name($agent['id_grupo']), ], true - ); + ).' '.ui_print_group_icon($agent['id_grupo'], true, '', 'margin-left: 2%;', true, false, false, '', true); $table_contact->data[] = $data; // Secondary groups. $data = []; - $data[0] = ''.__('Secondary groups').''; - $data[1] = implode(', ', $secondaryLinks); - $table_contact->data[] = $data; + if (!empty($secondaryLinks) === true) { + $data[0] = ''.__('Secondary groups').''; + $data[1] = implode(', ', $secondaryLinks); + $table_contact->data[] = $data; + } // Parent agent line. if (enterprise_installed() === true) { - $data = []; - $data[0] = ''.__('Parent').''; - if ((int) $agent['id_parent'] === 0) { - $data[1] = ''.__('N/A').''; - } else { + if ((int) $agent['id_parent'] !== 0) { + $data = []; + $data[0] = ''.__('Parent').''; $data[1] = html_print_anchor( [ 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_parent'], @@ -4851,9 +4851,9 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) ], true ); - } - $table_contact->data[] = $data; + $table_contact->data[] = $data; + } } // Last status change line. @@ -4862,6 +4862,123 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) $data[1] = $time_elapsed; $table_contact->data[] = $data; + $has_remote_conf = enterprise_hook( + 'config_agents_has_remote_configuration', + [$agent['id_agente']] + ); + + if ((bool) $has_remote_conf) { + $data = []; + $data[0] = __('Remote configuration'); + $data[1] = ''.__('Enabled').''; + $data[1] .= html_print_menu_button( + [ + 'href' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente='.$agent['id_agente'].'&disk_conf=1'), + 'image' => 'images/remote-configuration@svg.svg', + 'title' => __('Edit remote config'), + ], + true + ); + + $satellite_server = (int) db_get_value_filter( + 'satellite_server', + 'tagente', + ['id_agente' => $id_agente] + ); + + if (empty($satellite_server) === false) { + $satellite_name = db_get_value_filter( + 'name', + 'tserver', + ['id_server' => $satellite_server] + ); + + $data[0] = __('Satellite server'); + $data[1] = $satellite_name; + } + + $table_contact->data[] = $data; + } + + if (enterprise_installed() === true) { + // SecurityMon line. + $id_module_group = db_get_value('id_mg', 'tmodule_group', 'name', 'Security'); + $modules = db_get_all_rows_filter( + 'tagente_modulo', + [ + 'id_agente' => $agent['id_agente'], + 'id_module_group' => $id_module_group, + ] + ); + + if (is_array($modules) === true && count($modules) > 0) { + $secmon_status = secmon_status($agent['id_agente']); + $data = []; + $data[0] = ''.__('SecurityMon').''; + $data[1] = ui_print_status_secmon_div($secmon_status, __('Total security modules: %s', count($modules))); + $table_contact->data[] = $data; + } + + // Hardening line. + $module_score = modules_get_agentmodule_id(io_safe_input('Hardening - Score'), $agent['id_agente']); + $hardening = ''; + if (is_array($module_score) === true && key_exists('id_agente_modulo', $module_score) == true) { + $raw_data_score = modules_get_raw_data($module_score['id_agente_modulo'], 0, time()); + $hardening = format_numeric($raw_data_score[0]['datos'], 2); + $data = []; + $data[0] = ''.__('Hardening').''; + $data[1] = $hardening.' %'; + $table_contact->data[] = $data; + } + + // Vulnerabilities line. + $vuls = get_vulnerabilities($agent['id_agente']); + if (is_array($vuls) === true && count($vuls) > 0) { + $score = get_score($vuls); + $data = []; + $data[0] = ''.__('Vulnerability').''; + $data[1] = ui_print_status_vulnerability_div($score); + $table_contact->data[] = $data; + } + } + + // Optional data + // Position Information. + if ((bool) $config['activate_gis'] === true) { + $data = []; + + $dataPositionAgent = gis_get_data_last_position_agent( + $agent['id_agente'] + ); + if (is_array($dataPositionAgent) === true && $dataPositionAgent['stored_longitude'] !== '' && $dataPositionAgent['stored_latitude'] !== '') { + $data[0] = __('Position (Long, Lat)'); + + $dataOptionalOutput = html_print_anchor( + [ + 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=gis&id_agente='.$id_agente, + 'content' => $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude'], + ], + true + ); + + if (empty($dataPositionAgent['description']) === false) { + $dataOptionalOutput .= ' ('.$dataPositionAgent['description'].')'; + } + + $data[1] = $dataOptionalOutput; + } + + $table_contact->data[] = $data; + } + + // Timezone Offset. + if ((int) $agent['timezone_offset'] !== 0) { + $data = []; + $data[0] = __('Timezone Offset'); + $data[1] = $agent['timezone_offset']; + $table_contact->data[] = $data; + } + $agent_contact = html_print_div( [ 'class' => 'agent_details_header', @@ -4873,4 +4990,25 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) $agent_contact .= html_print_table($table_contact, true); return $agent_contact; +} + + +/** + * Return an array with a list of status agents + * + * @return array. + */ + + +function agents_status_list() +{ + $status_list = []; + $status_list[AGENT_STATUS_NORMAL] = __('Normal'); + $status_list[AGENT_STATUS_WARNING] = __('Warning'); + $status_list[AGENT_STATUS_CRITICAL] = __('Critical'); + $status_list[AGENT_STATUS_UNKNOWN] = __('Unknown'); + $status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); + $status_list[AGENT_STATUS_NOT_INIT] = __('Not init'); + + return $status_list; } \ No newline at end of file diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 2c738a6578..c461eb1402 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -22,7 +22,7 @@ require_once $config['homedir'].'/include/functions_modules.php'; require_once $config['homedir'].'/include/functions_users.php'; -function alerts_get_alerts($id_group=0, $free_search='', $status='all', $standby=-1, $acl=false, $total=false, $id_agent=0) +function alerts_get_alerts($id_group=0, $free_search='', $status='all', $standby=-1, $acl=false, $total=false, $id_agent=0, $only_enabled=false) { $sql = ''; $alerts = []; @@ -121,6 +121,10 @@ function alerts_get_alerts($id_group=0, $free_search='', $status='all', $standby // Only enabled agent. $sql .= ' AND t3.disabled = 0'; + if ($only_enabled === true) { + $sql .= ' AND t0.disabled = 0'; + } + $row_alerts = db_get_all_rows_sql($sql); if ($total) { @@ -2165,13 +2169,16 @@ function get_group_alerts( $strict_user=false, $tag=false, $action_filter=false, - $alert_action=true + $alert_action=true, + $search_sg=false ) { global $config; - $group_query = ''; if (!empty($idGroup)) { $group_query = ' AND id_grupo = '.$idGroup; + if ((bool) $search_sg === true) { + $group_query .= ' OR tasg.id_group = '.$idGroup; + } } if (is_array($filter)) { diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index f6d1674022..8f5fb66f54 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -82,7 +82,7 @@ function parseOtherParameter($other, $otherType, $rawDecode) case 'url_encode': $returnVar = [ 'type' => 'string', - 'data' => urldecode($other), + 'data' => $rawDecode ? rawurldecode($other) : urldecode($other), ]; break; @@ -12952,7 +12952,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) $values = []; if ($other['data'][0] != '') { - $values['event'] = $other['data'][0]; + $values['event'] = io_safe_input(io_safe_output($other['data'][0])); } else { returnError('Event text required.'); return; @@ -13132,7 +13132,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) if ($other['data'][18] != '') { $values['id_extra'] = $other['data'][18]; - $sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario + $sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario,event_custom_id FROM tevento WHERE estado IN (0,2) AND id_extra ="'.$other['data'][18].'";'; @@ -13147,6 +13147,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) $values['status'] = 2; $ack_utimestamp = $val['ack_utimestamp']; $values['id_usuario'] = $val['id_usuario']; + $values['event_custom_id'] = $val['event_custom_id']; } api_set_validate_event_by_id($val['id_evento']); @@ -13177,7 +13178,8 @@ function api_set_create_event($id, $trash1, $other, $returnType) $custom_data, $values['server_id'], $values['id_extra'], - $ack_utimestamp + $ack_utimestamp, + $values['event_custom_id'] ?? null ); if ($other['data'][12] != '') { @@ -17787,6 +17789,48 @@ function api_token_check(string $token) } +/** + * Set custom field value in tevento + * + * @param mixed $id_event Event id. + * @param mixed $custom_field Custom field to set. + * @return void + */ +function api_set_event_custom_id($id, $value) +{ + // Get the event + $event = events_get_event($id, false, is_metaconsole()); + // If event not exists, end the execution. + if ($event === false) { + returnError( + 'event_not_exists', + 'Event not exists' + ); + $result = false; + } + + // Safe custom fields for hacks. + if (preg_match('/script/i', io_safe_output($value))) { + $result = false; + } + + $result = events_event_custom_id( + $id, + $value + ); + + // If update results failed + if (empty($result) === true || $result === false) { + returnError( + 'The event could not be updated' + ); + return false; + } else { + returnData('string', ['data' => 'Event updated.']); + } +} + + /** * Extract info Agents for inventories ITSM. * diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 1fe38aac0b..e47e84adeb 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -249,10 +249,6 @@ function config_update_config() $error_update[] = __('Enable Netflow'); } - if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) { - $error_update[] = __('Enable Sflow'); - } - if (config_update_value('activate_feedback', (bool) get_parameter('activate_feedback'), true) === false) { $error_update[] = __('Enable Feedback'); } @@ -371,6 +367,10 @@ function config_update_config() $error_update[] = __('show_experimental_features'); } + if (config_update_value('number_modules_queue', get_parameter('number_modules_queue'), true) === false) { + $error_update[] = __('number_modules_queue'); + } + if (config_update_value('console_log_enabled', get_parameter('console_log_enabled'), true) === false) { $error_update[] = __('Console log enabled'); } @@ -487,6 +487,10 @@ function config_update_config() $error_update[] = __('Legacy database HA'); } + if (config_update_value('agent_vulnerabilities', get_parameter('agent_vulnerabilities'), true) === false) { + $error_update[] = __('agent_vulnerabilities'); + } + if (config_update_value('ipam_ocuppied_critical_treshold', get_parameter('ipam_ocuppied_critical_treshold'), true) === false) { $error_update[] = __('Ipam Ocuppied Manager Critical'); } @@ -913,10 +917,6 @@ function config_update_config() $error_update[] = __('Batch statistics period (secs)'); } - if (config_update_value('agentaccess', (int) get_parameter('agentaccess'), true) === false) { - $error_update[] = __('Use agent access graph'); - } - if (config_update_value('num_files_attachment', (int) get_parameter('num_files_attachment'), true) === false) { $error_update[] = __('Max. recommended number of files in attachment directory'); } @@ -1568,6 +1568,10 @@ function config_update_config() $error_update[] = __('Use data multiplier'); } + if (config_update_value('disable_general_statistics', get_parameter('disable_general_statistics', 0), true) === false) { + $error_update[] = __('Hide general stats for non admin users in tactical view'); + } + if (config_update_value('decimal_separator', (string) get_parameter('decimal_separator', '.'), true) === false) { $error_update[] = __('Decimal separator'); } else { @@ -1615,6 +1619,10 @@ function config_update_config() if (config_update_value('netflow_get_ip_hostname', (int) get_parameter('netflow_get_ip_hostname'), true) === false) { $error_update[] = __('Name resolution for IP address'); } + + if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) { + $error_update[] = __('Enable Sflow'); + } break; case 'sflow': @@ -2229,10 +2237,6 @@ function config_process_config() config_update_value('show_qr_code_header', false); } - if (!isset($config['agentaccess'])) { - config_update_value('agentaccess', true); - } - if (!isset($config['timezone'])) { config_update_value('timezone', 'Europe/Berlin'); } @@ -2441,6 +2445,14 @@ function config_process_config() config_update_value('show_experimental_features', 0); } + if (!isset($config['number_modules_queue'])) { + config_update_value('number_modules_queue', 500); + } + + if (!isset($config['agent_vulnerabilities'])) { + config_update_value('agent_vulnerabilities', 1); + } + if (!isset($config['console_log_enabled'])) { config_update_value('console_log_enabled', 0); } @@ -3703,6 +3715,10 @@ function config_process_config() config_update_value('use_data_multiplier', '1'); } + if (!isset($config['disable_general_statistics'])) { + config_update_value('disable_general_statistics', 0); + } + if (!isset($config['command_snapshot'])) { config_update_value('command_snapshot', 1); } diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index f709fe2b4c..747e5154ce 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -127,6 +127,58 @@ function events_translate_event_type($event_type) } +/** + * Module status event_type into descriptive text. + * + * @param integer $event_type Event type. + * + * @return string Module status. + */ +function events_status_module_event_type($event_type) +{ + $module_status = ''; + switch ($event_type) { + case 'alert_fired': + case 'alert_recovered': + case 'alert_ceased': + case 'alert_manual_validation': + $module_status = AGENT_MODULE_STATUS_CRITICAL_ALERT; + break; + + case 'going_down_normal': + case 'going_up_normal': + $module_status = AGENT_MODULE_STATUS_NORMAL; + break; + + case 'going_unknown': + case 'unknown': + $module_status = AGENT_MODULE_STATUS_UNKNOWN; + break; + + case 'going_up_warning': + case 'going_down_warning': + $module_status = AGENT_MODULE_STATUS_WARNING; + break; + + case 'going_up_critical': + case 'going_down_critical': + $module_status = AGENT_MODULE_STATUS_CRITICAL_BAD; + break; + + case 'recon_host_detected': + case 'system': + case 'error': + case 'new_agent': + case 'configuration_change': + default: + $module_status = AGENT_MODULE_STATUS_NOT_INIT; + break; + } + + return $module_status; +} + + /** * Translates a numeric value event_status into descriptive text. * @@ -219,6 +271,7 @@ function events_get_all_fields() $columns['module_status'] = __('Module status'); $columns['module_custom_id'] = __('Module custom id'); $columns['custom_data'] = __('Custom data'); + $columns['event_custom_id'] = __('Event Custom ID'); return $columns; } @@ -322,6 +375,9 @@ function events_get_column_name($field, $table_alias=false) case 'custom_data': return __('Custom data'); + case 'event_custom_id': + return __('Event Custom ID'); + default: return __($field); } @@ -982,6 +1038,9 @@ function events_get_all( case EVENT_NO_VALIDATED: $filter['status'][$key] = (EVENT_NEW.', '.EVENT_PROCESS); + + case EVENT_NO_PROCESS: + $filter['status'][$key] = (EVENT_NEW.', '.EVENT_VALIDATE); default: // Ignore. break; @@ -1027,6 +1086,24 @@ function events_get_all( $validatedState ); break; + + case EVENT_NO_PROCESS: + // Show comments in validated events. + $validatedState = ''; + if ($validatedEvents === true) { + $validatedState = sprintf( + 'OR estado = %d', + EVENT_VALIDATE + ); + } + + $sql_filters[] = sprintf( + ' AND (estado = %d OR estado = %d %s)', + EVENT_NEW, + EVENT_VALIDATE, + $validatedState + ); + break; } } } @@ -2335,7 +2412,8 @@ function events_create_event( $custom_data='', $server_id=0, $id_extra='', - $ack_utimestamp=0 + $ack_utimestamp=0, + $event_custom_id=null ) { if ($source === false) { $source = get_product_name(); @@ -2367,6 +2445,7 @@ function events_create_event( 'custom_data' => $custom_data, 'data' => '', 'module_status' => 0, + 'event_custom_id' => $event_custom_id, ]; return (int) db_process_sql_insert('tevento', $values); @@ -2590,10 +2669,9 @@ function events_print_type_img( $urlImage = ui_get_full_url(false); $icon = ''; $style = 'main_menu_icon'; - switch ($type) { case 'alert_recovered': - $style .= ' alert_module_background_state icon_background_normal '; + $icon = 'images/alert_recovered@svg.svg'; break; case 'alert_manual_validation': @@ -2609,20 +2687,16 @@ function events_print_type_img( case 'going_up_normal': case 'going_down_normal': // This is to be backwards compatible. - // $style .= ' event_module_background_state icon_background_normal'; $icon = 'images/module_ok.png'; break; case 'going_up_warning': $icon = 'images/module_warning.png'; - // $style .= ' event_module_background_state icon_background_warning'; case 'going_down_warning': $icon = 'images/module_warning.png'; - // $style .= ' event_module_background_state icon_background_warning'; break; case 'going_unknown': - // $style .= ' event_module_background_state icon_background_unknown'; $icon = 'images/module_unknown.png'; break; @@ -2660,16 +2734,6 @@ function events_print_type_img( if ($only_url) { $output = $urlImage.'/'.$icon; } else { - /* - $output .= html_print_div( - [ - 'title' => events_print_type_description($type, true), - 'class' => $style, - 'style' => ((empty($icon) === false) ? 'background-image: url('.$icon.'); background-repeat: no-repeat;' : ''), - ], - true - ); - */ $output .= html_print_image( $icon, true, @@ -3208,12 +3272,14 @@ function events_get_all_status($report=false) $fields[1] = __('Only validated'); $fields[2] = __('Only in process'); $fields[3] = __('Only not validated'); + $fields[4] = __('Only not in process'); } else { $fields[-1] = __('All event'); $fields[0] = __('New'); $fields[1] = __('Validated'); $fields[2] = __('In process'); $fields[3] = __('Not Validated'); + $fields[4] = __('Not in process'); } return $fields; @@ -4043,7 +4109,13 @@ function events_get_response_target( if (empty($event['custom_data']) === false) { $custom_data = json_decode($event['custom_data']); foreach ($custom_data as $key => $value) { - $target = str_replace('_customdata_'.$key.'_', $value, $target); + if (is_array($value) === true) { + foreach ($value as $k => $v) { + $target = str_replace('_customdata_'.$k.'_', $v, $target); + } + } else { + $target = str_replace('_customdata_'.$key.'_', $value, $target); + } } if (strpos($target, '_customdata_json_') !== false) { @@ -4633,6 +4705,30 @@ function events_page_details($event, $server_id=0) $data[1] = ''.__('N/A').''; } + $table_details->data[] = $data; + $readonly = true; + if (check_acl($config['id_user'], 0, 'EW')) { + $readonly = false; + } + + $data = []; + $data[0] = __('Event Custom ID'); + $data[1] = '
'.html_print_input_text('event_custom_id', $event['event_custom_id'], '', false, 255, true, $readonly, false, '', 'w60p'); + if ($readonly === false) { + $data[1] .= html_print_button( + __('Update'), + 'update_event_custom_id', + false, + 'update_event_custom_id('.$event['id_evento'].', '.$event['server_id'].');', + [ + 'icon' => 'next', + 'mode' => 'link', + ], + true + ); + } + + $data[1] .= '
'; $table_details->data[] = $data; $details = '
'.html_print_table($table_details, true).'
'; @@ -5997,17 +6093,47 @@ function get_count_event_criticity( $type = 'AND event_type = "'.$eventType.'"'; } - $groups = ' '; + $groups = ' '; if ((int) $groupId !== 0) { $groups = 'AND id_grupo IN ('.$groupId.')'; } - $status = ' '; - if ((int) $eventStatus !== -1) { - $status = 'AND estado = '.$eventStatus; + $status = ' '; + if (empty($eventStatus) === false) { + switch ($eventStatus) { + case EVENT_ALL: + default: + // Do not filter. + break; + + case EVENT_NEW: + case EVENT_VALIDATE: + case EVENT_PROCESS: + $status = sprintf( + ' AND estado = %d', + $eventStatus + ); + break; + + case EVENT_NO_VALIDATED: + $status = sprintf( + ' AND (estado = %d OR estado = %d)', + EVENT_NEW, + EVENT_PROCESS + ); + break; + + case EVENT_NO_PROCESS: + $status = sprintf( + ' AND (estado = %d OR estado = %d)', + EVENT_NEW, + EVENT_VALIDATE + ); + break; + } } - $criticity = ' '; + $criticity = ' '; if (empty($criticityId) === false) { $criticity = 'AND criticity IN ('.$criticityId.')'; } @@ -6203,3 +6329,201 @@ function event_get_counter_extraId(array $event, ?array $filters) return $counters; } + + +/** + * Update event detail custom field + * + * @param mixed $id_event Event ID or array of events. + * @param string $event_custom_id Event custom ID to be update. + * + * @return boolean Whether or not it was successful + */ +function events_event_custom_id( + $id_event, + $event_custom_id, +) { + global $config; + // Cleans up the selection for all unwanted values also casts any single + // values as an array. + if (![$id_event]) { + $id_event = (array) safe_int($id_event, 1); + } + + // Check ACL. + foreach ($id_event as $k => $id) { + $event_group = events_get_group($id); + if (check_acl($config['id_user'], $event_group, 'EW') == 0) { + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Attempted updating event #'.$id + ); + + unset($id_event[$k]); + } + } + + if (empty($id_event) === true) { + return false; + } + + // Get the current event comments. + $first_event = $id_event; + if (is_array($id_event) === true) { + $first_event = reset($id_event); + } + + // Update comment. + $ret = db_process_sql_update( + 'tevento', + ['event_custom_id' => $event_custom_id], + ['id_evento' => $first_event] + ); + + if (($ret === false) || ($ret === 0)) { + return false; + } + + return true; +} + + +function event_print_graph( + $filter, + $graph_height=100, +) { + global $config; + $show_all_data = false; + $events = events_get_all(['te.id_evento', 'te.timestamp', 'te.utimestamp'], $filter, null, null, 'te.utimestamp', true); + + if (empty($filter['date_from']) === false + && empty($filter['time_from']) === false + && empty($filter['date_to']) === false + && empty($filter['time_to']) === false + ) { + $start_utimestamp = strtotime($filter['date_from'].' '.$filter['time_from']); + $end_utimestamp = strtotime($filter['date_to'].' '.$filter['time_to']); + } else if ($filter['event_view_hr'] !== '') { + $start_utimestamp = strtotime('-'.$filter['event_view_hr'].' hours'); + $end_utimestamp = strtotime('now'); + } else { + $show_all_data = true; + $start_utimestamp = $events[0]['utimestamp']; + $end_utimestamp = $events[array_key_last($events)]['utimestamp']; + } + + $data_events = []; + $control_timestamp = $start_utimestamp; + $count = 0; + foreach ($events as $event) { + if ($event['utimestamp'] === $control_timestamp) { + $count++; + } else { + $control_timestamp = $event['utimestamp']; + $count = 1; + } + + $data_events[$control_timestamp] = $count; + } + + $num_data = count($data_events); + + $num_intervals = $num_data; + + $period = ($end_utimestamp - $start_utimestamp); + + if ($period <= SECONDS_6HOURS) { + $chart_time_format = 'H:i:s'; + } else if ($period < SECONDS_1DAY) { + $chart_time_format = 'H:i'; + } else if ($period < SECONDS_15DAYS) { + $chart_time_format = 'M d H:i'; + } else if ($period < SECONDS_1MONTH) { + $chart_time_format = 'M d H\h'; + } else { + $chart_time_format = 'M d H\h'; + } + + $chart = []; + $labels = []; + $color = []; + $count = 0; + + if ($show_all_data === true) { + foreach ($events as $event) { + if ($event['utimestamp'] === $control_timestamp) { + $count++; + } else { + $control_timestamp = $event['utimestamp']; + $count = 1; + } + + $data_events[$control_timestamp] = $count; + } + + $data_events = array_reverse($data_events, true); + + foreach ($data_events as $utimestamp => $count) { + $labels[] = date($chart_time_format, $utimestamp); + $chart[] = [ + 'y' => $count, + 'x' => date($chart_time_format, $utimestamp), + ]; + $color[] = '#82b92f'; + } + } else { + $interval_length = (int) ($period / $num_intervals); + $intervals = []; + $intervals[0] = $start_utimestamp; + for ($i = 0; $i < $num_intervals; $i++) { + $intervals[($i + 1)] = ($intervals[$i] + $interval_length); + } + + $control_data = []; + + foreach ($data_events as $utimestamp => $count_event) { + for ($i = 0; $i < $num_intervals; $i++) { + if ((int) $utimestamp > (int) $intervals[$i] && (int) $utimestamp < (int) $intervals[($i + 1)]) { + $control_data[(string) $intervals[$i]] += $count_event; + } + } + } + + for ($i = 0; $i < $num_intervals; $i++) { + $labels[] = date($chart_time_format, $intervals[$i]); + $chart[] = [ + 'y' => $control_data[$intervals[$i]], + 'x' => date($chart_time_format, $intervals[$i]), + ]; + $color[] = '#82b92f'; + } + } + + $water_mark = [ + 'file' => $config['homedir'].'/images/logo_vertical_water.png', + 'url' => ui_get_full_url('/images/logo_vertical_water.png'), + ]; + + $options = [ + 'height' => $graph_height, + 'waterMark' => $water_mark, + 'legend' => ['display' => false], + 'colors' => $color, + 'border' => false, + 'scales' => [ + 'x' => [ + 'grid' => ['display' => false], + ], + 'y' => [ + 'grid' => ['display' => false], + ], + ], + 'labels' => $labels, + ]; + + $graph = '
'; + $graph .= vbar_graph($chart, $options); + $graph .= '
'; + + return $graph; +} diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 3ba76b17d0..58ed138259 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -27,6 +27,8 @@ * ============================================================================ */ +use Models\VisualConsole\Items\Percentile; + require_once $config['homedir'].'/include/graphs/fgraph.php'; require_once $config['homedir'].'/include/functions_reporting.php'; require_once $config['homedir'].'/include/functions_agents.php'; @@ -2523,92 +2525,6 @@ function combined_graph_summatory_average( } -/** - * Print a graph with access data of agents. - * - * @param integer $id_agent Agent Id. - * @param integer $period Timestamp period graph. - * @param boolean|null $return Type return. - * - * @return string - */ -function graphic_agentaccess( - int $id_agent, - int $period=0, - ?bool $return=false, - ?bool $agent_view=false -) { - global $config; - - // Dates. - $date = get_system_time(); - $datelimit = ($date - $period); - $interval = 3600; - - // Query. - $sql = sprintf( - 'SELECT utimestamp, count(*) as data - FROM tagent_access - WHERE id_agent = %d - AND utimestamp >= %d - AND utimestamp <= %d - GROUP BY TRUNCATE(utimestamp/%d,0)', - $id_agent, - $datelimit, - $date, - $interval - ); - - $data = db_get_all_rows_sql($sql); - - // Array data. - $data_array = []; - $colors = []; - if (isset($data) === true && is_array($data) === true) { - foreach ($data as $value) { - $time = io_safe_output(date('H:m', $value['utimestamp'])); - $labels[] = $time; - $data_array[] = [ - 'y' => (int) $value['data'], - 'x' => $time, - ]; - - $colors[] = '#82b92f'; - } - } - - $options = []; - $options['grid']['hoverable'] = true; - - if ($agent_view === true) { - $options['agent_view'] = true; - } - - $options = [ - 'height' => 125, - 'colors' => $colors, - 'legend' => ['display' => false], - 'scales' => [ - 'x' => [ - 'grid' => ['display' => false], - 'ticks' => [ - 'fonts' => ['size' => 8], - ], - ], - 'y' => [ - 'grid' => ['display' => false], - 'ticks' => [ - 'fonts' => ['size' => 8], - ], - ], - ], - 'labels' => $labels, - ]; - - return vbar_graph($data_array, $options); -} - - /** * Print a pie graph with alerts defined/fired data * @@ -2686,7 +2602,9 @@ function graph_agent_status( $return=false, $show_not_init=false, $data_agents=false, - $donut_narrow_graph=false + $donut_narrow_graph=false, + $onClick='', + $data_in_percentage=false, ) { global $config; @@ -2766,6 +2684,25 @@ function graph_agent_status( 'labels' => array_keys($data), ]; + if (empty($onClick) === false) { + $options['onClick'] = $onClick; + } + + if ($data_in_percentage === true) { + $percentages = []; + $total = array_sum($data); + foreach ($data as $key => $value) { + $percentage = (($value / $total) * 100); + if ($percentage < 1 && $percentage > 0) { + $percentage = 1; + } + + $percentages[$key] = format_numeric($percentage, 0); + } + + $data = $percentages; + } + if ($donut_narrow_graph == true) { $out = ring_graph( $data, @@ -4625,9 +4562,15 @@ function graph_nodata_image($options) return base64_encode($dataImg); } - $widthImage = '200px'; + $style = ''; if (isset($options['nodata_image']['width']) === true) { - $widthImage = $options['nodata_image']['width']; + $style .= 'width: '.$options['nodata_image']['width'].'; '; + } else { + $style .= 'width: 200px; '; + } + + if (isset($options['nodata_image']['height']) === true) { + $style .= 'height: '.$options['nodata_image']['height'].'; '; } return html_print_image( @@ -4635,7 +4578,7 @@ function graph_nodata_image($options) true, [ 'title' => __('No data'), - 'style' => 'width: '.$widthImage.';', + 'style' => $style, ] ); } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 5481152ac6..5b37dc51d2 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -774,6 +774,7 @@ function html_print_select( $select2_multiple_enable_all=false, $form='', $order=false, + $custom_id=null ) { $output = "\n"; @@ -789,6 +790,10 @@ function html_print_select( $id = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : '')); + if ($custom_id !== null) { + $id = $custom_id; + } + $attributes = ''; if (!empty($script)) { $attributes .= ' onchange="'.$script.'"'; @@ -1740,20 +1745,37 @@ function html_print_select_multiple_modules_filtered(array $data):string } } - $output .= html_print_input( - [ - 'label' => __('Agents'), - 'label_class' => 'font-title-font', - 'type' => 'select_from_sql', - 'sql' => 'SELECT `id_agente`,`nombre` FROM tagente', - 'name' => 'filtered-module-agents-'.$uniqId, - 'selected' => explode(',', $data['mAgents']), - 'return' => true, - 'multiple' => true, - 'style' => 'min-width: 200px;max-width:200px;', - 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', - ] - ); + if (is_metaconsole() === true) { + $output .= html_print_input( + [ + 'label' => __('Agents'), + 'label_class' => 'font-title-font', + 'type' => 'select', + 'fields' => $agents, + 'name' => 'filtered-module-agents-'.$uniqId, + 'selected' => explode(',', $data['mAgents']), + 'return' => true, + 'multiple' => true, + 'style' => 'min-width: 200px;max-width:200px;', + 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', + ] + ); + } else { + $output .= html_print_input( + [ + 'label' => __('Agents'), + 'label_class' => 'font-title-font', + 'type' => 'select_from_sql', + 'sql' => 'SELECT `id_agente`,`alias` FROM tagente', + 'name' => 'filtered-module-agents-'.$uniqId, + 'selected' => explode(',', $data['mAgents']), + 'return' => true, + 'multiple' => true, + 'style' => 'min-width: 200px;max-width:200px;', + 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', + ] + ); + } $commonModules = 0; if (empty($data['mShowCommonModules']) === false) { @@ -4939,8 +4961,8 @@ function html_print_input_file($name, $return=false, $options=false, $inline_upl $inline_upload_anchor_to_form ), [ - 'mode' => 'link', - 'style' => 'min-width: initial;', + 'class' => 'secondary', + 'style' => 'min-width: initial; position: relative; margin-left: 5%; ', ], true, ); @@ -5409,7 +5431,7 @@ function html_print_link_with_params($text, $params=[], $type='text', $style='', $formStyle = ' style="'.$formStyle.'"'; } - $html = '
'; + $html = ''; switch ($type) { case 'image': $html .= html_print_input_image($text, $text, $text, $style, true); @@ -7305,8 +7327,10 @@ function html_print_select_date_range( $time_end='', $date_text=SECONDS_1DAY, $class='w100p', - $date_format='Y/m/d', - $time_format='H:i:s' + $date_format_php='Y/m/d', + $time_format_php='H:i:s', + $date_format_js='yy/mm/dd', + $time_format_js='HH:mm:ss' ) { global $config; @@ -7328,21 +7352,21 @@ function html_print_select_date_range( } if ($date_end === '') { - $date_end = date($date_format); + $date_end = date($date_format_php); } if ($date_init === '') { - $date_init = date($date_format, strtotime($date_end.' -1 days')); + $date_init = date($date_format_php, strtotime($date_end.' -1 days')); } - $date_init = date($date_format, strtotime($date_init)); + $date_init = date($date_format_php, strtotime($date_init)); if ($time_init === '') { - $time_init = date($time_format); + $time_init = date($time_format_php); } if ($time_end === '') { - $time_end = date($time_format); + $time_end = date($time_format_php); } $fields[SECONDS_1DAY] = __('Last 24hr'); @@ -7508,7 +7532,7 @@ function html_print_select_date_range( } $('#text-date').datepicker({ - dateFormat: '".DATE_FORMAT_JS."', + dateFormat: '".$date_format_js."', changeMonth: true, changeYear: true, showAnim: 'slideDown' @@ -7516,7 +7540,7 @@ function html_print_select_date_range( $('[id^=text-time_init]').timepicker({ showSecond: true, - timeFormat: '".TIME_FORMAT_JS."', + timeFormat: '".$time_format_js."', timeOnlyTitle: '".__('Choose time')."', timeText: '".__('Time')."', hourText: '".__('Hour')."', @@ -7527,7 +7551,7 @@ function html_print_select_date_range( }); $('[id^=text-date_init]').datepicker ({ - dateFormat: '".DATE_FORMAT_JS."', + dateFormat: '".$date_format_js."', changeMonth: true, changeYear: true, showAnim: 'slideDown', @@ -7549,7 +7573,7 @@ function html_print_select_date_range( }); $('[id^=text-date_end]').datepicker ({ - dateFormat: '".DATE_FORMAT_JS."', + dateFormat: '".$date_format_js."', changeMonth: true, changeYear: true, showAnim: 'slideDown', @@ -7572,7 +7596,7 @@ function html_print_select_date_range( $('[id^=text-time_end]').timepicker({ showSecond: true, - timeFormat: '".TIME_FORMAT_JS."', + timeFormat: '".$time_format_js."', timeOnlyTitle: '".__('Choose time')."', timeText: '".__('Time')."', hourText: '".__('Hour')."', diff --git a/pandora_console/include/functions_macros.php b/pandora_console/include/functions_macros.php new file mode 100644 index 0000000000..bba0bd1898 --- /dev/null +++ b/pandora_console/include/functions_macros.php @@ -0,0 +1,61 @@ + ($agente['nombre']) ?: '', + '_agentalias_' => ($agente['alias']) ?: '', + '_agent_' => ($agente['alias']) ?: (($agente['nombre']) ?: ''), + '_agentcustomid_' => ($agente['custom_id']) ?: '', + '_agentdescription_' => ($agente['comentarios']) ?: '', + '_agentgroup_' => ($grupo['nombre']) ?: '', + '_agentos_' => ($agente['id_os']) ?: '', + '_address_' => ($agente['direccion']) ?: '', + '_homeurl_' => ($config['public_url']) ?: '', + '_groupcontact_' => ($agente['contact']) ?: '', + '_groupcustomid_' => ($agente['custom_id']) ?: '', + '_groupother_' => ($agente['other']) ?: '', + '_server_ip_' => ($server_ip) ?: '', + '_server_name_' => ($agente['server_name']) ?: '', + ]; + + return $array_macros; +} diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index 346dee04b5..66b14a2776 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -1003,7 +1003,7 @@ if (is_ajax()) { $dialogButtons = []; $dialogButtons[] = html_print_button( - __('Update manager'), + __('Warp update'), 'update_manager', false, 'location.href="'.ui_get_full_url('/index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=history', false, false, false).'"', @@ -1170,6 +1170,14 @@ if (is_ajax()) {

'.$sys_info->data->ramInfo->value.'

+ + +

'.$sys_info->data->distroInfo->name.'

+ + +

'.$sys_info->data->distroInfo->value.'

+ +

'.$sys_info->data->osInfo->name.'

diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 189844c174..fe35d5b5a6 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -122,6 +122,7 @@ function messages_create_message( 'id_usuario_origen' => $usuario_origen, 'subject' => $subject, 'mensaje' => $mensaje, + 'subtype' => 'NOTIF.MESSAGE', 'id_source' => get_notification_source_id('message'), 'timestamp' => get_system_time(), ] diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index e82fca400b..5add1570d8 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -251,6 +251,11 @@ function modules_copy_agent_module_to_agent($id_agent_module, $id_destiny_agent, unset($new_module['id_agente_modulo']); unset($new_module['id_agente']); + // Set debug content. + if (empty($new_module['debug_content']) === false) { + $new_module['debug_content'] = str_replace("'", '"', $new_module['debug_content']); + } + $id_new_module = modules_create_agent_module( $id_destiny_agent, $new_module['nombre'], @@ -4735,7 +4740,7 @@ function export_agents_module_csv($filters) $query_filter .= ' AND tam.nombre IN '.$module_filter.' '; } else { $module_filter = '('.implode(', ', $filter).')'; - $query_filter .= ' AND tam.id_tipo_modulo IN '.$module_filter.' '; + $query_filter .= ' AND tam.id_agente_modulo IN '.$module_filter.' '; } } break; @@ -4762,3 +4767,31 @@ function export_agents_module_csv($filters) return $result; } + + +/** + * Check if modules are compatible with MADE server. + * + * @param integer $id_tipo_modulo + * @retur boolean True if compatible, false otherwise. + */ +function modules_made_compatible($id_tipo_modulo) +{ + $compatible_types = [ + 1, + 4, + 5, + 8, + 15, + 16, + 22, + 30, + 34, + ]; + + if (array_search($id_tipo_modulo, $compatible_types) === false) { + return false; + } else { + return true; + } +} diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index b9393ce1c4..c65c475550 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -142,7 +142,6 @@ function notifications_get_subtypes(?string $source=null) 'NOTIF.PANDORADB.HISTORICAL', 'NOTIF.HISTORYDB.MR', 'NOTIF.EXT.ELASTICSEARCH', - 'NOTIF.EXT.LOGSTASH', 'NOTIF.METACONSOLE.DB_CONNECTION', 'NOTIF.DOWNTIME', 'NOTIF.UPDATEMANAGER.REGISTRATION', @@ -659,7 +658,15 @@ function notifications_get_user_label_status($source, $user, $label) */ function notifications_set_user_label_status($source, $user, $label, $value) { + global $config; + + $user_info = get_user_info($config['id_user']); + if ((bool) $user_info['is_admin'] === false && $config['id_user'] !== $user) { + return false; + } + $source_info = notifications_get_all_sources(['id' => $source]); + if (!isset($source_info[0]) || !$source_info[0]['enabled'] || !$source_info[0]['user_editable'] @@ -1059,7 +1066,7 @@ function notification_filter() break; case 'UPDATEMANAGER': - $type_name = 'UPDATE MANAGER'; + $type_name = 'WARP UPDATE'; break; case 'ALLOWOVERRIDE': diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php index 7cdbd1c461..d97edf17aa 100644 --- a/pandora_console/include/functions_profile.php +++ b/pandora_console/include/functions_profile.php @@ -308,7 +308,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c 'del', 'images/delete.svg', 1, - '', + 'background-color: transparent !important;', true, [ 'onclick' => 'delete_profile(event, this)', @@ -316,8 +316,15 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c ] ); } else { - $data['actions'] = ''; - $data['actions'] .= html_print_input_image('del', 'images/delete.svg', 1, '', true, ['class' => 'main_menu_icon invert_filter']); + $data['actions'] = ''; + $data['actions'] .= html_print_input_image( + 'del', + 'images/delete.svg', + 1, + 'background-color: transparent !important;', + true, + ['class' => 'main_menu_icon invert_filter'] + ); $data['actions'] .= html_print_input_hidden('delete_profile', 1, true); $data['actions'] .= html_print_input_hidden('id_user_profile', $profile['id_up'], true); $data['actions'] .= html_print_input_hidden('id_user', $id, true); @@ -391,7 +398,14 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c $data['last_hierarchy'] = html_print_checkbox('no_hierarchy', 1, false, true); - $data['last_actions'] = html_print_input_image('add', 'images/validate.svg', 1, '', true, ['class' => 'main_menu_icon invert_filter']); + $data['last_actions'] = html_print_input_image( + 'add', + 'images/validate.svg', + 1, + 'background-color: transparent !important;', + true, + ['class' => 'main_menu_icon invert_filter'] + ); $data['last_actions'] .= html_print_input_hidden('id', $id, true); $data['last_actions'] .= html_print_input_hidden('add_profile', 1, true); $data['last_actions'] .= '
'; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 39f1642fa0..995375e87a 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -42,6 +42,7 @@ require_once $config['homedir'].'/include/functions_users.php'; enterprise_include_once('include/functions_reporting.php'); enterprise_include_once('include/functions_metaconsole.php'); enterprise_include_once('include/functions_inventory.php'); +require_once $config['homedir'].'/include/functions_inventory.php'; enterprise_include_once('include/functions_cron.php'); require_once $config['homedir'].'/include/functions_forecast.php'; require_once $config['homedir'].'/include/functions_ui.php'; @@ -1023,6 +1024,62 @@ function reporting_make_reporting_data( ); break; + case 'vuls_severity_graph': + $report['contents'][] = reporting_vuls_severity_graph( + $report, + $content, + $type + ); + break; + + case 'vuls_attack_complexity': + $report['contents'][] = reporting_vuls_attack_complexity_graph( + $report, + $content, + $type + ); + break; + + case 'vuls_by_packages': + $report['contents'][] = reporting_vuls_by_packages_graph( + $report, + $content, + $type + ); + break; + + case 'vuls_by_agent': + $report['contents'][] = reporting_vuls_by_agent( + $report, + $content, + $type + ); + break; + + case 'vuls_info_agent': + $report['contents'][] = reporting_vuls_info_agent( + $report, + $content, + $type + ); + break; + + case 'top_n_agents_vuls': + $report['contents'][] = reporting_top_n_agents_vuls( + $report, + $content, + $type + ); + break; + + case 'top_n_vuls_count': + $report['contents'][] = reporting_top_n_vuls_count( + $report, + $content, + $type + ); + break; + default: // Default. break; @@ -11294,7 +11351,7 @@ function reporting_simple_graph( ), 'ttl' => $ttl, 'compare' => $time_compare_overlapped, - 'show_unknown' => true, + 'show_unknown' => $content['check_unknowns_graph'], 'percentil' => ($content['style']['percentil'] == 1) ? $config['percentil'] : null, 'fullscale' => $fullscale, 'server_id' => $id_meta, @@ -13641,38 +13698,47 @@ function reporting_tiny_stats( } if ($modern === true) { - $out .= '
'; if (isset($fired_count) && $fired_count > 0) { + $out .= '
'; $out .= '
'; $out .= ''.$fired_count.'
'; + $out .= '
'; } if (isset($critical_count) && $critical_count > 0) { + $out .= '
'; $out .= '
'; $out .= ''.$critical_count.'
'; + $out .= '
'; } if (isset($warning_count) && $warning_count > 0) { + $out .= '
'; $out .= '
'; $out .= ''.$warning_count.'
'; + $out .= '
'; } if (isset($unknown_count) && $unknown_count > 0) { + $out .= '
'; $out .= '
'; $out .= ''.$unknown_count.'
'; + $out .= '
'; } if (isset($not_init_count) && $not_init_count > 0) { + $out .= '
'; $out .= '
'; $out .= ''.$not_init_count.'
'; + $out .= '
'; } if (isset($normal_count) && $normal_count > 0) { + $out .= '
'; $out .= '
'; $out .= ''.$normal_count.'
'; + $out .= '
'; } - - $out .= '
'; } else { // Classic ones. $out .= ''.$total_count.''; @@ -15920,171 +15986,174 @@ function reporting_module_histogram_graph($report, $content, $pdf=0) return false; } - $module_interval = modules_get_interval( - $content['id_agent_module'] - ); - $slice = ($content['period'] / $module_interval); + if ($metaconsole_on && $server_name != '') { + // Restore db connection. + metaconsole_restore_db(); + } - $result_sla = reporting_advanced_sla( - $content['id_agent_module'], - ($report['datetime'] - $content['period']), - $report['datetime'], - null, - null, + $filter = [ + 'id_agentmodule' => $content['id_agent_module'], + 'group_rep' => EVENT_GROUP_REP_ALL, + 'date_to' => date('Y-m-d', ($report['datetime'] - $content['period'])), + 'time_to' => date('H:i:s', ($report['datetime'] - $content['period'])), + ]; + + if ($metaconsole_on && $server_name != '') { + $filter['id_server'] = $connection['id']; + } + + $previous_event = events_get_all( + ['te.event_type, te.timestamp, te.utimestamp'], + $filter, 0, - null, - null, - null, - $slice, 1, + 'desc', + 'timestamp', true ); - // Select Warning and critical values. - $agentmodule_info = modules_get_agentmodule($content['id_agent_module']); - $min_value_critical = ($agentmodule_info['min_critical'] == 0) ? null : $agentmodule_info['min_critical']; + $status = ''; + if ($previous_event !== false) { + $previous_event = end($previous_event); + $status = $previous_event['event_type']; + } - // Check if module type is string. - $modules_is_string = modules_is_string($agentmodule_info['id_agente_modulo']); + $date_start = ($report['datetime'] - $content['period']); + $filter = [ + 'id_agentmodule' => $content['id_agent_module'], + 'group_rep' => EVENT_GROUP_REP_ALL, + 'date_from' => date('Y-m-d', $date_start), + 'date_to' => date('Y-m-d', $report['datetime']), + 'time_from' => date('H:i:s', $date_start), + 'time_to' => date('H:i:s', $report['datetime']), + ]; - if ($modules_is_string === false) { - if ($agentmodule_info['max_critical'] == 0) { - $max_value_critical = null; - if ($agentmodule_info['min_critical'] == 0) { - if ((bool) $content['dinamic_proc'] === true) { - $max_value_critical = 0.01; - } + if ($metaconsole_on && $server_name != '') { + $filter['id_server'] = $connection['id']; + } + + $events = events_get_all( + ['te.event_type, te.timestamp, te.utimestamp'], + $filter, + null, + null, + null, + null, + true + ); + + // Metaconsole connection. + if ($metaconsole_on && $server_name != '') { + $connection = metaconsole_get_connection($server_name); + if (!metaconsole_load_external_db($connection)) { + ui_print_error_message('Error connecting to '.$server_name); + } + } + + $not_init_data = []; + $previous_data = [ + 'event_type' => $status, + 'utimestamp' => $date_start, + ]; + if (empty($status) === true) { + // Si viene de no iniciado busco el primer dato del modulo y si es de histórico. + $first_utimestamp = false; + $search_historydb = false; + $extract_first_data = modules_get_first_date($content['id_agent_module'], 0); + if (empty($extract_first_data) === false) { + $first_utimestamp = $extract_first_data['first_utimestamp']; + $search_historydb = (isset($extract_first_data['search_historydb']) === true) ? $extract_first_data['search_historydb'] : false; + } + + // Si se encuentra algun dato. + // Si no hay eventos, la fecha del primer dato no sea mayor al fin del report (seria un bloque completo de no iniciado). + // Se comprueba que si existen eventos el dato no sea previo al evento. + if ($first_utimestamp !== false + && ((empty($events) === true && $first_utimestamp < $report['datetime']) || (empty($events) === false && $first_utimestamp < $events[0]['utimestamp'])) + ) { + // Tenemos en cuenta si el modulo es de tipo string. + $module = modules_get_agentmodule($content['id_agent_module']); + $module_type = $module['id_tipo_modulo']; + $module_type_str = modules_get_type_name($module_type); + $table = 'tagente_datos'; + if (strstr($module_type_str, 'string') !== false) { + $table = 'tagente_datos_string'; + } + + $query = sprintf( + 'SELECT datos,utimestamp + FROM %s + WHERE id_agente_modulo = %d + AND utimestamp = %d + ', + $table, + $content['id_agent_module'], + $first_utimestamp + ); + + $data = db_get_all_rows_sql($query, $search_historydb); + if ($data !== false) { + $not_init_data = [ + 'event_type' => $status, + 'utimestamp' => $date_start, + ]; + $previous_data = [ + 'event_type' => 'going_up_normal', + 'utimestamp' => $data[0]['utimestamp'], + ]; } - } else { - $max_value_critical = $agentmodule_info['max_critical']; - } - } else { - if ($agentmodule_info['str_critical'] == '') { - $max_value_critical = null; - } else { - $max_value_critical = $agentmodule_info['str_critical']; } } - $inverse_critical = $agentmodule_info['critical_inverse']; - - $min_value_warning = ($agentmodule_info['min_warning'] == 0) ? null : $agentmodule_info['min_warning']; - - if ($modules_is_string === false) { - if ($agentmodule_info['max_warning'] == 0) { - $max_value_warning = null; - } else { - $max_value_warning = $agentmodule_info['max_warning']; - } - } else { - if ($agentmodule_info['str_warning'] == '') { - $max_value_warning = null; - } else { - $max_value_warning = $agentmodule_info['str_warning']; - } + $array_result = []; + $time_total = $content['period']; + $check_total = 0; + $check_ok = 0; + $time_ok = 0; + if (empty($events) === true) { + $events = []; } - $inverse_warning = $agentmodule_info['warning_inverse']; + // Añadimos el dato previo. + array_unshift($events, $previous_data); + if (empty($not_init_data) === false) { + // Añadimos si viene de no iniciado el no iniciado. + array_unshift($events, $not_init_data); + } - $data = []; - $data['time_total'] = 0; - $data['time_ok'] = 0; - $data['time_error'] = 0; - $data['time_warning'] = 0; - $data['time_unknown'] = 0; - $data['time_not_init'] = 0; - $data['time_downtime'] = 0; - $data['checks_total'] = 0; - $data['checks_ok'] = 0; - $data['checks_error'] = 0; - $data['checks_warning'] = 0; - $data['checks_unknown'] = 0; - $data['checks_not_init'] = 0; - - $array_graph = []; + $current_time = time(); $i = 0; - foreach ($result_sla as $value_sla) { - $data['time_total'] += $value_sla['time_total']; - $data['time_ok'] += $value_sla['time_ok']; - $data['time_error'] += $value_sla['time_error']; - $data['time_warning'] += $value_sla['time_warning']; - $data['time_unknown'] += $value_sla['time_unknown']; - $data['time_downtime'] += $value_sla['time_downtime']; - $data['time_not_init'] += $value_sla['time_not_init']; - $data['checks_total'] += $value_sla['checks_total']; - $data['checks_ok'] += $value_sla['checks_ok']; - $data['checks_error'] += $value_sla['checks_error']; - $data['checks_warning'] += $value_sla['checks_warning']; - $data['checks_unknown'] += $value_sla['checks_unknown']; - $data['checks_not_init'] += $value_sla['checks_not_init']; - - // Generate raw data for graph. - if ($value_sla['time_total'] != 0) { - if ($value_sla['time_error'] > 0) { - // ERR. - $array_graph[$i]['data'] = 3; - } else if ($value_sla['time_unknown'] > 0) { - // UNKNOWN. - $array_graph[$i]['data'] = 4; - } else if ($value_sla['time_warning'] > 0) { - // Warning. - $array_graph[$i]['data'] = 2; - } else if ($value_sla['time_not_init'] == $value_sla['time_total']) { - // NOT INIT. - $array_graph[$i]['data'] = 6; - } else { - $array_graph[$i]['data'] = 1; - } + foreach ($events as $event) { + $array_result[$i]['data'] = events_status_module_event_type($event['event_type']); + if (isset($events[($i + 1)]) === true) { + $period = ($events[($i + 1)]['utimestamp'] - $event['utimestamp']); + $array_result[$i]['utimestamp'] = $period; } else { - $array_graph[$i]['data'] = 7; + $period = ($report['datetime'] - $event['utimestamp']); + // El ultimo evento solo lo arrastramos hasta la fecha actual. + // Si pedimos mas fecha sera desconocido. + if ($report['datetime'] > $current_time) { + $period = ($current_time - $event['utimestamp']); + } + + $array_result[$i]['utimestamp'] = $period; } - $array_graph[$i]['utimestamp'] = ($value_sla['date_to'] - $value_sla['date_from']); + if ($array_result[$i]['data'] === AGENT_MODULE_STATUS_NORMAL) { + $check_ok++; + $time_ok += $period; + } + + $check_total++; $i++; } - $data['sla_value'] = reporting_sla_get_compliance_from_array( - $data - ); - - $data['sla_fixed'] = sla_truncate( - $data['sla_value'], - $config['graph_precision'] - ); - - $data_init = -1; - $acum = 0; - $sum = 0; - $array_result = []; - $i = 0; - foreach ($array_graph as $value) { - if ($data_init == -1) { - $data_init = $value['data']; - $acum = $value['utimestamp']; - } else { - if ($data_init == $value['data']) { - $acum = ($acum + $value['utimestamp']); - } else { - $array_result[$i]['data'] = $data_init; - $array_result[$i]['utimestamp'] = $acum; - $array_result[$i]['real_data'] = $sum; - $i++; - $data_init = $value['data']; - $acum = $value['utimestamp']; - } - } + // Bloque por si se pide mas fecha. + if ($report['datetime'] > $current_time) { + $array_result[$i]['data'] = AGENT_MODULE_STATUS_UNKNOWN; + $array_result[$i]['utimestamp'] = ($report['datetime'] - $current_time); } - if (count($array_result) == 0) { - $array_result = $array_graph; - } else { - $array_result[$i]['data'] = $data_init; - $array_result[$i]['utimestamp'] = $acum; - $array_result[$i]['real_data'] = $sum; - } - - $time_total = $data['time_total']; - // Slice graphs calculation. $return['agent'] = modules_get_agentmodule_agent_alias( $content['id_agent_module'] ); @@ -16092,37 +16161,21 @@ function reporting_module_histogram_graph($report, $content, $pdf=0) $content['id_agent_module'] ); - $return['max_critical'] = $max_value_critical; - $return['min_critical'] = $min_value_critical; - $return['critical_inverse'] = $inverse_critical; - $return['max_warning'] = $max_value_warning; - $return['min_warning'] = $min_value_warning; - $return['warning_inverse'] = $inverse_warning; - $return['data_not_init'] = $data['checks_not_init']; - $return['data_unknown'] = $data['checks_unknown']; - $return['data_critical'] = $data['checks_error']; - $return['data_warning'] = $data['checks_warning']; - $return['data_ok'] = $data['checks_ok']; - $return['data_total'] = $data['checks_total']; - $return['time_not_init'] = $data['time_not_init']; - $return['time_unknown'] = $data['time_unknown']; - $return['time_critical'] = $data['time_error']; - $return['time_warning'] = $data['time_warning']; - $return['time_ok'] = $data['time_ok']; - if ($data['checks_total'] > 0) { - $return['percent_ok'] = (($data['checks_ok'] * 100) / $data['checks_total']); + $return['data_ok'] = $check_ok; + $return['data_total'] = $check_total; + if ($check_total > 0) { + $return['percent_ok'] = (($time_ok * 100) / $content['period']); } else { $return['percent_ok'] = 0; } $colors = [ - 1 => COL_NORMAL, - 2 => COL_WARNING, - 3 => COL_CRITICAL, - 4 => COL_UNKNOWN, - 5 => COL_DOWNTIME, - 6 => COL_NOTINIT, - 7 => COL_IGNORED, + AGENT_MODULE_STATUS_CRITICAL_ALERT => COL_ALERTFIRED, + AGENT_MODULE_STATUS_NORMAL => COL_NORMAL, + AGENT_MODULE_STATUS_UNKNOWN => COL_UNKNOWN, + AGENT_MODULE_STATUS_WARNING => COL_WARNING, + AGENT_MODULE_STATUS_CRITICAL_BAD => COL_CRITICAL, + AGENT_MODULE_STATUS_NOT_INIT => COL_NOTINIT, ]; $width_graph = 100; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 99f3af63ad..6699d2c74d 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -507,6 +507,34 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust case 'evolution': reporting_evolution_graph($table, $item); break; + + case 'vuls_severity_graph': + reporting_html_vuls_severity_graph($table, $item); + break; + + case 'vuls_attack_complexity': + reporting_html_vuls_attack_complexity($table, $item); + break; + + case 'vuls_by_packages': + reporting_html_vuls_by_packages($table, $item); + break; + + case 'vuls_by_agent': + reporting_html_vuls_by_agent($table, $item); + break; + + case 'vuls_info_agent': + reporting_html_vuls_info_agent($table, $item); + break; + + case 'top_n_agents_vuls': + reporting_html_top_n_agents_vuls($table, $item); + break; + + case 'top_n_vuls_count': + reporting_html_top_n_vuls_count($table, $item); + break; } if ($item['type'] == 'agent_module') { @@ -522,6 +550,300 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust } +/** + * Function to print top vulnerabiries more common. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param integer $pdf Flag for return table. + * + * @return mixed + */ +function reporting_html_top_n_vuls_count($table, $item, $pdf=0) +{ + global $config; + $table->width = '99%'; + $table->styleTable = 'border: 0px;'; + $table->colspan[2][0] = 3; + $table1 = new stdClass(); + $table1->headstyle = []; + $table1->width = '99%'; + $table1->class = 'info_table'; + $table1->titleclass = 'title_table_pdf'; + $table1->rowclass[0] = ''; + $table1->head[0] = __('Vulnerability'); + $table1->head[2] = __('Total'); + + $row = 2; + foreach ($item['data'] as $key => $vul) { + $table1->data[$row][0] = $vul['cve_id']; + $table1->data[$row][2] = $vul['count']; + $row++; + } + + if ($pdf === 1) { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + } + + $table->data[2][0] = html_print_table($table1, true); + if ($pdf === 1) { + return html_print_table($table, true); + } +} + + +/** + * Function to print top agents with worst score. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param integer $pdf Flag for return table. + * + * @return mixed + */ +function reporting_html_top_n_agents_vuls($table, $item, $pdf=0) +{ + global $config; + $table->width = '99%'; + $table->styleTable = 'border: 0px;'; + $table->colspan[2][0] = 3; + $table1 = new stdClass(); + $table1->headstyle = []; + $table1->width = '99%'; + $table1->class = 'info_table'; + $table1->titleclass = 'title_table_pdf'; + $table1->rowclass[0] = ''; + $table1->head[0] = __('Agent'); + $table1->head[2] = __('Risk'); + + $row = 2; + foreach ($item['data'] as $key => $agent) { + $table1->data[$row][0] = $agent['alias']; + $table1->data[$row][2] = $agent['score']; + $row++; + } + + if ($pdf === 1) { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + } + + $table->data[2][0] = html_print_table($table1, true); + if ($pdf === 1) { + return html_print_table($table, true); + } +} + + +/** + * Function to print vulnerabilities of agent. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param integer $pdf Flag for return table. + * + * @return mixed + */ +function reporting_html_vuls_info_agent($table, $item, $pdf=0) +{ + $table->width = '99%'; + $table->styleTable = 'border: 0px;'; + $table->colspan[2][0] = 3; + $table1 = new stdClass(); + $table1->headstyle[0] = 'text-align: left'; + $table1->headstyle[1] = 'text-align: left'; + $table1->headstyle[2] = 'text-align: left'; + $table1->width = '99%'; + $table1->class = 'info_table'; + $table1->titleclass = 'title_table_pdf'; + $table1->rowclass[0] = ''; + $table1->head[0] = __('Name'); + $table1->head[1] = __('CVE'); + $table1->head[2] = __('Version'); + $table1->head[3] = __('Score'); + $table1->head[4] = __('Detection time'); + $table1->head[5] = __('Severity'); + $table1->head[6] = __('Version'); + $table1->head[7] = __('Attack Vector'); + $table1->head[8] = __('Attack Complexity'); + $table1->head[9] = __('Privileges Required'); + $table1->head[10] = __('User Interaction'); + $table1->head[11] = __('Scope'); + $table1->head[12] = __('Confidentiality'); + $table1->head[13] = __('Integrity'); + $table1->head[14] = __('Availability'); + + $row = 1; + foreach ($item['data'] as $key => $vul) { + $table1->data[$row][0] = (key_exists('name', $vul) === true) ? $vul['name'] : ''; + $table1->data[$row][1] = (key_exists('cve', $vul) === true) ? $vul['cve'] : ''; + $table1->data[$row][2] = (key_exists('version', $vul) === true) ? $vul['version'] : ''; + $table1->data[$row][3] = (key_exists('score', $vul) === true) ? $vul['score'] : ''; + $table1->data[$row][4] = (key_exists('detection_time', $vul) === true) ? $vul['detection_time'] : ''; + $table1->data[$row][5] = (key_exists('severity', $vul) === true) ? $vul['severity'] : ''; + $table1->data[$row][6] = (key_exists('CVSS', $vul) === true) ? $vul['CVSS'] : ''; + $table1->data[$row][7] = (key_exists('AV', $vul) === true) ? $vul['AV'] : ''; + $table1->data[$row][8] = (key_exists('AC', $vul) === true) ? $vul['AC'] : ''; + $table1->data[$row][9] = (key_exists('PR', $vul) === true) ? $vul['PR'] : ''; + $table1->data[$row][10] = (key_exists('UI', $vul) === true) ? $vul['UI'] : ''; + $table1->data[$row][11] = (key_exists('S', $vul) === true) ? $vul['S'] : ''; + $table1->data[$row][12] = (key_exists('C', $vul) === true) ? $vul['C'] : ''; + $table1->data[$row][13] = (key_exists('I', $vul) === true) ? $vul['I'] : ''; + $table1->data[$row][14] = (key_exists('A', $vul) === true) ? $vul['A'] : ''; + + $row++; + } + + $table->data[2][0] = html_print_table($table1, true); + + if ($pdf === 1) { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + return html_print_table($table1, true); + } +} + + +/** + * Function to print total vulnerabilities by packages in graph. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param integer $pdf Flag for return table. + * + * @return mixed + */ +function reporting_html_vuls_by_packages($table, $item, $pdf=0) +{ + $table->rowclass[0] = ''; + $table->colspan['chart']['cell'] = 3; + $table->cellstyle['chart']['cell'] = 'text-align: center;'; + $table->data['chart']['cell'] = $item['chart']; + + if ($pdf === 1) { + return html_print_table($table, true); + } +} + + +/** + * Function to print attack complexity in graph + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param integer $pdf Flag for return table. + * + * @return mixed + */ +function reporting_html_vuls_attack_complexity($table, $item, $pdf=0) +{ + $table->rowclass[0] = ''; + $table->colspan['chart']['cell'] = 3; + $table->cellstyle['chart']['cell'] = 'text-align: center;'; + $table->data['chart']['cell'] = html_print_div( + [ + 'content' => $item['chart'], + 'style' => 'width: 450px; height: 300px; margin: 0 auto;', + ], + true + ); + + if ($pdf === 1) { + return html_print_table($table, true); + } +} + + +/** + * Function to print the severity vuls in graph. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param integer $pdf Flag for return table. + * + * @return mixed + */ +function reporting_html_vuls_severity_graph($table, $item, $pdf=0) +{ + $table->rowclass[0] = ''; + $table->colspan['chart']['cell'] = 3; + $table->cellstyle['chart']['cell'] = 'text-align: center;'; + $table->data['chart']['cell'] = $item['chart']; + + if ($pdf === 1) { + return html_print_table($table, true); + } +} + + +/** + * Function to print the all vulnerabilities by agent. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param integer $pdf Flag for return table. + * + * @return mixed + */ +function reporting_html_vuls_by_agent($table, $item, $pdf=0) +{ + $table->width = '99%'; + $table->styleTable = 'border: 0px;'; + $table->colspan[2][0] = 3; + $table1 = new stdClass(); + $table1->headstyle[0] = 'text-align: left'; + $table1->headstyle[1] = 'text-align: left'; + $table1->headstyle[2] = 'text-align: left'; + $table1->width = '99%'; + $table1->class = 'info_table'; + $table1->titleclass = 'title_table_pdf'; + $table1->rowclass[0] = ''; + $table1->head[0] = __('Agent'); + $table1->head[1] = __('OS'); + $table1->head[2] = __('OS Version'); + $table1->head[3] = __('Group'); + $table1->head[4] = __('Ip'); + $table1->head[5] = __('Status'); + $table1->head[6] = __('SecMon'); + $table1->head[7] = __('Hardening'); + $table1->head[8] = __('Vulnerability'); + $table1->head[9] = __('Last contact'); + $table1->head[10] = __('L.S. Change'); + + $row = 1; + foreach ($item['data'] as $key => $vul) { + $table1->data[$row][0] = $vul['alias']; + $table1->data[$row][2] = $vul['name']; + $table1->data[$row][3] = $vul['os_version']; + $table1->data[$row][4] = $vul['nombre_gr']; + $table1->data[$row][5] = $vul['direccion']; + $table1->data[$row][6] = $vul['status']; + $table1->data[$row][7] = $vul['secmon']; + $table1->data[$row][8] = $vul['hardening']; + $table1->data[$row][9] = $vul['vulnerabilities']; + $table1->data[$row][10] = $vul['ultimo_contacto']; + $table1->data[$row][11] = $vul['last_status_c']; + $row++; + } + + if ($pdf === 1) { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + } + + $table->data[2][0] = html_print_table($table1, true); + + if ($pdf === 1) { + return html_print_table($table1, true); + } +} + + /** * Function to print the security hardening evolution. * @@ -3249,7 +3571,7 @@ function reporting_html_group_report($table, $item, $pdf=0) $out .= ''; $out .= ''; $out .= ''; - $out .= '
'.__('Events per agent').''; + $out .= '
'.__('Events by agent').''; $data = []; $options = []; $labels = []; diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 3da9993933..9b77eed800 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -1003,6 +1003,41 @@ function reports_get_report_types($template=false, $not_editor=false) 'optgroup' => __('Security hardening'), 'name' => __('Evolution'), ]; + + $types['vuls_severity_graph'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Severity graph bar'), + ]; + + $types['vuls_attack_complexity'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Attack complexity doughnut chart'), + ]; + + $types['vuls_by_packages'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('By packages in pie chart'), + ]; + + $types['vuls_by_agent'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Detailed security report'), + ]; + + $types['vuls_info_agent'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Vulnerabilities of agent'), + ]; + + $types['top_n_agents_vuls'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Top-N agents with more risk'), + ]; + + $types['top_n_vuls_count'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Top-N common vulnerabilities'), + ]; } return $types; diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index 845a57a77b..ff6fab73c6 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -665,6 +665,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'data'; $id_modulo = 1; + $server['name'] = __('Data server'); break; case SERVER_TYPE_NETWORK: @@ -678,6 +679,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'network'; $id_modulo = 2; + $server['name'] = __('Network server'); break; case SERVER_TYPE_SNMP: @@ -691,6 +693,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'snmp'; $id_modulo = 0; + $server['name'] = __('SNMP Trap server'); break; case SERVER_TYPE_DISCOVERY: @@ -704,6 +707,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'recon'; $id_modulo = 0; + $server['name'] = __('Discovery server'); break; case SERVER_TYPE_PLUGIN: @@ -717,6 +721,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'plugin'; $id_modulo = 4; + $server['name'] = __('Plugin server'); break; case SERVER_TYPE_PREDICTION: @@ -730,6 +735,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'prediction'; $id_modulo = 5; + $server['name'] = __('Prediction server'); break; case SERVER_TYPE_WMI: @@ -743,6 +749,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'wmi'; $id_modulo = 6; + $server['name'] = __('WMI server'); break; case SERVER_TYPE_EXPORT: @@ -756,6 +763,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'export'; $id_modulo = 0; + $server['name'] = __('Export server'); break; case SERVER_TYPE_INVENTORY: @@ -769,6 +777,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'inventory'; $id_modulo = 0; + $server['name'] = __('Inventory server'); break; case SERVER_TYPE_WEB: @@ -782,6 +791,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'web'; $id_modulo = 0; + $server['name'] = __('Web server'); break; case SERVER_TYPE_EVENT: @@ -795,6 +805,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'event'; $id_modulo = 2; + $server['name'] = __('Event server'); break; case SERVER_TYPE_CORRELATION: @@ -808,6 +819,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'correlation'; $id_modulo = 0; + $server['name'] = __('Correlation server'); break; case SERVER_TYPE_ENTERPRISE_ICMP: @@ -821,6 +833,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'enterprise icmp'; $id_modulo = 2; + $server['name'] = __('Enterprise ICMP server'); break; case SERVER_TYPE_ENTERPRISE_SNMP: @@ -834,6 +847,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'enterprise snmp'; $id_modulo = 2; + $server['name'] = __('Enterprise SNMP server'); break; case SERVER_TYPE_ENTERPRISE_SATELLITE: @@ -847,6 +861,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'enterprise satellite'; $id_modulo = 0; + $server['name'] = __('Enterprise Satellite server'); break; case SERVER_TYPE_ENTERPRISE_TRANSACTIONAL: @@ -860,6 +875,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'enterprise transactional'; $id_modulo = 0; + $server['name'] = __('Enterprise Transactional server'); break; case SERVER_TYPE_MAINFRAME: @@ -873,6 +889,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'mainframe'; $id_modulo = 0; + $server['name'] = __('Mainframe server'); break; case SERVER_TYPE_SYNC: @@ -886,6 +903,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'sync'; $id_modulo = 0; + $server['name'] = __('Sync server'); break; case SERVER_TYPE_WUX: @@ -899,6 +917,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'wux'; $id_modulo = 0; + $server['name'] = __('Wux server'); break; case SERVER_TYPE_SYSLOG: @@ -912,6 +931,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'syslog'; $id_modulo = 0; + $server['name'] = __('Syslog server'); break; case SERVER_TYPE_NCM: @@ -925,6 +945,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'ncm'; $id_modulo = 0; + $server['name'] = __('NCM server'); break; case SERVER_TYPE_AUTOPROVISION: @@ -938,6 +959,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'autoprovision'; $id_modulo = 0; + $server['name'] = __('Autoprovision server'); break; case SERVER_TYPE_MIGRATION: @@ -951,6 +973,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'migration'; $id_modulo = 0; + $server['name'] = __('Migration server'); break; case SERVER_TYPE_ALERT: @@ -964,6 +987,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'alert'; $id_modulo = 0; + $server['name'] = __('Alert server'); break; case SERVER_TYPE_NETFLOW: @@ -977,6 +1001,7 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'netflow'; $id_modulo = 0; + $server['name'] = __('Netflow server'); break; case SERVER_TYPE_LOG: @@ -990,6 +1015,21 @@ function servers_get_info($id_server=-1, $sql_limit=-1) ); $server['type'] = 'log'; $id_modulo = 0; + $server['name'] = __('Log server'); + break; + + case SERVER_TYPE_MADE: + $server['img'] = html_print_image( + 'images/Anomaly-detection@svg.svg', + true, + [ + 'title' => __('MADE server'), + 'class' => 'main_menu_icon invert_filter', + ] + ); + $server['type'] = 'made'; + $id_modulo = 0; + $server['name'] = __('MADE server'); break; default: diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 480d0d865e..99a0b07612 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -644,14 +644,16 @@ function snmp_browser_print_oid( if (isset($_POST['print_create_agent_module'])) { // Hidden by default. - $output .= html_print_button( - __('Create agent module'), - 'create_module_agent_single', - false, - 'show_add_module()', - 'class="sub add invisible"', - true - ); + if (is_metaconsole() === false) { + $output .= html_print_button( + __('Create agent module'), + 'create_module_agent_single', + false, + 'show_add_module()', + 'class="sub add invisible"', + true + ); + } } if (isset($_POST['print_copy_oid'])) { @@ -1238,13 +1240,15 @@ function snmp_browser_print_container( if ($show_massive_buttons) { $output .= '
-
+
title; ?>
-
-
+
+
- getTagsGraph(); ?> + getMonitoringStatusGraph(); ?>
-
+
- getMonitoringStatusGraph(); ?> + getTagsGraph(); ?>
+
@@ -184,7 +187,7 @@ getTotalSources(); ?>
-
+
@@ -221,6 +224,7 @@
+
@@ -236,13 +240,13 @@
- getCurrentlyTriggered(); ?> + getCurrentlyTriggered(); ?>
- getActiveAlerts(); ?> + getActiveAlerts(); ?>
checkAclUserList() === true) : ?> @@ -261,13 +265,13 @@
title; ?>
-
-
+
+
loading(); ?>
-
+
@@ -276,7 +280,7 @@
- +
loading(); ?>
@@ -288,7 +292,7 @@
-
+
@@ -333,7 +337,7 @@
getOperatingSystemGraph(); ?>
- +
getStatusGraph(); ?>
@@ -341,41 +345,43 @@
-
-
- title; ?> -
- + checkAcl() === true) : ?>
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 8b3c1651f9..5646fc2bc9 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.773.3-231023 +Version: 7.0NG.774-231205 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index 697ae70551..38c79af777 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/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.773.3-231023" +pandora_version="7.0NG.774-231205" package_cpan=0 package_pandora=1 diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index eaf6f48968..619a00e1b6 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -818,6 +818,8 @@ sub main() { && $Config{"self_monitoring"} == 1 && !is_metaconsole(\%Config) && time() - $thr_time_ref > $Config{'self_monitoring_interval'}) { + # Update agent name token. + pandora_set_tconfig_token($DBH, 'self_monitoring_agent_name', $Config{'self_monitoring_agent_name'}); $thr_time_ref = time(); pandora_thread_monitoring (\%Config, $DBH, \@Servers); } diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index db6e45bebb..2e485501e4 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -1,7 +1,7 @@ ############################################################################# # Pandora FMS Server Parameters # Pandora FMS, the Flexible Monitoring System. -# Version 7.0NG.773.3 +# Version 7.0NG.774 # Licensed under GPL license v2, # (c) 2003-2023 Pandora FMS # http://www.pandorafms.com @@ -422,6 +422,9 @@ self_monitoring 1 # Self monitoring interval (in seconds). self_monitoring_interval 300 +# Self monitoring agent name. +self_monitoring_agent_name pandora.internals + # Update parent from the agent xml update_parent 1 @@ -783,3 +786,33 @@ netflowserver_threads 1 # Enable (1) or disable (0) the verification of SSL certificates (set to 0 when using self-signed certificates). ssl_verify 0 +# Enable (1) or disable (0) the Monitoring Anomaly Detection Engine (PANDORA FMS ENTERPRISE ONLY). +madeserver 0 + +# Directory where models will be stored (PANDORA FMS ENTERPRISE ONLY). +madeserver_path /var/spool/pandora/data_in/models + +# Number of server threads for MADE (PANDORA FMS ENTERPRISE ONLY). +madeserver_threads 2 + +# Model backend: 'prophet' or 'iforest' (PANDORA FMS ENTERPRISE ONLY). +# 'prophet' is better suited for temporal series and supports forecasting. +# 'iforest' is faster and more efficient (cpu, memory...). +madeserver_backend prophet + +# MADE will query the Pandora FMS database every madeserver_interval seconds +# to look for new data (PANDORA FMS ENTERPRISE ONLY). +madeserver_interval 60 + +# Minimum number of data required to train a model (e.g., '7d' for seven days) (PANDORA FMS ENTERPRISE ONLY). +madeserver_min_train 7d + +# Maximum number of data kept to train models (e.g., '90d' for 90 days) (PANDORA FMS ENTERPRISE ONLY). +madeserver_max_history 90d + +# Model automatic retraining period (e.g., '7d' for seven days) (PANDORA FMS ENTERPRISE ONLY). +madeserver_autofit 7d + +# Model sensitivity. A lower value triggers less anomalies (PANDORA FMS ENTERPRISE ONLY). +madeserver_sensitivity 0.1 + diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index a5477c7503..9e358948c4 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -45,8 +45,8 @@ our @EXPORT = qw( ); # version: Defines actual version of Pandora Server for this module only -my $pandora_version = "7.0NG.773.3"; -my $pandora_build = "231023"; +my $pandora_version = "7.0NG.774"; +my $pandora_build = "231205"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash @@ -128,7 +128,6 @@ sub pandora_get_sharedconfig ($$) { my ($pa_config, $dbh) = @_; # Agentaccess option - $pa_config->{"agentaccess"} = pandora_get_tconfig_token ($dbh, 'agentaccess', 1); # Realtimestats 0 disabled, 1 enabled. # Master servers will generate all the information (global tactical stats). @@ -206,6 +205,9 @@ sub pandora_get_sharedconfig ($$) { # Server identifier $pa_config->{'server_unique_identifier'} = pandora_get_tconfig_token ($dbh, 'server_unique_identifier', ''); + + # Vulnerability scans + $pa_config->{'agent_vulnerabilities'} = pandora_get_tconfig_token ($dbh, 'agent_vulnerabilities', 0); } ########################################################################## @@ -296,9 +298,9 @@ sub pandora_load_config { $pa_config->{"update_parent"} = 0; # 3.1 $pa_config->{"google_maps_description"} = 0; $pa_config->{'openstreetmaps_description'} = 0; - $pa_config->{"eventserver"} = 1; # 4.0 + $pa_config->{"eventserver"} = 0; # 4.0 $pa_config->{"eventserver_threads"} = 1; # 4.0 - $pa_config->{"logserver"} = 1; # 7.774 + $pa_config->{"logserver"} = 0; # 7.774 $pa_config->{"logserver_threads"} = 1; # 7.774 $pa_config->{"event_window"} = 3600; # 4.0 $pa_config->{"log_window"} = 3600; # 7.741 @@ -416,6 +418,9 @@ sub pandora_load_config { # Self monitoring interval $pa_config->{'self_monitoring_interval'} = 300; # 5.1SP1 + # Self monitoring agent name. + $pa_config->{'self_monitoring_agent_name'} = 'pandora.internals'; # 7.774 + # Process XML data files as a stack $pa_config->{"dataserver_lifo"} = 0; # 5.0 @@ -460,7 +465,6 @@ sub pandora_load_config { # don't get an error later. $pa_config->{"realtimestats"} = 0; $pa_config->{"stats_interval"} = 300; - $pa_config->{"agentaccess"} = 1; $pa_config->{"event_storm_protection"} = 0; $pa_config->{"use_custom_encoding"} = 0; $pa_config->{"node_metaconsole"} = 0; # > 7.0NG @@ -513,7 +517,7 @@ sub pandora_load_config { $pa_config->{"clean_wux_sessions"} = 1; # 7.0.746 (only selenium 3) # Syslog Server - $pa_config->{"syslogserver"} = 1; # 7.0.716 + $pa_config->{"syslogserver"} = 0; # 7.0.716 $pa_config->{"syslog_file"} = '/var/log/messages/'; # 7.0.716 $pa_config->{"syslog_max"} = 65535; # 7.0.716 $pa_config->{"syslog_threads"} = 4; # 7.0.716 @@ -583,6 +587,8 @@ sub pandora_load_config { $pa_config->{"ssl_verify"} = 0; # 7.0 774 + $pa_config->{"madeserver"} = 0; # 774. + # Check for UID0 if ($pa_config->{"quiet"} != 0){ if ($> == 0){ @@ -1039,6 +1045,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^self_monitoring_interval\s+([0-9]*)/i) { $pa_config->{'self_monitoring_interval'} = clean_blank($1); } + elsif ($parametro =~ m/^self_monitoring_agent_name\s+(.*)/i) { + $pa_config->{'self_monitoring_agent_name'} = clean_blank($1); + } elsif ($parametro =~ m/^update_parent\s+([0-1])/i) { $pa_config->{'update_parent'} = clean_blank($1); } @@ -1400,6 +1409,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^ssl_verify\s+([0-1])/i) { $pa_config->{'ssl_verify'} = clean_blank($1); } + elsif ($parametro =~ m/^madeserver\s+([0-1])/i){ + $pa_config->{'madeserver'}= clean_blank($1); + } } # end of loop for parameter # # The DB host was overridden by pandora_ha. diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 6da2b77b41..673ccce1f0 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -325,6 +325,7 @@ our @ServerTypes = qw ( ncmserver netflowserver logserver + madeserver ); our @AlertStatus = ('Execute the alert', 'Do not execute the alert', 'Do not execute the alert, but increment its internal counter', 'Cease the alert', 'Recover the alert', 'Reset internal counter'); @@ -1835,6 +1836,34 @@ sub pandora_execute_action ($$$$$$$$$;$$) { . $base64_data . "\n"; } + # Image that comes from module macro substitution. + if ($field3 =~ /cid:moduledata_/) { + $content_type = 'multipart/related; boundary="'.$boundary.'"'; + $boundary = "--" . $boundary; + + $field3 = $boundary . "\n" + . "Content-Type: " . $html_content_type . "\n\n" + # "Content-Transfer-Encoding: quoted-printable\n\n" + . $field3 . "\n"; + my @matches = ($field3 =~ /cid:moduledata_(\d+)/g); + foreach my $module_id (@matches) { + # Get base64 Image for the module. + my $module_data = get_db_value($dbh, 'SELECT datos FROM tagente_estado WHERE id_agente_modulo = ?', $module_id); + my $base64_data = substr($module_data, 23); # remove first 23 characters: 'data:image/png;base64, ' + + $cid = 'moduledata_'.$module_id; + my $filename = $cid . ".png"; + + $field3 .= $boundary . "\n" + . "Content-Type: image/png; name=\"" . $filename . "\"\n" + . "Content-Disposition: inline; filename=\"" . $filename . "\"\n" + . "Content-Transfer-Encoding: base64\n" + . "Content-ID: <" . $cid . ">\n" + . "Content-Location: " . $filename . "\n\n" + . $base64_data . "\n"; + } + } + if ($pa_config->{"mail_in_separate"} != 0){ foreach my $address (split (',', $field1)) { # Remove blanks @@ -2158,24 +2187,6 @@ sub send_console_notification { } } -########################################################################## -=head2 C<< pandora_access_update (I<$pa_config>, I<$agent_id>, I<$dbh>) >> - -Update agent access table. - -=cut -########################################################################## -sub pandora_access_update ($$$) { - my ($pa_config, $agent_id, $dbh) = @_; - - return if ($agent_id < 0); - - if ($pa_config->{"agentaccess"} == 0){ - return; - } - db_do ($dbh, "INSERT INTO tagent_access (id_agent, utimestamp) VALUES (?, ?)", $agent_id, time ()); -} - ########################################################################## =head2 C<< pandora_process_module (I<$pa_config>, I<$data>, I<$agent>, I<$module>, I<$module_type>, I<$timestamp>, I<$utimestamp>, I<$server_id>, I<$dbh>) >> @@ -2412,10 +2423,8 @@ sub pandora_process_module ($$$$$$$$$;$) { } else { if($new_status == 0 && $ff_normal > $min_ff_event) { - # Reached normal FF but status have not changed, reset counters. + # Reached normal FF but status have not changed, reset counter. $ff_normal = 0; - $ff_critical = 0; - $ff_warning = 0; } # Active ff interval @@ -3427,14 +3436,10 @@ sub pandora_update_agent ($$$$$$$;$$$) { # No access update for data without interval. # Single modules from network server, for example. This could be very Heavy for Pandora FMS - if ($agent_interval != -1){ - pandora_access_update ($pa_config, $agent_id, $dbh); - } else { - - # Do not update the agent interval + if ($agent_interval == -1){ $agent_interval = undef; } - + # Update tagente my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime()); my ($set, $values) = db_update_get_values ({'agent_version' => $agent_version, @@ -4239,9 +4244,6 @@ sub pandora_delete_agent ($$;$) { # Delete the agent db_do ($dbh, 'DELETE FROM tagente WHERE id_agente = ?', $agent_id); - # Delete agent access data - db_do ($dbh, 'DELETE FROM tagent_access WHERE id_agent = ?', $agent_id); - # Delete addresses db_do ($dbh, 'DELETE FROM taddress_agent WHERE id_ag = ?', $agent_id); @@ -4330,6 +4332,7 @@ sub pandora_event { my $utimestamp = time (); my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp)); + my $event_custom_id = undef; $id_agentmodule = 0 unless defined ($id_agentmodule); # Validate events with the same event id @@ -4347,6 +4350,7 @@ sub pandora_event { logger($pa_config, "Keeping In process status from last event with extended id '$id_extra'.", 10); $ack_utimestamp = get_db_value ($dbh, 'SELECT ack_utimestamp FROM tevento WHERE id_extra=? AND estado=2', $id_extra); $event_status = 2; + $event_custom_id = get_db_value ($dbh, 'SELECT event_custom_id FROM tevento WHERE id_extra=? AND estado=2', $id_extra); } } @@ -4358,8 +4362,8 @@ sub pandora_event { # Create the event logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10); - $event_id = db_insert ($dbh, 'id_evento','INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, safe_input($module_data), $module_status); + $event_id = db_insert ($dbh, 'id_evento','INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status, event_custom_id) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, safe_input($module_data), $module_status, $event_custom_id); if(defined($event_id) && $comment ne '') { my $comment_id = db_insert ($dbh, 'id','INSERT INTO tevent_comment (id_event, utimestamp, comment, id_user, action) @@ -5178,6 +5182,11 @@ sub on_demand_macro($$$$$$;$) { elsif (defined($unit_mod) && $unit_mod ne '') { $field_value .= $unit_mod; } + + if ($field_value =~ /^data:image\/png;base64, /) { + # macro _data_ substitution in case is image. + $field_value = ''; + } return(defined($field_value)) ? $field_value : ''; } elsif ($macro eq '_secondarygroups_') { @@ -6314,7 +6323,7 @@ sub pandora_self_monitoring ($$) { my $xml_output = ""; - $xml_output = "{'version'} . "' agent_name='pandora.internals' agent_alias='pandora.internals' interval='".$pa_config->{"self_monitoring_interval"}."' timestamp='".$timestamp."' >"; + $xml_output = "{'version'} . "' agent_name='" . $pa_config->{"self_monitoring_agent_name"} . "' agent_alias='" . $pa_config->{"self_monitoring_agent_name"} . "' interval='".$pa_config->{"self_monitoring_interval"}."' timestamp='".$timestamp."' >"; $xml_output .=" "; $xml_output .=" Status"; $xml_output .=" generic_proc"; @@ -6513,7 +6522,7 @@ sub pandora_self_monitoring ($$) { $xml_output .= ""; - my $filename = $pa_config->{"incomingdir"}."/pandora.internals.self".$utimestamp.".data"; + my $filename = $pa_config->{"incomingdir"}."/".$pa_config->{"self_monitoring_agent_name"}.".self".$utimestamp.".data"; open (XMLFILE, ">", $filename) or die "[FATAL] Could not open internal monitoring XML file for deploying monitorization at '$filename'"; print XMLFILE $xml_output; close (XMLFILE); @@ -6538,7 +6547,7 @@ sub pandora_thread_monitoring ($$$) { # All trhead modules are "Status" module sons. $module_parent = 'Status'; - $xml_output = "{'version'} . "' agent_name='pandora.internals' agent_alias='pandora.internals' interval='".$pa_config->{"self_monitoring_interval"}."' timestamp='".$timestamp."' >"; + $xml_output = "{'version'} . "' agent_name='" . $pa_config->{'self_monitoring_agent_name'} . "' agent_alias='pandora.internals' interval='".$pa_config->{"self_monitoring_interval"}."' timestamp='".$timestamp."' >"; foreach my $server (@{$servers}) { my $producer_stats = $server->getProducerStats(); while (my ($tid, $stats) = each(%{$producer_stats})) { @@ -6604,7 +6613,7 @@ sub pandora_thread_monitoring ($$$) { } $xml_output .= ""; - my $filename = $pa_config->{"incomingdir"}."/pandora.internals.threads.".$utimestamp.".data"; + my $filename = $pa_config->{"incomingdir"}."/".$pa_config->{'self_monitoring_agent_name'}.".threads.".$utimestamp.".data"; open (XMLFILE, ">", $filename) or die "[FATAL] Could not write to the thread monitoring XML file '$filename'"; print XMLFILE $xml_output; close (XMLFILE); @@ -6710,8 +6719,7 @@ sub pandora_installation_monitoring($$) { FROM information_schema.tables WHERE - table_schema not in ('information_schema', 'mysql') - AND table_name NOT IN ('tagent_access, tevento')" + table_schema not in ('information_schema', 'mysql')" ); $module->{'unit'} = '%'; push(@modules, $module); @@ -6739,24 +6747,23 @@ sub pandora_installation_monitoring($$) { my $data_size = get_db_value($dbh, 'SELECT SUM(data_length)/(1024*1024) FROM information_schema.TABLES'); my $index_size = get_db_value($dbh, 'SELECT SUM(index_length)/(1024*1024) FROM information_schema.TABLES'); my $writes = $insert->{'Value'} + $update->{'Value'} + $replace->{'Value'} + $delete->{'Value'} ; - + my $reads = $select->{'Value'}; + # Mysql Questions - Reads $module->{'name'} = "mysql_questions_reads"; $module->{'description'} = 'MySQL: Questions - Reads (#): Number of read questions'; - $module->{'data'} = $select->{'Value'}; - $module->{'unit'} = 'qu'; + $module->{'data'} = $reads; + $module->{'unit'} = 'qu/s'; + $module->{'type'} = 'generic_data_inc'; push(@modules, $module); undef $module; # Mysql Questions - Writes - my $question_writes = 0; - if(($writes + $select) > 0) { - $question_writes = (($writes * 10000) / ($select + $writes)) / 100; - } $module->{'name'} = "mysql_questions_writes"; $module->{'description'} = 'MySQL: Questions - Writes (#): Number of writed questions'; - $module->{'data'} = $question_writes; - $module->{'unit'} = 'qu'; + $module->{'data'} = $writes; + $module->{'unit'} = 'qu/s'; + $module->{'type'} = 'generic_data_inc'; push(@modules, $module); undef $module; @@ -6896,7 +6903,7 @@ sub pandora_installation_monitoring($$) { $dbh, 'SELECT COUNT(id_evento) FROM tevento - WHERE timestamp >=UNIX_TIMESTAMP(NOW() - INTERVAL 1 DAY)' + WHERE utimestamp >=UNIX_TIMESTAMP(NOW() - INTERVAL 1 DAY)' ); $module->{'name'} = "last_events_24h"; $module->{'description'} = 'Last 24h events'; @@ -7942,7 +7949,7 @@ sub process_inventory_data ($$$$$$$) { ################################################################################ # Process inventory module data, creating the module if necessary. ################################################################################ -sub process_inventory_module_data ($$$$$$$$) { +sub process_inventory_module_data { my ($pa_config, $data, $server_id, $agent_name, $module_name, $interval, $timestamp, $dbh) = @_; @@ -8004,12 +8011,20 @@ sub process_inventory_module_data ($$$$$$$$) { 'INSERT INTO tagente_datos_inventory (id_agent_module_inventory, data, timestamp, utimestamp) VALUES (?, ?, ?, ?)', $id_agent_module_inventory, safe_input($data), $timestamp, $utimestamp); - - return; + } else { + process_inventory_module_diff($pa_config, safe_input($data), + $inventory_module, $timestamp, $utimestamp, $dbh, $interval); + } + + # Vulnerability scan. + if (($pa_config->{'agent_vulnerabilities'} == 0 && $agent->{'vul_scan_enabled'} == 1) || + ($pa_config->{'agent_vulnerabilities'} == 1 && $agent->{'vul_scan_enabled'} == 1) || + ($pa_config->{'agent_vulnerabilities'} == 1 && $agent->{'vul_scan_enabled'} == 2)) { + my $vulnerability_data = enterprise_hook('process_inventory_vulnerabilities', [$pa_config, $data, $agent, $inventory_module, $dbh]); + if (defined($vulnerability_data) && $vulnerability_data ne '') { + process_inventory_module_data ($pa_config, $vulnerability_data, $server_id, $agent_name, 'Vulnerabilities', $interval, $timestamp, $dbh); + } } - - process_inventory_module_diff($pa_config, safe_input($data), - $inventory_module, $timestamp, $utimestamp, $dbh, $interval); } ################################################################################ diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 5e643a3f04..6c2927f2a6 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -433,16 +433,17 @@ sub exec_recon_app ($$$) { # Configure macros. my %macros = ( - "__taskMD5__" => md5($task->{'id_rt'}), - "__taskInterval__" => $task->{'interval_sweep'}, - "__taskGroup__" => get_group_name($dbh, $task->{'id_group'}), - "__taskGroupID__" => $task->{'id_group'}, - "__temp__" => $pa_config->{'temporal'}, - "__incomingDir__" => $pa_config->{'incomingdir'}, - "__consoleAPIURL__" => $pa_config->{'console_api_url'}, - "__consoleAPIPass__" => $pa_config->{'console_api_pass'}, - "__consoleUser__" => $pa_config->{'console_user'}, - "__consolePass__" => $pa_config->{'console_pass'}, + "__taskMD5__" => md5($task->{'id_rt'}), + "__taskInterval__" => $task->{'interval_sweep'}, + "__taskGroup__" => get_group_name($dbh, $task->{'id_group'}), + "__taskGroupID__" => $task->{'id_group'}, + "__temp__" => $pa_config->{'temporal'}, + "__incomingDir__" => $pa_config->{'incomingdir'}, + "__consoleAPIURL__" => $pa_config->{'console_api_url'}, + "__consoleAPIPass__" => $pa_config->{'console_api_pass'}, + "__consoleUser__" => $pa_config->{'console_user'}, + "__consolePass__" => $pa_config->{'console_pass'}, + "__pandoraServerConf__" => $pa_config->{'pandora_path'}, get_recon_app_macros($pa_config, $dbh, $task), get_recon_script_macros($pa_config, $dbh, $task) ); @@ -654,7 +655,11 @@ sub get_recon_macro_value($$$$) { } # Name of the group if it exists. Empty otherwise. elsif ($type eq 'agent_groups') { - my $group_name = get_group_name($dbh, $value); + my $group_name = ''; + if ($value > 0) { + $group_name = get_group_name($dbh, $value); + } + if (defined($group_name)) { $ret = $group_name; } @@ -2227,6 +2232,7 @@ sub PandoraFMS::Recon::Base::connect_agents($$$$$;$) { # data = [ # 'agent_data' => {}, # 'module_data' => [] +# 'inventory_data' => [] # ] ################################################################################ sub PandoraFMS::Recon::Base::create_agents($$) { @@ -2240,7 +2246,8 @@ sub PandoraFMS::Recon::Base::create_agents($$) { foreach my $information (@{$data}) { my $agent = $information->{'agent_data'}; - my $modules = $information->{'module_data'}; + my $modules = defined($information->{'module_data'}) ? $information->{'module_data'} : []; + my $inventory = defined($information->{'inventory_data'}) ? $information->{'inventory_data'} : []; my $force_processing = 0; # Search agent @@ -2249,7 +2256,9 @@ sub PandoraFMS::Recon::Base::create_agents($$) { ); my $parent_id; - if (defined($agent->{'parent_agent_name'})) { + if (defined($agent->{'id_parent'})) { + $parent_id = $agent->{'id_parent'}; + } elsif (defined($agent->{'parent_agent_name'})) { $parent_id = PandoraFMS::Core::locate_agent( $pa_config, $dbh, $agent->{'parent_agent_name'} ); @@ -2259,7 +2268,7 @@ sub PandoraFMS::Recon::Base::create_agents($$) { } my $agent_id; - my $os_id = get_os_id($dbh, $agent->{'os'}); + my $os_id = defined($agent->{'id_os'}) ? $agent->{'id_os'} : get_os_id($dbh, $agent->{'os'}); if ($os_id < 0) { $os_id = get_os_id($dbh, 'Other'); @@ -2322,8 +2331,20 @@ sub PandoraFMS::Recon::Base::create_agents($$) { ); } } - } + # Add inventory data. + if (ref($inventory) eq "HASH") { + PandoraFMS::Core::process_inventory_data ( + $pa_config, + $inventory, + 0, # Does not seem to be used. + $agent->{'agent_name'}, + $agent->{'interval'}, + strftime ("%Y/%m/%d %H:%M:%S", localtime()), + $dbh + ); + } + } } ################################################################################ diff --git a/pandora_server/lib/PandoraFMS/InventoryServer.pm b/pandora_server/lib/PandoraFMS/InventoryServer.pm index 5f0f90e95d..e6b070f4d8 100644 --- a/pandora_server/lib/PandoraFMS/InventoryServer.pm +++ b/pandora_server/lib/PandoraFMS/InventoryServer.pm @@ -181,17 +181,21 @@ sub data_consumer ($$) { AND tagent_module_inventory.id_module_inventory = tmodule_inventory.id_module_inventory', $module_id); - # No code to run - return if ($module->{'interpreter'} eq ''); - - # Save script in a temporary file + my $command; my ($fh, $temp_file) = tempfile(); - $fh->print (decode_base64($module->{'code'})); - close ($fh); - set_file_permissions($pa_config, $temp_file, "0777"); - # Run the script - my $command = $module->{'interpreter'} . ' ' . $temp_file . ' "' . $module->{'target'} . '"'; + if ($module->{'script_mode'} == '1') { + my $script_file = $module->{'script_path'}; + $command = $module->{'interpreter'} . ' ' . $script_file . ' "' . $module->{'target'} . '"'; + } else { + # Save script in a temporary file + $fh->print (decode_base64($module->{'code'})); + close ($fh); + set_file_permissions($pa_config, $temp_file, "0777"); + + # Run the script + $command = $module->{'interpreter'} . ' ' . $temp_file . ' "' . $module->{'target'} . '"'; + } # Try to read the custom fields to use them as arguments into the command if (defined($module->{'custom_fields'}) && $module->{'custom_fields'} ne '') { @@ -206,7 +210,11 @@ sub data_consumer ($$) { if (!defined ($decoded_cfields)) { logger ($pa_config, "Remote inventory module ".$module->{'name'}." has failed because the custom fields can't be read", 6); - unlink ($temp_file); + + if ($module->{'script_mode'} == '2') { + unlink ($temp_file); + } + return; } @@ -237,11 +245,18 @@ sub data_consumer ($$) { # Check for errors if ($? != 0) { logger ($pa_config, "Remote inventory module ".$module->{'name'}." has failed with error level $?", 6); - unlink ($temp_file); + + if ($module->{'script_mode'} == '2') { + unlink ($temp_file); + } + return; } - unlink ($temp_file); + if ($module->{'script_mode'} == '2') { + unlink ($temp_file); + } + my $utimestamp = time (); my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp)); eval { diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index d26ad54312..a9d7a94574 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -33,8 +33,8 @@ use base 'Exporter'; our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only -my $pandora_version = "7.0NG.773.3"; -my $pandora_build = "231023"; +my $pandora_version = "7.0NG.774"; +my $pandora_build = "231205"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 4af9292467..580344542c 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -79,6 +79,7 @@ our @EXPORT = qw( NCMSERVER NETFLOWSERVER LOGSERVER + MADESERVER METACONSOLE_LICENSE OFFLINE_LICENSE DISCOVERY_HOSTDEVICES @@ -180,6 +181,7 @@ our @EXPORT = qw( check_cron_value check_cron_element cron_check + p_pretty_json ); # ID of the different servers @@ -209,6 +211,7 @@ use constant CORRELATIONSERVER => 22; # Deprecated. use constant NCMSERVER => 23; use constant NETFLOWSERVER => 24; use constant LOGSERVER => 25; +use constant MADESERVER => 26; # Module status use constant MODULE_NORMAL => 0; @@ -2733,12 +2736,6 @@ sub get_user_agent { # Disable verify host certificate (only needed for self-signed cert) $ua->ssl_opts( 'verify_hostname' => 0 ); $ua->ssl_opts( 'SSL_verify_mode' => 0x00 ); - - # Disable library extra checks - BEGIN { - $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "Net::SSL"; - $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; - } } }; if($@) { @@ -2976,10 +2973,23 @@ sub get_server_name { return "NCMSERVER" if ($server_type eq NCMSERVER); return "NETFLOWSERVER" if ($server_type eq NETFLOWSERVER); return "LOGSERVER" if ($server_type eq LOGSERVER); + return "MADESERVER" if ($server_type eq MADESERVER); return "UNKNOWN"; } +################################################################################ +# Pretty print json. +################################################################################ +sub p_pretty_json { + my ($data) = @_; + + # Initialize JSON manager. + my $j = JSON->new->utf8(1)->pretty(1)->indent(1); + my $output = $j->encode($data); + + return $output; +} 1; __END__ diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 3044d2cba6..ea580fdac8 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -6,8 +6,8 @@ %define __strip /bin/true %define debug_package %{nil} %define name pandorafms_server -%define version 7.0NG.773.3 -%define release 231023 +%define version 7.0NG.774 +%define release 231205 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 6ac371b853..2ce48dd7cb 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,8 +3,8 @@ # %global __os_install_post %{nil} %define name pandorafms_server -%define version 7.0NG.773.3 -%define release 231023 +%define version 7.0NG.774 +%define release 231205 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 4bec5edfc5..28cf2f6746 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -8,8 +8,8 @@ # This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.773.3" -PI_BUILD="231023" +PI_VERSION="7.0NG.774" +PI_BUILD="231205" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 2272222299..5b16684570 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -26,6 +26,9 @@ use POSIX qw(strftime); use File::Path qw(rmtree); use Time::HiRes qw(usleep); +use List::Util qw(min); +use List::Util qw(sum); + # Default lib dir for RPM and DEB packages BEGIN { push @INC, '/usr/lib/perl5'; } @@ -35,7 +38,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.773.3 Build 231023"; +my $version = "7.0NG.774 Build 231205"; # Pandora server configuration my %conf; @@ -139,10 +142,18 @@ sub pandora_purgedb ($$$) { # Delete manually disabled agents after some period if (defined ($conf->{'_delete_disabled_agents'}) && $conf->{'_delete_disabled_agents'} > 0) { log_message('PURGE', "Deleting old disabled agents (More than " . $conf->{'_delete_disabled_agents'} . " days)."); - db_do ($dbh, "DELETE FROM tagente - WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW()) - AND disabled = 1 - AND modo != 2", $conf->{'_delete_disabled_agents'} * 8600); + my @agents_to_delete = get_db_rows ( + $dbh, + "SELECT id_agente FROM tagente + WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW()) + AND disabled = 1 + AND modo != 2", + $conf->{'_delete_disabled_agents'} * 8600 + ); + + foreach my $agent_to_delete (@agents_to_delete) { + pandora_delete_agent($dbh, $agent_to_delete->{'id_agente'}, $conf); + } } # Delete old data @@ -276,25 +287,7 @@ sub pandora_purgedb ($$$) { log_message ('PURGE', "Deleting old access data (More than 24hr)"); - $first_mark = get_db_value_limit ($dbh, 'SELECT utimestamp FROM tagent_access ORDER BY utimestamp ASC', 1); - if (defined ($first_mark)) { - $total_time = $ulimit_access_timestamp - $first_mark; - $purge_steps = int( $total_time / $BIG_OPERATION_STEP); - if ($purge_steps > 0) { - for (my $ax = 1; $ax <= $BIG_OPERATION_STEP; $ax++){ - db_do ($dbh, "DELETE FROM tagent_access WHERE utimestamp < ". ( $first_mark + ($purge_steps * $ax)) . " AND utimestamp >= ". $first_mark); - log_message ('PURGE', "Agent access deletion progress %$ax", "\r"); - # Do a nanosleep here for 0,01 sec - usleep (10000); - } - log_message ('', "\n"); - } else { - log_message ('PURGE', "No agent access data to purge."); - } - } else { - log_message ('PURGE', "No agent access data."); - } - + # Purge the reports if (defined($conf->{'_enterprise_installed'}) && $conf->{'_enterprise_installed'} eq '1' && defined($conf->{'_metaconsole'}) && $conf->{'_metaconsole'} eq '1'){ @@ -337,14 +330,22 @@ sub pandora_purgedb ($$$) { AND id_rc NOT IN (SELECT id_report_content FROM treport_content_sla_combined)"); } - - # Delete disabled autodisable agents after some period - log_message ('PURGE', 'Delete autodisabled agents where last contact is bigger than ' . $conf->{'_days_autodisable_deletion'} . ' days.'); - db_do ($dbh, "DELETE FROM tagente - WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW()) - AND disabled=1 - AND modo=2", $conf->{'_days_autodisable_deletion'}*8600); - + # Delete disabled autodisable agents after some period + if (defined ($conf->{'_days_autodisable_deletion'}) && $conf->{'_days_autodisable_deletion'} > 0) { + log_message ('PURGE', 'Delete autodisabled agents where last contact is bigger than ' . $conf->{'_days_autodisable_deletion'} . ' days.'); + my @agents_autodisable_to_delete = get_db_rows ( + $dbh, + "SELECT id_agente FROM tagente + WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW()) + AND disabled = 1 + AND modo = 2", + $conf->{'_days_autodisable_deletion'} * 8600 + ); + + foreach my $agent_autodisable_to_delete (@agents_autodisable_to_delete) { + pandora_delete_agent($dbh, $agent_autodisable_to_delete->{'id_agente'}, $conf); + } + } # Delete old netflow data if (!defined($conf->{'_netflow_max_lifetime'})){ @@ -443,116 +444,187 @@ sub pandora_purgedb ($$$) { ############################################################################### # Compact agent data. ############################################################################### -sub pandora_compactdb ($$$) { - my ($conf, $dbh, $dbh_conf) = @_; +sub pandora_compactdb { + my ($conf, $dbh, $dbh_conf) = @_; + + my $total_modules = get_db_value($dbh, "SELECT COUNT(id_agente_modulo) FROM tagente_modulo"); + + # Interval in hours to compact. + my $compaction_interval = 24; + my $compaction_factor = (3600 * $compaction_interval) / 300; + + # Number of agents to be proceced on this execution + my $agents_limit = int($total_modules / $compaction_factor); + + my $last_compact_offset = pandora_get_config_value($dbh, "last_compact_offset"); + + if ($last_compact_offset eq "") { + db_do($dbh, "INSERT INTO tconfig (token, value) VALUES ('last_compact_offset', '0')"); + $last_compact_offset = 0; + } + + # Obtain a group of modules to compact. + my @module_groups = get_db_rows( + $dbh, + 'SELECT id_agente_modulo, id_tipo_modulo, UNIX_TIMESTAMP(last_compact) as last_compact FROM tagente_modulo WHERE id_agente_modulo > ? LIMIT ?', + $last_compact_offset, + $agents_limit + ); + + # Compact the group of modules. + my $starting_time = time(); + pandora_compact_modules($dbh, $conf, @module_groups); + my $ending_time = time(); + log_message('COMPACT', "Time taken: " . ($ending_time - $starting_time) . " seconds."); + + # Add the offset. + $last_compact_offset += $agents_limit; + + # If the offset is higher than the max module start again + $last_compact_offset = 0 if ($last_compact_offset >= $total_modules); + + # Save the new offset + db_do($dbh, "UPDATE tconfig SET value = ? WHERE token = 'last_compact_offset'", $last_compact_offset); +} + +sub pandora_compact_modules { + my ($dbh, $conf, @module_groups) = @_; + + # Obtain the minimun last compact from the block + my $min_compact = min(map { $_->{"last_compact"} } @module_groups); + + # if the min has not been setted + if($min_compact == 0){ + $min_compact = get_db_value( + $dbh, + 'SELECT MIN(td.utimestamp) + FROM tagente_datos td, tagente_modulo tm + WHERE td.id_agente_modulo = tm.id_agente_modulo + AND tm.id_tipo_modulo not in (2, 6, 9, 18, 21, 31, 35, 100) + AND td.id_agente_modulo BETWEEN ? AND ?', + $module_groups[0]->{"id_agente_modulo"}, $module_groups[-1]->{"id_agente_modulo"} + ); + } + + # One week of data of data as max from the last min compact. + my $max_compact = $min_compact + (60 * 60 * 24 * 7); + + # If the last compact is on the future set the current time as max. + $max_compact = time() if($max_compact > time()); + + log_message('COMPACT', "Compacting data of agents agents $module_groups[0]->{'id_agente_modulo'} to $module_groups[-1]->{'id_agente_modulo'}, data between " . strftime('%Y-%m-%d %H:%M:%S', localtime($min_compact)) . " and " . strftime('%Y-%m-%d %H:%M:%S', localtime($max_compact))); + + # Obtain all the data from the interval to avoid multiple requests + # Avoid pull data from modules that should be skipped. + my @data = get_db_rows ( + $dbh, + 'SELECT td.id_agente_modulo, td.datos, td.utimestamp + FROM tagente_datos td, tagente_modulo tm + WHERE td.id_agente_modulo = tm.id_agente_modulo + AND tm.id_tipo_modulo not in (2, 6, 9, 18, 21, 31, 35, 100) + AND td.utimestamp < ? AND td.utimestamp >= ? + AND td.id_agente_modulo BETWEEN ? AND ? + ', + $max_compact, $min_compact, $module_groups[0]->{"id_agente_modulo"}, $module_groups[-1]->{"id_agente_modulo"} + ); + + my $total_data = scalar(@data); + my $proceced_total_data = 0; + my $progress = 0; + my $compactations = 0; - my %count_hash; - my %id_agent_hash; - my %value_hash; - my %module_proc_hash; - - return if ($conf->{'_days_compact'} == 0 || $conf->{'_step_compact'} < 1); - # Convert compact interval length from hours to seconds my $step = $conf->{'_step_compact'} * 3600; - # The oldest timestamp will be the lower limit - my $limit_utime = get_db_value ($dbh, 'SELECT min(utimestamp) as min FROM tagente_datos'); - return unless (defined ($limit_utime) && $limit_utime > 0); + # Max. 168 steps or 7 days in one hour steps. + # This avoids blocking of old modules without last compact + my $step_limit = 24 * 7; - # Calculate the start date - my $start_utime = time() - $conf->{'_days_compact'} * 24 * 60 * 60; - my $last_compact = $start_utime; - my $stop_utime; + # Compact the modules in this block + foreach my $module (@module_groups) { + $progress = $total_data == 0 ? 0 : ($proceced_total_data / $total_data) * 100; + printf(strftime("\r" . "%H:%M:%S", localtime()) . ' [COMPACT] ' . "Progress: %.2f%%", $progress); + + my $id = $module->{"id_agente_modulo"}; + my $module_type = $module->{"id_tipo_modulo"}; - # Do not compact the same data twice! - if (defined ($conf->{'_last_compact'}) && $conf->{'_last_compact'} > $limit_utime) { - $limit_utime = $conf->{'_last_compact'}; - } - - if ($start_utime <= $limit_utime || ( defined ($conf->{'_last_compact'}) && (($conf->{'_last_compact'} + 24 * 60 * 60) > $start_utime))) { - log_message ('COMPACT', "Data already compacted."); - return; - } - - log_message ('COMPACT', "Compacting data from " . strftime ("%Y-%m-%d %H:%M:%S", localtime($limit_utime)) . " to " . strftime ("%Y-%m-%d %H:%M:%S", localtime($start_utime)) . '.', ''); + next unless defined ($module_type); + next if ($module_type == 2 || $module_type == 6 || $module_type == 9 || $module_type == 18 || $module_type == 21 || $module_type == 31 || $module_type == 35 || $module_type == 100); - # Prepare the query to retrieve data from an interval - while (1) { + # Obtain the data just for this module + my @module_data = grep { $_->{"id_agente_modulo"} == $id } @data; + my $total_elements = scalar(@module_data); - # Calculate the stop date for the interval - $stop_utime = $start_utime - $step; + # No data for this module. + next if ($total_elements == 0); - # Out of limits - last if ($start_utime < $limit_utime); + # Obtain the last compact of this module to avoid compact something previously compacted + my $last_compact = $module ->{"last_compact"}; - # Mark the progress - log_message ('', "."); + # In case that the last compact has not been defined take the minimun data as last compact + $last_compact = min(map { $_->{"utimestamp"} } @module_data)-1 if($last_compact == 0); + + # Create an array to store INSERT commands + my @insert_commands; + my $insert_command = 'INSERT INTO tagente_datos (id_agente_modulo, datos, utimestamp) VALUES (?, ?, ?)'; + + my $step_number = 0; + my $first_compact = $last_compact; + + # Compact using the steps + while($step_number < $step_limit){ + + my $next_compact = $last_compact + $step; - my @data = get_db_rows ($dbh, 'SELECT * FROM tagente_datos WHERE utimestamp < ? AND utimestamp >= ?', $start_utime, $stop_utime); - # No data, move to the next interval - if ($#data == 0) { - $start_utime = $stop_utime; + last if($next_compact > time()); + + # Obtain the data between the last compact and the next step. + my @data_in_range = grep { $_->{"utimestamp"} > $last_compact && $_->{"utimestamp"} <= $next_compact } @module_data; + + my $total_range_elements = scalar(@data_in_range); + + # Nothing to compress, skip this step. + if($total_range_elements == 0){ + $last_compact = $next_compact; next; } - # Get interval data - foreach my $data (@data) { - my $id_module = $data->{'id_agente_modulo'}; - if (! defined($module_proc_hash{$id_module})) { - my $module_type = get_db_value ($dbh, 'SELECT id_tipo_modulo FROM tagente_modulo WHERE id_agente_modulo = ?', $id_module); - next unless defined ($module_type); + my $total_data = sum(map { $_->{"datos"} } @data_in_range); - # Mark proc modules. - if ($module_type == 2 || $module_type == 6 || $module_type == 9 || $module_type == 18 || $module_type == 21 || $module_type == 31 || $module_type == 35 || $module_type == 100) { - $module_proc_hash{$id_module} = 1; - } - else { - $module_proc_hash{$id_module} = 0; - } - } + my $avg = $total_data / $total_range_elements; - # Skip proc modules! - next if ($module_proc_hash{$id_module} == 1); + $proceced_total_data += $total_range_elements; + + push @insert_commands, [$insert_command, $id, $avg, int($last_compact + ($step / 2))]; - if (! defined($value_hash{$id_module})) { - $value_hash{$id_module} = 0; - $count_hash{$id_module} = 0; + $last_compact = $next_compact; + + $step_number +=1; + # Small sleep to don't burn the DB + usleep (1000); + + } - if (! defined($id_agent_hash{$id_module})) { - $id_agent_hash{$id_module} = $data->{'id_agente'}; - } - } + $dbh->begin_work; - $value_hash{$id_module} += $data->{'datos'}; - $count_hash{$id_module}++; - } + db_do ($dbh, 'DELETE FROM tagente_datos WHERE utimestamp > ? AND utimestamp <= ? AND id_agente_modulo = ?', $first_compact, $last_compact, $id); - # Delete interval from the database - db_do ($dbh, 'DELETE ad FROM tagente_datos ad - INNER JOIN tagente_modulo am ON ad.id_agente_modulo = am.id_agente_modulo AND am.id_tipo_modulo NOT IN (2,6,9,18,21,31,35,100) - WHERE ad.utimestamp < ? AND ad.utimestamp >= ?', $start_utime, $stop_utime); + # Execute the INSERT commands + foreach my $command (@insert_commands) { + my ($sql, @params) = @$command; + db_do($dbh, $sql, @params); + } - # Insert interval average value - foreach my $key (keys(%value_hash)) { - $value_hash{$key} /= $count_hash{$key}; - db_do ($dbh, 'INSERT INTO tagente_datos (id_agente_modulo, datos, utimestamp) VALUES (?, ?, ?)', $key, $value_hash{$key}, $stop_utime); - delete($value_hash{$key}); - delete($count_hash{$key}); - } - - usleep (1000); # Very small usleep, just to don't burn the DB - # Move to the next interval - $start_utime = $stop_utime; + $dbh->commit; + # Update the last compacted timestamp. + db_do($dbh, "UPDATE tagente_modulo SET last_compact = FROM_UNIXTIME(?) WHERE id_agente_modulo = ?", $last_compact, $module ->{"id_agente_modulo"}); + $compactations += $step_number; } - log_message ('', "\n"); - # Mark the last compact date - if (defined ($conf->{'_last_compact'})) { - db_do ($dbh_conf, 'UPDATE tconfig SET value=? WHERE token=?', $last_compact, 'last_compact'); - } else { - db_do ($dbh_conf, 'INSERT INTO tconfig (value, token) VALUES (?, ?)', $last_compact, 'last_compact'); - } + printf(strftime("\r" . "%H:%M:%S", localtime()) . ' [COMPACT] ' . "Progress: %.2f%%", 100); + print("\n"); + log_message('COMPACT', "A total of $proceced_total_data elements has been compacted into $compactations elements"); + } ######################################################################## @@ -1234,9 +1306,8 @@ sub pandoradb_main { # Only active database should be compacted. Disabled for historical database. # Compact on if enable and DaysCompact are below DaysPurge if (($conf->{'_onlypurge'} == 0) - && ($conf->{'_days_compact'} < $conf->{'_days_purge'}) ) { - pandora_compactdb ($conf, defined ($history_dbh) ? $history_dbh : $dbh, $dbh); + pandora_compactdb ($conf, $dbh, $dbh); } # Update tconfig with last time of database maintance time (now) diff --git a/pandora_server/util/pandora_ha.pl b/pandora_server/util/pandora_ha.pl index 941b6dc854..23bc79189a 100755 --- a/pandora_server/util/pandora_ha.pl +++ b/pandora_server/util/pandora_ha.pl @@ -168,6 +168,7 @@ sub ha_load_pandora_conf($) { $conf->{'pandora_service_cmd'} = 'service pandora_server' unless defined($conf->{'pandora_service_cmd'}); $conf->{'tentacle_service_cmd'} = 'service tentacle_serverd' unless defined ($conf->{'tentacle_service_cmd'}); $conf->{'tentacle_service_watchdog'} = 1 unless defined ($conf->{'tentacle_service_watchdog'}); + $conf->{'made_service_cmd'} = 'service pandora_made' unless defined($conf->{'made_service_cmd'}); } ############################################################################## @@ -257,6 +258,31 @@ sub ha_keep_pandora_running($$) { } } +############################################################################## +# Keep MADE running +############################################################################## +sub ha_keep_made_running($$) { + my ($conf, $dbh) = @_; + + # Is MADE enabled? + return unless (defined($conf->{'madeserver'}) && $conf->{'madeserver'} == 1); + + # Is MADE installed? + `$conf->{'made_service_cmd'} status 2>/dev/null`; + if (($? >> 8) == 4) { + log_message($conf, 'LOG', "Pandora FMS MADE is not installed."); + return; + } + + # Try to get the PID of the service. + my $pid = `systemctl show --property MainPID pandora_made | cut -d= -f2`; + chomp($pid); + if ($pid eq "0") { + log_message($conf, 'LOG', 'MADE service not running.'); + `$conf->{'made_service_cmd'} start 2>/dev/null`; + } +} + ############################################################################## # Keep the Tentacle server running ############################################################################## @@ -535,6 +561,9 @@ sub ha_main_pacemaker($) { # Keep Tentacle running ha_keep_tentacle_running($conf, $dbh); + # Keep MADE running + ha_keep_made_running($conf, $dbh); + # Are we the master? pandora_set_master($conf, $dbh); if (!pandora_is_master($conf)) { @@ -627,6 +656,9 @@ sub ha_main_pandora($) { # Keep Tentacle running ha_keep_tentacle_running($conf, $dbh); + # Keep MADE running + ha_keep_made_running($conf, $dbh); + # Are we the master? pandora_set_master($conf, $dbh); if (!pandora_is_master($conf)) { diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 7bedc825b3..f1d150756b 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.773.3 Build 231023"; +my $version = "7.0NG.774 Build 231205"; # save program name for logging my $progname = basename($0); @@ -201,6 +201,7 @@ sub help_screen{ help_screen_line('--disable_double_auth', '', 'Disable the double authentication for the specified user'); print "\nEVENTS:\n\n" unless $param ne ''; help_screen_line('--create_event', " [ \n\t \n\t \n\t ]", 'Add event'); + help_screen_line('--update_event_custom_id', " ", 'Update Event Custom ID'); help_screen_line('--validate_event', " \n\t []", 'Validate events'); help_screen_line('--validate_event_id', '', 'Validate event given a event id'); help_screen_line('--get_event_info', '[]', 'Show info about a event given a event id'); @@ -4549,6 +4550,17 @@ sub cli_create_event() { } } +############################################################################## +# Update event custom id +# Related option: --update_event_custom_id +############################################################################## + +sub cli_update_event_custom_id() { + my ($id_event, $event_custom_id) = @ARGV[2..3]; + my $result = api_call(\%conf, 'set', 'event_custom_id', $id_event, $event_custom_id); + print "\n$result\n"; +} + ############################################################################## # Validate event. # Related option: --validate_event @@ -8335,6 +8347,10 @@ sub pandora_manage_main ($$$) { param_check($ltotal, 4, 0); cli_insert_gis_data(); } + elsif ($param eq '--update_event_custom_id'){ + param_check($ltotal, 2); + cli_update_event_custom_id(); + } else { print_log "[ERROR] Invalid option '$param'.\n\n"; $param = ''; diff --git a/pandora_server/util/pandora_perf_report.pl b/pandora_server/util/pandora_perf_report.pl index cbc11219c7..cdad51d9ab 100644 --- a/pandora_server/util/pandora_perf_report.pl +++ b/pandora_server/util/pandora_perf_report.pl @@ -212,7 +212,6 @@ sub stress_agent { sub table_stats { my ($dbh, $conf) = @_; my $stats = { - tagent_access => 'N/A', tagente => 'N/A', tagente_datos => 'N/A', tagente_datos_string => 'N/A', @@ -225,8 +224,7 @@ sub table_stats { FROM information_schema.TABLES WHERE TABLE_SCHEMA=? AND TABLE_NAME IN (?, ?, ?, ?, ?, ?, ?)", - $conf->{'dbname'}, - 'tagent_access', + $conf->{'dbname'},, 'tagente', 'tagente_datos', 'tagente_datos_string', @@ -309,7 +307,6 @@ sub generate_optimized_my_cnf { sub table_comments { my ($stats) = @_; my $comments = { - tagent_access => 'OK', tagente => 'OK', tagente_datos => 'OK', tagente_datos_string => 'OK', @@ -319,12 +316,6 @@ sub table_comments { tsesion => 'OK', }; - if ($stats->{'tagent_access'} > $stats->{'tagente'} * 24 * 250) { - $comments->{'tagent_access'} = 'CRITICAL: Table too big. Please contact our support team at: support@artica.es'; - } elsif ($stats->{'tagent_access'} > $stats->{'tagente'} * 24 * 100) { - $comments->{'tagent_access'} = 'WARNING: Table too big. Please contact our support team at: support@artica.es'; - } - if ($stats->{'tagente_datos'} > 5000000) { $comments->{'tagente_datos'} = 'CRITICAL: Table too big. Please use a history database or decrease the purge period.'; } elsif ($stats->{'tagente_datos'} > 1000000) { @@ -474,7 +465,6 @@ Module table $table_stats->{'tagente_modulo'} $tab Data table $table_stats->{'tagente_datos'} $table_comments->{'tagente_datos'} String data table $table_stats->{'tagente_datos_string'} $table_comments->{'tagente_datos_string'} Event table $table_stats->{'tevento'} $table_comments->{'tevento'} -Access stats $table_stats->{'tagent_access'} $table_comments->{'tagent_access'} Audit information $table_stats->{'tsesion'} $table_comments->{'tsesion'} diff --git a/tests/console/Views.py b/tests/console/Views.py index b4ad48134e..f4967e3db7 100644 --- a/tests/console/Views.py +++ b/tests/console/Views.py @@ -305,7 +305,7 @@ class viewAppear(PandoraWebDriverTestCase): click_menu_element(driver,"CSV import") time.sleep(2) self.assertEqual("Upload file" in driver.page_source,True) - click_menu_element(driver,"CSV import group") + click_menu_element(driver,"Import groups with CSV file") time.sleep(2) self.assertEqual("Upload file" in driver.page_source,True) click_menu_element(driver,"IPAM")