diff --git a/extras/deploy-scripts/deploy_ext_database_el8.sh b/extras/deploy-scripts/deploy_ext_database_el8.sh new file mode 100644 index 0000000000..422887b0e2 --- /dev/null +++ b/extras/deploy-scripts/deploy_ext_database_el8.sh @@ -0,0 +1,320 @@ +#!/bin/bash +####################################################### +# PandoraFMS Community online installation script +####################################################### +## Tested versions ## +# Centos 8.4, 8.5 +# Rocky 8.4, 8.5, 8.6, 8.7 +# Almalinuz 8.4, 8.5 +# RedHat 8.5 + +#Constants +S_VERSION='202302081' +LOGFILE="/tmp/deploy-ext-db-$(date +%F).log" + + +# define default variables +[ "$TZ" ] || TZ="Europe/Madrid" +[ "$MYVER" ] || MYVER=57 +[ "$DBHOST" ] || DBHOST=127.0.0.1 +[ "$DBNAME" ] || DBNAME=pandora +[ "$DBUSER" ] || DBUSER=pandora +[ "$DBPASS" ] || DBPASS=pandora +[ "$DBPORT" ] || DBPORT=3306 +[ "$DBROOTUSER" ] || DBROOTUSER=root +[ "$DBROOTPASS" ] || DBROOTPASS=pandora +[ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0 +[ "$SKIP_KERNEL_OPTIMIZATIONS" ] || SKIP_KERNEL_OPTIMIZATIONS=0 +[ "$POOL_SIZE" ] || POOL_SIZE=$(grep -i total /proc/meminfo | head -1 | awk '{printf "%.2f \n", $(NF-1)*0.4/1024}' | sed "s/\\..*$/M/g") + +# Ansi color code variables +red="\e[0;91m" +green="\e[0;92m" +cyan="\e[0;36m" +reset="\e[0m" + +# Functions +execute_cmd () { + local cmd="$1" + local msg="$2" + + echo -e "${cyan}$msg...${reset}" + $cmd &>> "$LOGFILE" + if [ $? -ne 0 ]; then + echo -e "${red}Fail${reset}" + [ "$3" ] && echo "$3" + echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE" + rm -rf "$HOME"/pandora_deploy_tmp &>> "$LOGFILE" + exit 1 + else + echo -e "\e[1A\e ${cyan}$msg...${reset} ${green}OK${reset}" + return 0 + fi +} + +check_cmd_status () { + if [ $? -ne 0 ]; then + echo -e "${red}Fail${reset}" + [ "$1" ] && echo "$1" + echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE" + rm -rf "$HOME"/pandora_deploy_tmp/*.rpm* &>> "$LOGFILE" + exit 1 + else + echo -e "${green}OK${reset}" + return 0 + fi +} + +check_root_permissions () { + echo -en "${cyan}Checking root account... ${reset}" + if [ "$(whoami)" != "root" ]; then + echo -e "${red}Fail${reset}" + echo "Please use a root account or sudo for installing Pandora FMS" + echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE" + exit 1 + + else + echo -e "${green}OK${reset}" + fi +} + +## Main +echo "Starting PandoraFMS External DB deployment EL8 ver. $S_VERSION" + +# Centos Version +if [ ! "$(grep -Ei 'centos|rocky|Almalinux|Red Hat Enterprise' /etc/redhat-release)" ]; then + printf "\n ${red}Error this is not a Centos/Rocky/Almalinux Base system, this installer is compatible with RHEL/Almalinux/Centos/Rockylinux systems only${reset}\n" + exit 1 +fi + + +echo -en "${cyan}Check Centos Version...${reset}" +[ $(sed -nr 's/VERSION_ID+=\s*"([0-9]).*"$/\1/p' /etc/os-release) -eq '8' ] +check_cmd_status 'Error OS version, RHEL/Almalinux/Centos/Rockylinux 8+ is expected' + +#Detect OS +os_name=$(grep ^PRETTY_NAME= /etc/os-release | cut -d '=' -f2 | tr -d '"') +execute_cmd "echo $os_name" "OS detected: ${os_name}" + +# initialice logfile +execute_cmd "echo 'Starting community deployment' > $LOGFILE" "All installer activity is logged on $LOGFILE" +echo "Community installer version: $S_VERSION" >> "$LOGFILE" + +# Pre checks +# Root permisions +check_root_permissions + +# Systemd +execute_cmd "systemctl status" "Checking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env please check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8' + +# Check memomry greather or equal to 2G +execute_cmd "[ $(grep MemTotal /proc/meminfo | awk '{print $2}') -ge 1700000 ]" 'Checking memory (required: 2 GB)' + +# Check disk size at least 10 Gb free space +execute_cmd "[ $(df -BM / | tail -1 | awk '{print $4}' | tr -d M) -gt 10000 ]" 'Checking Disk (required: 10 GB free min)' + +# Setting timezone +rm -rf /etc/localtime &>> "$LOGFILE" +execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ" + +# Execute tools check +execute_cmd "awk --version" 'Checking needed tools: awk' +execute_cmd "grep --version" 'Checking needed tools: grep' +execute_cmd "sed --version" 'Checking needed tools: sed' +execute_cmd "dnf --version" 'Checking needed tools: dnf' + +# Creating working directory +rm -rf "$HOME"/pandora_deploy_tmp/*.rpm* &>> "$LOGFILE" +mkdir "$HOME"/pandora_deploy_tmp &>> "$LOGFILE" +execute_cmd "cd $HOME/pandora_deploy_tmp" "Moving to workspace: $HOME/pandora_deploy_tmp" + +## Extra steps on redhat envs +if [ "$(grep -Ei 'Red Hat Enterprise' /etc/redhat-release)" ]; then + ## In case REDHAT + # Check susbscription manager status: + echo -en "${cyan}Checking Red Hat Enterprise subscription... ${reset}" + subscription-manager list &>> "$LOGFILE" + subscription-manager status &>> "$LOGFILE" + check_cmd_status 'Error checking subscription status, make sure your server is activated and suscribed to Red Hat Enterprise repositories' + + # Ckeck repolist + dnf repolist &>> "$LOGFILE" + echo -en "${cyan}Checking Red Hat Enterprise repolist... ${reset}" + dnf repolist | grep 'rhel-8-for-x86_64-baseos-rpms' &>> "$LOGFILE" + check_cmd_status 'Error checking repositories status, could try a subscription-manager attach command or contact sysadmin' + + #install extra repos + extra_repos=" \ + tar \ + dnf-utils \ + https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \ + https://repo.percona.com/yum/percona-release-latest.noarch.rpm" + + execute_cmd "dnf install -y $extra_repos" "Installing extra repositories" + execute_cmd "subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms" "Enabling subscription to codeready-builder" +else + # For alma/rocky/centos + extra_repos=" \ + tar \ + dnf-utils \ + epel-release \ + https://repo.percona.com/yum/percona-release-latest.noarch.rpm" + + execute_cmd "dnf install -y $extra_repos" "Installing extra repositories" + execute_cmd "dnf config-manager --set-enabled powertools" "Configuring Powertools" +fi + + +#Installing wget +execute_cmd "dnf install -y wget" "Installing wget" + + +# Install percona Database +execute_cmd "dnf module disable -y mysql" "Disabiling mysql module" + +if [ "$MYVER" -eq '80' ] ; then + execute_cmd "percona-release setup ps80 -y" "Enabling mysql80 module" + execute_cmd "dnf install -y percona-server-server percona-xtrabackup-24" "Installing Percona Server 80" +fi + +if [ "$MYVER" -ne '80' ] ; then + execute_cmd "dnf install -y Percona-Server-server-57 percona-xtrabackup-24" "Installing Percona Server 57" +fi + +# Disabling SELINUX and firewalld +setenforce 0 &>> "$LOGFILE" +sed -i -e "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config &>> "$LOGFILE" +systemctl disable firewalld --now &>> "$LOGFILE" + +# Adding standar cnf for initial setup. +cat > /etc/my.cnf << EO_CONFIG_TMP +[mysqld] +datadir=/var/lib/mysql +socket=/var/lib/mysql/mysql.sock +symbolic-links=0 +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid +EO_CONFIG_TMP + +#Configuring Database +if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then + execute_cmd "systemctl start mysqld" "Starting database engine" + export MYSQL_PWD=$(grep "temporary password" /var/log/mysqld.log | rev | cut -d' ' -f1 | rev) + if [ "$MYVER" -eq '80' ] ; then + echo """ + SET PASSWORD FOR '$DBROOTUSER'@'localhost' = 'Pandor4!'; + UNINSTALL COMPONENT 'file://component_validate_password'; + SET PASSWORD FOR '$DBROOTUSER'@'localhost' = '$DBROOTPASS'; + """ | mysql --connect-expired-password -u$DBROOTUSER &>> "$LOGFILE" + fi + + if [ "$MYVER" -ne '80' ] ; then + echo """ + SET PASSWORD FOR '$DBROOTUSER'@'localhost' = PASSWORD('Pandor4!'); + UNINSTALL PLUGIN validate_password; + SET PASSWORD FOR '$DBROOTUSER'@'localhost' = PASSWORD('$DBROOTPASS'); + """ | mysql --connect-expired-password -u$DBROOTUSER &>> "$LOGFILE"fi + fi + + export MYSQL_PWD=$DBROOTPASS + echo -en "${cyan}Creating Pandora FMS database...${reset}" + echo "create database $DBNAME" | mysql -u$DBROOTUSER -P$DBPORT -h$DBHOST + check_cmd_status "Error creating database $DBNAME, is this an empty node? if you have a previus installation please contact with support." + + echo "CREATE USER \"$DBUSER\"@'%' IDENTIFIED BY \"$DBPASS\";" | mysql -u$DBROOTUSER -P$DBPORT -h$DBHOST + echo "ALTER USER \"$DBUSER\"@'%' IDENTIFIED WITH mysql_native_password BY \"$DBPASS\"" | mysql -u$DBROOTUSER -P$DBPORT -h$DBHOST + echo "GRANT ALL PRIVILEGES ON $DBNAME.* TO \"$DBUSER\"@'%'" | mysql -u$DBROOTUSER -P$DBPORT -h$DBHOST + +#Generating my.cnf +cat > /etc/my.cnf << EO_CONFIG_F +[mysqld] +datadir=/var/lib/mysql +socket=/var/lib/mysql/mysql.sock +user=mysql +character-set-server=utf8 +skip-character-set-client-handshake +# Disabling symbolic-links is recommended to prevent assorted security risks +symbolic-links=0 +# Mysql optimizations for Pandora FMS +# Please check the documentation in http://pandorafms.com for better results + +max_allowed_packet = 64M +innodb_buffer_pool_size = $POOL_SIZE +innodb_lock_wait_timeout = 90 +innodb_file_per_table +innodb_flush_log_at_trx_commit = 0 +innodb_flush_method = O_DIRECT +innodb_log_file_size = 64M +innodb_log_buffer_size = 16M +innodb_io_capacity = 100 +thread_cache_size = 8 +thread_stack = 256K +max_connections = 100 + +key_buffer_size=4M +read_buffer_size=128K +read_rnd_buffer_size=128K +sort_buffer_size=128K +join_buffer_size=4M + +query_cache_type = 1 +query_cache_size = 64M +query_cache_min_res_unit = 2k +query_cache_limit = 256K + +#skip-log-bin + +sql_mode="" + +[mysqld_safe] +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid + +EO_CONFIG_F + + if [ "$MYVER" -eq '80' ] ; then + sed -i -e "/query_cache.*/ s/^#*/#/g" /etc/my.cnf + sed -i -e "s/#skip-log-bin/skip-log-bin/g" /etc/my.cnf + fi + + execute_cmd "systemctl restart mysqld" "Configuring database engine" + execute_cmd "systemctl enable mysqld --now" "Enabling Database service" +fi +export MYSQL_PWD=$DBPASS + + +# Kernel optimization + +if [ "$SKIP_KERNEL_OPTIMIZATIONS" -eq '0' ] ; then +cat >> /etc/sysctl.conf < /dev/null # remove last log before start + +# define default variables +[ "$TZ" ] || TZ="Europe/Madrid" +[ "$DBHOST" ] || DBHOST=127.0.0.1 +[ "$DBNAME" ] || DBNAME=pandora +[ "$DBUSER" ] || DBUSER=pandora +[ "$DBPASS" ] || DBPASS=pandora +[ "$DBPORT" ] || DBPORT=3306 +[ "$DBROOTPASS" ] || DBROOTPASS=pandora +[ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0 +[ "$SKIP_KERNEL_OPTIMIZATIONS" ] || SKIP_KERNEL_OPTIMIZATIONS=0 +[ "$POOL_SIZE" ] || POOL_SIZE=$(grep -i total /proc/meminfo | head -1 | awk '{printf "%.2f \n", $(NF-1)*0.4/1024}' | sed "s/\\..*$/M/g") + + +# Ansi color code variables +red="\e[0;91m" +green="\e[0;92m" +cyan="\e[0;36m" +reset="\e[0m" + +# Functions + +execute_cmd () { + local cmd="$1" + local msg="$2" + + echo -e "${cyan}$msg...${reset}" + $cmd &>> "$LOGFILE" + if [ $? -ne 0 ]; then + echo -e "${red}Fail${reset}" + [ "$3" ] && echo "$3" + echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE" + rm -rf "$WORKDIR" &>> "$LOGFILE" + exit 1 + else + echo -e "\e[1A\e ${cyan}$msg...${reset} ${green}OK${reset}" + return 0 + fi +} + +check_cmd_status () { + if [ $? -ne 0 ]; then + echo -e "${red}Fail${reset}" + [ "$1" ] && echo "$1" + echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE" + rm -rf "$WORKDIR" &>> "$LOGFILE" + exit 1 + else + echo -e "${green}OK${reset}" + return 0 + fi +} + +check_root_permissions () { + echo -en "${cyan}Checking root account... ${reset}" + if [ "$(whoami)" != "root" ]; then + echo -e "${red}Fail${reset}" + echo "Please use a root account or sudo for installing Pandora FMS" + echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE" + exit 1 + + else + echo -e "${green}OK${reset}" + fi +} + +## Main +echo "Starting PandoraFMS External DB deployment Ubuntu 22.04 ver. $S_VERSION" + +# Ubuntu Version +if [ ! "$(grep -Ei 'Ubuntu' /etc/lsb-release)" ]; then + printf "\n ${red}Error this is not a Ubuntu system, this installer is compatible with Ubuntu systems only${reset}\n" + exit 1 +fi + + +echo -en "${cyan}Check Ubuntu Version...${reset}" +[ $(sed -nr 's/VERSION_ID+=\s*"([0-9][0-9].[0-9][0-9])"$/\1/p' /etc/os-release) == "22.04" ] +check_cmd_status 'Error OS version, Ubuntu 22.04 is expected' + +#Detect OS +os_name=$(grep ^PRETTY_NAME= /etc/os-release | cut -d '=' -f2 | tr -d '"') +execute_cmd "echo $os_name" "OS detected: ${os_name}" + +# initialice logfile +execute_cmd "echo 'Starting community deployment' > $LOGFILE" "All installer activity is logged on $LOGFILE" +echo "Community installer version: $S_VERSION" >> "$LOGFILE" + +# Pre checks +# Root permisions +check_root_permissions + +#Install awk, sed, grep if not present +execute_cmd "apt install -y gawk sed grep" 'Installing needed tools' + +# Systemd +execute_cmd "systemctl --version" "Checking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env please check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8' + +# Check memomry greather or equal to 2G +execute_cmd "[ $(grep MemTotal /proc/meminfo | awk '{print $2}') -ge 1700000 ]" 'Checking memory (required: 2 GB)' + +# Check disk size at least 10 Gb free space +execute_cmd "[ $(df -BM / | tail -1 | awk '{print $4}' | tr -d M) -gt 10000 ]" 'Checking Disk (required: 10 GB free min)' + +# Setting timezone +rm -rf /etc/localtime &>> "$LOGFILE" +execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ" + +# Execute tools check +execute_cmd "awk --version" 'Checking needed tools: awk' +execute_cmd "grep --version" 'Checking needed tools: grep' +execute_cmd "sed --version" 'Checking needed tools: sed' +execute_cmd "apt --version" 'Checking needed tools: apt' + +# Creating working directory +rm -rf "$WORKDIR" &>> "$LOGFILE" +mkdir -p "$WORKDIR" &>> "$LOGFILE" +execute_cmd "cd $WORKDIR" "Moving to workdir: $WORKDIR" + +## Install utils +execute_cmd "apt update" "Updating repos" +execute_cmd "apt install -y net-tools vim curl wget software-properties-common apt-transport-https" "Installing utils" + +# Disabling apparmor and ufw +systemctl stop ufw.service &>> "$LOGFILE" +systemctl disable ufw &>> "$LOGFILE" +systemctl stop apparmor &>> "$LOGFILE" +systemctl disable apparmor &>> "$LOGFILE" + +#install mysql +execute_cmd "curl -O https://repo.percona.com/apt/percona-release_latest.generic_all.deb" "Downloading Percona repository for MySQL8" +execute_cmd "apt install -y gnupg2 lsb-release ./percona-release_latest.generic_all.deb" "Installing Percona repository for MySQL8" +execute_cmd "percona-release setup ps80" "Configuring Percona repository for MySQL8" + +echo -en "${cyan}Installing Percona Server for MySQL8...${reset}" + env DEBIAN_FRONTEND=noninteractive apt install -y percona-server-server &>> "$LOGFILE" +check_cmd_status "Error Installing MySql Server" + +#Configuring Database +if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then + execute_cmd "systemctl start mysql" "Starting database engine" + + echo """ + ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '$DBROOTPASS'; + """ | mysql -uroot &>> "$LOGFILE" + + export MYSQL_PWD=$DBROOTPASS + echo -en "${cyan}Creating Pandora FMS database...${reset}" + echo "create database $DBNAME" | mysql -uroot -P$DBPORT -h$DBHOST + check_cmd_status "Error creating database $DBNAME, is this an empty node? if you have a previus installation please contact with support." + + echo "CREATE USER \"$DBUSER\"@'%' IDENTIFIED BY \"$DBPASS\";" | mysql -uroot -P$DBPORT -h$DBHOST + echo "ALTER USER \"$DBUSER\"@'%' IDENTIFIED WITH mysql_native_password BY \"$DBPASS\"" | mysql -uroot -P$DBPORT -h$DBHOST + echo "GRANT ALL PRIVILEGES ON $DBNAME.* TO \"$DBUSER\"@'%'" | mysql -uroot -P$DBPORT -h$DBHOST +fi +export MYSQL_PWD=$DBPASS + +#Generating my.cnf +cat > /etc/mysql/my.cnf << EOF_DB +[mysqld] +datadir=/var/lib/mysql +user=mysql +character-set-server=utf8 +skip-character-set-client-handshake +# Disabling symbolic-links is recommended to prevent assorted security risks +symbolic-links=0 +# Mysql optimizations for Pandora FMS +# Please check the documentation in http://pandorafms.com for better results + +max_allowed_packet = 64M +innodb_buffer_pool_size = $POOL_SIZE +innodb_lock_wait_timeout = 90 +innodb_file_per_table +innodb_flush_log_at_trx_commit = 0 +innodb_flush_method = O_DIRECT +innodb_log_file_size = 64M +innodb_log_buffer_size = 16M +innodb_io_capacity = 100 +thread_cache_size = 8 +thread_stack = 256K +max_connections = 100 + +key_buffer_size=4M +read_buffer_size=128K +read_rnd_buffer_size=128K +sort_buffer_size=128K +join_buffer_size=4M + +skip-log-bin + +sql_mode="" + +log-error=/var/log/mysql/error.log +[mysqld_safe] +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid + +EOF_DB + +execute_cmd "systemctl restart mysql" "Configuring and restarting database engine" + +# Kernel optimization +if [ "$SKIP_KERNEL_OPTIMIZATIONS" -eq '0' ] ; then +cat >> /etc/sysctl.conf <> $LOGFILE execute_cmd "service tentacle_serverd start" "Starting Tentacle Server" # Enabling condole cron -execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron" -echo "* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab +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 ## 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_el8.sh b/extras/deploy-scripts/pandora_deploy_community_el8.sh index 794e11f8fe..13f90fcf85 100644 --- a/extras/deploy-scripts/pandora_deploy_community_el8.sh +++ b/extras/deploy-scripts/pandora_deploy_community_el8.sh @@ -732,8 +732,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 http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron" -echo "* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab +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 ## 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 f52eb625e2..b22d5d163f 100644 --- a/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh +++ b/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh @@ -732,8 +732,8 @@ execute_cmd "service tentacle_serverd start" "Starting Tentacle Server" systemctl enable tentacle_serverd &>> "$LOGFILE" # Enabling condole cron -execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron" -echo "* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab +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 ## Enabling agent adn configuring Agente sed -i "s/^remote_config.*$/remote_config 1/g" $PANDORA_AGENT_CONF &>> "$LOGFILE" diff --git a/extras/docker/centos8/pandora-stack/sources/init_pandora.sh b/extras/docker/centos8/pandora-stack/sources/init_pandora.sh index 76a0954bb8..e9265a0981 100755 --- a/extras/docker/centos8/pandora-stack/sources/init_pandora.sh +++ b/extras/docker/centos8/pandora-stack/sources/init_pandora.sh @@ -277,8 +277,8 @@ export ORACLE_HOME=/usr/lib/oracle/$VERSION/client64 EOF_ENV echo ">> Enable discovery cron: " -#while true ; do wget -q -O - --no-check-certificate http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/pandora_console.log && sleep 60 ; done & -echo "*/5 * * * * wget -q -O - --no-check-certificate http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/log/cron.log" >> /opt/pandora/crontasks +#while true ; do wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/pandora_console.log && sleep 60 ; done & +echo "*/5 * * * * wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/log/cron.log" >> /opt/pandora/crontasks echo ">> Enable pandora_db cron: " /usr/bin/perl /usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index c8512ffc13..9af85a5200 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.768, AIX version +# Version 7.0NG.769, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index c98b6c4f48..6650404c74 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.768, FreeBSD Version +# Version 7.0NG.769, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # 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 a17181b6c2..957396affa 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.768, HP-UX Version +# Version 7.0NG.769, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index 7eea50cdac..dac6aefc04 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.768, GNU/Linux +# Version 7.0NG.769, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index ed7aae82b3..a12c8ccce7 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.768, GNU/Linux +# Version 7.0NG.769, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index 8c189f05bf..75ff20dba4 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.768, Solaris Version +# Version 7.0NG.769, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 46a569686d..6fca0a4523 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-2021 Artica Soluciones Tecnologicas -# Version 7.0NG.768 +# Version 7.0NG.769 # 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.redhat.spec b/pandora_agents/pc/pandora_agent.redhat.spec index ae481e3403..ce60c8841f 100644 --- a/pandora_agents/pc/pandora_agent.redhat.spec +++ b/pandora_agents/pc/pandora_agent.redhat.spec @@ -1,6 +1,7 @@ # #Pandora FMS Linux Agent # +%global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 4.0 %define release 1 diff --git a/pandora_agents/pc/pandora_agent.spec b/pandora_agents/pc/pandora_agent.spec index 1bfc289d52..5ad481315a 100644 --- a/pandora_agents/pc/pandora_agent.spec +++ b/pandora_agents/pc/pandora_agent.spec @@ -1,6 +1,7 @@ # #Pandora FMS Linux Agent # +%global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 4.0.1 %define release 1 diff --git a/pandora_agents/pc/pandora_agent_exec b/pandora_agents/pc/pandora_agent_exec index 48fba5c0d8..2a990067ae 100644 --- a/pandora_agents/pc/pandora_agent_exec +++ b/pandora_agents/pc/pandora_agent_exec @@ -1,15 +1,8 @@ #!/usr/bin/perl -########################################################################## -# pandora_agent_exec +################################################################################ +# pandora_exec - Execute a command with a time limit. # -# Executes the given command and prints its output to stdout. If the -# execution times out or the command does not exist nothing is printed -# to stdout. This is part of Pandora FMS Plugin server, do not delete!. -# -# Usage: pandora_agent_exec -########################################################################## -# Copyright (c) 2008-2010 Ramon Novoa, rnovoa@gmail.com -# (c) 2008-2010 Artica Soluciones Tecnologicas S.L +# Copyright (c) 2008-2023 Artica PFMS S.L. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -22,37 +15,41 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -########################################################################## - +################################################################################ use strict; use warnings; +use POSIX qw(WEXITSTATUS WIFEXITED); -# Check command line parameters +# Check command line arguments. if ($#ARGV < 1) { + print("Usage: $0 \n"); exit 1; } my @opts = @ARGV; my $timeout = shift(@opts); -my $command = join(' ', @opts); -my $output = ''; -my $ReturnCode = 0; +my $command = ($0 =~ m/_agent_exec$/) ? # For backward compatibility with pandora_agent. + join(' ', @opts) : + join(' ', map { quotemeta($_) } @opts); -# Execute the command -eval { - local $SIG{ALRM} = sub { die "alarm\n" }; - alarm $timeout; - - $output = `$command`; - $ReturnCode = ($? >> 8) & 0xff; - alarm 0; -}; - -# Timeout -if ($@ eq "alarm\n") { - exit 3; +# Fork: +# * The child will run the command. +# * The parent will timeout if needed +# and exit with the appropriate exit status. +my $pid = fork(); +if ($pid == 0) { + setpgrp(); + exec($command); +} else { + eval { + local $SIG{ALRM} = sub { kill(9, -$pid); exit 1; }; + alarm $timeout; + waitpid($pid, 0); + alarm 0; + if (WIFEXITED(${^CHILD_ERROR_NATIVE})) { + exit WEXITSTATUS(${^CHILD_ERROR_NATIVE}); + } + }; } -print $output; - -exit $ReturnCode; +exit 1; diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index a723aa503b..e47ec5442a 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.768, AIX version +# Version 7.0NG.769, 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 e8dd39e1d2..bc353d4077 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.768 +# Version 7.0NG.769 # 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 6b4ea56e3d..7e9f290fd0 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.768, HPUX Version +# Version 7.0NG.769, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 5ca49a15e1..674d2a3992 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.768 +# Version 7.0NG.769 # Licensed under GPL license v2, # (c) 2003-2021 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/linux/pandora_agent.spec b/pandora_agents/shellscript/linux/pandora_agent.spec index 64b33bfecf..9c5e0296c6 100755 --- a/pandora_agents/shellscript/linux/pandora_agent.spec +++ b/pandora_agents/shellscript/linux/pandora_agent.spec @@ -1,6 +1,7 @@ # #Pandora FMS Linux Agent # +%global __os_install_post %{nil} %define name pandorafms_agent %define version 3.2 Summary: Pandora FMS Linux agent diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index b26ec72942..9654e1f2ee 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.768 +# Version 7.0NG.769 # Licensed under GPL license v2, # (c) 2003-2021 Artica Soluciones Tecnologicas # 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 b9b09e0f02..4fc7cf3202 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.768 +# Version 7.0NG.769 # 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 20036302b7..2113795918 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.768, Solaris version +# Version 7.0NG.769, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index e2050f1a5c..b02f88017e 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.768, AIX version +# Version 7.0NG.769, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index afc54471c1..c34db5f894 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.768-230201 +Version: 7.0NG.769-230222 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 9df0081520..72b549f170 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.768-230201" +pandora_version="7.0NG.769-230222" 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 fd449c646b..b8862d3ee9 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.768" + VERSION="7.0NG.769" 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 4e4b347f08..f1aebe06a1 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