Moved snmptraps to different image

This commit is contained in:
dotneft
2016-08-03 05:23:39 -07:00
parent e710748c64
commit dcd7f63aa9
47 changed files with 316 additions and 1240 deletions

View File

@ -6,6 +6,7 @@ ARG APK_FLAGS_PERSISTANT="${APK_FLAGS_COMMON} --clean-protected --no-cache"
ARG APK_FLAGS_DEV="${APK_FLAGS_COMMON} --no-cache"
ARG DB_TYPE=mysql
ENV TERM=xterm
ENV MIBDIRS=/var/lib/zabbix/mibs MIBS=+ALL
RUN addgroup zabbix && \
adduser -S \
@ -22,6 +23,8 @@ RUN addgroup zabbix && \
mkdir -p /var/lib/zabbix/ssl/keys && \
mkdir -p /var/lib/zabbix/ssl/ssl_ca && \
mkdir -p /usr/lib/zabbix/externalscripts && \
mkdir -p /var/lib/zabbix/mibs && \
mkdir -p /var/lib/zabbix/snmptraps && \
chown --quiet -R zabbix:root /var/lib/zabbix && \
mkdir -p /usr/share/doc/zabbix-proxy-${DB_TYPE} && \
apk update && \
@ -40,8 +43,8 @@ RUN addgroup zabbix && \
libssh2 && \
rm -rf /var/cache/apk/*
ARG MAJOR_VERSION=master
ARG ZBX_VERSION=${MAJOR_VERSION}
ARG MAJOR_VERSION=3.0
ARG ZBX_VERSION=${MAJOR_VERSION}.4
ARG ZBX_SOURCES=svn://svn.zabbix.com/tags/${ZBX_VERSION}/
ENV ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES} DB_TYPE=${DB_TYPE}
@ -89,7 +92,6 @@ RUN apk add ${APK_FLAGS_DEV} --virtual build-dependencies \
cp conf/zabbix_proxy.conf /etc/zabbix/zabbix_proxy.conf && \
chown --quiet -R zabbix:root /etc/zabbix && \
cp database/${DB_TYPE}/schema.sql /usr/share/doc/zabbix-proxy-${DB_TYPE}/ && \
cp misc/snmptrap/zabbix_trap_receiver.pl /usr/sbin/zabbix_trap_receiver.pl && \
cd /tmp/ && \
rm -rf /tmp/zabbix-${ZBX_VERSION}/ && \
apk del ${APK_FLAGS_COMMON} --purge \
@ -101,7 +103,7 @@ EXPOSE 10051/TCP 162/UDP
WORKDIR /var/lib/zabbix
VOLUME ["/usr/lib/zabbix/externalscripts", "/var/lib/zabbix/enc", "/var/lib/zabbix/modules", "/var/lib/zabbix/ssh_keys"]
VOLUME ["/var/lib/zabbix/ssl/certs", "/var/lib/zabbix/ssl/keys", "/var/lib/zabbix/ssl/ssl_ca"]
VOLUME ["/var/lib/zabbix/ssl/certs", "/var/lib/zabbix/ssl/keys", "/var/lib/zabbix/ssl/ssl_ca", "/var/lib/zabbix/snmptraps", "/var/lib/zabbix/mibs"]
ADD conf/etc/supervisor/ /etc/supervisor/
ADD run_zabbix_component.sh /data/

View File

@ -21,8 +21,6 @@ ZBX_SERVER_HOST=${ZBX_SERVER_HOST:-"zabbix-server"}
# Default Zabbix server port number
ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"}
ZBX_ENABLE_SNMP_TRAPS=${ZBX_ENABLE_SNMP_TRAPS:-"false"}
TZ=${TZ:-"Europe/Riga"}
# Default directories
@ -135,7 +133,7 @@ check_variables_mysql() {
# If root password is not specified use provided credentials
DB_SERVER_ROOT_USER=${DB_SERVER_ROOT_USER:-${MYSQL_USER}}
DB_SERVER_ROOT_PASS=${DB_SERVER_ROOT_PASS:-${MYSQL_PASSWORD}}
[ "${MYSQL_ALLOW_EMPTY_PASSWORD}" == "true" ] || DB_SERVER_ROOT_PASS=${DB_SERVER_ROOT_PASS:-${MYSQL_PASSWORD}}
DB_SERVER_ZBX_USER=${MYSQL_USER:-"zabbix"}
DB_SERVER_ZBX_PASS=${MYSQL_PASSWORD:-"zabbix"}
@ -309,21 +307,21 @@ create_db_schema_mysql() {
if [ -z "${ZBX_DB_VERSION}" ]; then
echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL"
[ -n "${DB_SERVER_ROOT_PASS}" ] && DB_TMP_PASSWORD="--password=\"${DB_SERVER_ROOT_PASS}\""
[ -n "${DB_SERVER_ROOT_PASS}" ] && DB_TMP_PASSWORD=--password=\"${DB_SERVER_ROOT_PASS}\"
cat /usr/share/doc/zabbix-$type-mysql/schema.sql | mysql --silent --skip-column-names \
-h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
-u ${DB_SERVER_ROOT_USER} $DB_TMP_PASSWORD \
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" \
${DB_SERVER_DBNAME} 1>/dev/null
if [ "$type" == "server" ]; then
echo "** Fill the schema with initial data"
cat /usr/share/doc/zabbix-$type-mysql/images.sql | mysql --silent --skip-column-names \
-h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
-u ${DB_SERVER_ROOT_USER} $DB_TMP_PASSWORD \
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" \
${DB_SERVER_DBNAME} 1>/dev/null
cat /usr/share/doc/zabbix-$type-mysql/data.sql | mysql --silent --skip-column-names \
-h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
-u ${DB_SERVER_ROOT_USER} $DB_TMP_PASSWORD \
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" \
${DB_SERVER_DBNAME} 1>/dev/null
fi
fi
@ -482,46 +480,6 @@ prepare_web_server_nginx() {
ln -sf /dev/fd/2 /var/log/php5-fpm.log
}
prepare_snmptrapd() {
SNMPTRAPD_CONF="/etc/snmp/snmptrapd.conf"
SNMPTRAPFMT_CONF="/etc/snmp/snmptrapfmt.conf"
if [ ! -d "/etc/snmp/" ] || [ ! -f "/usr/sbin/snmptrapd" ]; then
echo "**** Impossible to enable SNMP traps feature"
ZBX_ENABLE_SNMP_TRAPS=false
return
fi
echo "** Updating SNMP traps related configuration files"
echo "** Updating snmptrapd"
echo "disableAuthorization yes" >> "$SNMPTRAPD_CONF"
if [ -f "/usr/sbin/snmptrapfmt" ]; then
echo "traphandle default /usr/sbin/snmptrapfmthdlr" >> "$SNMPTRAPD_CONF"
echo "** Updating snmptrapfmt"
sed -i \
-e "/^VARFMT=/s/=.*/=\"%n %v \"/" \
-e '/^LOGFMT=/s/=.*/=\"$x ZBXTRAP $R $G $S $e $*\"/' \
-e "/^LOGFILE=/s/=.*/=\"\/tmp\/snmptraps.log\"/" \
"$SNMPTRAPFMT_CONF"
elif [ -f "/usr/sbin/zabbix_trap_receiver.pl" ]; then
echo "perl do \"/usr/sbin/zabbix_trap_receiver.pl\";" >> "$SNMPTRAPD_CONF"
update_config_var "/usr/sbin/zabbix_trap_receiver.pl" "\$SNMPTrapperFile " "/tmp/snmptraps.log"
fi
if [ -f "/usr/sbin/logrotate" ]; then
if [ ! -f "/etc/logrotate.d/logrotate_zabbix.conf" ]; then
echo "**** Impossible to manage SNMP traps log file. Zabbix logrotate configuration file not found"
fi
else
rm -f "/etc/logrotate.d/logrotate_zabbix.conf"
echo "**** Impossible to manage SNMP traps log file. Logrotate not found"
fi
}
clear_deploy() {
local type=$1
echo "** Cleaning the system"
@ -610,8 +568,9 @@ update_zbx_config() {
update_config_var $ZBX_CONFIG "VMwareCacheSize" "${ZBX_VMWARECACHESIZE}"
update_config_var $ZBX_CONFIG "VMwareTimeout" "${ZBX_VMWARETIMEOUT}"
ZBX_ENABLE_SNMP_TRAPS=${ZBX_ENABLE_SNMP_TRAPS:-"false"}
if [ "${ZBX_ENABLE_SNMP_TRAPS}" == "true" ]; then
update_config_var $ZBX_CONFIG "SNMPTrapperFile" "/tmp/snmptraps.log"
update_config_var $ZBX_CONFIG "SNMPTrapperFile" "${ZABBIX_USER_HOME_DIR}/snmptraps/snmptraps.log"
update_config_var $ZBX_CONFIG "StartSNMPTrapper" "1"
else
update_config_var $ZBX_CONFIG "SNMPTrapperFile"
@ -834,12 +793,6 @@ prepare_server() {
create_db_database_$db_type
create_db_schema_$db_type "server"
if [ "${ZBX_ENABLE_SNMP_TRAPS}" == "true" ]; then
prepare_snmptrapd
else
rm -f $SUPERVISOR_CONFD/supervisord_snmptraps.conf
fi
update_zbx_config "server" "$db_type"
}
prepare_proxy() {
@ -855,12 +808,6 @@ prepare_proxy() {
create_db_schema_$db_type "proxy"
fi
if [ "${ZBX_ENABLE_SNMP_TRAPS}" == "true" ]; then
prepare_snmptrapd
else
rm -f $SUPERVISOR_CONFD/supervisord_snmptraps.conf
fi
update_zbx_config "proxy" $db_type
}
prepare_web() {

View File

@ -6,11 +6,10 @@ ARG APT_FLAGS_PERSISTANT="${APT_FLAGS_COMMON} --no-install-recommends"
ARG APT_FLAGS_DEV="${APT_FLAGS_COMMON} --no-install-recommends"
ARG DB_TYPE=mysql
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive TERM=xterm
ENV MIBDIRS=/var/lib/zabbix/mibs MIBS=+ALL
RUN DISTRIB_CODENAME=$(/bin/bash -c 'source /etc/lsb-release && echo $DISTRIB_CODENAME') && \
locale-gen $LC_ALL && \
RUN locale-gen $LC_ALL && \
echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \
echo "deb http://us.archive.ubuntu.com/ubuntu/ $DISTRIB_CODENAME multiverse" >> /etc/apt/sources.list && \
addgroup --system --quiet zabbix && \
adduser --quiet \
--system --disabled-login \
@ -26,6 +25,8 @@ RUN DISTRIB_CODENAME=$(/bin/bash -c 'source /etc/lsb-release && echo $DISTRIB_CO
mkdir -p /var/lib/zabbix/ssl/certs && \
mkdir -p /var/lib/zabbix/ssl/keys && \
mkdir -p /var/lib/zabbix/ssl/ssl_ca && \
mkdir -p /var/lib/zabbix/mibs && \
mkdir -p /var/lib/zabbix/snmptraps && \
mkdir -p /usr/lib/zabbix/externalscripts && \
chown --quiet -R zabbix:root /var/lib/zabbix && \
mkdir -p /usr/share/doc/zabbix-proxy-${DB_TYPE} && \
@ -35,21 +36,20 @@ RUN DISTRIB_CODENAME=$(/bin/bash -c 'source /etc/lsb-release && echo $DISTRIB_CO
mysql-client \
libmysqlclient18 \
libiksemel3 \
libsnmp30 \
libcurl3 \
unixodbc \
libssh2-1 \
libssl1.0.0 \
libxml2 \
fping \
libopenipmi0 \
snmptrapfmt \
snmp-mibs-downloader 1>/dev/null && \
libopenipmi0 1>/dev/null && \
apt-get ${APT_FLAGS_COMMON} autoremove && \
apt-get ${APT_FLAGS_COMMON} clean && \
rm -rf /var/lib/apt/lists/*
ARG MAJOR_VERSION=master
ARG ZBX_VERSION=${MAJOR_VERSION}
ARG MAJOR_VERSION=3.0
ARG ZBX_VERSION=${MAJOR_VERSION}.4
ARG ZBX_SOURCES=svn://svn.zabbix.com/tags/${ZBX_VERSION}/
ENV ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES} DB_TYPE=${DB_TYPE}
@ -117,8 +117,6 @@ RUN apt-get ${APT_FLAGS_COMMON} update && \
make \
automake \
subversion 1>/dev/null && \
apt-get ${APT_FLAGS_PERSISTANT} install \
snmp-mibs-downloader 1>/dev/null && \
apt-get ${APT_FLAGS_COMMON} autoremove 1>/dev/null && \
rm -rf /var/lib/apt/lists/*
@ -127,10 +125,9 @@ EXPOSE 10051/TCP 162/UDP
WORKDIR /var/lib/zabbix
VOLUME ["/usr/lib/zabbix/externalscripts", "/var/lib/zabbix/enc", "/var/lib/zabbix/modules", "/var/lib/zabbix/ssh_keys"]
VOLUME ["/var/lib/zabbix/ssl/certs", "/var/lib/zabbix/ssl/keys", "/var/lib/zabbix/ssl/ssl_ca"]
VOLUME ["/var/lib/zabbix/ssl/certs", "/var/lib/zabbix/ssl/keys", "/var/lib/zabbix/ssl/ssl_ca", "/var/lib/zabbix/snmptraps", "/var/lib/zabbix/mibs"]
ADD conf/etc/supervisor/ /etc/supervisor/
ADD conf/etc/logrotate.d/logrotate_zabbix.conf /etc/logrotate.d/
ADD run_zabbix_component.sh /data/
ENTRYPOINT ["/bin/bash"]

View File

@ -1,8 +0,0 @@
# https://support.zabbix.com/browse/ZBX-9858
/tmp/snmptrapfmt.log {
missingok
daily
rotate 0
minsize 50M notifempty
su zabbix zabbix
}

View File

@ -1,19 +0,0 @@
[program:snmptrapfmt]
command = /usr/sbin/snmptrapfmt -f /etc/snmp/snmptrapfmt.conf
auto_start = true
autorestart = true
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
[program:snmptrapd]
command = /usr/sbin/snmptrapd -f -n -Lsd -p /var/run/snmptrapd.pid
auto_start = true
autorestart = true
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0

View File

@ -21,8 +21,6 @@ ZBX_SERVER_HOST=${ZBX_SERVER_HOST:-"zabbix-server"}
# Default Zabbix server port number
ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"}
ZBX_ENABLE_SNMP_TRAPS=${ZBX_ENABLE_SNMP_TRAPS:-"false"}
TZ=${TZ:-"Europe/Riga"}
# Default directories
@ -135,7 +133,7 @@ check_variables_mysql() {
# If root password is not specified use provided credentials
DB_SERVER_ROOT_USER=${DB_SERVER_ROOT_USER:-${MYSQL_USER}}
DB_SERVER_ROOT_PASS=${DB_SERVER_ROOT_PASS:-${MYSQL_PASSWORD}}
[ "${MYSQL_ALLOW_EMPTY_PASSWORD}" == "true" ] || DB_SERVER_ROOT_PASS=${DB_SERVER_ROOT_PASS:-${MYSQL_PASSWORD}}
DB_SERVER_ZBX_USER=${MYSQL_USER:-"zabbix"}
DB_SERVER_ZBX_PASS=${MYSQL_PASSWORD:-"zabbix"}
@ -309,21 +307,21 @@ create_db_schema_mysql() {
if [ -z "${ZBX_DB_VERSION}" ]; then
echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL"
[ -n "${DB_SERVER_ROOT_PASS}" ] && DB_TMP_PASSWORD="--password=\"${DB_SERVER_ROOT_PASS}\""
[ -n "${DB_SERVER_ROOT_PASS}" ] && DB_TMP_PASSWORD=--password=\"${DB_SERVER_ROOT_PASS}\"
cat /usr/share/doc/zabbix-$type-mysql/schema.sql | mysql --silent --skip-column-names \
-h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
-u ${DB_SERVER_ROOT_USER} $DB_TMP_PASSWORD \
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" \
${DB_SERVER_DBNAME} 1>/dev/null
if [ "$type" == "server" ]; then
echo "** Fill the schema with initial data"
cat /usr/share/doc/zabbix-$type-mysql/images.sql | mysql --silent --skip-column-names \
-h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
-u ${DB_SERVER_ROOT_USER} $DB_TMP_PASSWORD \
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" \
${DB_SERVER_DBNAME} 1>/dev/null
cat /usr/share/doc/zabbix-$type-mysql/data.sql | mysql --silent --skip-column-names \
-h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
-u ${DB_SERVER_ROOT_USER} $DB_TMP_PASSWORD \
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" \
${DB_SERVER_DBNAME} 1>/dev/null
fi
fi
@ -482,46 +480,6 @@ prepare_web_server_nginx() {
ln -sf /dev/fd/2 /var/log/php5-fpm.log
}
prepare_snmptrapd() {
SNMPTRAPD_CONF="/etc/snmp/snmptrapd.conf"
SNMPTRAPFMT_CONF="/etc/snmp/snmptrapfmt.conf"
if [ ! -d "/etc/snmp/" ] || [ ! -f "/usr/sbin/snmptrapd" ]; then
echo "**** Impossible to enable SNMP traps feature"
ZBX_ENABLE_SNMP_TRAPS=false
return
fi
echo "** Updating SNMP traps related configuration files"
echo "** Updating snmptrapd"
echo "disableAuthorization yes" >> "$SNMPTRAPD_CONF"
if [ -f "/usr/sbin/snmptrapfmt" ]; then
echo "traphandle default /usr/sbin/snmptrapfmthdlr" >> "$SNMPTRAPD_CONF"
echo "** Updating snmptrapfmt"
sed -i \
-e "/^VARFMT=/s/=.*/=\"%n %v \"/" \
-e '/^LOGFMT=/s/=.*/=\"$x ZBXTRAP $R $G $S $e $*\"/' \
-e "/^LOGFILE=/s/=.*/=\"\/tmp\/snmptraps.log\"/" \
"$SNMPTRAPFMT_CONF"
elif [ -f "/usr/sbin/zabbix_trap_receiver.pl" ]; then
echo "perl do \"/usr/sbin/zabbix_trap_receiver.pl\";" >> "$SNMPTRAPD_CONF"
update_config_var "/usr/sbin/zabbix_trap_receiver.pl" "\$SNMPTrapperFile " "/tmp/snmptraps.log"
fi
if [ -f "/usr/sbin/logrotate" ]; then
if [ ! -f "/etc/logrotate.d/logrotate_zabbix.conf" ]; then
echo "**** Impossible to manage SNMP traps log file. Zabbix logrotate configuration file not found"
fi
else
rm -f "/etc/logrotate.d/logrotate_zabbix.conf"
echo "**** Impossible to manage SNMP traps log file. Logrotate not found"
fi
}
clear_deploy() {
local type=$1
echo "** Cleaning the system"
@ -610,8 +568,9 @@ update_zbx_config() {
update_config_var $ZBX_CONFIG "VMwareCacheSize" "${ZBX_VMWARECACHESIZE}"
update_config_var $ZBX_CONFIG "VMwareTimeout" "${ZBX_VMWARETIMEOUT}"
ZBX_ENABLE_SNMP_TRAPS=${ZBX_ENABLE_SNMP_TRAPS:-"false"}
if [ "${ZBX_ENABLE_SNMP_TRAPS}" == "true" ]; then
update_config_var $ZBX_CONFIG "SNMPTrapperFile" "/tmp/snmptraps.log"
update_config_var $ZBX_CONFIG "SNMPTrapperFile" "${ZABBIX_USER_HOME_DIR}/snmptraps/snmptraps.log"
update_config_var $ZBX_CONFIG "StartSNMPTrapper" "1"
else
update_config_var $ZBX_CONFIG "SNMPTrapperFile"
@ -834,12 +793,6 @@ prepare_server() {
create_db_database_$db_type
create_db_schema_$db_type "server"
if [ "${ZBX_ENABLE_SNMP_TRAPS}" == "true" ]; then
prepare_snmptrapd
else
rm -f $SUPERVISOR_CONFD/supervisord_snmptraps.conf
fi
update_zbx_config "server" "$db_type"
}
prepare_proxy() {
@ -855,12 +808,6 @@ prepare_proxy() {
create_db_schema_$db_type "proxy"
fi
if [ "${ZBX_ENABLE_SNMP_TRAPS}" == "true" ]; then
prepare_snmptrapd
else
rm -f $SUPERVISOR_CONFD/supervisord_snmptraps.conf
fi
update_zbx_config "proxy" $db_type
}
prepare_web() {