Merge remote-tracking branch 'origin/develop' into ent-8898-anida-mapas-de-red-no-actualizan-bien
This commit is contained in:
commit
9f30d66328
|
@ -1,62 +0,0 @@
|
|||
# Dockerfile for the Pandora FMS image.
|
||||
FROM debian:jessie
|
||||
|
||||
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
|
||||
RUN groupadd -r mysql && useradd -r -g mysql mysql
|
||||
|
||||
RUN mkdir /docker-entrypoint-initdb.d
|
||||
|
||||
# FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
|
||||
# File::Basename
|
||||
# File::Copy
|
||||
# Sys::Hostname
|
||||
# Data::Dumper
|
||||
RUN apt-get update && apt-get install -y perl pwgen git openssh-client --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# gpg: key 5072E1F5: public key "MySQL Release Engineering <mysql-build@oss.oracle.com>" imported
|
||||
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5
|
||||
|
||||
ENV MYSQL_MAJOR 5.6
|
||||
ENV MYSQL_VERSION 5.6.29-1debian8
|
||||
|
||||
RUN echo "deb http://repo.mysql.com/apt/debian/ jessie mysql-${MYSQL_MAJOR}" > /etc/apt/sources.list.d/mysql.list
|
||||
|
||||
# the "/var/lib/mysql" stuff here is because the mysql-server postinst doesn't have an explicit way to disable the mysql_install_db codepath besides having a database already "configured" (ie, stuff in /var/lib/mysql/mysql)
|
||||
# also, we set debconf keys to make APT a little quieter
|
||||
RUN { \
|
||||
echo mysql-community-server mysql-community-server/data-dir select ''; \
|
||||
echo mysql-community-server mysql-community-server/root-pass password ''; \
|
||||
echo mysql-community-server mysql-community-server/re-root-pass password ''; \
|
||||
echo mysql-community-server mysql-community-server/remove-test-db select false; \
|
||||
} | debconf-set-selections \
|
||||
&& apt-get update && apt-get install -y mysql-server="${MYSQL_VERSION}" && rm -rf /var/lib/apt/lists/* \
|
||||
&& rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql
|
||||
|
||||
# comment out a few problematic configuration values
|
||||
# don't reverse lookup hostnames, they are usually another container
|
||||
RUN sed -Ei 's/^(bind-address|log)/#&/' /etc/mysql/my.cnf \
|
||||
&& echo 'skip-host-cache\nskip-name-resolve' | awk '{ print } $1 == "[mysqld]" && c == 0 { c = 1; system("cat") }' /etc/mysql/my.cnf > /tmp/my.cnf \
|
||||
&& mv /tmp/my.cnf /etc/mysql/my.cnf
|
||||
|
||||
VOLUME /var/lib/mysql
|
||||
|
||||
COPY docker-entrypoint.sh /entrypoint.sh
|
||||
COPY pandora.cnf /etc/mysql/conf.d
|
||||
COPY pandora_initdb.sh /docker-entrypoint-initdb.d
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
# Make ssh dir
|
||||
RUN mkdir /root/.ssh/
|
||||
# Copy over private key, and set permissions
|
||||
RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
|
||||
RUN chown -R root:root /root/.ssh
|
||||
|
||||
|
||||
#Clone the repo
|
||||
RUN git config --global http.sslVerify false
|
||||
RUN git clone -b develop --single-branch https://github.com/pandorafms/pandorafms.git /tmp/pandorafms
|
||||
#RUN mv -f /tmp/pandorafms/pandora_console/pandoradb.sql /docker-entrypoint-initdb.d
|
||||
#RUN mv -f /tmp/pandorafms/pandora_console/pandoradb_data.sql /docker-entrypoint-initdb.d
|
||||
|
||||
EXPOSE 3306
|
||||
CMD ["mysqld"]
|
|
@ -1,113 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
|
||||
# if command starts with an option, prepend mysqld
|
||||
if [ "${1:0:1}" = '-' ]; then
|
||||
set -- mysqld "$@"
|
||||
fi
|
||||
|
||||
if [ "$1" = 'mysqld' ]; then
|
||||
# Get config
|
||||
DATADIR="$("$@" --verbose --help --log-bin-index=`mktemp -u` 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')"
|
||||
|
||||
if [ ! -d "$DATADIR/mysql" ]; then
|
||||
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
|
||||
echo >&2 'error: database is uninitialized and password option is not specified '
|
||||
echo >&2 ' You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$DATADIR"
|
||||
chown -R mysql:mysql "$DATADIR"
|
||||
|
||||
echo 'Initializing database'
|
||||
mysql_install_db --user=mysql --datadir="$DATADIR" --rpm --keep-my-cnf
|
||||
echo 'Database initialized'
|
||||
|
||||
"$@" --skip-networking &
|
||||
pid="$!"
|
||||
|
||||
mysql=( mysql --protocol=socket -uroot )
|
||||
|
||||
for i in {30..0}; do
|
||||
if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then
|
||||
break
|
||||
fi
|
||||
echo 'MySQL init process in progress...'
|
||||
sleep 1
|
||||
done
|
||||
if [ "$i" = 0 ]; then
|
||||
echo >&2 'MySQL init process failed.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$MYSQL_INITDB_SKIP_TZINFO" ]; then
|
||||
# sed is for https://bugs.mysql.com/bug.php?id=20545
|
||||
mysql_tzinfo_to_sql /usr/share/zoneinfo | sed 's/Local time zone must be set--see zic manual page/FCTY/' | "${mysql[@]}" mysql
|
||||
fi
|
||||
|
||||
if [ ! -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
|
||||
MYSQL_ROOT_PASSWORD="$(pwgen -1 32)"
|
||||
echo "GENERATED ROOT PASSWORD: $MYSQL_ROOT_PASSWORD"
|
||||
fi
|
||||
"${mysql[@]}" <<-EOSQL
|
||||
-- What's done in this file shouldn't be replicated
|
||||
-- or products like mysql-fabric won't work
|
||||
SET @@SESSION.SQL_LOG_BIN=0;
|
||||
|
||||
DELETE FROM mysql.user ;
|
||||
CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
|
||||
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ;
|
||||
DROP DATABASE IF EXISTS test ;
|
||||
FLUSH PRIVILEGES ;
|
||||
EOSQL
|
||||
|
||||
if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then
|
||||
mysql+=( -p"${MYSQL_ROOT_PASSWORD}" )
|
||||
fi
|
||||
|
||||
if [ "$MYSQL_DATABASE" ]; then
|
||||
echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;" | "${mysql[@]}"
|
||||
mysql+=( "$MYSQL_DATABASE" )
|
||||
fi
|
||||
|
||||
if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then
|
||||
echo "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;" | "${mysql[@]}"
|
||||
|
||||
if [ "$MYSQL_DATABASE" ]; then
|
||||
echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* TO '$MYSQL_USER'@'%' ;" | "${mysql[@]}"
|
||||
fi
|
||||
|
||||
echo 'FLUSH PRIVILEGES ;' | "${mysql[@]}"
|
||||
fi
|
||||
|
||||
echo
|
||||
for f in /docker-entrypoint-initdb.d/*; do
|
||||
case "$f" in
|
||||
*.sh) echo "$0: running $f"; . "$f" ;;
|
||||
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;;
|
||||
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;;
|
||||
*) echo "$0: ignoring $f" ;;
|
||||
esac
|
||||
echo
|
||||
done
|
||||
|
||||
if [ ! -z "$MYSQL_ONETIME_PASSWORD" ]; then
|
||||
"${mysql[@]}" <<-EOSQL
|
||||
ALTER USER 'root'@'%' PASSWORD EXPIRE;
|
||||
EOSQL
|
||||
fi
|
||||
if ! kill -s TERM "$pid" || ! wait "$pid"; then
|
||||
echo >&2 'MySQL init process failed.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo 'MySQL init process done. Ready for start up.'
|
||||
echo
|
||||
fi
|
||||
|
||||
chown -R mysql:mysql "$DATADIR"
|
||||
fi
|
||||
|
||||
exec "$@"
|
|
@ -1,57 +0,0 @@
|
|||
FROM pandorafms/pandorafms-base:centos7
|
||||
|
||||
# Build variables.
|
||||
ARG BRANCH=develop
|
||||
ARG DB_PASS=pandora
|
||||
|
||||
# Clone the Pandora FMS repo.
|
||||
RUN git clone --depth 1 -b "$BRANCH" https://github.com/pandorafms/pandorafms.git /tmp/pandorafms || \
|
||||
git clone --depth 1 -b develop https://github.com/pandorafms/pandorafms.git /tmp/pandorafms
|
||||
|
||||
# Install the Pandora FMS Server.
|
||||
RUN cd /tmp/pandorafms/pandora_server && \
|
||||
yes | ./pandora_server_installer --install && \
|
||||
sed -i "s/^dbuser.*/dbuser root/" /etc/pandora/pandora_server.conf && \
|
||||
sed -i "s/^dbpass.*/dbpass $DB_PASS/" /etc/pandora/pandora_server.conf
|
||||
|
||||
# Install the Pandora FMS Agent.
|
||||
RUN cd /tmp/pandorafms/pandora_agents/unix && \
|
||||
./pandora_agent_installer --install
|
||||
|
||||
# Set the server's name in Apache's configuration file to avoid warnings.
|
||||
RUN sed -i "s/#ServerName.*/ServerName localhost:80/" /etc/httpd/conf/httpd.conf
|
||||
|
||||
# Install the Pandora FMS Console.
|
||||
RUN rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql && \
|
||||
mkdir -p /var/log/mysql/ && chown mysql. /var/log/mysql && \
|
||||
chown mysql. -R /var/lib/mysql && \
|
||||
sudo -u mysql mysqld --initialize --explicit_defaults_for_timestamp && \
|
||||
sudo -u mysql mysqld --daemonize & \
|
||||
sleep 50 && \
|
||||
mysql_default_pass=$(cat /var/log/mysqld.log | grep "temporary password" | awk '{print $NF}') && \
|
||||
mysqladmin -u root -p"$mysql_default_pass" --user=root password 'pandora' && \
|
||||
httpd -k start && \
|
||||
cp -r /tmp/pandorafms/pandora_console /var/www/html && \
|
||||
chown -R apache.apache /var/www/html/pandora_console/ && \
|
||||
python /tmp/pandorafms/tests/install_console.py
|
||||
|
||||
# Redirect HTTP requests to / to the Pandora FMS Console.
|
||||
RUN echo '<meta http-equiv="refresh" content="0;url=/pandora_console">' > /var/www/html/index.html
|
||||
|
||||
# Create the entrypoint script.
|
||||
RUN echo -e '#/bin/bash\n \
|
||||
sudo -u mysql mysqld --daemonize &&\n \
|
||||
httpd -k start &&\n \
|
||||
/usr/sbin/crond &&\n \
|
||||
/etc/init.d/pandora_agent_daemon start && \
|
||||
/etc/init.d/pandora_server start && \
|
||||
tail -f /var/log/pandora/pandora_server.log' \
|
||||
>> /entrypoint.sh && \
|
||||
chmod +x /entrypoint.sh
|
||||
|
||||
# Clean-up.
|
||||
RUN rm -rf /tmp/pandorafms
|
||||
RUN yum clean all
|
||||
|
||||
EXPOSE 80 3306 41121
|
||||
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
docker build --rm=true --pull --no-cache --build-arg BRANCH="develop" --build-arg DB_PASS="pandora" -t pandorafms/pandorafms:7 . && \
|
||||
[ "$QA_ENV" == "" ] && \
|
||||
docker push pandorafms/pandorafms:7
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.764-220831
|
||||
Version: 7.0NG.764-220902
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.764-220831"
|
||||
pandora_version="7.0NG.764-220902"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -1015,7 +1015,7 @@ my $Sem = undef;
|
|||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.764';
|
||||
use constant AGENT_BUILD => '220831';
|
||||
use constant AGENT_BUILD => '220902';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.764
|
||||
%define release 220831
|
||||
%define release 220902
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.764
|
||||
%define release 220831
|
||||
%define release 220902
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.764"
|
||||
PI_BUILD="220831"
|
||||
PI_BUILD="220902"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
|
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{220831}
|
||||
{220902}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.764 Build 220831")
|
||||
#define PANDORA_VERSION ("7.0NG.764 Build 220902")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
|||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.764(Build 220831))"
|
||||
VALUE "ProductVersion", "(7.0NG.764(Build 220902))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
FROM mysql:5.5
|
||||
MAINTAINER Pandora FMS Team <info@pandorafms.com>
|
||||
|
||||
WORKDIR /pandorafms/pandora_console
|
||||
|
||||
ADD pandoradb.sql /docker-entrypoint-initdb.d
|
||||
ADD pandoradb_data.sql /docker-entrypoint-initdb.d
|
||||
RUN chown mysql /docker-entrypoint-initdb.d
|
||||
|
||||
ENV MYSQL_DATABASE=pandora
|
||||
|
||||
RUN echo " \n\
|
||||
sed -i \"1iUSE \$MYSQL_DATABASE\" /docker-entrypoint-initdb.d/pandoradb.sql \n\
|
||||
sed -i \"1iUSE \$MYSQL_DATABASE\" /docker-entrypoint-initdb.d/pandoradb_data.sql \n\
|
||||
" >> /docker-entrypoint-initdb.d/create_pandoradb.sh
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 7.0NG.764-220831
|
||||
Version: 7.0NG.764-220902
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.764-220831"
|
||||
pandora_version="7.0NG.764-220902"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
FROM centos:centos6
|
||||
MAINTAINER Pandora FMS Team <info@pandorafms.com>
|
||||
|
||||
RUN { \
|
||||
echo '[EPEL]'; \
|
||||
echo 'name = CentOS Epel'; \
|
||||
echo 'baseurl = http://dl.fedoraproject.org/pub/epel/6/x86_64'; \
|
||||
echo 'enabled=1'; \
|
||||
echo 'gpgcheck=0'; \
|
||||
} > /etc/yum.repos.d/extra_repos.repo
|
||||
|
||||
RUN { \
|
||||
echo '[artica_pandorafms]'; \
|
||||
echo 'name=CentOS6 - PandoraFMS official repo'; \
|
||||
echo 'baseurl=http://artica.es/centos6'; \
|
||||
echo 'gpgcheck=0'; \
|
||||
echo 'enabled=1'; \
|
||||
} > /etc/yum.repos.d/pandorafms.repo
|
||||
|
||||
RUN yum -y update; yum clean all;
|
||||
RUN yum install -y \
|
||||
git \
|
||||
httpd \
|
||||
cronie \
|
||||
ntp \
|
||||
openldap \
|
||||
nfdump \
|
||||
wget \
|
||||
curl \
|
||||
openldap \
|
||||
plymouth \
|
||||
xterm \
|
||||
php \
|
||||
php-gd \
|
||||
graphviz \
|
||||
php-mysql \
|
||||
php-pear-DB \
|
||||
php-pear \
|
||||
php-pdo \
|
||||
php-mbstring \
|
||||
php-ldap \
|
||||
php-snmp \
|
||||
php-ldap \
|
||||
php-common \
|
||||
php-zip \
|
||||
nmap \
|
||||
net-snmp-utils \
|
||||
mod_ssl \
|
||||
xprobe2
|
||||
|
||||
#Clone the repo
|
||||
RUN git clone -b develop https://github.com/pandorafms/pandorafms.git /tmp/pandorafms
|
||||
|
||||
#Exposing ports for: HTTP, SNMP Traps, Tentacle protocol
|
||||
EXPOSE 80 162/udp 443 41121
|
||||
|
||||
# Simple startup script to avoid some issues observed with container restart
|
||||
ADD docker_entrypoint.sh /entrypoint.sh
|
||||
RUN chmod -v +x /entrypoint.sh
|
||||
|
||||
CMD ["/entrypoint.sh"]
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
|
||||
if [ -z "$PANDORA_DB_HOST" ]; then
|
||||
PANDORA_DB_HOST='mysql'
|
||||
else
|
||||
echo >&2 'warning: both PANDORA_DB_HOST and MYSQL_PORT_3306_TCP found'
|
||||
echo >&2 " Connecting to PANDORA_DB_HOST ($PANDORA_DB_HOST)"
|
||||
echo >&2 ' instead of the linked mysql container'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$PANDORA_DB_HOST" ]; then
|
||||
echo >&2 'error: missing PANDORA_DB_HOST and MYSQL_PORT_3306_TCP environment variables'
|
||||
echo >&2 ' Did you forget to --link some_mysql_container:mysql or set an external db'
|
||||
echo >&2 ' with -e PANDORA_DB_HOST=hostname:port?'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if we're linked to MySQL and thus have credentials already, let's use them
|
||||
: ${PANDORA_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}
|
||||
if [ "$PANDORA_DB_USER" = 'root' ]; then
|
||||
: ${PANDORA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
|
||||
fi
|
||||
: ${PANDORA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_PASSWORD}
|
||||
if [ -z "$PANDORA_DB_NAME" ]; then
|
||||
: ${PANDORA_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-pandora}}
|
||||
fi
|
||||
|
||||
if [ -z "$PANDORA_DB_PASSWORD" ]; then
|
||||
echo >&2 'error: missing required PANDORA_DB_PASSWORD environment variable'
|
||||
echo >&2 ' Did you forget to -e PANDORA_DB_PASSWORD=... ?'
|
||||
echo >&2
|
||||
echo >&2 ' (Also of interest might be PANDORA_DB_USER and PANDORA_DB_NAME.)'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mv -f /tmp/pandorafms/pandora_console /var/www/html
|
||||
cd /var/www/html/pandora_console/include
|
||||
cat > config.php <<- 'EOF'
|
||||
<?php
|
||||
$config["dbtype"] = "mysql";
|
||||
$config["homedir"]="/var/www/html/pandora_console"; // Config homedir
|
||||
$config["homeurl"]="/pandora_console"; // Base URL
|
||||
$config["homeurl_static"]="/pandora_console"; // Don't delete
|
||||
error_reporting(E_ALL);
|
||||
$ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
|
||||
EOF
|
||||
|
||||
echo "\$config[\"dbname\"]=\"$PANDORA_DB_NAME\";" >> config.php
|
||||
echo "\$config[\"dbuser\"]=\"$PANDORA_DB_USER\";" >> config.php
|
||||
echo "\$config[\"dbpass\"]=\"$PANDORA_DB_PASSWORD\";" >> config.php
|
||||
echo "\$config[\"dbhost\"]=\"$PANDORA_DB_HOST\";" >> config.php
|
||||
echo "include (\$ownDir . \"config_process.php\");" >> config.php
|
||||
echo "?>" >> config.php
|
||||
|
||||
echo "Granting apache permissions to the console directory"
|
||||
chown -R apache:apache /var/www/html/pandora_console
|
||||
chmod 600 /var/www/html/pandora_console/include/config.php
|
||||
|
||||
# Customize php.iniA
|
||||
echo "Configuring Pandora FMS elements and depending services"
|
||||
sed "s/.*error_reporting =.*/error_reporting = E_ALL \& \~E_DEPRECATED \& \~E_NOTICE \& \~E_USER_WARNING/" /etc/php.ini > /tmp/php.ini && mv /tmp/php.ini /etc/php.ini
|
||||
sed "s/.*max_execution_time =.*/max_execution_time = 0/" /etc/php.ini > /tmp/php.ini && mv /tmp/php.ini /etc/php.ini
|
||||
sed "s/.*max_input_time =.*/max_input_time = -1/" /etc/php.ini > /tmp/php.ini && mv /tmp/php.ini /etc/php.ini
|
||||
sed "s/.*upload_max_filesize =.*/upload_max_filesize = 800M/" /etc/php.ini > /tmp/php.ini && mv /tmp/php.ini /etc/php.ini
|
||||
sed "s/.*memory_limit =.*/memory_limit = 800M/" /etc/php.ini > /tmp/php.ini && mv /tmp/php.ini /etc/php.ini
|
||||
sed "s/.*post_max_size =.*/post_max_size = 100M/" /etc/php.ini > /tmp/php.ini && mv /tmp/php.ini /etc/php.ini
|
||||
|
||||
cd /var/www/html/pandora_console && mv -f install.php install.php.done
|
||||
|
||||
#Create the pandora user
|
||||
/usr/sbin/useradd -d /home/pandora -s /bin/false -M -g 0 pandora
|
||||
|
||||
#Rock n' roll!
|
||||
/etc/init.d/crond start &
|
||||
/etc/init.d/ntpd start &
|
||||
|
||||
rm -rf /run/httpd/*
|
||||
exec /usr/sbin/apachectl -D FOREGROUND
|
|
@ -1,6 +1,8 @@
|
|||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `tmap` ADD COLUMN `refresh_time` INT UNSIGNED NOT NULL DEFAULT 0;
|
||||
ALTER TABLE `tplanned_downtime` ADD COLUMN `cron_interval_from` VARCHAR(100) DEFAULT '';
|
||||
ALTER TABLE `tplanned_downtime` ADD COLUMN `cron_interval_to` VARCHAR(100) DEFAULT '';
|
||||
|
||||
SET @id_config := (SELECT id_config FROM tconfig WHERE `token` = 'metaconsole_node_id' AND `value` IS NOT NULL ORDER BY id_config DESC LIMIT 1);
|
||||
DELETE FROM tconfig WHERE `token` = 'metaconsole_node_id' AND (id_config < @id_config OR `value` IS NULL);
|
||||
|
|
|
@ -137,7 +137,16 @@ $table->data[] = $tdata;
|
|||
|
||||
// Modules by status.
|
||||
$tdata = [];
|
||||
$tdata[0] = reporting_get_stats_modules_status($data, 180, 100);
|
||||
|
||||
$data_agents = [
|
||||
__('Critical') => $data['monitor_critical'],
|
||||
__('Warning') => $data['monitor_warning'],
|
||||
__('Normal') => $data['monitor_ok'],
|
||||
__('Unknown') => $data['monitor_unknown'],
|
||||
__('Not init') => $data['monitor_not_init'],
|
||||
];
|
||||
|
||||
$tdata[0] = reporting_get_stats_modules_status($data, 180, 100, false, $data_agents);
|
||||
$table->rowclass[] = '';
|
||||
$table->data[] = $tdata;
|
||||
|
||||
|
|
|
@ -466,7 +466,14 @@ if ($module_action === 'delete') {
|
|||
$id_agent_module_disable
|
||||
);
|
||||
|
||||
if (db_process_sql($sql)) {
|
||||
$id_agent_changed[] = modules_get_agentmodule_agent($id_agent_module_disable);
|
||||
$agent_update_result = db_process_sql_update(
|
||||
'tagente',
|
||||
['update_module_count' => 1],
|
||||
['id_agente' => $id_agent_changed]
|
||||
);
|
||||
|
||||
if (db_process_sql($sql) !== false && $agent_update_result !== false) {
|
||||
$updated_count++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ if (!$agent_d && !$agent_w) {
|
|||
set_unless_defined($config['past_planned_downtimes'], 1);
|
||||
|
||||
require_once 'include/functions_users.php';
|
||||
require_once $config['homedir'].'/include/functions_cron.php';
|
||||
|
||||
// Buttons.
|
||||
$buttons = [
|
||||
|
@ -123,6 +124,18 @@ $periodically_time_to = (string) get_parameter(
|
|||
date(TIME_FORMAT, ($system_time + SECONDS_1HOUR))
|
||||
);
|
||||
|
||||
$hour_from = get_parameter('cron_hour_from', '*');
|
||||
$minute_from = get_parameter('cron_minute_from', '*');
|
||||
$mday_from = get_parameter('cron_mday_from', '*');
|
||||
$month_from = get_parameter('cron_month_from', '*');
|
||||
$wday_from = get_parameter('cron_wday_from', '*');
|
||||
|
||||
$hour_to = get_parameter('cron_hour_to', '*');
|
||||
$minute_to = get_parameter('cron_minute_to', '*');
|
||||
$mday_to = get_parameter('cron_mday_to', '*');
|
||||
$month_to = get_parameter('cron_month_to', '*');
|
||||
$wday_to = get_parameter('cron_wday_to', '*');
|
||||
|
||||
$monday = (bool) get_parameter('monday');
|
||||
$tuesday = (bool) get_parameter('tuesday');
|
||||
$wednesday = (bool) get_parameter('wednesday');
|
||||
|
@ -262,6 +275,193 @@ if ($create_downtime || $update_downtime) {
|
|||
);
|
||||
} else {
|
||||
$sql = '';
|
||||
$error_cron_from = false;
|
||||
$error_cron_to = false;
|
||||
$error_field = '';
|
||||
|
||||
if ($type_execution === 'cron') {
|
||||
// Validate 'from' cron values.
|
||||
$hour_from = io_safe_output(trim($hour_from));
|
||||
if (preg_match('/^((?:([0-1]?[0-9]|2[0-3])|\*)\s*(?:(?:[\/-]([0-1]?[0-9]|2[0-3])))?\s*)$/', $hour_from, $matches) !== 1) {
|
||||
$error_cron_from = true;
|
||||
$error_field = __('hour (from)');
|
||||
} else {
|
||||
$interval_values = explode('-', $hour_from);
|
||||
|
||||
if (count($interval_values) > 1) {
|
||||
$interval_from = $interval_values[0];
|
||||
$interval_to = $interval_values[1];
|
||||
|
||||
if ((int) $interval_to < (int) $interval_from) {
|
||||
$error_cron_from = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$minute_from = io_safe_output(trim($minute_from));
|
||||
if (preg_match('/^((?:(5[0-9]|[0-5]?[0-9])|\*)\s*(?:(?:[\/-](5[0-9]|[0-5]?[0-9])))?\s*)$/', $minute_from, $matches) !== 1) {
|
||||
$error_cron_from = true;
|
||||
$error_field = __('minute (from)');
|
||||
} else {
|
||||
$interval_values = explode('-', $minute_from);
|
||||
|
||||
if (count($interval_values) > 1) {
|
||||
$interval_from = $interval_values[0];
|
||||
$interval_to = $interval_values[1];
|
||||
|
||||
if ((int) $interval_to < (int) $interval_from) {
|
||||
$error_cron_from = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mday_from = io_safe_output(trim($mday_from));
|
||||
if (preg_match('/^((?:(0?[1-9]|[12][0-9]|3[01])|\*)\s*(?:(?:[\/-](0?[1-9]|[12][0-9]|3[01])))?\s*)$/', $mday_from, $matches) !== 1) {
|
||||
$error_cron_from = true;
|
||||
$error_field = __('month day (from)');
|
||||
} else {
|
||||
$interval_values = explode('-', $mday_from);
|
||||
|
||||
if (count($interval_values) > 1) {
|
||||
$interval_from = $interval_values[0];
|
||||
$interval_to = $interval_values[1];
|
||||
|
||||
if ((int) $interval_to < (int) $interval_from) {
|
||||
$error_cron_from = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$month_from = io_safe_output(trim($month_from));
|
||||
if (preg_match('/^((?:([1-9]|1[012])|\*)\s*(?:(?:[\/-]([1-9]|1[012])))?\s*)$/', $month_from, $matches) !== 1) {
|
||||
$error_cron_from = true;
|
||||
$error_field = __('month (from)');
|
||||
} else {
|
||||
$interval_values = explode('-', $month_from);
|
||||
|
||||
if (count($interval_values) > 1) {
|
||||
$interval_from = $interval_values[0];
|
||||
$interval_to = $interval_values[1];
|
||||
|
||||
if ((int) $interval_to < (int) $interval_from) {
|
||||
$error_cron_from = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$wday_from = io_safe_output(trim($wday_from));
|
||||
if (preg_match('/^((?:[0-6]|\*)\s*(?:(?:[\/-][0-6]))?\s*)$/', $wday_from, $matches) !== 1) {
|
||||
$error_cron_from = true;
|
||||
$error_field = __('week day (from)');
|
||||
} else {
|
||||
$interval_values = explode('-', $wday_from);
|
||||
if (count($interval_values) > 1) {
|
||||
$interval_from = $interval_values[0];
|
||||
$interval_to = $interval_values[1];
|
||||
|
||||
if ((int) $interval_to < (int) $interval_from) {
|
||||
$error_cron_from = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate 'to' cron values.
|
||||
$hour_to = io_safe_output(trim($hour_to));
|
||||
if (preg_match('/^((?:([0-1]?[0-9]|2[0-3])|\*)\s*(?:(?:[\/-]([0-1]?[0-9]|2[0-3])))?\s*)$/', $hour_to, $matches) !== 1) {
|
||||
$error_cron_to = true;
|
||||
$error_field = __('hour (to)');
|
||||
} else {
|
||||
$interval_values = explode('-', $hour_to);
|
||||
|
||||
if (count($interval_values) > 1) {
|
||||
$interval_from = $interval_values[0];
|
||||
$interval_to = $interval_values[1];
|
||||
|
||||
if ((int) $interval_to < (int) $interval_from) {
|
||||
$error_cron_to = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$minute_to = io_safe_output(trim($minute_to));
|
||||
if (preg_match('/^((?:(5[0-9]|[0-5]?[0-9])|\*)\s*(?:(?:[\/-](5[0-9]|[0-5]?[0-9])))?\s*)$/', $minute_to, $matches) !== 1) {
|
||||
$error_cron_to = true;
|
||||
$error_field = __('minute (to)');
|
||||
} else {
|
||||
$interval_values = explode('-', $minute_to);
|
||||
|
||||
if (count($interval_values) > 1) {
|
||||
$interval_from = $interval_values[0];
|
||||
$interval_to = $interval_values[1];
|
||||
|
||||
if ((int) $interval_to < (int) $interval_from) {
|
||||
$error_cron_to = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mday_to = io_safe_output(trim($mday_to));
|
||||
if (preg_match('/^((?:(0?[1-9]|[12][0-9]|3[01])|\*)\s*(?:(?:[\/-](0?[1-9]|[12][0-9]|3[01])))?\s*)$/', $mday_to, $matches) !== 1) {
|
||||
$error_cron_to = true;
|
||||
$error_field = __('month day (to)');
|
||||
} else {
|
||||
$interval_values = explode('-', $mday_to);
|
||||
|
||||
if (count($interval_values) > 1) {
|
||||
$interval_from = $interval_values[0];
|
||||
$interval_to = $interval_values[1];
|
||||
|
||||
if ((int) $interval_to < (int) $interval_from) {
|
||||
$error_cron_to = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$month_to = io_safe_output(trim($month_to));
|
||||
if (preg_match('/^((?:([1-9]|1[012])|\*)\s*(?:(?:[\/-]([1-9]|1[012])))?\s*)$/', $month_to, $matches) !== 1) {
|
||||
$error_cron_to = true;
|
||||
$error_field = __('month (to)');
|
||||
} else {
|
||||
$interval_values = explode('-', $month_to);
|
||||
|
||||
if (count($interval_values) > 1) {
|
||||
$interval_from = $interval_values[0];
|
||||
$interval_to = $interval_values[1];
|
||||
|
||||
if ((int) $interval_to < (int) $interval_from) {
|
||||
$error_cron_to = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$wday_to = io_safe_output(trim($wday_to));
|
||||
if (preg_match('/^((?:[0-6]|\*)\s*(?:(?:[\/-][0-6]))?\s*)$/', $wday_to, $matches) !== 1) {
|
||||
$error_cron_to = true;
|
||||
$error_field = __('week day (to)');
|
||||
} else {
|
||||
$interval_values = explode('-', $wday_to);
|
||||
if (count($interval_values) > 1) {
|
||||
$interval_from = $interval_values[0];
|
||||
$interval_to = $interval_values[1];
|
||||
|
||||
if ((int) $interval_to < (int) $interval_from) {
|
||||
$error_cron_to = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$cron_interval_from = io_safe_output($minute_from.' '.$hour_from.' '.$mday_from.' '.$month_from.' '.$wday_from);
|
||||
$cron_interval_to = io_safe_output($minute_to.' '.$hour_to.' '.$mday_to.' '.$month_to.' '.$wday_to);
|
||||
}
|
||||
|
||||
if (cron_check_syntax($cron_interval_from) !== 1) {
|
||||
$cron_interval_from = '';
|
||||
}
|
||||
|
||||
if (cron_check_syntax($cron_interval_to) !== 1) {
|
||||
$cron_interval_to = '';
|
||||
}
|
||||
|
||||
if ($create_downtime) {
|
||||
// Check AD permission on new downtime.
|
||||
if (!in_array($id_group, $user_groups_ad)) {
|
||||
|
@ -273,6 +473,21 @@ if ($create_downtime || $update_downtime) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($error_cron_to === true || $error_cron_from === true) {
|
||||
if ($error_cron_from === true) {
|
||||
ui_print_error_message(
|
||||
__('Downtime start cron expression is not correct').': '.$error_field
|
||||
);
|
||||
}
|
||||
|
||||
if ($error_cron_to === true) {
|
||||
ui_print_error_message(
|
||||
__('Downtime stop cron expression is not correct').': '.$error_field
|
||||
);
|
||||
}
|
||||
|
||||
$result = false;
|
||||
} else {
|
||||
if (trim(io_safe_output($name)) != '') {
|
||||
if (!$check) {
|
||||
$values = [
|
||||
|
@ -298,6 +513,8 @@ if ($create_downtime || $update_downtime) {
|
|||
'type_execution' => $type_execution,
|
||||
'type_periodicity' => $type_periodicity,
|
||||
'id_user' => $config['id_user'],
|
||||
'cron_interval_from' => $cron_interval_from,
|
||||
'cron_interval_to' => $cron_interval_to,
|
||||
];
|
||||
if ($config['dbtype'] == 'oracle') {
|
||||
$values['periodically_time_from'] = '1970/01/01 '.$values['periodically_time_from'];
|
||||
|
@ -318,6 +535,7 @@ if ($create_downtime || $update_downtime) {
|
|||
__('Scheduled downtime must have a name')
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if ($update_downtime) {
|
||||
$old_downtime = db_get_row('tplanned_downtime', 'id', $id_downtime);
|
||||
|
||||
|
@ -381,6 +599,8 @@ if ($create_downtime || $update_downtime) {
|
|||
'type_execution' => $type_execution,
|
||||
'type_periodicity' => $type_periodicity,
|
||||
'id_user' => $config['id_user'],
|
||||
'cron_interval_from' => $cron_interval_from,
|
||||
'cron_interval_to' => $cron_interval_to,
|
||||
];
|
||||
if ($config['dbtype'] == 'oracle') {
|
||||
$values['periodically_time_from'] = '1970/01/01 '.$values['periodically_time_from'];
|
||||
|
@ -388,6 +608,21 @@ if ($create_downtime || $update_downtime) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($error_cron_to === true || $error_cron_from === true) {
|
||||
if ($error_cron_from === true) {
|
||||
ui_print_error_message(
|
||||
__('Downtime start cron expression is not correct').': '.$error_field
|
||||
);
|
||||
}
|
||||
|
||||
if ($error_cron_to === true) {
|
||||
ui_print_error_message(
|
||||
__('Downtime stop cron expression is not correct').': '.$error_field
|
||||
);
|
||||
}
|
||||
|
||||
$result = false;
|
||||
} else {
|
||||
if ($is_running) {
|
||||
$result = false;
|
||||
} else {
|
||||
|
@ -400,6 +635,7 @@ if ($create_downtime || $update_downtime) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($result === false) {
|
||||
if ($create_downtime) {
|
||||
|
@ -458,6 +694,8 @@ if ($id_downtime > 0) {
|
|||
'type_execution',
|
||||
'type_periodicity',
|
||||
'id_user',
|
||||
'cron_interval_from',
|
||||
'cron_interval_to',
|
||||
];
|
||||
|
||||
switch ($config['dbtype']) {
|
||||
|
@ -532,6 +770,36 @@ if ($id_downtime > 0) {
|
|||
$saturday = (bool) $result['saturday'];
|
||||
$sunday = (bool) $result['sunday'];
|
||||
|
||||
$cron_interval_from = explode(' ', $result['cron_interval_from']);
|
||||
if (isset($cron_interval_from[4]) === true) {
|
||||
$minute_from = $cron_interval_from[0];
|
||||
$hour_from = $cron_interval_from[1];
|
||||
$mday_from = $cron_interval_from[2];
|
||||
$month_from = $cron_interval_from[3];
|
||||
$wday_from = $cron_interval_from[4];
|
||||
} else {
|
||||
$minute_from = '*';
|
||||
$hour_from = '*';
|
||||
$mday_from = '*';
|
||||
$month_from = '*';
|
||||
$wday_from = '*';
|
||||
}
|
||||
|
||||
$cron_interval_to = explode(' ', $result['cron_interval_to']);
|
||||
if (isset($cron_interval_to[4]) === true) {
|
||||
$minute_to = $cron_interval_to[0];
|
||||
$hour_to = $cron_interval_to[1];
|
||||
$mday_to = $cron_interval_to[2];
|
||||
$month_to = $cron_interval_to[3];
|
||||
$wday_to = $cron_interval_to[4];
|
||||
} else {
|
||||
$minute_to = '*';
|
||||
$hour_to = '*';
|
||||
$mday_to = '*';
|
||||
$month_to = '*';
|
||||
$wday_to = '*';
|
||||
}
|
||||
|
||||
$running = (bool) $result['executed'];
|
||||
}
|
||||
|
||||
|
@ -611,6 +879,7 @@ $table->data[4][1] = html_print_select(
|
|||
[
|
||||
'once' => __('Once'),
|
||||
'periodically' => __('Periodically'),
|
||||
'cron' => __('Cron from/to'),
|
||||
],
|
||||
'type_execution',
|
||||
$type_execution,
|
||||
|
@ -740,6 +1009,18 @@ $table->data[5][1] = "
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="cron_time" style="display: none;">
|
||||
<table class="w100p">
|
||||
<tr>
|
||||
<td>'.__('Cron from:').'</td>
|
||||
<td>'.html_print_extended_select_for_cron($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, false, false, true, 'from').'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>'.__('Cron to:').'</td>
|
||||
<td>'.html_print_extended_select_for_cron($hour_to, $minute_to, $mday_to, $month_to, $wday_to, true, false, true, true, 'to').'</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>';
|
||||
|
||||
if ($id_downtime > 0) {
|
||||
|
@ -1254,12 +1535,19 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
|
|||
switch ($("#type_execution").val()) {
|
||||
case 'once':
|
||||
$("#periodically_time").hide();
|
||||
$("#cron_time").hide();
|
||||
$("#once_time").show();
|
||||
break;
|
||||
case 'periodically':
|
||||
$("#once_time").hide();
|
||||
$("#cron_time").hide();
|
||||
$("#periodically_time").show();
|
||||
break;
|
||||
case 'cron':
|
||||
$("#once_time").hide();
|
||||
$("#periodically_time").hide();
|
||||
$("#cron_time").show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -317,6 +317,7 @@ $row = [];
|
|||
$execution_type_fields = [
|
||||
'once' => __('Once'),
|
||||
'periodically' => __('Periodically'),
|
||||
'cron' => __('Cron'),
|
||||
];
|
||||
$row[] = __('Execution type').' '.html_print_select(
|
||||
$execution_type_fields,
|
||||
|
@ -460,10 +461,15 @@ if (empty($groups) === false) {
|
|||
strtotime($date_to.' 23:59:59')
|
||||
);
|
||||
|
||||
$cron = sprintf(
|
||||
'type_execution = "cron"'
|
||||
);
|
||||
|
||||
$where_values .= sprintf(
|
||||
' AND ((%s) OR (%s))',
|
||||
' AND ((%s) OR (%s) OR (%s))',
|
||||
$periodically_w,
|
||||
$once_w
|
||||
$once_w,
|
||||
$cron
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -471,6 +477,7 @@ if (empty($groups) === false) {
|
|||
$filter_performed = true;
|
||||
$where_values .= sprintf(
|
||||
' AND (type_execution = "periodically"
|
||||
OR type_execution = "cron"
|
||||
OR (type_execution = "once"
|
||||
AND date_to >= "%s"))',
|
||||
time()
|
||||
|
@ -530,6 +537,8 @@ if (empty($groups) === false) {
|
|||
'type_execution',
|
||||
'type_periodicity',
|
||||
'id_user',
|
||||
'cron_interval_from',
|
||||
'cron_interval_to',
|
||||
];
|
||||
|
||||
$columns_str = implode(',', $columns);
|
||||
|
@ -660,8 +669,9 @@ if ($downtimes === false && $filter_performed === false) {
|
|||
$data['type'] = $type_text[$downtime['type_downtime']];
|
||||
|
||||
$execution_text = [
|
||||
'once' => __('once'),
|
||||
'once' => __('Once'),
|
||||
'periodically' => __('Periodically'),
|
||||
'cron' => __('Cron'),
|
||||
];
|
||||
|
||||
$data['execution'] = $execution_text[$downtime['type_execution']];
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC220831';
|
||||
$build_version = 'PC220902';
|
||||
$pandora_version = 'v7.0NG.764';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
|
|
@ -45,6 +45,7 @@ require_once $config['homedir'].'/include/functions_servers.php';
|
|||
require_once $config['homedir'].'/include/functions_planned_downtimes.php';
|
||||
require_once $config['homedir'].'/include/functions_db.php';
|
||||
require_once $config['homedir'].'/include/functions_event_responses.php';
|
||||
require_once $config['homedir'].'/include/functions_tactical.php';
|
||||
enterprise_include_once('include/functions_local_components.php');
|
||||
enterprise_include_once('include/functions_events.php');
|
||||
enterprise_include_once('include/functions_agents.php');
|
||||
|
@ -12706,7 +12707,7 @@ function api_get_total_modules($id_group, $trash1, $trash2, $returnType)
|
|||
{
|
||||
global $config;
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
if (is_metaconsole() === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -12715,20 +12716,9 @@ function api_get_total_modules($id_group, $trash1, $trash2, $returnType)
|
|||
return;
|
||||
}
|
||||
|
||||
$groups_clause = '1 = 1';
|
||||
if (!users_is_admin($config['id_user'])) {
|
||||
$user_groups = implode(',', array_keys(users_get_groups()));
|
||||
$groups_clause = "(ta.id_grupo IN ($user_groups) OR tasg.id_group IN ($user_groups))";
|
||||
}
|
||||
$partial = tactical_status_modules_agents($config['id_user'], false, 'AR');
|
||||
|
||||
$sql = "SELECT COUNT(DISTINCT(id_agente_modulo))
|
||||
FROM tagente_modulo tam, tagente ta
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
WHERE tam.id_agente = ta.id_agente AND id_module_group = $id_group
|
||||
AND delete_pending = 0 AND $groups_clause";
|
||||
|
||||
$total = db_get_value_sql($sql);
|
||||
$total = (int) $partial['_monitor_total_'];
|
||||
|
||||
$data = [
|
||||
'type' => 'string',
|
||||
|
|
|
@ -2237,7 +2237,7 @@ function html_print_extended_select_for_time(
|
|||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*', $month='*', $wday='*', $return=false, $disabled=false, $to=false)
|
||||
function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*', $month='*', $wday='*', $return=false, $disabled=false, $to=false, $advanced=false, $adv_mode_name='')
|
||||
{
|
||||
// Hours
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
|
@ -2286,6 +2286,7 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
|
|||
$table->head[3] = __('Month');
|
||||
$table->head[4] = __('Week day');
|
||||
|
||||
if ($advanced === false) {
|
||||
if ($to) {
|
||||
$table->data[0][0] = html_print_select($hours, 'hour_to', $hour, '', __('Any'), '*', true, false, false, '', $disabled);
|
||||
$table->data[0][1] = html_print_select($minutes, 'minute_to', $minute, '', __('Any'), '*', true, false, false, '', $disabled, false, $minutes_hidden_options);
|
||||
|
@ -2299,6 +2300,91 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
|
|||
$table->data[0][3] = html_print_select($months, 'month_from', $month, '', __('Any'), '*', true, false, false, '', $disabled);
|
||||
$table->data[0][4] = html_print_select($wdays, 'wday_from', $wday, '', __('Any'), '*', true, false, false, '', $disabled);
|
||||
}
|
||||
} else {
|
||||
if ($adv_mode_name !== '') {
|
||||
$adv_mode_name = '_'.$adv_mode_name;
|
||||
}
|
||||
|
||||
$table->data[0][0] = html_print_extended_select_for_downtime_cron(
|
||||
'cron_hour'.$adv_mode_name,
|
||||
$hours,
|
||||
$hour,
|
||||
'',
|
||||
__('Any'),
|
||||
'*',
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
'Valid values: [0-23], [0-23]-[0-23], *, or step value (example: */3, 10/5)'
|
||||
);
|
||||
|
||||
$table->data[0][1] = html_print_extended_select_for_downtime_cron(
|
||||
'cron_minute'.$adv_mode_name,
|
||||
$minutes,
|
||||
$minute,
|
||||
'',
|
||||
__('Any'),
|
||||
'*',
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
'Valid values: [0-59], [0-59]-[0-59], *, or step value (example: */5, 10/1)'
|
||||
);
|
||||
|
||||
$table->data[0][2] = html_print_extended_select_for_downtime_cron(
|
||||
'cron_mday'.$adv_mode_name,
|
||||
$mdays,
|
||||
$mday,
|
||||
'',
|
||||
__('Any'),
|
||||
'*',
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
'Valid values: [1-31], [1-31]-[1-31], *, or step value (example: */5, 7/2)'
|
||||
);
|
||||
|
||||
$table->data[0][3] = html_print_extended_select_for_downtime_cron(
|
||||
'cron_month'.$adv_mode_name,
|
||||
$months,
|
||||
$month,
|
||||
'',
|
||||
__('Any'),
|
||||
'*',
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
'Valid values: [1-12], [1-12]-[1-12], *, or step value (example: */3, 9/1)'
|
||||
);
|
||||
|
||||
$table->data[0][4] = html_print_extended_select_for_downtime_cron(
|
||||
'cron_wday'.$adv_mode_name,
|
||||
$wdays,
|
||||
$wday,
|
||||
'',
|
||||
__('Any'),
|
||||
'*',
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
'Valid values: [0-6], [0-6]-[0-6], *, or step value (example: */2, 3/1)'
|
||||
);
|
||||
}
|
||||
|
||||
return html_print_table($table, $return);
|
||||
}
|
||||
|
@ -6171,3 +6257,112 @@ function html_print_go_back_button(string $url, array $options=[], bool $return=
|
|||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render select box for numeric values and text box for complex values.
|
||||
*
|
||||
* @param string $name Select form name.
|
||||
* @param string $fields Fields to populate select box.
|
||||
* @param mixed $selected Current selected value. It can be a single value or an array of selected values (in combination with multiple).
|
||||
* @param string $script Javascript onChange (select) code.
|
||||
* @param string $nothing Label when nothing is selected.
|
||||
* @param mixed $nothing_value Value when nothing is selected.
|
||||
* @param integer $size Size of the input.
|
||||
* @param boolean $return Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param boolean $select_style Wherter to assign to combo a unique name (to have more than one on same page, like dashboard).
|
||||
* @param boolean $unique_name Uunique name value.
|
||||
* @param boolean $disabled Input renders as disabled.
|
||||
* @param boolean $no_change No change value.
|
||||
* @param boolean $text_help Tooltip.
|
||||
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
function html_print_extended_select_for_downtime_cron(
|
||||
$name,
|
||||
$fields,
|
||||
$selected='',
|
||||
$script='',
|
||||
$nothing='',
|
||||
$nothing_value='0',
|
||||
$size=false,
|
||||
$return=false,
|
||||
$select_style=false,
|
||||
$unique_name=true,
|
||||
$disabled=false,
|
||||
$no_change=0,
|
||||
$text_help=''
|
||||
) {
|
||||
global $config;
|
||||
|
||||
if ($unique_name === true) {
|
||||
$uniq_name = uniqid($name);
|
||||
} else {
|
||||
$uniq_name = $name;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
echo '<div id="'.$uniq_name.'_default" class="w100p inline_line">';
|
||||
html_print_select(
|
||||
$fields,
|
||||
$uniq_name.'_select',
|
||||
$selected,
|
||||
''.$script,
|
||||
$nothing,
|
||||
$nothing_value,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
$disabled,
|
||||
'font-size: xx-small;'.$select_style
|
||||
);
|
||||
echo ' <a href="javascript:">'.html_print_image(
|
||||
'images/pencil.png',
|
||||
true,
|
||||
[
|
||||
'class' => $uniq_name.'_toggler',
|
||||
'alt' => __('Custom'),
|
||||
'title' => __('Custom'),
|
||||
'style' => 'width: 18px;',
|
||||
]
|
||||
).'</a>';
|
||||
echo '</div>';
|
||||
|
||||
$help_tooltip = ($text_help !== '') ? ui_print_help_tip(__($text_help), true) : '';
|
||||
|
||||
echo '<div id="'.$uniq_name.'_manual" class="w100p inline_line">';
|
||||
html_print_input_text($uniq_name.'_text', $selected, '', 20);
|
||||
|
||||
html_print_input_hidden($name, $selected, false, $uniq_name);
|
||||
echo ' <a href="javascript:">'.$help_tooltip.' '.html_print_image(
|
||||
'images/default_list.png',
|
||||
true,
|
||||
[
|
||||
'class' => $uniq_name.'_toggler',
|
||||
'alt' => __('List'),
|
||||
'title' => __('List'),
|
||||
'style' => 'width: 18px;',
|
||||
]
|
||||
).'</a>';
|
||||
echo '</div>';
|
||||
|
||||
$select_init_func = (is_numeric($selected) === true || $selected === '*') ? 'post_process_select_init' : 'post_process_select_init_inv';
|
||||
|
||||
echo "<script type='text/javascript'>
|
||||
$(document).ready (function () {
|
||||
".$select_init_func."('$uniq_name','$selected');
|
||||
post_process_select_events_unit('$uniq_name','$selected');
|
||||
});
|
||||
|
||||
</script>";
|
||||
|
||||
$returnString = ob_get_clean();
|
||||
|
||||
if ($return) {
|
||||
return $returnString;
|
||||
} else {
|
||||
echo $returnString;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11621,7 +11621,7 @@ function reporting_get_stats_alerts($data, $links=false)
|
|||
{
|
||||
global $config;
|
||||
|
||||
// Link URLS
|
||||
// Link URLS.
|
||||
$mobile = false;
|
||||
if (isset($data['mobile'])) {
|
||||
if ($data['mobile']) {
|
||||
|
@ -11637,14 +11637,14 @@ function reporting_get_stats_alerts($data, $links=false)
|
|||
$urls = [];
|
||||
if ($links) {
|
||||
$urls['monitor_alerts'] = 'index.php?sec=estado&sec2=operation/agentes/alerts_status&pure='.$config['pure'];
|
||||
$urls['monitor_alerts_fired'] = 'index.php?sec=estado&sec2=operation/agentes/alerts_status&filter=fired&pure='.$config['pure'];
|
||||
$urls['monitor_alerts_fired'] = 'index.php?sec=estado&sec2=operation/agentes/alerts_status&disabled=fired&pure='.$config['pure'];
|
||||
} else {
|
||||
$urls['monitor_alerts'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60';
|
||||
$urls['monitor_alerts_fired'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&filter=fired';
|
||||
$urls['monitor_alerts_fired'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&disabled=fired';
|
||||
}
|
||||
}
|
||||
|
||||
// Alerts table
|
||||
// Alerts table.
|
||||
$table_al = html_get_predefined_table();
|
||||
|
||||
$tdata = [];
|
||||
|
@ -11683,7 +11683,7 @@ function reporting_get_stats_alerts($data, $links=false)
|
|||
$output = '<fieldset class="databox tactical_set">
|
||||
<legend>'.__('Defined and fired alerts').'</legend>'.html_print_table($table_al, true).'</fieldset>';
|
||||
} else {
|
||||
// Remove the defined alerts cause with the new cache table is difficult to retrieve them
|
||||
// Remove the defined alerts cause with the new cache table is difficult to retrieve them.
|
||||
unset($table_al->data[0][0], $table_al->data[0][1]);
|
||||
|
||||
$table_al->class = 'tactical_view';
|
||||
|
@ -14366,6 +14366,10 @@ function reporting_format_planned_downtime_dates($planned_downtime)
|
|||
$dates = date('Y-m-d H:i', $planned_downtime['date_from']).' '.__('to').' '.date('Y-m-d H:i', $planned_downtime['date_to']);
|
||||
break;
|
||||
|
||||
case 'cron':
|
||||
$dates = __('Start condition').': <span class="italic">'.$planned_downtime['cron_interval_from'].'</span> - '.__('Stop condition').': <span class="italic">'.$planned_downtime['cron_interval_to'].'</span>';
|
||||
break;
|
||||
|
||||
case 'periodically':
|
||||
if (!isset($planned_downtime['type_periodicity'])) {
|
||||
return '';
|
||||
|
|
|
@ -737,6 +737,11 @@ function post_process_select_init(name) {
|
|||
$("#" + name + "_default").show();
|
||||
}
|
||||
|
||||
function post_process_select_init_inv(name) {
|
||||
$("#" + name + "_manual").show();
|
||||
$("#" + name + "_default").hide();
|
||||
}
|
||||
|
||||
function post_process_select_init_unit(name, selected) {
|
||||
// Manual mode is hidden by default
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.764';
|
||||
$build = '220831';
|
||||
$build = '220902';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.764
|
||||
%define release 220831
|
||||
%define release 220902
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.764
|
||||
%define release 220831
|
||||
%define release 220902
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.764
|
||||
%define release 220831
|
||||
%define release 220902
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
|
|
@ -1816,6 +1816,8 @@ CREATE TABLE IF NOT EXISTS `tplanned_downtime` (
|
|||
`type_execution` VARCHAR(100) NOT NULL DEFAULT 'once',
|
||||
`type_periodicity` VARCHAR(100) NOT NULL DEFAULT 'weekly',
|
||||
`id_user` VARCHAR(255) NOT NULL DEFAULT '0',
|
||||
`cron_interval_from` VARCHAR(100) DEFAULT '',
|
||||
`cron_interval_to` VARCHAR(100) DEFAULT '',
|
||||
PRIMARY KEY ( `id` )
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-server
|
||||
Version: 7.0NG.764-220831
|
||||
Version: 7.0NG.764-220902
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.764-220831"
|
||||
pandora_version="7.0NG.764-220902"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
FROM centos:centos6
|
||||
MAINTAINER Pandora FMS Team <info@pandorafms.com>
|
||||
|
||||
RUN { \
|
||||
echo '[EPEL]'; \
|
||||
echo 'name = CentOS Epel'; \
|
||||
echo 'baseurl = http://dl.fedoraproject.org/pub/epel/6/x86_64'; \
|
||||
echo 'enabled=1'; \
|
||||
echo 'gpgcheck=0'; \
|
||||
} > /etc/yum.repos.d/extra_repos.repo
|
||||
|
||||
RUN { \
|
||||
echo '[artica_pandorafms]'; \
|
||||
echo 'name=CentOS6 - PandoraFMS official repo'; \
|
||||
echo 'baseurl=http://artica.es/centos6'; \
|
||||
echo 'gpgcheck=0'; \
|
||||
echo 'enabled=1'; \
|
||||
} > /etc/yum.repos.d/pandorafms.repo
|
||||
|
||||
RUN yum -y update; yum clean all;
|
||||
RUN yum install -y \
|
||||
git \
|
||||
cronie \
|
||||
ntp \
|
||||
wget \
|
||||
curl \
|
||||
xterm \
|
||||
postfix \
|
||||
wmic \
|
||||
perl-HTML-Tree \
|
||||
perl-DBI \
|
||||
perl-DBD-mysql \
|
||||
perl-libwww-perl \
|
||||
perl-XML-Simple \
|
||||
perl-XML-SAX \
|
||||
perl-NetAddr-IP \
|
||||
net-snmp \
|
||||
net-tools \
|
||||
perl-IO-Socket-INET6 \
|
||||
perl-Socket6 \
|
||||
nmap \
|
||||
sudo \
|
||||
xprobe2 \
|
||||
make \
|
||||
perl-CPAN \
|
||||
perl-JSON \
|
||||
net-snmp-perl \
|
||||
perl-Time-HiRes \
|
||||
perl-XML-Twig \
|
||||
perl-Encode-Locale \
|
||||
net-snmp \
|
||||
net-snmp-utils
|
||||
|
||||
|
||||
#Clone the repo
|
||||
RUN git clone -b develop https://github.com/pandorafms/pandorafms.git /tmp/pandorafms
|
||||
|
||||
#Exposing ports for: Tentacle protocol
|
||||
EXPOSE 41121
|
||||
|
||||
# Simple startup script to avoid some issues observed with container restart
|
||||
ADD docker_entrypoint.sh /entrypoint.sh
|
||||
RUN chmod -v +x /entrypoint.sh
|
||||
|
||||
CMD ["/entrypoint.sh"]
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
|
||||
if [ -z "$PANDORA_DB_HOST" ]; then
|
||||
PANDORA_DB_HOST='mysql'
|
||||
else
|
||||
echo >&2 'warning: both PANDORA_DB_HOST and MYSQL_PORT_3306_TCP found'
|
||||
echo >&2 " Connecting to PANDORA_DB_HOST ($PANDORA_DB_HOST)"
|
||||
echo >&2 ' instead of the linked mysql container'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$PANDORA_DB_HOST" ]; then
|
||||
echo >&2 'error: missing PANDORA_DB_HOST and MYSQL_PORT_3306_TCP environment variables'
|
||||
echo >&2 ' Did you forget to --link some_mysql_container:mysql or set an external db'
|
||||
echo >&2 ' with -e PANDORA_DB_HOST=hostname:port?'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if we're linked to MySQL and thus have credentials already, let's use them
|
||||
: ${PANDORA_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}
|
||||
if [ "$PANDORA_DB_USER" = 'root' ]; then
|
||||
: ${PANDORA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
|
||||
fi
|
||||
: ${PANDORA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_PASSWORD}
|
||||
if [ -z "$PANDORA_DB_NAME" ]; then
|
||||
: ${PANDORA_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-pandora}}
|
||||
fi
|
||||
|
||||
if [ -z "$PANDORA_DB_PASSWORD" ]; then
|
||||
echo >&2 'error: missing required PANDORA_DB_PASSWORD environment variable'
|
||||
echo >&2 ' Did you forget to -e PANDORA_DB_PASSWORD=... ?'
|
||||
echo >&2
|
||||
echo >&2 ' (Also of interest might be PANDORA_DB_USER and PANDORA_DB_NAME.)'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Create the pandora user, mainly
|
||||
/usr/sbin/useradd -d /home/pandora -s /bin/false -M -g 0 pandora
|
||||
|
||||
cd /tmp/pandorafms/pandora_server && ./pandora_server_installer --install
|
||||
|
||||
#Configure the Pandora FMS Server to connect to the database
|
||||
sed -i "s/dbname pandora/dbname $PANDORA_DB_NAME/g" /etc/pandora/pandora_server.conf
|
||||
sed -i "s/dbpass pandora/dbpass $PANDORA_DB_PASSWORD/g" /etc/pandora/pandora_server.conf
|
||||
sed -i "s/dbuser pandora/dbuser $PANDORA_DB_USER/g" /etc/pandora/pandora_server.conf
|
||||
sed -i "s/dbhost 127.0.0.1/dbhost $PANDORA_DB_HOST/g" /etc/pandora/pandora_server.conf
|
||||
|
||||
#Rock n' roll!
|
||||
/etc/init.d/crond start &
|
||||
/etc/init.d/ntpd start &
|
||||
/etc/init.d/postfix start &
|
||||
/etc/init.d/tentacle_serverd start &
|
||||
/usr/bin/pandora_server /etc/pandora/pandora_server.conf
|
|
@ -46,7 +46,7 @@ our @EXPORT = qw(
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.764";
|
||||
my $pandora_build = "220831";
|
||||
my $pandora_build = "220902";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
|
|
@ -228,6 +228,8 @@ our @EXPORT = qw(
|
|||
pandora_planned_downtime_monthly_stop
|
||||
pandora_planned_downtime_weekly_start
|
||||
pandora_planned_downtime_weekly_stop
|
||||
pandora_planned_downtime_cron_start
|
||||
pandora_planned_downtime_cron_stop
|
||||
pandora_process_alert
|
||||
pandora_process_module
|
||||
pandora_reset_server
|
||||
|
@ -2224,6 +2226,108 @@ sub pandora_process_module ($$$$$$$$$;$) {
|
|||
}
|
||||
}
|
||||
|
||||
########################################################################
|
||||
=head2 C<< pandora_planned_downtime_cron_start (I<$pa_config>, I<$dbh>) >>
|
||||
|
||||
Start the planned downtime, the cron type.
|
||||
|
||||
=cut
|
||||
########################################################################
|
||||
sub pandora_planned_downtime_cron_start($$) {
|
||||
my ($pa_config, $dbh) = @_;
|
||||
|
||||
my $utimestamp = time();
|
||||
|
||||
# Start pending downtimes
|
||||
my @downtimes = get_db_rows($dbh, 'SELECT *
|
||||
FROM tplanned_downtime
|
||||
WHERE type_execution = ?
|
||||
AND executed = 0', 'cron');
|
||||
|
||||
foreach my $downtime (@downtimes) {
|
||||
my $start_downtime = PandoraFMS::Tools::cron_check($downtime->{'cron_interval_from'}, $utimestamp);
|
||||
|
||||
if ($start_downtime) {
|
||||
if (!defined($downtime->{'description'})) {
|
||||
$downtime->{'description'} = "N/A";
|
||||
}
|
||||
|
||||
if (!defined($downtime->{'name'})) {
|
||||
$downtime->{'name'} = "N/A";
|
||||
}
|
||||
|
||||
logger($pa_config, "Starting planned downtime '" . $downtime->{'name'} . "'.", 10);
|
||||
|
||||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 1
|
||||
WHERE id = ?', $downtime->{'id'});
|
||||
pandora_event ($pa_config,
|
||||
"Server ".$pa_config->{'servername'}." started planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
if ($downtime->{'type_downtime'} eq "quiet") {
|
||||
pandora_planned_downtime_set_quiet_elements($pa_config,
|
||||
$dbh, $downtime->{'id'});
|
||||
}
|
||||
elsif (($downtime->{'type_downtime'} eq "disable_agents")
|
||||
|| ($downtime->{'type_downtime'} eq "disable_agents_alerts")) {
|
||||
pandora_planned_downtime_set_disabled_elements($pa_config,
|
||||
$dbh, $downtime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
########################################################################
|
||||
=head2 C<< pandora_planned_downtime_cron_stop (I<$pa_config>, I<$dbh>) >>
|
||||
|
||||
Stop the planned downtime, the cron type.
|
||||
|
||||
=cut
|
||||
########################################################################
|
||||
sub pandora_planned_downtime_cron_stop($$) {
|
||||
my ($pa_config, $dbh) = @_;
|
||||
|
||||
my $utimestamp = time();
|
||||
|
||||
# Stop executed downtimes
|
||||
my @downtimes = get_db_rows($dbh, 'SELECT *
|
||||
FROM tplanned_downtime
|
||||
WHERE type_execution = ?
|
||||
AND executed = 1', 'cron');
|
||||
|
||||
foreach my $downtime (@downtimes) {
|
||||
my $stop_downtime = PandoraFMS::Tools::cron_check($downtime->{'cron_interval_to'}, $utimestamp);
|
||||
|
||||
if ($stop_downtime) {
|
||||
if (!defined($downtime->{'description'})) {
|
||||
$downtime->{'description'} = "N/A";
|
||||
}
|
||||
|
||||
if (!defined($downtime->{'name'})) {
|
||||
$downtime->{'name'} = "N/A";
|
||||
}
|
||||
|
||||
logger($pa_config, "Stopping planned cron downtime '" . $downtime->{'name'} . "'.", 10);
|
||||
|
||||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 0
|
||||
WHERE id = ?', $downtime->{'id'});
|
||||
pandora_event ($pa_config,
|
||||
"Server ".$pa_config->{'servername'}." stopped planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
if ($downtime->{'type_downtime'} eq "quiet") {
|
||||
pandora_planned_downtime_unset_quiet_elements($pa_config,
|
||||
$dbh, $downtime->{'id'});
|
||||
}
|
||||
elsif (($downtime->{'type_downtime'} eq "disable_agents")
|
||||
|| ($downtime->{'type_downtime'} eq "disable_agents_alerts")) {
|
||||
pandora_planned_downtime_unset_disabled_elements($pa_config,
|
||||
$dbh, $downtime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
########################################################################
|
||||
=head2 C<< pandora_planned_downtime_disabled_once_stop (I<$pa_config>, I<$dbh>) >>
|
||||
|
||||
|
@ -2483,7 +2587,6 @@ sub pandora_planned_downtime_quiet_once_stop($$) {
|
|||
|
||||
logger($pa_config, "[PLANNED_DOWNTIME] " .
|
||||
"Starting planned downtime '" . $downtime->{'name'} . "'.", 10);
|
||||
|
||||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 0
|
||||
WHERE id = ?', $downtime->{'id'});
|
||||
|
@ -2564,6 +2667,7 @@ sub pandora_planned_downtime_monthly_start($$) {
|
|||
WHERE type_periodicity = ?
|
||||
AND executed = 0
|
||||
AND type_execution <> ' . $RDBMS_QUOTE_STRING . 'once' . $RDBMS_QUOTE_STRING . '
|
||||
AND type_execution <> ' . $RDBMS_QUOTE_STRING . 'cron' . $RDBMS_QUOTE_STRING . '
|
||||
AND ((periodically_day_from = ? AND periodically_time_from <= ?) OR (periodically_day_from < ?))
|
||||
AND ((periodically_day_to = ? AND periodically_time_to >= ?) OR (periodically_day_to > ?))',
|
||||
'monthly',
|
||||
|
@ -2641,9 +2745,10 @@ sub pandora_planned_downtime_monthly_stop($$) {
|
|||
WHERE type_periodicity = ?
|
||||
AND executed = 1
|
||||
AND type_execution <> ?
|
||||
AND type_execution <> ?
|
||||
AND (((periodically_day_from = ? AND periodically_time_from > ?) OR (periodically_day_from > ?))
|
||||
OR ((periodically_day_to = ? AND periodically_time_to < ?) OR (periodically_day_to < ?)))',
|
||||
'monthly', 'once',
|
||||
'monthly', 'once', 'cron',
|
||||
$number_day_month, $time, $number_day_month,
|
||||
$number_day_month, $time, $number_day_month);
|
||||
|
||||
|
@ -2701,7 +2806,8 @@ sub pandora_planned_downtime_weekly_start($$) {
|
|||
FROM tplanned_downtime
|
||||
WHERE type_periodicity = ?
|
||||
AND type_execution <> ?
|
||||
AND executed = 0', 'weekly', 'once');
|
||||
AND type_execution <> ?
|
||||
AND executed = 0', 'weekly', 'once', 'cron');
|
||||
|
||||
foreach my $downtime (@downtimes) {
|
||||
my $across_date = $downtime->{'periodically_time_from'} gt $downtime->{'periodically_time_to'} ? 1 : 0 ;
|
||||
|
@ -2811,7 +2917,8 @@ sub pandora_planned_downtime_weekly_stop($$) {
|
|||
FROM tplanned_downtime
|
||||
WHERE type_periodicity = ?
|
||||
AND type_execution <> ?
|
||||
AND executed = 1', 'weekly', 'once');
|
||||
AND type_execution <> ?
|
||||
AND executed = 1', 'weekly', 'once', 'cron');
|
||||
|
||||
foreach my $downtime (@downtimes) {
|
||||
my $across_date = $downtime->{'periodically_time_from'} gt $downtime->{'periodically_time_to'} ? 1 : 0;
|
||||
|
@ -2922,6 +3029,9 @@ sub pandora_planned_downtime ($$) {
|
|||
|
||||
pandora_planned_downtime_weekly_stop($pa_config, $dbh);
|
||||
pandora_planned_downtime_weekly_start($pa_config, $dbh);
|
||||
|
||||
pandora_planned_downtime_cron_start($pa_config, $dbh);
|
||||
pandora_planned_downtime_cron_stop($pa_config, $dbh);
|
||||
}
|
||||
|
||||
########################################################################
|
||||
|
|
|
@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.764";
|
||||
my $pandora_build = "220831";
|
||||
my $pandora_build = "220902";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
|
|
@ -170,6 +170,12 @@ our @EXPORT = qw(
|
|||
p_encode_json
|
||||
p_decode_json
|
||||
get_server_name
|
||||
check_cron_syntax
|
||||
check_cron_interval
|
||||
check_cron_skips
|
||||
check_cron_value
|
||||
check_cron_element
|
||||
cron_check
|
||||
);
|
||||
|
||||
# ID of the different servers
|
||||
|
@ -2688,6 +2694,125 @@ sub p_decode_json {
|
|||
return $decoded_data;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Verify cron syntax
|
||||
################################################################################
|
||||
sub check_cron_syntax ($) {
|
||||
my ($cron) = @_;
|
||||
|
||||
return 0 if !defined ($cron);
|
||||
return ($cron =~ m/^(\d|\*|-|\/|,)+ (\d|\*|-|\/|,)+ (\d|\*|-|\/|,)+ (\d|\*|-|\/|,)+ (\d|\*|-|\/|,)+$/);
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Check if rule is interval rule
|
||||
################################################################################
|
||||
sub check_cron_interval {
|
||||
my ($elem, $elem_curr_time) = @_;
|
||||
|
||||
# Not a range
|
||||
if ($elem !~ /(\d+)\-(\d+)/) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
my ($down, $up) = ($1, $2);
|
||||
|
||||
if ($elem_curr_time >= $down && $elem_curr_time <=$up) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
################################################################################
|
||||
# Check if rule is skip rule
|
||||
################################################################################
|
||||
sub check_cron_skips {
|
||||
my ($elem, $elem_curr_time) = @_;
|
||||
|
||||
if ($elem !~ /(\d+|\*)\/(\d+)/) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
my ($init, $skip) = ($1, $2);
|
||||
|
||||
if ($init eq '*') {
|
||||
$init = 0;
|
||||
}
|
||||
|
||||
if ($elem_curr_time == $init || (($elem_curr_time - $init) % $skip == 0 && $elem_curr_time > $init)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Check if rule is value rule
|
||||
################################################################################
|
||||
sub check_cron_value {
|
||||
my ($elem, $elem_curr_time) = @_;
|
||||
|
||||
if ($elem eq '*' || $elem eq $elem_curr_time) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Check if element match rules
|
||||
###############################################################################
|
||||
sub check_cron_element {
|
||||
my ($elem_cron, $elem_curr_time) = @_;
|
||||
|
||||
my @elems = (split (/,/, $elem_cron));
|
||||
|
||||
my $elem_res = 0;
|
||||
foreach my $elem (@elems) {
|
||||
|
||||
if (check_cron_interval($elem, $elem_curr_time) || check_cron_skips($elem, $elem_curr_time) || check_cron_value($elem, $elem_curr_time)) {
|
||||
$elem_res = 1;
|
||||
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
return $elem_res;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Check if timestamp matches cron command
|
||||
###############################################################################
|
||||
sub cron_check {
|
||||
my ($cron, $utimestamp) = @_;
|
||||
|
||||
if (!check_cron_syntax($cron)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
my @time = localtime($utimestamp);
|
||||
|
||||
my ($minute, $hour, $mday, $month, $wday) = split (/\s/, $cron);
|
||||
|
||||
my $res = 0;
|
||||
|
||||
$res += check_cron_element($minute, $time[1]);
|
||||
$res += check_cron_element($hour, $time[2]);
|
||||
$res += check_cron_element($mday, $time[3]);
|
||||
$res += check_cron_element($month, $time[4]+1);
|
||||
$res += check_cron_element($wday, $time[6]);
|
||||
|
||||
if ($res < 5) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# String name for server type.
|
||||
################################################################################
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.764
|
||||
%define release 220831
|
||||
%define release 220902
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.764
|
||||
%define release 220831
|
||||
%define release 220902
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.764"
|
||||
PI_BUILD="220831"
|
||||
PI_BUILD="220902"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
|
|
@ -35,7 +35,7 @@ use PandoraFMS::Config;
|
|||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.764 Build 220831";
|
||||
my $version = "7.0NG.764 Build 220902";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
|
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
|||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.764 Build 220831";
|
||||
my $version = "7.0NG.764 Build 220902";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
|
Loading…
Reference in New Issue