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/.gitattributes b/extras/pandora_gotty/.gitattributes new file mode 100644 index 0000000000..ca0a55fe2e --- /dev/null +++ b/extras/pandora_gotty/.gitattributes @@ -0,0 +1 @@ +src/pandora_gotty filter=lfs diff=lfs merge=lfs -text diff --git a/extras/pandora_gotty/.gitignore b/extras/pandora_gotty/.gitignore new file mode 100644 index 0000000000..db388678f7 --- /dev/null +++ b/extras/pandora_gotty/.gitignore @@ -0,0 +1,2 @@ +*.rpm +*.deb \ No newline at end of file diff --git a/extras/pandora_gotty/Dockerfile-RPM b/extras/pandora_gotty/Dockerfile-RPM new file mode 100644 index 0000000000..f708a6f4a7 --- /dev/null +++ b/extras/pandora_gotty/Dockerfile-RPM @@ -0,0 +1,8 @@ +FROM rockylinux:8 + +RUN dnf install -y rpm-build rpmdevtools +RUN rpmdev-setuptree +RUN mkdir /root/pandora_gotty +WORKDIR /root/pandora_gotty + +#CMD bash build.sh diff --git a/extras/pandora_gotty/Dockerfile-deb b/extras/pandora_gotty/Dockerfile-deb new file mode 100644 index 0000000000..02a30a43d3 --- /dev/null +++ b/extras/pandora_gotty/Dockerfile-deb @@ -0,0 +1,6 @@ +FROM ubuntu:22.04 + +RUN apt-get update +RUN apt-get install -y dh-make debhelper build-essential +RUN mkdir /root/pandora_gotty +WORKDIR /root/pandora_gotty \ No newline at end of file diff --git a/extras/pandora_gotty/README.md b/extras/pandora_gotty/README.md new file mode 100644 index 0000000000..c31e228c46 --- /dev/null +++ b/extras/pandora_gotty/README.md @@ -0,0 +1 @@ +To create the .deb and .rpm package need to hace docker installed on main system and execit `build_all_docker.sh` diff --git a/extras/pandora_gotty/build_all_docker.sh b/extras/pandora_gotty/build_all_docker.sh new file mode 100755 index 0000000000..cb280999ba --- /dev/null +++ b/extras/pandora_gotty/build_all_docker.sh @@ -0,0 +1,11 @@ +#Build RPM +docker build -t pandora_gotty_builder_rpm -f Dockerfile-RPM . || exit 1 +docker run --rm -it -v `pwd`:/root/pandora_gotty pandora_gotty_builder_rpm /root/pandora_gotty/build_rpm.sh || exit 1 + +#Buikd DEB +docker build -t pandora_gotty_builder_deb -f Dockerfile-deb . || exit 1 +docker run --rm -it -v `pwd`:/root/pandora_gotty pandora_gotty_builder_deb /root/pandora_gotty/build_deb.sh || exit 1 + +echo " - Done" +pwd +ls -l | grep -E "(\.deb|\.rpm)" \ No newline at end of file diff --git a/extras/pandora_gotty/build_deb.sh b/extras/pandora_gotty/build_deb.sh new file mode 100755 index 0000000000..fbcb2a6790 --- /dev/null +++ b/extras/pandora_gotty/build_deb.sh @@ -0,0 +1,17 @@ +#!/bin/bash +#DEB +cd deb +VERSION=$(grep 'Version:' pandora_gotty/DEBIAN/control | awk '{print $2}') +mkdir -p pandora_gotty/usr/bin +mkdir -p pandora_gotty/etc/pandora_gotty +cp -a ../src/pandora_gotty pandora_gotty/usr/bin +cp -a ../src/pandora_gotty.conf pandora_gotty/etc/pandora_gotty +curl -SsL --output pandora_gotty/usr/bin/pandora_gotty_exec http://192.168.50.31/installers/installers/Linux/x86_64/pandora_gotty_exec +chmod +x pandora_gotty/usr/bin/pandora_gotty_exec +dpkg-deb --build pandora_gotty +mv pandora_gotty.deb ../ +rm -rf pandora_gotty/usr/ +rm -rf pandora_gotty/etc/ +cd .. +mv pandora_gotty.deb pandora_gotty_${VERSION}.deb +chmod 777 pandora_gotty_${VERSION}.deb diff --git a/extras/pandora_gotty/build_rpm.sh b/extras/pandora_gotty/build_rpm.sh new file mode 100755 index 0000000000..e08fa0e65b --- /dev/null +++ b/extras/pandora_gotty/build_rpm.sh @@ -0,0 +1,15 @@ +#!/bin/bash +#RPM +VERSION=$(grep '%define version' pandora_gotty.spec | awk '{print $3}') +mkdir -p pandora_gotty-${VERSION} +cp src/pandora_gotty pandora_gotty-${VERSION}/ +cp src/pandora_gotty.conf pandora_gotty-${VERSION}/ +curl -SsL --output pandora_gotty-${VERSION}/pandora_gotty_exec http://192.168.50.31/installers/installers/Linux/x86_64/pandora_gotty_exec +chmod +x pandora_gotty-${VERSION}/pandora_gotty_exec +tar -cvzf pandora_gotty-${VERSION}.tar.gz pandora_gotty-${VERSION}/* +mv pandora_gotty-${VERSION}.tar.gz ${HOME}/rpmbuild/SOURCES/ +rm -rf ${HOME}/rpmbuild/RPMS/x86_64/pandora_gotty* +rpmbuild -ba pandora_gotty.spec +rm -rf pandora_gotty-${VERSION} +mv ${HOME}/rpmbuild/RPMS/x86_64/pandora_gotty* . +chmod 777 *.rpm \ No newline at end of file diff --git a/extras/pandora_gotty/deb/.gitignore b/extras/pandora_gotty/deb/.gitignore new file mode 100644 index 0000000000..92a9f94179 --- /dev/null +++ b/extras/pandora_gotty/deb/.gitignore @@ -0,0 +1,3 @@ +*.deb +**/usr +**/etc diff --git a/extras/pandora_gotty/deb/pandora_gotty/DEBIAN/changelog b/extras/pandora_gotty/deb/pandora_gotty/DEBIAN/changelog new file mode 100644 index 0000000000..5d7e7f2ab6 --- /dev/null +++ b/extras/pandora_gotty/deb/pandora_gotty/DEBIAN/changelog @@ -0,0 +1,5 @@ +pandora_gotty (1.0-1) stable; urgency=low + + * Initial release. + + -- PandoraFMS Mon, 18 Sep 2023 00:00:00 +0000 \ No newline at end of file diff --git a/extras/pandora_gotty/deb/pandora_gotty/DEBIAN/control b/extras/pandora_gotty/deb/pandora_gotty/DEBIAN/control new file mode 100644 index 0000000000..fda06b3e36 --- /dev/null +++ b/extras/pandora_gotty/deb/pandora_gotty/DEBIAN/control @@ -0,0 +1,9 @@ +Source: pandora_gotty +Section: utils +Version: 1.1.0 +Priority: optional +Maintainer: PandoraFMS +Build-Depends: debhelper (>= 12) +Package: pandora-gotty +Architecture: amd64 +Description: pandora_gotty for Pandora FMS. diff --git a/extras/pandora_gotty/pandora_gotty.spec b/extras/pandora_gotty/pandora_gotty.spec new file mode 100644 index 0000000000..d322fae653 --- /dev/null +++ b/extras/pandora_gotty/pandora_gotty.spec @@ -0,0 +1,41 @@ +%define name pandora_gotty +%define version 1.1 +%define release 1%{?dist} +Summary: pandora_gptty for Pandora FMS +Name: %{name} +Version: %{version} +Release: %{release} +License: GPL +Vendor: PandoraFMS +Source0: %{name}-%{version}.tar.gz +URL: https://pandorafms.com +Group: System/Monitoring +Packager: PandoraFMS +BuildArch: x86_64 +Provides: %{name}-%{version} + +%description +pandora_gotty for Pandora FMS. + +%prep +%setup -q + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT/%{_bindir} +mkdir -p %{buildroot}/etc/pandora_gotty/ +cp %{name} $RPM_BUILD_ROOT/%{_bindir} +cp pandora_gotty_exec $RPM_BUILD_ROOT/%{_bindir} +cp pandora_gotty.conf %{buildroot}/etc/pandora_gotty/ +%clean +rm -Rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root,-) +%config(noreplace) /etc/pandora_gotty/pandora_gotty.conf +%{_bindir}/%{name} +%{_bindir}/pandora_gotty_exec + +%changelog +* Mon Sep 18 2023 PandoraFMS - 1.0-1 +- Initial RPM release diff --git a/extras/pandora_gotty/src/.gitignore b/extras/pandora_gotty/src/.gitignore new file mode 100644 index 0000000000..a2acfc48bf --- /dev/null +++ b/extras/pandora_gotty/src/.gitignore @@ -0,0 +1,2 @@ +*rpm +bin/* diff --git a/extras/pandora_gotty/src/pandora_gotty b/extras/pandora_gotty/src/pandora_gotty new file mode 100755 index 0000000000..dc71d46eaf --- /dev/null +++ b/extras/pandora_gotty/src/pandora_gotty @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3758eddb64db79c6ea1dac4cb200ee8ec86ef3f51723dad5be4365a1315b952b +size 13642854 diff --git a/extras/pandora_gotty/src/pandora_gotty.conf b/extras/pandora_gotty/src/pandora_gotty.conf new file mode 100644 index 0000000000..09d54e64c0 --- /dev/null +++ b/extras/pandora_gotty/src/pandora_gotty.conf @@ -0,0 +1,29 @@ +//Pandora Gotty config file + +// [bool] Permit clients to write to the TTY +permit_write = true + +// [bool] Permit clients to send command line arguments in URL (e.g. http://example.com:8080/?arg=AAA&arg=BBB) +permit_arguments = true + +// [bool] Enable random URL generation +enable_random_url = true + +// [int] Default length of random strings appended to URL +// To enable random URL generation, set `true` to `enable_random_url` +random_url_length = 32 + +// [bool] Enable TLS/SSL +// enable_tls = false + +// [string] Default TLS certificate file path +// tls_crt_file = "~/.gotty.crt" + +// [string] Default TLS key file path +// tls_key_file = "~/.gotty.key" + +// [bool] Enable client certificate authentication +// enable_tls_client_auth = false + +// [string] Certificate file of CA for client certificates +// tls_ca_crt_file = "~/.gotty.ca.crt" \ No newline at end of file diff --git a/extras/pandora_gotty/src/pandora_gotty_exec.py b/extras/pandora_gotty/src/pandora_gotty_exec.py new file mode 100644 index 0000000000..2444d88363 --- /dev/null +++ b/extras/pandora_gotty/src/pandora_gotty_exec.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +__author__ = "PandoraFMS Team" +__copyright__ = "Copyright 2023, PandoraFMS" +#__credits__ = ["Rob Knight", "Peter Maxwell", "Gavin Huttley", "Matthew Wakefield"] +__maintainer__ = "Projects/QA department" +__status__ = "Prod" +__version__ = "1.0" + +import sys, argparse, signal, re, datetime, subprocess + +info= f""" +SSH and TELNET helper for pandora_gotty. +Version: {__version__} +""" + +parser = argparse.ArgumentParser(description= info, formatter_class=argparse.RawTextHelpFormatter) +parser.add_argument('exec_cmd', + help='Aplication to be executed, avalibles: ssh or telnet',type=str, choices=['ssh', 'telnet']) +parser.add_argument('address', + help='IP addres or dns name to connect', type=str, default="") +parser.add_argument('port', + help='Port to connect', type=int, default=23) +parser.add_argument('user', + help='Username, only requiered for ssh connection', type=str, default="", nargs='?') + +args = parser.parse_args() + +# Define a function to handle the SIGINT signal +def sigint_handler(signal, frame): + print ('\nInterrupted by user', file=sys.stderr) + sys.exit(0) +signal.signal(signal.SIGINT, sigint_handler) + +# Define a function to handle the SIGTERM signal +def sigterm_handler(signum, frame): + print("Received SIGTERM signal.", file=sys.stderr) + sys.exit(0) +signal.signal(signal.SIGTERM, sigterm_handler) + +# Functions +def is_valid_add(add:str): + # Regular expression to match an IP address + ip_pattern = r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$' + + # Regular expression to match a DNS name (domain name) + dns_pattern = r'^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$' + + if re.match(ip_pattern, add) or re.match(dns_pattern, add): + return True + else: + print(f"Error not valid address: {add}", file=sys.stderr) + return False + +def is_valid_username(username:str): + # Regular expression to match a valid Linux username + username_pattern = r'^[a-zA-Z_][a-zA-Z0-9_]{0,31}$' + if re.match(username_pattern, username) is not None: + return True + else: + print(f"Error not valid username: {username}", file=sys.stderr) + return False + +def exec_ssh (user:str, add:str, port:int): + # Previus checks + if is_valid_username(user) == False: + return False + if is_valid_add(add) == False: + return False + if port == 0 : + return False + + try: + print("> Starting SSH connection...") + ssh_command = f"ssh {user}@{add} -p {port}" + subprocess.run(ssh_command, shell=True, encoding='utf-8', text=True) + + except subprocess.CalledProcessError as e: + raise SystemExit(e) + return True + +def exec_telnet (add:str, port:int): + # Previus checks + if is_valid_add(add) == False: + return False + + try: + print("> Starting Telnet connection...") + ssh_command = f"telnet -E {add} {port}" + subprocess.run(ssh_command, shell=True, encoding='utf-8', text=True) + + except subprocess.CalledProcessError as e: + raise SystemExit(e) + return True + + +# Main +if __name__ == "__main__": + if args.exec_cmd == "ssh": + exec_ssh(args.user, args.address, args.port) + print ("> ssh session finished") + sys.exit(0) + + if args.exec_cmd == "telnet": + exec_telnet(args.address, args.port) + print ("> telnet session finished") + sys.exit(0) + + sys.exit(0) 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 0a3a48950c..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 @@ -300,3 +300,7 @@ module_plugin grep_log /var/log/syslog Syslog ssh #module_exec echo 5 #module_description Postcondition test module #module_end + +# This plugin runs several security checks in a Linux system + +#module_plugin pandora_security_check \ No newline at end of file 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 81808209d5..3c97c6e154 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-231010 +Version: 7.0NG.774-231201 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 7c985eda83..ca4c9222aa 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-231010" +pandora_version="7.0NG.774-231201" 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 + 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/log_server.svg b/pandora_console/images/log_server.svg new file mode 100644 index 0000000000..26f27c6ae9 --- /dev/null +++ b/pandora_console/images/log_server.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + 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/module_event_critical.png b/pandora_console/images/module_event_critical.png new file mode 100644 index 0000000000..d92fd2cf07 Binary files /dev/null and b/pandora_console/images/module_event_critical.png differ diff --git a/pandora_console/images/module_event_ok.png b/pandora_console/images/module_event_ok.png new file mode 100644 index 0000000000..d92fd2cf07 Binary files /dev/null and b/pandora_console/images/module_event_ok.png differ diff --git a/pandora_console/images/module_event_unknown.png b/pandora_console/images/module_event_unknown.png new file mode 100644 index 0000000000..d92fd2cf07 Binary files /dev/null and b/pandora_console/images/module_event_unknown.png differ diff --git a/pandora_console/images/module_event_warning.png b/pandora_console/images/module_event_warning.png new file mode 100644 index 0000000000..d92fd2cf07 Binary files /dev/null and b/pandora_console/images/module_event_warning.png differ diff --git a/pandora_console/images/status_check@svg.svg b/pandora_console/images/status_check@svg.svg new file mode 100644 index 0000000000..78e62ea848 --- /dev/null +++ b/pandora_console/images/status_check@svg.svg @@ -0,0 +1,26 @@ + + + AE320C3A-79E4-4E24-956A-B81125ACFA52@svg + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/status_error@svg.svg b/pandora_console/images/status_error@svg.svg new file mode 100644 index 0000000000..e6502bff7e --- /dev/null +++ b/pandora_console/images/status_error@svg.svg @@ -0,0 +1,26 @@ + + + CD9D3D2F-E199-427F-BC6C-532C8382EE45@svg + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/system_event.svg b/pandora_console/images/system_event.svg new file mode 100644 index 0000000000..41a9b2c0ec --- /dev/null +++ b/pandora_console/images/system_event.svg @@ -0,0 +1,15 @@ + + + F7C0551D-EEAD-4AA0-87B8-DE2D255390BB + + + + + + + + + + + + \ 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/custom_fields.php b/pandora_console/include/ajax/custom_fields.php index a403f77748..f247c2e51e 100644 --- a/pandora_console/include/ajax/custom_fields.php +++ b/pandora_console/include/ajax/custom_fields.php @@ -65,6 +65,7 @@ if (check_login()) { } } + if ($get_custom_fields_data) { $name_custom_fields = get_parameter('name_custom_fields', 0); $array_custom_fields_data = get_custom_fields_data($name_custom_fields); @@ -110,30 +111,51 @@ if (check_login()) { // Table temporary for save array in table // by order and search custom_field data. - $table_temporary = 'CREATE TEMPORARY TABLE temp_custom_fields ( - id_server int(10), - id_agent int(10), - name_custom_fields varchar(2048), - critical_count int, - warning_count int, - unknown_count int, - notinit_count int, - normal_count int, - total_count int, - `status` int(2), - KEY `data_index_temp_1` (`id_server`, `id_agent`) - )'; - db_process_sql($table_temporary); + if (is_metaconsole() === true) { + $table_temporary = 'CREATE TEMPORARY TABLE temp_custom_fields ( + id_server int(10), + id_agent int(10), + name_custom_fields varchar(2048), + critical_count int, + warning_count int, + unknown_count int, + notinit_count int, + normal_count int, + total_count int, + `status` int(2), + KEY `data_index_temp_1` (`id_server`, `id_agent`) + )'; + } else { + $table_temporary = 'CREATE TEMPORARY TABLE temp_custom_fields ( + id_agent int(10), + name_custom_fields varchar(2048), + critical_count int, + warning_count int, + unknown_count int, + notinit_count int, + normal_count int, + total_count int, + `status` int(2), + KEY `data_index_temp_1` ( `id_agent`) + )'; + } + + $resul_tab_temp = db_process_sql($table_temporary); // Insert values array in table temporary. $values_insert = []; foreach ($indexed_descriptions as $key => $value) { - $values_insert[] = '('.$value['id_server'].', '.$value['id_agente'].", '".$value['description']."', '".$value['critical_count']."', '".$value['warning_count']."', '".$value['unknown_count']."', '".$value['notinit_count']."', '".$value['normal_count']."', '".$value['total_count']."', ".$value['status'].')'; + if (is_metaconsole() === true) { + $values_insert[] = '('.$value['id_server'].', '.$value['id_agente'].", '".$value['description']."', '".$value['critical_count']."', '".$value['warning_count']."', '".$value['unknown_count']."', '".$value['notinit_count']."', '".$value['normal_count']."', '".$value['total_count']."', ".$value['status'].')'; + } else { + $values_insert[] = '('.$value['id_agente'].", '".$value['description']."', '".$value['critical_count']."', '".$value['warning_count']."', '".$value['unknown_count']."', '".$value['notinit_count']."', '".$value['normal_count']."', '".$value['total_count']."', ".$value['status'].')'; + } } $values_insert_implode = implode(',', $values_insert); $query_insert = 'INSERT INTO temp_custom_fields VALUES '.$values_insert_implode; - db_process_sql($query_insert); + + $result_temp = db_process_sql($query_insert); // Search table for alias, custom field data, server_name, direction. $search_query = ''; @@ -199,41 +221,17 @@ if (check_login()) { } // Query all fields result. - $query = sprintf( - 'SELECT - tma.id_agente, - tma.id_tagente, - tma.id_tmetaconsole_setup, - tma.alias, - tma.direccion, - tma.server_name, - temp.name_custom_fields, - temp.status - FROM tmetaconsole_agent tma - INNER JOIN temp_custom_fields temp - ON temp.id_agent = tma.id_tagente - AND temp.id_server = tma.id_tmetaconsole_setup - WHERE tma.disabled = 0 - %s - %s - %s - %s - LIMIT %d OFFSET %d - ', - $search_query, - $status_agent_search, - $status_module_search, - $order_by, - $length, - $start - ); - - $result = db_get_all_rows_sql($query); - - // Query count. - $query_count = sprintf( - 'SELECT - COUNT(tma.id_agente) AS `count` + if (is_metaconsole() === true) { + $query = sprintf( + 'SELECT + tma.id_agente, + tma.id_tagente, + tma.id_tmetaconsole_setup, + tma.alias, + tma.direccion, + tma.server_name, + temp.name_custom_fields, + temp.status FROM tmetaconsole_agent tma INNER JOIN temp_custom_fields temp ON temp.id_agent = tma.id_tagente @@ -242,16 +240,87 @@ if (check_login()) { %s %s %s + %s + LIMIT %d OFFSET %d ', - $search_query, - $status_agent_search, - $status_module_search - ); + $search_query, + $status_agent_search, + $status_module_search, + $order_by, + $length, + $start + ); + } else { + $query = sprintf( + 'SELECT + tma.id_agente, + tma.alias, + tma.direccion, + tma.server_name, + temp.name_custom_fields, + temp.status + FROM tagente as tma + INNER JOIN temp_custom_fields temp + ON temp.id_agent = tma.id_agente + WHERE tma.disabled = 0 + %s + %s + %s + %s + LIMIT %d OFFSET %d + ', + $search_query, + $status_agent_search, + $status_module_search, + $order_by, + $length, + $start + ); + } + + $result = db_get_all_rows_sql($query); + // Query count. + if (is_metaconsole() === true) { + $query_count = sprintf( + 'SELECT + COUNT(tma.id_agente) AS `count` + FROM tmetaconsole_agent tma + INNER JOIN temp_custom_fields temp + ON temp.id_agent = tma.id_tagente + AND temp.id_server = tma.id_tmetaconsole_setup + WHERE tma.disabled = 0 + %s + %s + %s + ', + $search_query, + $status_agent_search, + $status_module_search + ); + } else { + $query_count = sprintf( + 'SELECT + COUNT(tma.id_agente) AS `count` + FROM tagente tma + INNER JOIN temp_custom_fields temp + ON temp.id_agent = tma.id_agente + WHERE tma.disabled = 0 + %s + %s + %s + ', + $search_query, + $status_agent_search, + $status_module_search + ); + } $count = db_get_sql($query_count); - // For link nodes. - $array_nodes = metaconsole_get_connections(); + if (is_metaconsole() === true) { + $array_nodes = metaconsole_get_connections(); + } + if (isset($array_nodes) && is_array($array_nodes)) { $hash_array_nodes = []; foreach ($array_nodes as $key => $server) { @@ -280,19 +349,24 @@ if (check_login()) { $data = []; foreach ($result as $values) { $image_status = agents_get_image_status($values['status']); - // Link nodes. - $agent_link = ''; + if (is_metaconsole() === true) { + $agent_link = ''; + $agent_alias = ui_print_truncate_text( + $values['alias'], + 'agent_small', + false, + true, + true, + '[…]', + 'font-size:7.5pt;' + ); + } else { + $agent_link = ''; + $agent_alias = $values['alias']; + } + - $agent_alias = ui_print_truncate_text( - $values['alias'], - 'agent_small', - false, - true, - true, - '[…]', - 'font-size:7.5pt;' - ); if (can_user_access_node()) { $agent = $agent_link.''.$agent_alias.''; @@ -300,6 +374,11 @@ if (check_login()) { $agent = $agent_alias; } + if (is_metaconsole() === false) { + $values['id_tagente'] = $values['id_agente']; + $values['id_tmetaconsole_setup'] = 1; + } + $data[] = [ 'ref' => $referencia, 'data_custom_field' => ui_bbcode_to_html($values['name_custom_fields']), @@ -405,7 +484,7 @@ if (check_login()) { $table_modules = new stdClass(); $table_modules->width = '100%'; - $table_modules->class = 'databox data'; + $table_modules->class = 'databox data custom_field_data'; $table_modules->head = []; $table_modules->head[0] = __('Module name'); @@ -589,7 +668,11 @@ if (check_login()) { __('Load filter'), 'load_filter', false, - 'class="sub upd"', + [ + 'icon' => 'search', + 'class' => 'sub upd', + 'onclick' => 'load_filter()', + ], true ); @@ -608,12 +691,14 @@ if (check_login()) { ), true ); - $table = new StdClass; $table->id = 'save_filter_form'; $table->width = '100%'; $table->class = 'databox'; $table->rowspan = []; + $table->style = []; + $table->cellstyle[0][0] = 'display: grid'; + $table->cellstyle[0][1] = 'display: grid'; if ($filters['id'] == 'extended_create_filter') { echo "
"; @@ -624,7 +709,7 @@ if (check_login()) { '', 15, 255, - true + true, ); $table->data[1][0] = __('Group'); @@ -650,11 +735,16 @@ if (check_login()) { ); $table->rowspan[0][2] = 2; + $table->data[0][2] = html_print_submit_button( __('Create filter'), 'create_filter', false, - 'class="sub upd"', + [ + 'icon' => 'search', + 'class' => 'sub upd', + 'onclick' => 'create_filter()', + ], true ); } else { @@ -702,14 +792,23 @@ if (check_login()) { __('Delete filter'), 'delete_filter', false, - 'class="sub upd"', + [ + 'icon' => 'delete', + 'class' => 'sub upd', + 'onclick' => 'delete_filter()', + ], true ); + $table->data[1][2] = html_print_submit_button( __('Update filter'), 'update_filter', false, - 'class="sub upd"', + [ + 'icon' => 'update', + 'class' => 'sub upd', + 'onclick' => 'update_filter()', + ], true ); } 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/general_tactical_view.ajax.php b/pandora_console/include/ajax/general_tactical_view.ajax.php new file mode 100644 index 0000000000..99c9b09a57 --- /dev/null +++ b/pandora_console/include/ajax/general_tactical_view.ajax.php @@ -0,0 +1,78 @@ + 'noaccess']); + } else { + include 'general/noaccess.php'; + } + + exit; +} + + +// AJAX controller. +if (is_ajax()) { + $dir = $config['homedir'].'/include/lib/TacticalView/elements/'; + $method = get_parameter('method'); + $class = get_parameter('class'); + + $filepath = realpath($dir.'/'.$class.'.php'); + if (is_readable($filepath) === false + || is_dir($filepath) === true + || preg_match('/.*\.php$/', $filepath) === false + ) { + exit; + } + + include_once $filepath; + + if (class_exists($class) === true) { + $instance = new $class(); + if ($instance->ajaxMethod($method) === true) { + echo $instance->{$method}(); + } else { + $instance->error('Unavailable method.'); + } + } else { + $class->error('Class not found. ['.$class.']'); + } + + exit; +} diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 78daacb0a0..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, ] ), ], @@ -1627,7 +1656,6 @@ if (check_login()) { // Uncompress. try { - ob_start(); $dateNow = get_system_time(); $final = ($dateNow - $period); $date = ($dateNow - ($time_all_box * $start)); @@ -1751,31 +1779,11 @@ if (check_login()) { 'recordsFiltered' => $total_box, ] ); - - $response = ob_get_clean(); - - // Clean output buffer. - while (ob_get_level() !== 0) { - ob_end_clean(); - } } catch (Exception $e) { echo json_encode( ['error' => $e->getMessage()] ); } - - // If not valid it will throw an exception. - json_decode($response); - if (json_last_error() === JSON_ERROR_NONE) { - // If valid dump. - echo $response; - } else { - echo json_encode( - ['error' => $response] - ); - } - - return; } if ($get_cluster_module_detail === true) { 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/ajax/visual_console.ajax.php b/pandora_console/include/ajax/visual_console.ajax.php index 402a5ddc1a..5e0351f9b0 100644 --- a/pandora_console/include/ajax/visual_console.ajax.php +++ b/pandora_console/include/ajax/visual_console.ajax.php @@ -96,9 +96,6 @@ if ($force_remote_check) { if ($load_css_cv === true) { $uniq = get_parameter('uniq', 0); $ratio = get_parameter('ratio', 0); - - $output = css_label_styles_visual_console($uniq, $ratio); - echo $output; return; } diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index b5f6d44ab7..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( @@ -124,18 +123,22 @@ if (empty($apiPassword) === true ) { // Allow internal direct node -> metaconsole connection // or node -> own console connection. + $server_uid = get_parameter(('server_auth')); $config['__internal_call'] = true; - $config['id_usuario'] = 'admin'; + $config['id_usuario'] = $server_uid; // Compat. - $config['id_user'] = 'admin'; + $config['id_user'] = $server_uid; $correctLogin = true; + $config['is_admin'][$server_uid] = true; // Bypass credentials if server-auth and api-pass are correct. } else if (($config['server_unique_identifier'] === get_parameter('server_auth')) && ($api_password === $apiPassword) && ((bool) isInACL($ipOrigin) === true) ) { - $config['id_usuario'] = 'admin'; - $config['id_user'] = 'admin'; + $server_uid = get_parameter(('server_auth')); + $config['id_usuario'] = $server_uid; + $config['id_user'] = $server_uid; + $config['is_admin'][$server_uid] = true; $correctLogin = true; } else if ((bool) isInACL($ipOrigin) === true) { // External access. diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index 64a95b778d..529684569d 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -66,13 +66,34 @@ global $config; // Care whit this!!! check_login not working if you remove this. $config['id_user'] = $id_user; $_SESSION['id_usuario'] = $id_user; + +// Checks for server api req. +$bypassLogin = false; +if ($data_decoded['apipass'] !== null + && ($config['server_unique_identifier'] === $_SESSION['id_usuario']) +) { + $apiPassword = io_output_password( + db_get_value_filter( + 'value', + 'tconfig', + ['token' => '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) { + +if (check_login(false) === false && $bypassLogin !== true) { // Error handler. ?> diff --git a/pandora_console/include/class/AgentWizard.class.php b/pandora_console/include/class/AgentWizard.class.php index e700ec61bb..7292e794aa 100644 --- a/pandora_console/include/class/AgentWizard.class.php +++ b/pandora_console/include/class/AgentWizard.class.php @@ -829,17 +829,47 @@ class AgentWizard extends HTML ]; } - html_print_action_buttons( - html_print_submit_button( - $this->actionLabel, - 'sub-protocol', + $create_modules_button = ''; + if ($this->actionType === 'snmp' && $this->version !== null && $this->message['type'][0] !== 'error') { + $create_modules_button = html_print_submit_button( + __('Create modules'), + 'create-modules-action', false, [ - 'icon' => 'cog', - 'onclick' => '$("#form-main-wizard").submit();', + 'icon' => 'next', + 'onclick' => 'processListModules()', ], true - ) + ); + } else if ($this->actionType === 'wmi' && $this->protocol === 'wmi' && $this->message['type'][0] !== 'error') { + $create_modules_button = html_print_submit_button( + __('Create modules'), + 'create-modules-action', + false, + [ + 'icon' => 'next', + 'onclick' => 'processListModules()', + ], + true + ); + } else { + $create_modules_button = ''; + } + + html_print_action_buttons( + [ + html_print_submit_button( + $this->actionLabel, + 'sub-protocol', + false, + [ + 'icon' => 'cog', + 'onclick' => '$("#form-main-wizard").submit();', + ], + true + ), + $create_modules_button, + ] ); // Prints main form. @@ -3765,7 +3795,10 @@ class AgentWizard extends HTML 'label' => __('Create modules'), 'name' => 'create-modules-action', 'type' => 'button', - 'attributes' => [ 'icon' => 'next' ], + 'attributes' => [ + 'icon' => 'next', + 'style' => 'display: none;', + ], 'script' => 'processListModules();', 'return' => true, ], diff --git a/pandora_console/include/class/AgentsAlerts.class.php b/pandora_console/include/class/AgentsAlerts.class.php index e55566f469..70c1ff9e3c 100644 --- a/pandora_console/include/class/AgentsAlerts.class.php +++ b/pandora_console/include/class/AgentsAlerts.class.php @@ -457,9 +457,7 @@ class AgentsAlerts extends HTML $template2 = get_parameter('template'); $module_action_threshold = get_parameter('module_action_threshold'); $action_select = get_parameter('action_select', 0); - - $id_alert = alerts_create_alert_agent_module($this->create_alert, $template2); - + $id_alert = alerts_create_alert_agent_module($this->createAlert, $template2); if ($id_alert !== false) { if ($action_select != 0) { $values = []; diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index b054f3362b..83208256fb 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -200,9 +200,7 @@ class ConsoleSupervisor * NOTIF.CRON.CONFIGURED */ - if (enterprise_installed()) { - $this->checkCronRunning(); - } + $this->checkCronRunning(); /* * Check if instance is registered. @@ -258,6 +256,7 @@ class ConsoleSupervisor /* * Check if performance variables are corrects */ + $this->checkPerformanceVariables(); /* @@ -270,13 +269,6 @@ class ConsoleSupervisor $this->checkSyncQueueStatus(); } - /* - * Check number of agents is equals and more than 200. - * NOTIF.ACCESSSTASTICS.PERFORMANCE - */ - - $this->checkAccessStatisticsPerformance(); - /* * Checkc agent missing libraries. * NOTIF.AGENT.LIBRARY @@ -291,6 +283,12 @@ class ConsoleSupervisor */ $this->checkMYSQLSettings(); + + /* + * Check log alerts version + */ + + $this->checkLogAlerts(); } @@ -501,9 +499,7 @@ class ConsoleSupervisor * NOTIF.CRON.CONFIGURED */ - if (enterprise_installed()) { - $this->checkCronRunning(); - } + $this->checkCronRunning(); /* * Check if instance is registered. @@ -570,13 +566,6 @@ class ConsoleSupervisor $this->checkSyncQueueStatus(); } - /* - * Check number of agents is equals and more than 200. - * NOTIF.ACCESSSTASTICS.PERFORMANCE - */ - - $this->checkAccessStatisticsPerformance(); - /* * Checkc agent missing libraries. * NOTIF.AGENT.LIBRARY @@ -729,6 +718,8 @@ class ConsoleSupervisor 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', ] ); + } else { + $this->cleanNotifications('NOTIF.ACCESSSTASTICS.PERFORMANCE'); } } else { $this->cleanNotifications('NOTIF.ACCESSSTASTICS.PERFORMANCE'); @@ -2103,8 +2094,8 @@ class ConsoleSupervisor $this->notify( [ 'type' => 'NOTIF.EXT.ELASTICSEARCH', - 'title' => __('Log collector cannot connect to ElasticSearch'), - 'message' => __('ElasticSearch is not available using current configuration.'), + 'title' => __('Log collector cannot connect to OpenSearch'), + 'message' => __('OpenSearch is not available using current configuration.'), 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=log', ] ); @@ -2387,17 +2378,19 @@ class ConsoleSupervisor include_once $config['homedir'].'/include/functions_update_manager.php'; $login = get_parameter('login', false); - if (update_manager_verify_registration() === false) { - $this->notify( - [ - 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', - 'title' => __('This instance is not registered in the Warp Update section'), - 'message' => __('Click here to start the registration process'), - 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', - ] - ); - } else { - $this->cleanNotifications('NOTIF.UPDATEMANAGER.REGISTRATION'); + if ($config['autoupdate'] === '1' || $_GET['sec2'] === 'godmode/update_manager/update_manager') { + if (update_manager_verify_registration() === false) { + $this->notify( + [ + 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', + 'title' => __('This instance is not registered in the Warp Update section'), + 'message' => __('Click here to start the registration process'), + 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + ] + ); + } else { + $this->cleanNotifications('NOTIF.UPDATEMANAGER.REGISTRATION'); + } } } @@ -2411,13 +2404,17 @@ class ConsoleSupervisor { global $config; include_once $config['homedir'].'/include/functions_update_manager.php'; - + $server_name = db_get_value_filter( + 'name', + 'tserver', + [ 'server_type' => '1' ] + ); if (update_manager_verify_api() === false) { $this->notify( [ 'type' => 'NOTIF.API.ACCESS', 'title' => __('Cannot access the Pandora FMS API '), - 'message' => __('Please check the configuration, some components may fail due to this misconfiguration.'), + 'message' => __('Please check the configuration, some components may fail due to this misconfiguration in '.$server_name.' ('.$config['public_url'].')'), ] ); } else { @@ -2651,14 +2648,20 @@ class ConsoleSupervisor if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { $message_conf_cron .= __('Discovery relies on an appropriate cron setup.'); $message_conf_cron .= '. '.__('Please, add the following line to your crontab file:'); - $message_conf_cron .= '
* * * * * <user> wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies ';
-                $message_conf_cron .= str_replace(
-                    ENTERPRISE_DIR.'/meta/',
-                    '',
-                    ui_get_full_url(false)
-                );
-                $message_conf_cron .= ENTERPRISE_DIR.'/'.EXTENSIONS_DIR;
-                $message_conf_cron .= '/cron/cron.php >> 
'; + if (enterprise_installed()) { + $message_conf_cron .= '
* * * * * <user> wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies ';
+                    $message_conf_cron .= str_replace(
+                        ENTERPRISE_DIR.'/meta/',
+                        '',
+                        ui_get_full_url(false)
+                    );
+                    $message_conf_cron .= ENTERPRISE_DIR.'/'.EXTENSIONS_DIR;
+                    $message_conf_cron .= '/cron/cron.php >> 
'; + } else { + $message_conf_cron .= '
* * * * * <user> wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies ';
+                    $message_conf_cron .= ui_get_full_url(false).'cron.php >> 
'; + } + $message_conf_cron .= $config['homedir'].'/log/cron.log'; } @@ -3104,4 +3107,32 @@ class ConsoleSupervisor } + /** + * Checks log alerts version. + * + * @return void + */ + public function checkLogAlerts() + { + global $config; + + if ((bool) check_acl($config['id_user'], 0, 'LM') === true) { + $current_package = (int) $config['current_package']; + if ($current_package >= 774 && $current_package <= 777) { + $url = '__url__index.php?sec=galertas&sec2=enterprise/godmode/alerts/event_alerts'; + $this->notify( + [ + 'type' => 'NOTIF.LOG.ALERT', + 'title' => __('Alert correlation changed since version 774'), + 'message' => __('Log correlation and log correlation with events will be disabled in this update. Some event correlation alerts may need to be modified to adapt to the new format'), + 'url' => $url, + ] + ); + } else { + $this->cleanNotifications('NOTIF.LOG.ALERT'); + } + } + } + + } diff --git a/pandora_console/include/class/Diagnostics.class.php b/pandora_console/include/class/Diagnostics.class.php index 7d7532189c..ea3caaf276 100644 --- a/pandora_console/include/class/Diagnostics.class.php +++ b/pandora_console/include/class/Diagnostics.class.php @@ -580,9 +580,6 @@ class Diagnostics extends Wizard $countModuleData = db_get_value_sql( 'SELECT COUNT(*) FROM tagente_datos' ); - $countAgentAccess = db_get_value_sql( - 'SELECT COUNT(*) FROM tagent_access' - ); $countEvents = db_get_value_sql('SELECT COUNT(*) FROM tevento'); if (enterprise_installed() === true) { @@ -595,39 +592,35 @@ class Diagnostics extends Wizard $result = [ 'error' => false, 'data' => [ - 'countAgents' => [ + 'countAgents' => [ 'name' => __('Total agents'), 'value' => $countAgents, ], - 'countModules' => [ + 'countModules' => [ 'name' => __('Total modules'), 'value' => $countModules, ], - 'countGroups' => [ + 'countGroups' => [ 'name' => __('Total groups'), 'value' => $countGroups, ], - 'countModuleData' => [ + 'countModuleData' => [ 'name' => __('Total module data records'), 'value' => $countModuleData, ], - 'countAgentAccess' => [ - 'name' => __('Total agent access record'), - 'value' => $countAgentAccess, - ], - 'countEvents' => [ + 'countEvents' => [ 'name' => __('Total events'), 'value' => $countEvents, ], - 'countTraps' => [ + 'countTraps' => [ 'name' => __('Total traps'), 'value' => $countTraps, ], - 'countUsers' => [ + 'countUsers' => [ 'name' => __('Total users'), 'value' => $countUsers, ], - 'countSessions' => [ + 'countSessions' => [ 'name' => __('Total sessions'), 'value' => $countSessions, ], @@ -744,7 +737,7 @@ class Diagnostics extends Wizard $cpuModelName = 'cat /proc/cpuinfo | grep "model name" | tail -1 | cut -f 2 -d ":"'; $cpuProcessor = 'cat /proc/cpuinfo | grep "processor" | wc -l'; $ramMemTotal = 'cat /proc/meminfo | grep "MemTotal"'; - + $distroInfo = 'cat /etc/os-release | grep "PRETTY_NAME" | cut -f 2 -d "="'; exec( "ifconfig | awk '{ print $2}' | grep -E -o '([0-9]{1,3}[\.]){3}[0-9]{1,3}'", $output @@ -763,6 +756,10 @@ class Diagnostics extends Wizard 'name' => __('RAM'), 'value' => exec($ramMemTotal), ], + 'distroInfo' => [ + 'name' => __('Distro'), + 'value' => str_replace('"', '', exec($distroInfo)), + ], 'osInfo' => [ 'name' => __('Os'), 'value' => exec('uname -a'), diff --git a/pandora_console/include/class/DiscoveryConsoleTask.php b/pandora_console/include/class/DiscoveryConsoleTask.php new file mode 100644 index 0000000000..b0bd4846e9 --- /dev/null +++ b/pandora_console/include/class/DiscoveryConsoleTask.php @@ -0,0 +1,345 @@ + 0) { + $console_exists = db_get_row('tconsole', 'id_console', $config['id_console']); + if ($console_exists === false) { + db_process_sql_insert( + 'tconsole', + [ + 'id_console' => $config['id_console'], + 'description' => $config['console_description'], + 'version' => $pandora_version, + 'console_type' => ($config['reporting_console_node'] === true) ? 1 : 0, + 'timezone' => $config['timezone'], + 'public_url' => $config['public_url'], + ] + ); + } else { + db_process_sql_update( + 'tconsole', + [ + 'description' => $config['console_description'], + 'timezone' => $config['timezone'], + 'public_url' => $config['public_url'], + 'console_type' => (int) $config['reporting_console_node'], + 'version' => $pandora_version, + ], + [ + 'id_console' => $config['id_console'], + ] + ); + } + } + + // Maintenance task: schedule daily task to manage GoTTY processes if not defined yet. + // Must do at every Cron execution. + $gotty_ssh_enabled = (bool) $config['gotty_ssh_enabled']; + $gotty_telnet_enabled = (bool) $config['gotty_telnet_enabled']; + + if ($gotty_ssh_enabled === true || $gotty_telnet_enabled === true) { + // Create necessary data in task tables when some method of GoTTY is enabled in setup. + if ((bool) $config['enterprise_installed'] === false) { + $call_func_user_task_id = db_get_value_sql('SELECT id FROM `tuser_task` WHERE `function_name` = "cron_task_call_user_function"'); + if ($call_func_user_task_id === false) { + db_process_sql("INSERT INTO `tuser_task` (`function_name`, `parameters`, `name`) VALUES ('cron_task_call_user_function','a:1:{i:0;a:2:{s:11:\"description\";s:13:\"Function name\";s:4:\"type\";s:4:\"text\";}}','Call PHP function')"); + } + } + + $user_function_task_id = db_get_value_sql('SELECT id FROM `tuser_task_scheduled` WHERE `args` LIKE "%cron_task_start_gotty%"'); + + if ($user_function_task_id === false) { + // Schedule task to manage GoTTY processes daily if it is not scheduled yet. + $this->schedule( + 'cron_task_call_user_function', + [ + 0 => 'cron_task_start_gotty', + 'function_name' => 'cron_task_start_gotty', + 'internal' => 1, + ], + 'daily', + 0, + 0, + strtotime('tomorrow') + ); + } + } + + // Maintenance task: check whether start GoTTY SSH and Telnet processes are running and start otherwise. + // Must do at every Cron execution. + cron_task_start_gotty(false); + + // Do not output anything until is completed. There're session + // operations inside cron_task_run function. + ob_start(); + + if (cron_task_lock() === false) { + // Cannot continue. Locked. + echo ob_get_clean(); + exit; + } + + $time = get_system_time(); + $scheduled_tasks = db_get_all_rows_in_table('tuser_task_scheduled'); + if (!$scheduled_tasks) { + $scheduled_tasks = []; + } + + /* + Watch out! First_execution corresponds to next_execution the name + of the bbdd is maintained to ensure integrity. + */ + + foreach ($scheduled_tasks as $task) { + $params = unserialize($task['args']); + if ($this->shouldTaskRun($task) === false) { + continue; + } + + if ($task['scheduled'] == 'no') { + if (($params['first_execution']) < $time) { + echo date('Y/m/d H:i:s').' Execute once time cron task: '; + echo $task['id']; + echo "\n\n"; + cron_task_run($task['id']); + // The task was not scheduled and was executed once. + db_process_sql_delete( + 'tuser_task_scheduled', + ['id' => $task['id']] + ); + } + } else { + if (($params['first_execution']) < $time) { + echo date('Y/m/d H:i:s').' EXECUTED CRON TASK: '.$task['id']; + echo "\n"; + echo "\n"; + cron_task_run($task['id']); + } + } + } + + // Dump to output. + echo ob_get_clean(); + + // Release the lock. + cron_task_release_lock(); + + } + + + /** + * Schedules a discovery console task to be executed by cron. + * + * @param string $function_name Name of the function: + * cron_task_generate_report + * cron_task_generate_report_by_template + * cron_task_save_report_to_disk + * cron_task_do_backup + * cron_task_execute_custom_script + * cron_task_save_xml_report_to_disk + * cron_task_feedback_send_mail + * cron_task_generate_csv_log. + * @param array $arguments Task execution arguments (if needed). + * @param string $schedule Task schedule options: + * 'no', + * 'hourly', + * 'daily', + * 'weekly', + * 'monthly', + * 'yearly', + * 'custom'. + * @param integer $group_id Group id (0 => all). + * @param string|null $id_user User id, if null, current user. + * @param integer|null $time_start When to start, if null, now. + * + * @return boolean Sucessfully scheduled or not. + */ + public function schedule( + string $function_name, + array $arguments=[], + string $schedule='no', + int $group_id=0, + ?string $id_user=null, + ?int $time_start=null + ) { + global $config; + + if ($id_user === null) { + $id_user = $config['id_user']; + } + + $idUserTask = db_get_value( + 'id', + 'tuser_task', + 'function_name', + $function_name + ); + + if ($idUserTask === false) { + // Failed to identify function. + return false; + } + + if (in_array($schedule, self::SCHEDULES) === false) { + // Failed to schedule. Not a valid schedule option. + return false; + } + + if ($time_start === null) { + $time_start = strtotime('now'); + } + + // Params for send mail with cron. + $parameters = array_merge( + $arguments, + [ 'first_execution' => $time_start ] + ); + + // Values insert task cron. + $task = [ + 'id_usuario' => $id_user, + 'id_user_task' => $idUserTask, + 'args' => serialize($parameters), + 'scheduled' => $schedule, + 'id_grupo' => $group_id, + ]; + + $result = db_process_sql_insert( + 'tuser_task_scheduled', + $task + ); + + return ($result !== false); + } + + +} diff --git a/pandora_console/include/class/NetworkMap.class.php b/pandora_console/include/class/NetworkMap.class.php index 353a17b80e..184e830e9c 100644 --- a/pandora_console/include/class/NetworkMap.class.php +++ b/pandora_console/include/class/NetworkMap.class.php @@ -1590,6 +1590,8 @@ class NetworkMap { global $config; + include_once 'include/functions_os.php'; + $return = []; $count_item_holding_area = 0; foreach ($nodes as $node) { diff --git a/pandora_console/include/class/SnmpConsole.class.php b/pandora_console/include/class/SnmpConsole.class.php index 86132d3956..6945d9b1fb 100644 --- a/pandora_console/include/class/SnmpConsole.class.php +++ b/pandora_console/include/class/SnmpConsole.class.php @@ -738,7 +738,7 @@ class SnmpConsole extends HTML $sql_count = sprintf($sql_count, $whereSubquery); $traps = db_get_all_rows_sql($sql, true); - $total = (int) db_get_value_sql($sql_count, false, true); + $total = (int) db_get_value_sql($sql_count, false, false); if (empty($traps) === false) { $data = $traps; diff --git a/pandora_console/include/class/TipsWindow.class.php b/pandora_console/include/class/TipsWindow.class.php index ae4271fba9..6406c69194 100644 --- a/pandora_console/include/class/TipsWindow.class.php +++ b/pandora_console/include/class/TipsWindow.class.php @@ -47,6 +47,7 @@ class TipsWindow 'renderPreview', 'setShowTipsAtStartup', 'getTips', + 'getTipById', ]; /** @@ -221,8 +222,13 @@ class TipsWindow * * @return array $tip */ - public function getTipById($idTip) + public function getTipById($idTip=false, $return=false) { + if ($idTip === false) { + $idTip = get_parameter('idTip'); + } + + $return = get_parameter('return', false); $tip = db_get_row( 'twelcome_tip', 'id', @@ -232,9 +238,20 @@ class TipsWindow $tip['title'] = io_safe_output($tip['title']); $tip['text'] = io_safe_output($tip['text']); $tip['url'] = io_safe_output($tip['url']); + $tip['files'] = $this->getFilesFromTip($tip['id']); } - return $tip; + if ($return !== false) { + if (empty($tip) === false) { + echo json_encode(['success' => true, 'data' => $tip]); + return; + } else { + echo json_encode(['success' => false]); + return; + } + } else { + return $tip; + } } diff --git a/pandora_console/include/class/TreeGroupEdition.class.php b/pandora_console/include/class/TreeGroupEdition.class.php index 4071266a58..48a103c724 100644 --- a/pandora_console/include/class/TreeGroupEdition.class.php +++ b/pandora_console/include/class/TreeGroupEdition.class.php @@ -106,20 +106,24 @@ class TreeGroupEdition extends TreeGroup } // Build the group hierarchy. - foreach ($groups as $id => $group) { - if (isset($groups[$id]['parent']) === true - && ($groups[$id]['parent'] != 0) - ) { - $parent = $groups[$id]['parent']; - // Parent exists. - if (isset($groups[$parent]['children']) === false) { - $groups[$parent]['children'] = []; - } + if (isset($this->filter['show_full_hirearchy']) === false + || (isset($this->filter['show_full_hirearchy']) === true && (bool) $this->filter['show_full_hirearchy'] === true) + ) { + foreach ($groups as $id => $group) { + if (isset($groups[$id]['parent']) === true + && ($groups[$id]['parent'] != 0) + ) { + $parent = $groups[$id]['parent']; + // Parent exists. + if (isset($groups[$parent]['children']) === false) { + $groups[$parent]['children'] = []; + } - // Store a reference to the group into the parent. - $groups[$parent]['children'][] = &$groups[$id]; - // This group was introduced into a parent. - $groups[$id]['have_parent'] = true; + // Store a reference to the group into the parent. + $groups[$parent]['children'][] = &$groups[$id]; + // This group was introduced into a parent. + $groups[$id]['have_parent'] = true; + } } } @@ -167,24 +171,112 @@ class TreeGroupEdition extends TreeGroup ]; $group_acl = ''; - if (users_can_manage_group_all('AR') === false) { - $user_groups_str = implode(',', $this->userGroupsArray); - $group_acl = sprintf( - 'AND id_grupo IN (%s)', - $user_groups_str + $search_agent = ''; + $status_agent = ''; + $inner_agent = ''; + + if ((bool) is_metaconsole() === true) { + if (users_can_manage_group_all('AR') === false) { + $user_groups_str = implode(',', $this->userGroupsArray); + $group_acl = sprintf( + ' AND tgrupo.id_grupo IN (%s) ', + $user_groups_str + ); + } + + if (isset($this->filter['searchAgent']) === true && empty($this->filter['searchAgent']) === false + || isset($this->filter['statusAgent']) === true && strlen($this->filter['statusAgent']) > 0 + ) { + $inner_agent = 'INNER JOIN tmetaconsole_agent ON tgrupo.id_grupo = tmetaconsole_agent.id_grupo'; + } + + if (isset($this->filter['searchAgent']) === true && empty($this->filter['searchAgent']) === false) { + $search_agent = ' AND tmetaconsole_agent.alias LIKE "%'.$this->filter['searchAgent'].'%" '; + } + + if (isset($this->filter['statusAgent']) === true && strlen($this->filter['statusAgent']) > 0) { + switch ($this->filter['statusAgent']) { + case AGENT_STATUS_NORMAL: + $status_agent = ' AND ( + tmetaconsole_agent.critical_count = 0 + AND tmetaconsole_agent.warning_count = 0 + AND tmetaconsole_agent.unknown_count = 0 + AND tmetaconsole_agent.normal_count > 0)'; + break; + + case AGENT_STATUS_WARNING: + $status_agent = ' AND ( + tmetaconsole_agent.critical_count = 0 + AND tmetaconsole_agent.warning_count > 0 + AND tmetaconsole_agent.total_count > 0)'; + break; + + case AGENT_STATUS_CRITICAL: + $status_agent = ' AND tmetaconsole_agent.critical_count > 0'; + break; + + case AGENT_STATUS_UNKNOWN: + $status_agent = ' AND ( + tmetaconsole_agent.critical_count = 0 + AND tmetaconsole_agent.warning_count = 0 + AND tmetaconsole_agent.unknown_count > 0)'; + break; + + case AGENT_STATUS_NOT_NORMAL: + $status_agent = ' AND ( + tmetaconsole_agent.normal_count <> total_count + OR tmetaconsole_agent.total_count = notinit_count)'; + break; + + case AGENT_STATUS_NOT_INIT: + $status_agent = ' AND ( + tmetaconsole_agent.total_count = 0 + OR tmetaconsole_agent.total_count = notinit_count)'; + break; + + default: + // Nothing to do. + break; + } + } + + $sql = sprintf( + 'SELECT tgrupo.id_grupo AS gid, + tgrupo.nombre as name, + tgrupo.parent, + tgrupo.icon + FROM tgrupo + %s + WHERE 1=1 + %s + %s + %s ', + $inner_agent, + $search_agent, + $status_agent, + $group_acl + ); + } else { + if (users_can_manage_group_all('AR') === false) { + $user_groups_str = implode(',', $this->userGroupsArray); + $group_acl = sprintf( + 'AND id_grupo IN (%s)', + $user_groups_str + ); + } + + $sql = sprintf( + 'SELECT id_grupo AS gid, + nombre as name, + parent, + icon + FROM tgrupo + WHERE 1=1 + %s ', + $group_acl ); } - $sql = sprintf( - 'SELECT id_grupo AS gid, - nombre as name, - parent, - icon - FROM tgrupo - WHERE 1=1 %s', - $group_acl - ); - $stats = db_get_all_rows_sql($sql); $group_stats = []; foreach ($stats as $group) { diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 5e66268403..dec741c3f0 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -372,7 +372,7 @@ class WelcomeWindow extends Wizard $flag_um = true; } - if (empty($config['welcome_mail_configured']) === false) { + if (empty($config['email_username']) === false && empty($config['email_password']) === false) { $btn_configure_mail_class = ''; $li_configure_mail_class = 'row_green'; $flag_cm = true; @@ -702,7 +702,7 @@ class WelcomeWindow extends Wizard 'next', 'style' => 'margin-top:15px; float:right;']); ?> @@ -1136,7 +1135,7 @@ class WelcomeWindow extends Wizard } function configureEmail() { - window.location = ''; + window.location = ''; } function serversUp() { @@ -1263,14 +1262,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 467b9356c5..5c60ea7ced 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 = 'PC231010'; -$pandora_version = 'v7.0NG.773.3'; +$build_version = 'PC231201'; +$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 889e32f693..5207298b03 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); @@ -441,6 +442,8 @@ define('SERVER_TYPE_ALERT', 21); 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); @@ -887,3 +890,8 @@ define('HOME_SCREEN_ALERT_DETAIL', 'alert_detail'); define('HOME_SCREEN_EXTERNAL_LINK', 'external_link'); define('HOME_SCREEN_OTHER', 'other'); define('HOME_SCREEN_DASHBOARD', 'dashboard'); + + +// Alert correlation. +define('EVENT_ALERTS', 1); +define('LOG_ALERTS', 2); diff --git a/pandora_console/include/ehorus/images/Pandora RC blanco.svg b/pandora_console/include/ehorus/images/Pandora RC blanco.svg new file mode 100644 index 0000000000..1092ba6c90 --- /dev/null +++ b/pandora_console/include/ehorus/images/Pandora RC blanco.svg @@ -0,0 +1,20 @@ + + + Pandora RC blanco + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/include/ehorus/images/Pandora RC blanco@2x.png b/pandora_console/include/ehorus/images/Pandora RC blanco@2x.png new file mode 100644 index 0000000000..444fc6397b Binary files /dev/null and b/pandora_console/include/ehorus/images/Pandora RC blanco@2x.png differ diff --git a/pandora_console/include/ehorus/images/Pandora RC negro.svg b/pandora_console/include/ehorus/images/Pandora RC negro.svg new file mode 100644 index 0000000000..f70b0cd6fa --- /dev/null +++ b/pandora_console/include/ehorus/images/Pandora RC negro.svg @@ -0,0 +1,20 @@ + + + Pandora RC negro + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/include/ehorus/images/Pandora RC negro@2x.png b/pandora_console/include/ehorus/images/Pandora RC negro@2x.png new file mode 100644 index 0000000000..d8e182f641 Binary files /dev/null and b/pandora_console/include/ehorus/images/Pandora RC negro@2x.png differ diff --git a/pandora_console/include/ehorus/images/Pandora RC.svg b/pandora_console/include/ehorus/images/Pandora RC.svg new file mode 100644 index 0000000000..40ae2cc21b --- /dev/null +++ b/pandora_console/include/ehorus/images/Pandora RC.svg @@ -0,0 +1,28 @@ + + + Pandora RC + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/include/ehorus/images/Pandora RC@2x.png b/pandora_console/include/ehorus/images/Pandora RC@2x.png new file mode 100644 index 0000000000..b979f96270 Binary files /dev/null and b/pandora_console/include/ehorus/images/Pandora RC@2x.png differ diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 52409c14a6..855083dac5 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. * @@ -4336,6 +4400,8 @@ function generator_chart_to_pdf( 'id_user' => $config['id_user'], 'slicebar' => $_SESSION['slicebar'], 'slicebar_value' => $config[$_SESSION['slicebar']], + 'apipass' => get_parameter('apipass', null), + ]; } else { $data = [ @@ -4345,6 +4411,7 @@ function generator_chart_to_pdf( 'id_user' => $config['id_user'], 'slicebar' => $_SESSION['slicebar'], 'slicebar_value' => $config[$_SESSION['slicebar']], + 'apipass' => get_parameter('apipass', null), ]; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 720b0e6e55..2d6803ccd4 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -4752,7 +4752,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( @@ -4811,22 +4811,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'], @@ -4834,9 +4834,9 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) ], true ); - } - $table_contact->data[] = $data; + $table_contact->data[] = $data; + } } // Last status change line. @@ -4845,6 +4845,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', @@ -4856,4 +4973,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..94dcb97f6c 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) { diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index f6d1674022..2381d51ad6 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -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 28f5f695cd..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'); } @@ -1497,7 +1497,6 @@ function config_update_config() $interval_values = implode(',', $interval_values_array); } - hd($interval_values, true); if (config_update_value('interval_values', $interval_values, true) === false) { $error_update[] = __('Delete interval'); } @@ -1569,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 { @@ -1616,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': @@ -1677,6 +1684,18 @@ function config_update_config() if (config_update_value('Days_purge_old_information', (int) get_parameter('Days_purge_old_information'), true) === false) { $error_update[] = __('Days to purge old information'); } + + if (config_update_value('elasticsearch_user', get_parameter('elasticsearch_user'), true) === false) { + $error_update[] = __('User ElasticSearch server'); + } + + if (config_update_value('elasticsearch_pass', get_parameter('elasticsearch_pass'), true) === false) { + $error_update[] = __('Pass ElasticSearch server'); + } + + if (config_update_value('elasticsearch_https', get_parameter('elasticsearch_https'), true) === false) { + $error_update[] = __('Https ElasticSearch server'); + } break; case 'hist_db': @@ -2034,20 +2053,6 @@ function config_update_config() } break; - case 'websocket_engine': - if (config_update_value('ws_bind_address', get_parameter('ws_bind_address'), true) === false) { - $error_update[] = __('WebSocket bind address'); - } - - if (config_update_value('ws_port', get_parameter('ws_port'), true) === false) { - $error_update[] = __('WebSocket port'); - } - - if (config_update_value('ws_proxy_url', get_parameter('ws_proxy_url'), true) === false) { - $error_update[] = __('WebSocket proxy url'); - } - break; - default: // Ignore. break; @@ -2232,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'); } @@ -2444,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); } @@ -2481,7 +2490,19 @@ function config_process_config() } if (!isset($config['Days_purge_old_information'])) { - config_update_value('Days_purge_old_information', 90); + config_update_value('Days_purge_old_information', 30); + } + + if (!isset($config['elasticsearch_user'])) { + config_update_value('elasticsearch_user', ''); + } + + if (!isset($config['elasticsearch_pass'])) { + config_update_value('elasticsearch_pass', ''); + } + + if (!isset($config['elasticsearch_https'])) { + config_update_value('elasticsearch_https', ''); } if (!isset($config['font_size'])) { @@ -2504,6 +2525,18 @@ function config_process_config() config_update_value('2Fa_auth', ''); } + if (!isset($config['gotty_ssh_enabled'])) { + config_update_value('gotty_ssh_enabled', 1); + } + + if (!isset($config['gotty_telnet_enabled'])) { + config_update_value('gotty_telnet_enabled', 0); + } + + if (!isset($config['gotty_port'])) { + config_update_value('gotty_port', 8080); + } + if (isset($config['performance_variables_control']) === false) { config_update_value( 'performance_variables_control', @@ -3682,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_cron.php b/pandora_console/include/functions_cron.php index 2eafd8dccb..711ed7f6ba 100644 --- a/pandora_console/include/functions_cron.php +++ b/pandora_console/include/functions_cron.php @@ -463,7 +463,6 @@ function cron_list_table() ); $defined_tasks = db_get_all_rows_sql($sql); - if (!check_acl($config['id_user'], 0, 'PM')) { $read_tasks = []; foreach ($defined_tasks as $task) { diff --git a/pandora_console/include/functions_cron_task.php b/pandora_console/include/functions_cron_task.php new file mode 100644 index 0000000000..9de0520ccd --- /dev/null +++ b/pandora_console/include/functions_cron_task.php @@ -0,0 +1,545 @@ + time()) + ) { + // Locked! + return false; + } + } + + // Try to get a lock from DB. + $dblock = db_get_lock($config['dbname'].'.'.$lockfile); + if ($dblock !== 1) { + // Locked! + return false; + } + + // Store PID in lock file. + $PID = getmypid(); + echo 'CRON running ['.$PID."]\n"; + file_put_contents($lock, $PID); + return true; +} + + +/** + * Check if CRON.task is available to start. + * + * @return boolean True, available. False not available. + */ +function cron_task_lock() +{ + return cron_lock('cron.lock'); +} + + +/** + * Release CRON.task lock + * + * @return void + */ +function cron_task_release_lock() +{ + global $config; + + // Release DB lock. + $dblock = db_release_lock($config['dbname'].'.cron.lock'); + unlink($config['attachment_store'].'/cron.lock'); +} + + +/** + * Calculates target schedule time + * + * @param string $scheduled_time Desired scheduled time. + * @param integer $custom_data Custom scheduled time. + * @param integer|null $timestamp Custom timestamp. + * + * @return integer amount of time. + */ +function cron_get_scheduled_time( + string $scheduled_time, + int $custom_data=0, + $timestamp=null +) { + if ($scheduled_time == 'no') { + return 0; + } + + if ($scheduled_time == 'hourly') { + return SECONDS_1HOUR; + } + + if ($scheduled_time == 'daily') { + return SECONDS_1DAY; + } + + if ($scheduled_time == 'weekly') { + return SECONDS_1WEEK; + } + + if ($scheduled_time == 'monthly') { + $month = (($timestamp === null) ? date('m') : date('m', $timestamp)); + $year = (($timestamp === null) ? date('Y') : date('Y', $timestamp)); + + $days_month = (cal_days_in_month( + CAL_GREGORIAN, + $month, + $year + ) * SECONDS_1DAY); + + return $days_month; + } + + if ($scheduled_time == 'yearly') { + return SECONDS_1YEAR; + } + + if ($scheduled_time == 'custom') { + return $custom_data; + } + + return 0; +} + + +/** + * Run scheduled task. + * + * @param integer $id_user_task Task to be run. + * @param boolean $force_run Force run. + * + * @return void + */ +function cron_task_run( + int $id_user_task, + bool $force_run=false +) { + global $config; + + if (isset($config['id_console']) === true && $config['id_console'] > 0) { + $sql = sprintf( + 'SELECT * + FROM tuser_task_scheduled + WHERE id=%d AND id_console IN (0, %d)', + $id_user_task, + $config['id_console'] + ); + + $task_scheduled = db_get_row_sql($sql); + + if ($task_scheduled !== false) { + db_process_sql_update( + 'tconsole', + ['last_execution' => time()], + ['id_console' => $config['id_console']] + ); + } + } else { + $filter = [ + 'id' => $id_user_task, + 'id_console' => 0, + ]; + + $task_scheduled = db_get_row_filter('tuser_task_scheduled', $filter, false); + } + + $args = unserialize($task_scheduled['args']); + + if ((bool) $config['enterprise_installed'] === false + && isset($args['function_name']) === true + && $args['function_name'] !== 'cron_task_start_gotty' + ) { + // Only cron_task_start_gotty is allowed to run in non enterprise environments. + return; + } + + if ((bool) $config['enterprise_installed'] === true) { + $task = db_get_row('tuser_task', 'id', $task_scheduled['id_user_task']); + } else { + $task = [ + 'name' => 'Call PHP function', + 'function_name' => 'cron_task_call_user_function', + ]; + } + + // Register shutdown function in case of fatal error, like. + register_shutdown_function('cron_task_handle_error', $task_scheduled, $task, $force_run); + + if (is_metaconsole() && !defined('METACONSOLE')) { + define('METACONSOLE', 1); + } + + if (! function_exists($task['function_name'])) { + return; + } + + // If the task is disable, not run. + if ((bool) $task_scheduled['enabled'] === false) { + return; + } + + if (session_status() === PHP_SESSION_DISABLED) { + return; + } + + $old_user = ''; + if (isset($config['id_user']) === false) { + $config['id_user'] = $task_scheduled['id_usuario']; + } + + $old_user = $config['id_user']; + + $old_session_id = session_id(); + $new_session_id = 'cron-'.uniqid(); + + // Simulate user login. + session_id($new_session_id); + session_start(); + $_SESSION['id_usuario'] = $config['id_user']; + session_write_close(); + + set_time_limit(0); + + if ($task['function_name'] == 'cron_task_generate_report_by_template' + || $task['function_name'] == 'cron_task_generate_report' + ) { + // If empty agent position, add it. + if (!isset($args[1])) { + array_splice($args, 1, 0, ''); + } + + $args[] = $task_scheduled['scheduled']; + } + + call_user_func_array( + $task['function_name'], + array_merge(array_values(($args ?? [])), [$id_user_task]) + ); + + if (session_status() === PHP_SESSION_ACTIVE) { + @session_destroy(); + } + + session_id($old_session_id); + session_start(); + + $config['id_user'] = $old_user; + $sql = ''; + $sql2 = ''; + + if (!$force_run) { + $period = cron_get_scheduled_time( + $task_scheduled['scheduled'], + $task_scheduled['custom_data'] + ); + $old_args = unserialize($task_scheduled['args']); + if ($period > 3600) { + $array_explode = explode( + ':', + date('H:i', $old_args['first_execution']) + ); + $hora_en_segundos = (($array_explode[0] * 3600 ) + ($array_explode[1] * 60)); + + $array_explode_period = explode( + ':', + date('H:i', ($old_args['first_execution'] + $period)) + ); + $hora_en_segundos2 = (($array_explode_period[0] * 3600 ) + ($array_explode_period[1] * 60)); + + if ($hora_en_segundos !== $hora_en_segundos2) { + $period = ($period + ($hora_en_segundos - $hora_en_segundos2)); + } + } + + try { + /* + Calculate the number of periods between last execution and + current time. + */ + + $num_of_periods = 0; + if ($period !== 0) { + $num_of_periods = ceil( + (time() - $old_args['first_execution']) / $period + ); + } + + if ($task_scheduled['scheduled'] == 'monthly') { + $updated_time = $old_args['first_execution']; + + // Update updated_time adding the period for each month individually since it is a variable value depending on the number of days a month has. + while ($num_of_periods > 0) { + // Get days of current month. + $monthly_period = cron_get_scheduled_time( + 'monthly', + $task_scheduled['custom_data'], + $updated_time + ); + $updated_time += $monthly_period; + $num_of_periods--; + } + + $old_args['first_execution'] = $updated_time; + } else if ($task_scheduled['scheduled'] == 'weekly') { + $weekly_schedule = json_decode(io_safe_output($old_args['weekly_schedule']), true); + if (empty($weekly_schedule) !== true) { + $datetime = new DateTime('tomorrow'); + $nameday = strtolower($datetime->format('l')); + $continue = true; + while ($continue === true) { + if (isset($weekly_schedule[$nameday]) === true) { + $weekly_date = $datetime->format('Y-m-d'); + $weekly_time = $weekly_schedule[$nameday][0]['start']; + $old_args['first_execution'] = strtotime($weekly_date.' '.$weekly_time); + + $continue = false; + } else { + $datetime->modify('+1 day'); + $nameday = strtolower($datetime->format('l')); + } + } + } + } else { + // Add it to next execution. + $old_args['first_execution'] += ($period * $num_of_periods); + } + } catch (Exception $e) { + // If some error (ex $period=0) next execution=current time+period. + $old_args['first_execution'] = (time() + $period); + } + + $new_args = serialize($old_args); + } + + if ($config['timesource'] == 'sql') { + $sql = sprintf( + 'UPDATE tuser_task_scheduled + SET last_run=UNIX_TIMESTAMP() + WHERE id=%d', + $id_user_task + ); + } else { + $sql = sprintf( + 'UPDATE tuser_task_scheduled + SET last_run= %d + WHERE id=%d', + time(), + $id_user_task + ); + } + + if (!$force_run) { + $sql2 = "UPDATE tuser_task_scheduled + SET args = '".$new_args."' + WHERE id=".$id_user_task; + } + + db_process_sql($sql); + db_process_sql($sql2); +} + + +/** + * Execuytes custom function defined in PHP. + * + * @param string $function_name Name to execute. + * + * @return void + */ +function cron_task_call_user_function(string $function_name) +{ + global $config; + + include_once $config['homedir'].'/vendor/autoload.php'; + + call_user_func($function_name); +} + + +/** + * Check whether GoTTY SSH and Telnet processes are running and start otherwise. + * + * @param boolean $restart_mode Restart the processes if running. + * + * @return void + */ +function cron_task_start_gotty(bool $restart_mode=true) +{ + global $config; + + include_once $config['homedir'].'/include/functions_config.php'; + + $gotty_ssh_enabled = (bool) $config['gotty_ssh_enabled']; + $gotty_telnet_enabled = (bool) $config['gotty_telnet_enabled']; + + // Check prev process running and kill it (only if port changed in setup params). + if (empty($config['restart_gotty_next_cron_port']) === false) { + config_update_value('restart_gotty_next_cron_port', ''); + + $prevProcessRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'"); + + if (empty($prevProcessRunning) === false) { + shell_exec("pkill -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'"); + } + } + + // Check if gotty is running on the configured port. + $processRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['gotty_port']."'"); + + $start_proc = true; + + // If both methods are disabled, do not start process. + if ($gotty_ssh_enabled === false && $gotty_telnet_enabled === false) { + $start_proc = false; + } + + if (empty($processRunning) === false) { + // Process is running. + if ($restart_mode === true || $start_proc === false) { + // Stop the process for restarting or in case GoTTY method is disabled in this iteration. + shell_exec("pkill -f 'pandora_gotty.*-p ".$config['gotty_port']."'"); + } else { + // Prevent starting if already running and must not be restarted or terminated. + return; + } + } + + if ($start_proc === true) { + $logFilePath = $config['homedir'].'/log/gotty_cron_tmp.log'; + shell_exec('touch '.$logFilePath); + + // Start gotty process and capture the output. + $command = '/usr/bin/nohup /usr/bin/pandora_gotty --config /etc/pandora_gotty/pandora_gotty.conf -p '.$config['gotty_port'].' /usr/bin/pandora_gotty_exec > '.$logFilePath.' 2>&1 &'; + shell_exec($command); + } else { + return; + } + + $hash_read = false; + + // Maximum wait time to read asynchronously the output of the executed commands (seconds). + $maxWaitTime = 10; + + // Wait for content to appear in the log file. + $startTime = time(); + + // Workaround to wait until process inputs data in the log. + while ((time() - $startTime) < $maxWaitTime) { + if ($start_proc === true) { + // Read command output. + $log_content = file_get_contents($logFilePath); + } + + if ($start_proc === true + && !empty($log_content) + && $hash_read === false + ) { + // Extract the URL from the output. + if (preg_match('/.*?HTTP server is listening at:\s+(\S+)/', $log_content, $matches)) { + $url = $matches[1]; + + // Extract the hash. + $parts = explode('/', $url); + $hash = array_slice($parts, -2, 1)[0]; + + config_update_value('gotty_connection_hash', $hash); + $hash_read = true; + } + + unlink($logFilePath); + } + + if ($start_proc === false || $hash_read === true) { + // As soon as the read has completed, the timing loop will terminate. + break; + } + + // Sleep for a short interval before checking again. + usleep(100000); + } +} diff --git a/pandora_console/include/functions_custom_fields.php b/pandora_console/include/functions_custom_fields.php index 3632f9511c..9ce92a0c78 100644 --- a/pandora_console/include/functions_custom_fields.php +++ b/pandora_console/include/functions_custom_fields.php @@ -613,8 +613,198 @@ function agent_counters_custom_fields($filters) $final_result['indexed_descriptions'] = $data; } else { - // TODO. - $final_result = false; + $result_meta = []; + $data = []; + + $query = sprintf( + "SELECT tcd.description AS name_data, + SUM(IF($agent_state_total, 1, 0)) AS a_agents, + SUM(IF($agent_state_critical, 1, 0)) AS a_critical, + SUM(IF($agent_state_warning, 1, 0)) AS a_warning, + SUM(IF($agent_state_unknown, 1, 0)) AS a_unknown, + SUM(IF($agent_state_normal, 1, 0)) AS a_normal, + SUM(IF($agent_state_notinit, 1, 0)) AS a_not_init, + SUM(tagent_counters.mm_normal) AS m_normal, + SUM(tagent_counters.mm_critical) AS m_critical, + SUM(tagent_counters.mm_warning) AS m_warning, + SUM(tagent_counters.mm_unknown) AS m_unknown, + SUM(tagent_counters.mm_not_init) AS m_not_init, + SUM(tagent_counters.mm_total) AS m_total + FROM tagent_custom_data tcd + INNER JOIN tagent_custom_fields tcf + ON tcd.id_field = tcf.id_field + INNER JOIN ( + SELECT ta.id_agente, + ta.total_count AS c_m_total, + SUM( IF(tae.estado = 0, 1, 0) ) AS mm_normal, + SUM( IF(tae.estado = 1, 1, 0) ) AS mm_critical, + SUM( IF(tae.estado = 2, 1, 0) ) AS mm_warning, + SUM( IF(tae.estado = 3, 1, 0) ) AS mm_unknown, + SUM( IF(tae.estado = 4 OR tae.estado = 5, 1, 0) ) AS mm_not_init, + COUNT(tam.id_agente_modulo) AS mm_total + FROM tagente ta + LEFT JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + INNER JOIN tagente_modulo tam + ON ta.id_agente = tam.id_agente + INNER JOIN tagente_estado tae + ON tam.id_agente = tae.id_agente + AND tam.id_agente_modulo = tae.id_agente_modulo + WHERE ta.disabled = 0 + AND tam.disabled = 0 + %s + %s + %s + %s + GROUP by ta.id_agente + %s + ) AS tagent_counters + ON tcd.id_agent = tagent_counters.id_agente + INNER JOIN tagente ta + ON ta.id_agente = tagent_counters.id_agente + WHERE tcf.name = '%s' + AND tcd.description <> '' + %s + GROUP BY tcd.description", + $groups_and, + $and_status, + $and_module_search, + $and_module_status, + $empty_agents_count, + $custom_field_name, + $custom_data_and + ); + + $result_meta[] = db_get_all_rows_sql($query); + + $query_data = sprintf( + "SELECT + tcd.description, + ta.id_agente, + %d AS id_server, + (CASE + WHEN ta.critical_count > 0 + THEN 1 + WHEN ta.critical_count = 0 + AND ta.warning_count > 0 + THEN 2 + WHEN ta.critical_count = 0 + AND ta.warning_count = 0 + AND ta.unknown_count > 0 + THEN 3 + WHEN ta.critical_count = 0 + AND ta.warning_count = 0 + AND ta.unknown_count = 0 + AND ta.notinit_count <> ta.total_count + THEN 0 + WHEN ta.total_count = ta.notinit_count + THEN 5 + ELSE 0 + END) AS `status`, + ta.critical_count, + ta.warning_count, + ta.unknown_count, + ta.notinit_count, + ta.normal_count, + ta.total_count + FROM tagente ta + LEFT JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + INNER JOIN tagente_modulo tam + ON ta.id_agente = tam.id_agente + INNER JOIN tagente_estado tae + ON tam.id_agente = tae.id_agente + AND tam.id_agente_modulo = tae.id_agente_modulo + INNER JOIN tagent_custom_data tcd + ON tcd.id_agent = ta.id_agente + INNER JOIN tagent_custom_fields tcf + ON tcd.id_field = tcf.id_field + WHERE ta.disabled = 0 + AND tcf.name = '%s' + AND tcd.description <> '' + AND tam.disabled = 0 + %s + %s + %s + %s + %s + GROUP BY ta.id_agente + ", + $server_data['id'], + $custom_field_name, + $custom_data_and, + $groups_and, + $and_status, + $and_module_search, + $and_module_status + ); + + $node_result = db_get_all_rows_sql($query_data); + ; + if (empty($node_result)) { + $node_result = []; + } + + $data = array_merge($data, $node_result); + $final_result = []; + $array_data = []; + if (isset($result_meta) && is_array($result_meta)) { + // Initialize counters. + $final_result['counters_total'] = [ + 't_m_normal' => 0, + 't_m_critical' => 0, + 't_m_warning' => 0, + 't_m_unknown' => 0, + 't_m_not_init' => 0, + 't_m_alerts' => 0, + 't_m_total' => 0, + 't_a_critical' => 0, + 't_a_warning' => 0, + 't_a_unknown' => 0, + 't_a_normal' => 0, + 't_a_not_init' => 0, + 't_a_agents' => 0, + ]; + foreach ($result_meta as $k => $nodo) { + if (isset($nodo) && is_array($nodo)) { + foreach ($nodo as $key => $value) { + // Sum counters total. + $final_result['counters_total']['t_m_normal'] += $value['m_normal']; + $final_result['counters_total']['t_m_critical'] += $value['m_critical']; + $final_result['counters_total']['t_m_warning'] += $value['m_warning']; + $final_result['counters_total']['t_m_unknown'] += $value['m_unknown']; + $final_result['counters_total']['t_m_not_init'] += $value['m_not_init']; + $final_result['counters_total']['t_m_alerts'] += $value['m_alerts']; + $final_result['counters_total']['t_m_total'] += $value['m_total']; + $final_result['counters_total']['t_a_critical'] += $value['a_critical']; + $final_result['counters_total']['t_a_warning'] += $value['a_warning']; + $final_result['counters_total']['t_a_unknown'] += $value['a_unknown']; + $final_result['counters_total']['t_a_normal'] += $value['a_normal']; + $final_result['counters_total']['t_a_not_init'] += $value['a_not_init']; + $final_result['counters_total']['t_a_agents'] += $value['a_agents']; + + // Sum counters for data. + $array_data[$value['name_data']]['m_normal'] += $value['m_normal']; + $array_data[$value['name_data']]['m_critical'] += $value['m_critical']; + $array_data[$value['name_data']]['m_warning'] += $value['m_warning']; + $array_data[$value['name_data']]['m_unknown'] += $value['m_unknown']; + $array_data[$value['name_data']]['m_not_init'] += $value['m_not_init']; + $array_data[$value['name_data']]['m_alerts'] += $value['m_alerts']; + $array_data[$value['name_data']]['m_total'] += $value['m_total']; + $array_data[$value['name_data']]['a_critical'] += $value['a_critical']; + $array_data[$value['name_data']]['a_warning'] += $value['a_warning']; + $array_data[$value['name_data']]['a_unknown'] += $value['a_unknown']; + $array_data[$value['name_data']]['a_normal'] += $value['a_normal']; + $array_data[$value['name_data']]['a_not_init'] += $value['a_not_init']; + $array_data[$value['name_data']]['a_agents'] += $value['a_agents']; + } + } + } + + $final_result['counters_name'] = $array_data; + } + + $final_result['indexed_descriptions'] = $data; } return $final_result; diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index f709fe2b4c..013698b33d 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -219,6 +219,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 +323,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 +986,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 +1034,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 +2360,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 +2393,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 +2617,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 +2635,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 +2682,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 +3220,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 +4057,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 +4653,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 +6041,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 +6277,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 e6605a488b..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; @@ -2763,8 +2681,28 @@ function graph_agent_status( 'height' => $height, 'colors' => array_values($colors), 'legend' => ['display' => false], + '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, @@ -4624,12 +4562,23 @@ function graph_nodata_image($options) return base64_encode($dataImg); } + $style = ''; + if (isset($options['nodata_image']['width']) === true) { + $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( 'images/image_problem_area.png', true, [ 'title' => __('No data'), - 'style' => 'width: 200px;', + 'style' => $style, ] ); } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 2552fbcdc1..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); @@ -7304,7 +7326,11 @@ function html_print_select_date_range( $date_end='', $time_end='', $date_text=SECONDS_1DAY, - $class='w100p' + $class='w100p', + $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; @@ -7326,21 +7352,21 @@ function html_print_select_date_range( } if ($date_end === '') { - $date_end = date('Y/m/d'); + $date_end = date($date_format_php); } if ($date_init === '') { - $date_init = date('Y/m/d', strtotime($date_end.' -1 days')); + $date_init = date($date_format_php, strtotime($date_end.' -1 days')); } - $date_init = date('Y/m/d', strtotime($date_init)); + $date_init = date($date_format_php, strtotime($date_init)); if ($time_init === '') { - $time_init = date('H:i:s'); + $time_init = date($time_format_php); } if ($time_end === '') { - $time_end = date('H:i:s'); + $time_end = date($time_format_php); } $fields[SECONDS_1DAY] = __('Last 24hr'); @@ -7506,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' @@ -7514,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')."', @@ -7525,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', @@ -7547,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', @@ -7570,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 a67892a6f1..66b14a2776 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -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..090bb8bdb9 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4735,7 +4735,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 +4762,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_netflow.php b/pandora_console/include/functions_netflow.php index 79fcd9a0db..bc8495969f 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -498,7 +498,7 @@ function netflow_get_top_N( $options = '-o "fmt:%sap,%dap,%ibyt,%bps" -q -n '.$max.' -s record/bytes -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); - $command = netflow_get_command($options, $filter); + $command = netflow_get_command($options, $filter, $start_date, $end_date); // Execute nfdump. exec($command, $lines); @@ -656,7 +656,10 @@ function netflow_get_data( $aggregate, $max, $absolute, - $connection_name + $connection_name, + false, + $start_date, + $end_date ); foreach ($data as $line) { @@ -734,6 +737,8 @@ function netflow_get_data( * to get troughput. * @param string $connection_name Node name when data is get in meta. * @param boolean $address_resolution True to resolve ips to hostnames. + * @param integer $start_date_fixed Start date for use in command netflow. + * @param integer $end_date_fixed End date for use in command netflow. * * @return array With netflow stats. */ @@ -745,7 +750,9 @@ function netflow_get_stats( $max, $absolute=true, $connection_name='', - $address_resolution=false + $address_resolution=false, + $start_date_fixed=0, + $end_date_fixed=0, ) { global $config, $nfdump_date_format; @@ -757,8 +764,7 @@ function netflow_get_stats( // Get the command to call nfdump. $options = "-o csv -q -n $max -s $aggregate/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); - $command = netflow_get_command($options, $filter); - + $command = netflow_get_command($options, $filter, $start_date_fixed, $end_date_fixed); // Execute nfdump. exec($command, $string); @@ -845,7 +851,7 @@ function netflow_get_summary($start_date, $end_date, $filter, $connection_name=' // Get the command to call nfdump. $options = '-o csv -n 1 -s srcip/bytes -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); - $command = netflow_get_command($options, $filter); + $command = netflow_get_command($options, $filter, $start_date, $end_date); // Execute nfdump. exec($command, $string); @@ -916,7 +922,7 @@ function netflow_get_relationships_raw_data( // Get the command to call nfdump. $options = ' -q -o csv -n 10000 -s record/bytes -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); - $command = netflow_get_command($options, $filter); + $command = netflow_get_command($options, $filter, $start_date, $end_date); // Execute nfdump. // $command .= ' -q -o csv -n 10000 -s record/bytes -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); @@ -1018,7 +1024,7 @@ function netflow_parse_relationships_for_circular_mesh( * * @return string Command to run. */ -function netflow_get_command($options, $filter) +function netflow_get_command($options, $filter, $date_init=0, $date_end=0) { global $config; @@ -1030,14 +1036,46 @@ function netflow_get_command($options, $filter) && isset($config['netflow_name_dir']) && $config['netflow_name_dir'] !== '' && isset($config['general_network_path']) && $config['general_network_path'] !== '' ) { - $command .= ' -R. -M '.$config['general_network_path'].$config['netflow_name_dir'].':'.$config['sflow_name_dir']; + if ($date_init > 0 && $date_end > 0) { + $path = $config['general_network_path'].$config['sflow_name_dir']; + $range_time = find_range_files_time($path, $date_init, $date_end); + if ($range_time[0] === 0 && $range_time[1] === 0) { + $interval_files_sflow = $path; + } else { + $interval_files_sflow = $path.'/'.$range_time[0].':'.$range_time[1]; + } + + $path = $config['general_network_path'].$config['netflow_name_dir']; + $range_time = find_range_files_time($path, $date_init, $date_end); + if ($range_time[0] === 0 && $range_time[1] === 0) { + $interval_files_netflow = $path; + } else { + $interval_files_netflow = $path.'/'.$range_time[0].':'.$range_time[1]; + } + + $command .= ' -R '.$interval_files_sflow.' -R '.$interval_files_netflow; + } else { + $command .= ' -R. -M '.$config['general_network_path'].$config['netflow_name_dir'].':'.$config['sflow_name_dir']; + } } } else { if ($config['activate_sflow']) { if (isset($config['sflow_name_dir']) && $config['sflow_name_dir'] !== '' && isset($config['general_network_path']) && $config['general_network_path'] !== '' ) { - $command .= ' -R. -M '.$config['general_network_path'].$config['sflow_name_dir']; + if ($date_init > 0 && $date_end > 0) { + $path = $config['general_network_path'].$config['sflow_name_dir']; + $range_time = find_range_files_time($path, $date_init, $date_end); + if ($range_time[0] === 0 && $range_time[1] === 0) { + $interval_files = '.'; + } else { + $interval_files = $range_time[0].':'.$range_time[1]; + } + } else { + $interval_files = '.'; + } + + $command .= ' -R '.$interval_files.' -M '.$config['general_network_path'].$config['sflow_name_dir']; } } @@ -1045,7 +1083,19 @@ function netflow_get_command($options, $filter) if (isset($config['netflow_name_dir']) && $config['netflow_name_dir'] !== '' && isset($config['general_network_path']) && $config['general_network_path'] !== '' ) { - $command .= ' -R. -M '.$config['general_network_path'].$config['netflow_name_dir']; + if ($date_init > 0 && $date_end > 0) { + $path = $config['general_network_path'].$config['netflow_name_dir']; + $range_time = find_range_files_time($path, $date_init, $date_end); + if ($range_time[0] === 0 && $range_time[1] === 0) { + $interval_files = '.'; + } else { + $interval_files = $range_time[0].':'.$range_time[1]; + } + } else { + $interval_files = '.'; + } + + $command .= ' -R '.$interval_files.' -M '.$config['general_network_path'].$config['netflow_name_dir']; } } } @@ -1059,6 +1109,62 @@ function netflow_get_command($options, $filter) } +/** + * Find the two files closest to the time range. + * + * @param string $folder Folder of netflow. + * @param integer $date_init Time init for range. + * @param integer $date_end Time end for range. + * + * @return array + */ +function find_range_files_time($folder, $date_init, $date_end) +{ + $closest_init = 0; + $closest_end = 0; + $closest_init_date = 0; + $closest_end_date = 0; + $min_diff_init = PHP_INT_MAX; + $min_diff_end = PHP_INT_MAX; + $files = scandir($folder); + if ($date_init > 0) { + foreach ($files as $file) { + if (preg_match('/^nfcapd\.(\d{12})$/', $file, $matches)) { + $file_date = $matches[1]; + + $file_date = strtotime(substr($file_date, 0, 4).'-'.substr($file_date, 4, 2).'-'.substr($file_date, 6, 2).' '.substr($file_date, 8, 2).':'.substr($file_date, 10, 2)); + $diff_init = abs($file_date - $date_init); + if ($diff_init < $min_diff_init) { + $closest_init_date = $file_date; + $min_diff_init = $diff_init; + $closest_init = $file; + } + + $diff_end = abs($file_date - $date_end); + if ($diff_end < $min_diff_end) { + $closest_end_date = $file_date; + $min_diff_end = $diff_end; + $closest_end = $file; + } + } + } + } + + if ($closest_end_date < $date_init || $closest_init_date > $date_end) { + return [ + 0, + 0, + ]; + } else { + return [ + $closest_init, + $closest_end, + ]; + } + +} + + /** * Returns the nfdump command line arguments that match the given filter. * @@ -1336,7 +1442,9 @@ function netflow_draw_item( $max_aggregates, true, $connection_name, - $address_resolution + $address_resolution, + $start_date, + $end_date ); if (empty($data_pie) === true) { @@ -1451,7 +1559,9 @@ function netflow_draw_item( $max_aggregates, true, $connection_name, - $address_resolution + $address_resolution, + $start_date, + $end_date ); if (empty($data_stats) === false) { @@ -1572,7 +1682,9 @@ function netflow_get_item_data( $aggregate, $max_aggregates, true, - $connection_name + $connection_name, + $start_date, + $end_date ); $data = [ @@ -1801,7 +1913,7 @@ function netflow_get_top_summary( } $options = "-q -o csv -n $max -s $sort/$order_text -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); - $command = netflow_get_command($options, $netflow_filter); + $command = netflow_get_command($options, $netflow_filter, $start_date, $end_date); exec($command, $result); if (! is_array($result)) { @@ -1962,7 +2074,7 @@ function netflow_get_top_data( date($nfdump_date_format, $start_date), date($nfdump_date_format, $end_date) ); - $agg_command = netflow_get_command($options, $filter); + $agg_command = netflow_get_command($options, $filter, $start_date, $end_date); // Call nfdump. exec($agg_command, $string); diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 5fa9ec2a8d..f5115a73e9 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -4466,7 +4466,7 @@ function networkmap_get_new_nodes_and_links($networkmap, $x, $y) 'id_child' => $child_node, 'id_parent_source_data' => $parent, 'id_child_source_data' => $node['source_data'], - 'parent_type' => 0, + 'parent_type' => 2, 'child_type' => 0, ] ); diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index d9ac1c9f38..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'] 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..dce7dd9efc 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.''; 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..e5b8f52b7b 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 graph donut'), + ]; + + $types['vuls_by_packages'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('By packages in graph pie'), + ]; + + $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 3a4273efa4..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: @@ -906,12 +925,13 @@ function servers_get_info($id_server=-1, $sql_limit=-1) 'images/logs@svg.svg', true, [ - 'title' => __('Log server'), + 'title' => __('Syslog server'), 'class' => 'main_menu_icon invert_filter', ] ); $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,35 @@ 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: + $server['img'] = html_print_image( + 'images/log_server.svg', + true, + [ + 'title' => __('Log server'), + 'class' => 'main_menu_icon invert_filter', + ] + ); + $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 .= '