From 6fdea112c7e0dff8eec5f16d09b628f53a6a1b98 Mon Sep 17 00:00:00 2001 From: Jonathan Senecal Date: Thu, 13 Sep 2018 10:51:18 -0400 Subject: [PATCH 01/16] Adding python-memcached module required for distributed poller setup See [the docs](https://docs.librenms.org/#Extensions/Distributed-Poller/#distributed-poller) --- Dockerfile | 57 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0b72548..4c4ef0c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,12 +16,57 @@ LABEL maintainer="CrazyMax" \ org.label-schema.schema-version="1.0" RUN apk --update --no-cache add \ - bash binutils ca-certificates coreutils curl fping git graphviz imagemagick mtr \ - mysql-client net-snmp net-snmp-tools nginx nmap openssl python2 py-mysqldb rrdtool runit \ - shadow supervisor syslog-ng tzdata util-linux whois \ - php7 php7-cli php7-ctype php7-curl php7-fpm php7-gd php7-json php7-mcrypt php7-memcached php7-mbstring php7-mysqli \ - php7-opcache php7-openssl php7-pdo php7-pdo_mysql php7-phar php7-posix php7-session php7-simplexml php7-snmp \ - php7-tokenizer php7-xml php7-zip \ + bash \ + binutils \ + ca-certificates \ + coreutils \ + curl \ + fping \ + git \ + graphviz \ + imagemagick \ + mtr \ + mysql-client \ + net-snmp \ + net-snmp-tools \ + nginx \ + nmap \ + openssl \ + php7 \ + php7-cli \ + php7-ctype \ + php7-curl \ + php7-fpm \ + php7-gd \ + php7-json \ + php7-mbstring \ + php7-mcrypt \ + php7-memcached \ + php7-mysqli \ + php7-opcache \ + php7-openssl \ + php7-pdo \ + php7-pdo_mysql \ + php7-phar \ + php7-posix \ + php7-session \ + php7-simplexml \ + php7-snmp \ + php7-tokenizer \ + php7-xml \ + php7-zip \ + py-mysqldb \ + py2-pip \ + python2 \ + rrdtool \ + runit \ + shadow \ + supervisor \ + syslog-ng \ + tzdata \ + util-linux \ + whois \ + && pip install python-memcached \ && sed -i -e "s/;date\.timezone.*/date\.timezone = UTC/" /etc/php7/php.ini \ && rm -rf /var/cache/apk/* /var/www/* /tmp/* From 0dd57a170cea078bd87bbf4d901d1f951478f3a0 Mon Sep 17 00:00:00 2001 From: Jonathan Senecal Date: Thu, 13 Sep 2018 11:04:15 -0400 Subject: [PATCH 02/16] Ignore Visual Studio Code project dir. --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 98df5db..83a80f2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,8 @@ /.idea /*.iml +# Visual Studio Code +/.vscode + # App -/.dev +/.dev \ No newline at end of file From 6e032f3a81a50dec4eb1a8331c15b5ce7ac8f0aa Mon Sep 17 00:00:00 2001 From: Jonathan Senecal Date: Thu, 13 Sep 2018 11:19:27 -0400 Subject: [PATCH 03/16] Provide ability to override Memcached and RRD ports --- entrypoint.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8e27e0f..02075be 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -20,6 +20,10 @@ DB_NAME=${DB_NAME:-"librenms"} DB_USER=${DB_USER:-"librenms"} DB_PASSWORD=${DB_PASSWORD:-"asupersecretpassword"} +MEMCACHED_PORT=${MEMCACHED_PORT:-"11211"} + +RRDCACHED_PORT=${RRDCACHED_PORT:-"42217"} + # Timezone echo "Setting timezone to ${TZ}..." ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime @@ -112,7 +116,7 @@ if [ ! -z "${MEMCACHED_HOST}" ]; then ${LIBRENMS_PATH}/config.d/rrdcached.php < Date: Thu, 13 Sep 2018 11:27:57 -0400 Subject: [PATCH 04/16] Allow setting sensible variables via files --- entrypoint.sh | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 02075be..55d02da 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -13,17 +13,39 @@ UPLOAD_MAX_SIZE=${UPLOAD_MAX_SIZE:-"16M"} OPCACHE_MEM_SIZE=${OPCACHE_MEM_SIZE:-"128"} LIBRENMS_POLLER_THREADS=${LIBRENMS_POLLER_THREADS:-"16"} -LIBRENMS_SNMP_COMMUNITY=${LIBRENMS_SNMP_COMMUNITY:-"librenmsdocker"} DB_PORT=${DB_PORT:-"3306"} DB_NAME=${DB_NAME:-"librenms"} DB_USER=${DB_USER:-"librenms"} -DB_PASSWORD=${DB_PASSWORD:-"asupersecretpassword"} MEMCACHED_PORT=${MEMCACHED_PORT:-"11211"} RRDCACHED_PORT=${RRDCACHED_PORT:-"42217"} +# From https://github.com/docker-library/mariadb/blob/master/docker-entrypoint.sh +# usage: file_env VAR [DEFAULT] +# ie: file_env 'XYZ_DB_PASSWORD' 'example' +# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of +# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) +file_env() { + local var="$1" + local fileVar="${var}_FILE" + local def="${2:-}" + if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then + echo >&2 "error: both $var and $fileVar are set (but are exclusive)" + exit 1 + fi + local val="$def" + if [ "${!var:-}" ]; then + val="${!var}" + elif [ "${!fileVar:-}" ]; then + val="$(< "${!fileVar}")" + fi + export "$var"="$val" + unset "$fileVar" +} + + # Timezone echo "Setting timezone to ${TZ}..." ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime @@ -57,6 +79,7 @@ sed -e "s/@UPLOAD_MAX_SIZE@/$UPLOAD_MAX_SIZE/g" \ # SNMP echo "Updating SNMP community..." +file_env 'LIBRENMS_SNMP_COMMUNITY' 'librenmsdocker' sed -i -e "s/RANDOMSTRINGGOESHERE/${LIBRENMS_SNMP_COMMUNITY}/" /etc/snmp/snmpd.conf # Init files and folders @@ -81,6 +104,11 @@ if [ -z "$DB_HOST" ]; then >&2 echo "ERROR: DB_HOST must be defined" exit 1 fi +file_env 'DB_PASSWORD' +if [ -z "$DB_PASSWORD" ]; then + >&2 echo "ERROR: Either DB_PASSWORD or DB_PASSWORD_FILE must be defined" + exit 1 +fi cat > ${LIBRENMS_PATH}/config.d/database.php < Date: Thu, 13 Sep 2018 11:37:56 -0400 Subject: [PATCH 05/16] Add lines to docstring --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 55d02da..ab6875a 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -22,7 +22,7 @@ MEMCACHED_PORT=${MEMCACHED_PORT:-"11211"} RRDCACHED_PORT=${RRDCACHED_PORT:-"42217"} -# From https://github.com/docker-library/mariadb/blob/master/docker-entrypoint.sh +# From https://github.com/docker-library/mariadb/blob/master/docker-entrypoint.sh#L21-L41 # usage: file_env VAR [DEFAULT] # ie: file_env 'XYZ_DB_PASSWORD' 'example' # (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of From deb9929cb88623980e3bf0444ffeaf6434956790 Mon Sep 17 00:00:00 2001 From: Jonathan Senecal Date: Thu, 13 Sep 2018 13:02:47 -0400 Subject: [PATCH 06/16] Use Bash --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index ab6875a..7bf1d05 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash function runas_librenms() { su - librenms -s /bin/sh -c "$1" From e20faf98db84a28e894501e53b44bc52c50abf98 Mon Sep 17 00:00:00 2001 From: Jonathan Senecal Date: Thu, 13 Sep 2018 13:15:04 -0400 Subject: [PATCH 07/16] Configurable DB_TIMEOUT --- entrypoint.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 7bf1d05..b8a7bdc 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -17,6 +17,7 @@ LIBRENMS_POLLER_THREADS=${LIBRENMS_POLLER_THREADS:-"16"} DB_PORT=${DB_PORT:-"3306"} DB_NAME=${DB_NAME:-"librenms"} DB_USER=${DB_USER:-"librenms"} +DB_TIMEOUT=${DB_TIMEOUT:-"30"} MEMCACHED_PORT=${MEMCACHED_PORT:-"11211"} @@ -78,8 +79,8 @@ sed -e "s/@UPLOAD_MAX_SIZE@/$UPLOAD_MAX_SIZE/g" \ /tpls/etc/nginx/nginx.conf > /etc/nginx/nginx.conf # SNMP -echo "Updating SNMP community..." file_env 'LIBRENMS_SNMP_COMMUNITY' 'librenmsdocker' +echo "Updating SNMP community to ${LIBRENMS_SNMP_COMMUNITY}..." sed -i -e "s/RANDOMSTRINGGOESHERE/${LIBRENMS_SNMP_COMMUNITY}/" /etc/snmp/snmpd.conf # Init files and folders @@ -196,18 +197,17 @@ else ${LIBRENMS_PATH}/storage \ ${LIBRENMS_PATH}/storage/framework/* - echo "Waiting database..." - waitdb_timeout=30 + echo "Waiting ${DB_TIMEOUT}s for database to be ready..." counter=1 while ! ${dbcmd} -e "show databases;" > /dev/null 2>&1; do sleep 1 counter=`expr $counter + 1` - if [ ${counter} -gt ${waitdb_timeout} ]; then + if [ ${counter} -gt ${DB_TIMEOUT} ]; then >&2 echo "ERROR: Failed to connect to database on $DB_HOST" exit 1 fi; done - echo "Database up!" + echo "Database ready!" counttables=$(echo 'SHOW TABLES' | ${dbcmd} "$DB_NAME" | wc -l) From f9949d149102f677f09a174690d9dd2bbd327daf Mon Sep 17 00:00:00 2001 From: Jonathan Senecal Date: Thu, 13 Sep 2018 13:58:50 -0400 Subject: [PATCH 08/16] Cleanup from previous commit --- entrypoint.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index b8a7bdc..58a732d 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -79,8 +79,8 @@ sed -e "s/@UPLOAD_MAX_SIZE@/$UPLOAD_MAX_SIZE/g" \ /tpls/etc/nginx/nginx.conf > /etc/nginx/nginx.conf # SNMP +echo "Updating SNMP community..." file_env 'LIBRENMS_SNMP_COMMUNITY' 'librenmsdocker' -echo "Updating SNMP community to ${LIBRENMS_SNMP_COMMUNITY}..." sed -i -e "s/RANDOMSTRINGGOESHERE/${LIBRENMS_SNMP_COMMUNITY}/" /etc/snmp/snmpd.conf # Init files and folders @@ -164,6 +164,11 @@ if [ "$1" == "/usr/local/bin/cron" ]; then echo ">>" # Init + if [ -z "$CRONTAB_PATH" ]; then + >&2 echo "ERROR: CRONTAB_PATH must be defined" + exit 1 + fi + rm -rf ${CRONTAB_PATH} mkdir -m 0644 -p ${CRONTAB_PATH} touch ${CRONTAB_PATH}/librenms From 6ee3a5600af253023ae8bf24d6fb8814b2083586 Mon Sep 17 00:00:00 2001 From: Jonathan Senecal Date: Thu, 13 Sep 2018 15:06:53 -0400 Subject: [PATCH 09/16] Added the ability to configure distributed polling --- entrypoint.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 58a732d..1142f0d 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -12,16 +12,31 @@ MEMORY_LIMIT=${MEMORY_LIMIT:-"256M"} UPLOAD_MAX_SIZE=${UPLOAD_MAX_SIZE:-"16M"} OPCACHE_MEM_SIZE=${OPCACHE_MEM_SIZE:-"128"} +MEMCACHED_PORT=${MEMCACHED_PORT:-"11211"} +RRDCACHED_PORT=${RRDCACHED_PORT:-"42217"} + LIBRENMS_POLLER_THREADS=${LIBRENMS_POLLER_THREADS:-"16"} +LIBRENMS_POLLER_INTERVAL=${LIBRENMS_POLLER_INTERVAL:-"5"} + +LIBRENMS_DISTRIBUTED_POLLER_ENABLE=${LIBRENMS_DISTRIBUTED_POLLER_ENABLE:-false} +LIBRENMS_DISTRIBUTED_POLLER_NAME=${LIBRENMS_DISTRIBUTED_POLLER_NAME:-$(hostname -f)} +LIBRENMS_DISTRIBUTED_POLLER_GROUP=${LIBRENMS_DISTRIBUTED_POLLER_GROUP:-'0'} +LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_HOST=${LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_HOST:-"${RRDCACHED_HOST}"} +LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_PORT=${LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_PORT:-"${RRDCACHED_PORT}"} + +LIBRENMS_CRON_DISCOVERY_ENABLE=${LIBRENMS_CRON_DISCOVERY_ENABLE:-true} +LIBRENMS_CRON_DAILY_ENABLE=${LIBRENMS_CRON_DAILY_ENABLE:-true} +LIBRENMS_CRON_ALERTS_ENABLE=${LIBRENMS_CRON_ALERTS_ENABLE:-true} +LIBRENMS_CRON_BILLING_ENABLE=${LIBRENMS_CRON_BILLING_ENABLE:-true} +LIBRENMS_CRON_BILLING_CALCULATE_ENABLE=${LIBRENMS_CRON_BILLING_CALCULATE_ENABLE:-true} +LIBRENMS_CRON_CHECK_SERVICES_ENABLE=${LIBRENMS_CRON_CHECK_SERVICES_ENABLE:-true} +LIBRENMS_CRON_POLLER_ENABLE=${LIBRENMS_CRON_POLLER_ENABLE:-true} DB_PORT=${DB_PORT:-"3306"} DB_NAME=${DB_NAME:-"librenms"} DB_USER=${DB_USER:-"librenms"} DB_TIMEOUT=${DB_TIMEOUT:-"30"} -MEMCACHED_PORT=${MEMCACHED_PORT:-"11211"} - -RRDCACHED_PORT=${RRDCACHED_PORT:-"42217"} # From https://github.com/docker-library/mariadb/blob/master/docker-entrypoint.sh#L21-L41 # usage: file_env VAR [DEFAULT] @@ -157,6 +172,18 @@ if [ ! -z "${RRDCACHED_HOST}" ]; then EOL fi +# Config : Ditributed poller +if [ ! -z "${LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_HOST}" -a ! -z "${RRDCACHED_HOST}" -a $LIBRENMS_DISTRIBUTED_POLLER_ENABLE = true ]; then + cat > ${LIBRENMS_PATH}/config.d/distributed_poller.php <>" @@ -173,10 +200,40 @@ if [ "$1" == "/usr/local/bin/cron" ]; then mkdir -m 0644 -p ${CRONTAB_PATH} touch ${CRONTAB_PATH}/librenms - # Add crons + # Add crontab cat ${LIBRENMS_PATH}/librenms.nonroot.cron > ${CRONTAB_PATH}/librenms sed -i -e "s/ librenms //" ${CRONTAB_PATH}/librenms - sed -i -e "s/poller-wrapper.py 16/poller-wrapper.py ${LIBRENMS_POLLER_THREADS}/g" ${CRONTAB_PATH}/librenms + + if [ $LIBRENMS_CRON_DISCOVERY_ENABLE != true ]; then + sed -i "/discovery.php/d" ${CRONTAB_PATH}/librenms + fi + + if [ $LIBRENMS_CRON_DAILY_ENABLE != true ]; then + sed -i "/daily.sh/d" ${CRONTAB_PATH}/librenms + fi + + if [ $LIBRENMS_CRON_ALERTS_ENABLE != true ]; then + sed -i "/alerts.php/d" ${CRONTAB_PATH}/librenms + fi + + if [ $LIBRENMS_CRON_BILLING_ENABLE != true ]; then + sed -i "/poll-billing.php/d" ${CRONTAB_PATH}/librenms + fi + + if [ $LIBRENMS_CRON_BILLING_CALCULATE_ENABLE != true ]; then + sed -i "/billing-calculate.php/d" ${CRONTAB_PATH}/librenms + fi + + if [ $LIBRENMS_CRON_CHECK_SERVICES_ENABLE != true ]; then + sed -i "/check-services.php/d" ${CRONTAB_PATH}/librenms + fi + + sed -i "/poller-wrapper.py/d" ${CRONTAB_PATH}/librenms + if [ $LIBRENMS_CRON_POLLER_ENABLE = true ]; then + cat >> ${CRONTAB_PATH}/librenms < Date: Thu, 13 Sep 2018 15:47:00 -0400 Subject: [PATCH 10/16] Update documentation --- CONTRIBUTORS | 1 + README.md | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 CONTRIBUTORS diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..466cb8d --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1 @@ +Jonathan Senecal \ No newline at end of file diff --git a/README.md b/README.md index 0f194fe..770174b 100644 --- a/README.md +++ b/README.md @@ -44,14 +44,30 @@ If you are interested, [check out](https://hub.docker.com/r/crazymax/) my other * `UPLOAD_MAX_SIZE` : Upload max size (default `16M`) * `OPCACHE_MEM_SIZE` : PHP OpCache memory consumption (default `128`) * `LIBRENMS_POLLER_THREADS` : Threads that `poller-wrapper.py` runs (default `16`) -* `LIBRENMS_SNMP_COMMUNITY` : Your community string (default `librenmsdocker`) +* `LIBRENMS_POLLER_INTERVAL` : Interval in minutes at which `poller-wrapper.py` runs (defaults to `5`) [docs](https://docs.librenms.org/#Support/1-Minute-Polling/) +* `LIBRENMS_DISTRIBUTED_POLLER_ENABLE` : Enable distributed poller functionality +* `LIBRENMS_DISTRIBUTED_POLLER_NAME` : Optional name of poller (defaults to hostname) +* `LIBRENMS_DISTRIBUTED_POLLER_GROUP` : By default, all hosts are shared and have the poller_group = 0. To pin a device to a poller, set it to a value greater than 0 and set the same value here. One can also specify a comma separated string of poller groups. The poller will then poll devices from any of the groups listed. [docs](https://docs.librenms.org/#Extensions/Distributed-Poller/#distributed-poller) +* `LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_HOST` : Memcached server for poller synchronization (Defaults to `$MEMCACHED_HOST`) +* `LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_PORT` : Port of memcached server (Defaults to `$MEMCACHED_PORT`) +* `LIBRENMS_CRON_DISCOVERY_ENABLE` : Enable LibreNMS discovery for this container cronjobs (default `true`) +* `LIBRENMS_CRON_DAILY_ENABLE` : Enable LibreNMS daily script for this container cronjobs (default `true`) +* `LIBRENMS_CRON_ALERTS_ENABLE` : Enable LibreNMS alerts generation for this container cronjobs (default `true`) +* `LIBRENMS_CRON_BILLING_ENABLE` : Enable LibreNMS billing polling for this container cronjobs (default `true`) +* `LIBRENMS_CRON_BILLING_CALCULATE_ENABLE` : Enable LibreNMS billing for this container cronjobs (default `true`) +* `LIBRENMS_CRON_CHECK_SERVICES_ENABLE` : Enable LibreNMS service checks for this container cronjobs (default `true`) +* `LIBRENMS_CRON_POLLER_ENABLE` : Enable LibreNMS polling for this container cronjobs (default `true`) +* `LIBRENMS_SNMP_COMMUNITY` : This container's SNMP v2c community string (default `librenmsdocker`) * `DB_HOST` : MySQL database hostname / IP address * `DB_PORT` : MySQL database port (default `3306`) * `DB_NAME` : MySQL database name (default `librenms`) * `DB_USER` : MySQL user (default `librenms`) * `DB_PASSWORD` : MySQL password (default `librenms`) +* `DB_TIMEOUT` : Time in seconds after which we stop trying to reach the MySQL server (userful for clusters, default `30`) * `MEMCACHED_HOST` : Hostname / IP address of a Memcached server +* `MEMCACHED_PORT` : Port of the Memcached server * `RRDCACHED_HOST` : Hostname / IP address of a RRDcached server +* `RRDCACHED_PORT` : Port of the RRDcached server ### Volumes From 09e5fa34250ac784931c72bd59039c45354fc33c Mon Sep 17 00:00:00 2001 From: Jonathan Senecal Date: Fri, 14 Sep 2018 15:28:34 -0400 Subject: [PATCH 11/16] Copy/Paste mistake... --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 1142f0d..71602c3 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -21,8 +21,8 @@ LIBRENMS_POLLER_INTERVAL=${LIBRENMS_POLLER_INTERVAL:-"5"} LIBRENMS_DISTRIBUTED_POLLER_ENABLE=${LIBRENMS_DISTRIBUTED_POLLER_ENABLE:-false} LIBRENMS_DISTRIBUTED_POLLER_NAME=${LIBRENMS_DISTRIBUTED_POLLER_NAME:-$(hostname -f)} LIBRENMS_DISTRIBUTED_POLLER_GROUP=${LIBRENMS_DISTRIBUTED_POLLER_GROUP:-'0'} -LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_HOST=${LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_HOST:-"${RRDCACHED_HOST}"} -LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_PORT=${LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_PORT:-"${RRDCACHED_PORT}"} +LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_HOST=${LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_HOST:-"${MEMCACHED_HOST}"} +LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_PORT=${LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_PORT:-"${MEMCACHED_PORT}"} LIBRENMS_CRON_DISCOVERY_ENABLE=${LIBRENMS_CRON_DISCOVERY_ENABLE:-true} LIBRENMS_CRON_DAILY_ENABLE=${LIBRENMS_CRON_DAILY_ENABLE:-true} From 8639c392637c652b56f83d4284c28fd835a70b8d Mon Sep 17 00:00:00 2001 From: Jonathan Senecal Date: Fri, 14 Sep 2018 16:15:03 -0400 Subject: [PATCH 12/16] Added rrdtool_version' to config [docs](https://github.com/librenms/librenms/blob/master/doc/Extensions/RRDCached.md) --- entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/entrypoint.sh b/entrypoint.sh index 71602c3..3067bd5 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -169,6 +169,7 @@ if [ ! -z "${RRDCACHED_HOST}" ]; then cat > ${LIBRENMS_PATH}/config.d/rrdcached.php < Date: Fri, 14 Sep 2018 16:28:40 -0400 Subject: [PATCH 13/16] Fix data permissions for crontab too --- entrypoint.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 3067bd5..b6793a4 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -185,6 +185,18 @@ if [ ! -z "${LIBRENMS_DISTRIBUTED_POLLER_MEMCACHED_HOST}" -a ! -z "${RRDCACHED_H EOL fi + # Fix perms +echo "Fixing permissions..." +chown -R librenms. ${DATA_PATH} \ + ${LIBRENMS_PATH}/config.d \ + ${LIBRENMS_PATH}/bootstrap \ + ${LIBRENMS_PATH}/storage +chmod ug+rw ${DATA_PATH}/logs \ + ${DATA_PATH}/rrd \ + ${LIBRENMS_PATH}/bootstrap/cache \ + ${LIBRENMS_PATH}/storage \ + ${LIBRENMS_PATH}/storage/framework/* + # Sidecar cron container ? if [ "$1" == "/usr/local/bin/cron" ]; then echo ">>" @@ -236,8 +248,8 @@ if [ "$1" == "/usr/local/bin/cron" ]; then EOL fi - # Fix perms - echo "Fixing permissions..." + # Fix crontab perms + echo "Fixing crontab permissions..." chmod -R 0644 ${CRONTAB_PATH} elif [ "$1" == "/usr/sbin/syslog-ng" ]; then echo ">>" @@ -248,18 +260,6 @@ elif [ "$1" == "/usr/sbin/syslog-ng" ]; then mkdir -p ${DATA_PATH}/syslog-ng /run/syslog-ng chown -R librenms. ${DATA_PATH}/syslog-ng /run/syslog-ng else - # Fix perms - echo "Fixing permissions..." - chown -R librenms. ${DATA_PATH} \ - ${LIBRENMS_PATH}/config.d \ - ${LIBRENMS_PATH}/bootstrap \ - ${LIBRENMS_PATH}/storage - chmod ug+rw ${DATA_PATH}/logs \ - ${DATA_PATH}/rrd \ - ${LIBRENMS_PATH}/bootstrap/cache \ - ${LIBRENMS_PATH}/storage \ - ${LIBRENMS_PATH}/storage/framework/* - echo "Waiting ${DB_TIMEOUT}s for database to be ready..." counter=1 while ! ${dbcmd} -e "show databases;" > /dev/null 2>&1; do From cd9defce7bc430f61dffdbec3787e277b996db89 Mon Sep 17 00:00:00 2001 From: Jonathan Senecal Date: Fri, 21 Sep 2018 10:54:46 -0400 Subject: [PATCH 14/16] Removed CONTRIBUTORS --- CONTRIBUTORS | 1 - 1 file changed, 1 deletion(-) delete mode 100644 CONTRIBUTORS diff --git a/CONTRIBUTORS b/CONTRIBUTORS deleted file mode 100644 index 466cb8d..0000000 --- a/CONTRIBUTORS +++ /dev/null @@ -1 +0,0 @@ -Jonathan Senecal \ No newline at end of file From cb07a9cfebe08ed4668e413ccf405d0a34497232 Mon Sep 17 00:00:00 2001 From: Jonathan Senecal Date: Fri, 21 Sep 2018 10:58:36 -0400 Subject: [PATCH 15/16] Typo fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 770174b..f4b183a 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ If you are interested, [check out](https://hub.docker.com/r/crazymax/) my other * `DB_NAME` : MySQL database name (default `librenms`) * `DB_USER` : MySQL user (default `librenms`) * `DB_PASSWORD` : MySQL password (default `librenms`) -* `DB_TIMEOUT` : Time in seconds after which we stop trying to reach the MySQL server (userful for clusters, default `30`) +* `DB_TIMEOUT` : Time in seconds after which we stop trying to reach the MySQL server (useful for clusters, default `30`) * `MEMCACHED_HOST` : Hostname / IP address of a Memcached server * `MEMCACHED_PORT` : Port of the Memcached server * `RRDCACHED_HOST` : Hostname / IP address of a RRDcached server From 507ea1515afd4537790e3e60d6d5685faa412c27 Mon Sep 17 00:00:00 2001 From: Jonathan Senecal Date: Fri, 21 Sep 2018 10:59:05 -0400 Subject: [PATCH 16/16] Missing CAP_NET_RAW on nmap and fping --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4c4ef0c..b13076e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,7 +68,9 @@ RUN apk --update --no-cache add \ whois \ && pip install python-memcached \ && sed -i -e "s/;date\.timezone.*/date\.timezone = UTC/" /etc/php7/php.ini \ - && rm -rf /var/cache/apk/* /var/www/* /tmp/* + && rm -rf /var/cache/apk/* /var/www/* /tmp/* \ + && setcap cap_net_raw+ep /usr/bin/nmap \ + && setcap cap_net_raw+ep /usr/sbin/fping ENV LIBRENMS_VERSION="1.43" \ LIBRENMS_PATH="/opt/librenms" \