Compare commits

..

No commits in common. "master" and "build-12" have entirely different histories.

7 changed files with 85 additions and 526 deletions

View file

@ -6,7 +6,6 @@ name: Nagios Build
# https://github.com/marketplace/actions/docker-setup-buildx
# https://github.com/marketplace/actions/docker-login
# https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions/58034787
on: [push]
jobs:
@ -55,38 +54,33 @@ jobs:
run: |
echo "My docker tag will be: ${{ env.action_mytag }}"
- name: Login to DockerHub
uses: docker/login-action@v3
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v2
-
name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
-
name: Cache Docker layers for this Git branch
uses: actions/cache@v4
uses: actions/cache@v3
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.ref }}
restore-keys: |
${{ runner.os }}-buildx-${{ github.ref }}
- name: Docker Buildx (build and cache)
-
name: Docker Buildx (build and cache)
run: |
docker buildx build \
--progress plain \
@ -94,33 +88,21 @@ jobs:
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \
--label "gitCommit=${{ github.sha }}" \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
--tag ${GITHUB_ACTOR}/nagios:${{ env.action_mytag }} \
--tag manios/nagios:${{ env.action_mytag }} \
--output "type=image,push=false" .
- name: 'Docker Buildx: Push to Dockerhub'
-
name: Docker Buildx (push)
run: |
echo "== This branch is : ${GITHUB_REF}"
echo "Will push image ${GITHUB_ACTOR}/nagios:${{ env.action_mytag }} to DockerHub"
echo "Will push image manios/nagios:${{ env.action_mytag }} to DockerHub"
docker buildx build \
--progress plain \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \
--label "gitCommit=${{ github.sha }}" \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
--tag ${GITHUB_ACTOR}/nagios:${{ env.action_mytag }} \
--tag manios/nagios:${{ env.action_mytag }} \
--output "type=image,push=true" .
- name: 'Docker Buildx: Push to GitHub Container Registry'
-
name: Inspect image
run: |
echo "== This branch is : ${GITHUB_REF}"
echo "Will push image ghcr.io/${GITHUB_ACTOR}/nagios:${{ env.action_mytag }} to GitHub Container Registry"
docker buildx build \
--progress plain \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \
--label "gitCommit=${{ github.sha }}" \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
--tag ghcr.io/${GITHUB_ACTOR}/nagios:${{ env.action_mytag }} \
--output "type=image,push=true" .
- name: Inspect image
run: |
docker buildx imagetools inspect ${GITHUB_ACTOR}/nagios:${{ env.action_mytag }}
docker buildx imagetools inspect manios/nagios:${{ env.action_mytag }}

View file

@ -3,280 +3,6 @@
This Docker image contains more than one software (Nagios, Nagios plugins, NRPE, Apache HTTPD, etc.) with different versions. Hence we decided to name the releases with the naming `Build - <number>` which will have an incremental unsigned integer. In this document we will describe the contents of every image in every build.
## Build 36 (2026-06-12)
* Nagios core: v4.5.13
* Nagios plugins: v2.5.0
* NRPE: 4.1.3
* Alpine:
* 3.23.4: `amd64`, `i386`, `arm64`,`arm/v6`, `arm/v7`
### Features
* Upgrade to Nagios Core `4.5.13`. ([#102](https://github.com/manios/docker-nagios/issues/102))
## Build 35 (2026-04-03)
* Nagios core: v4.5.12
* Nagios plugins: v2.5.0
* NRPE: 4.1.3
* Alpine:
* 3.23.2: `amd64`, `i386`, `arm64`,`arm/v6`, `arm/v7`
### Features
* Upgrade to Nagios Plugins to `2.5.0`. ([#101](https://github.com/manios/docker-nagios/issues/101))
## Build 34 (2026-03-26)
* Nagios core: v4.5.12
* Nagios plugins: v2.4.12
* NRPE: 4.1.3
* Alpine:
* 3.23.2: `amd64`, `i386`, `arm64`,`arm/v6`, `arm/v7`
### Features
* Upgrade to Nagios Core `4.5.12`. ([#100](https://github.com/manios/docker-nagios/issues/100))
## Build 33 (2026-01-15)
* Nagios core: v4.5.11
* Nagios plugins: v2.4.12
* NRPE: 4.1.3
* Alpine:
* 3.23.2: `amd64`, `i386`, `arm64`,`arm/v6`, `arm/v7`
### Features
* Upgrade to Nagios Core `4.5.11`. ([#99](https://github.com/manios/docker-nagios/issues/99))
## Build 32 (2025-12-04)
* Nagios core: v4.5.10
* Nagios plugins: v2.4.12
* NRPE: 4.1.3
* Alpine:
* 3.23.0: `amd64`, `i386`, `arm64`,`arm/v6`, `arm/v7`
### Features
* Use Alpine 3.23 as base image for all architectures after [nagioscore #1025](https://github.com/NagiosEnterprises/nagioscore/issues/1025) was fixed and tested in `arm/v6` and `arm/v7`. ([#92](https://github.com/manios/docker-nagios/issues/92))
## Build 31 (2025-12-01)
* Nagios core: v4.5.10
* Nagios plugins: v2.4.12
* NRPE: 4.1.3
* Alpine:
* 3.22.2: `amd64`, `i386`, `arm64`
* 3.12.12: `arm/v6`, `arm/v7`
### Features
* Upgrade to Nagios Core `4.5.10`. ([#95](https://github.com/manios/docker-nagios/issues/95))
* Add init script functionality. ([#96](https://github.com/manios/docker-nagios/issues/96))
* Remove [gosu](https://github.com/tianon/gosu) from the image as it is not needed anymore. ([#91](https://github.com/manios/docker-nagios/issues/91))
### Bug Fixes
* Modify `etc/resource.cfg` in order to include custom plugins directory.
## Build 30 (2025-04-10)
* Nagios core: v4.5.9
* Nagios plugins: v2.4.12
* NRPE: 4.1.3
* Alpine:
* 3.21.3: `amd64`, `i386`, `arm64`
* 3.12.12: `arm/v6`, `arm/v7`
### Features
* Use Alpine 3.21 as base image for `amd64`, `i386`, `arm64`. Until [nagioscore #1025](https://github.com/NagiosEnterprises/nagioscore/issues/1025) is fixed, we are going to use 3.12 as base image for `arm/v6` and `arm/v7`. ([#92](https://github.com/manios/docker-nagios/issues/92))
## Build 29 (2025-02-23)
* Nagios core: v4.5.9
* Nagios plugins: v2.4.12
* NRPE: 4.1.3
* Alpine:
* 3.12.12: `amd64`, `i386`, `arm64`, `arm/v6`, `arm/v7`
### Bug Fixes
* Do not set the `setuid` field in [gosu](https://github.com/tianon/gosu) as it causes errors and `ping` command does not work. ([#91](https://github.com/manios/docker-nagios/issues/91))
## Build 28 (2025-02-22)
* Nagios core: v4.5.9
* Nagios plugins: v2.4.12
* NRPE: 4.1.3
* Alpine:
* 3.12.12: `amd64`, `i386`, `arm64`, `arm/v6`, `arm/v7`
### Features
* Upgrade NRPE to `4.1.3` and gosu to `v1.13`. ([#90](https://github.com/manios/docker-nagios/issues/90))
## Build 27 (2024-12-29)
* Nagios core: v4.5.9
* Nagios plugins: v2.4.12
* NRPE: 4.1.1
* Alpine:
* 3.12.12: `amd64`, `i386`, `arm64`, `arm/v6`, `arm/v7`
### Features
* Upgrade to Nagios Core `4.5.9`. ([#88](https://github.com/manios/docker-nagios/issues/88))
## Build 26 (2024-11-22)
* Nagios core: v4.5.8
* Nagios plugins: v2.4.12
* NRPE: 4.1.1
* Alpine:
* 3.12.12: `amd64`, `i386`, `arm64`, `arm/v6`, `arm/v7`
### Features
* Upgrade to Nagios Core `4.5.8`. ([#87](https://github.com/manios/docker-nagios/issues/87))
## Build 25 (2024-10-27)
* Nagios core: v4.5.7
* Nagios plugins: v2.4.12
* NRPE: 4.1.1
### Features
* Upgrade to Nagios Core `4.5.7`. ([#86](https://github.com/manios/docker-nagios/issues/86))
## Build 24 (2024-10-11)
* Nagios core: v4.5.6
* Nagios plugins: v2.4.12
* NRPE: 4.1.1
### Features
* Upgrade to Nagios Core `4.5.6`. ([#84](https://github.com/manios/docker-nagios/issues/84))
## Build 23 (2024-09-29)
* Nagios core: v4.5.5
* Nagios plugins: v2.4.12
* NRPE: 4.1.1
### Features
* Upgrade to Nagios Core `4.5.5`. ([#81](https://github.com/manios/docker-nagios/issues/81))
* Push container images to Github Container Registry ([#83](https://github.com/manios/docker-nagios/issues/83))
* Re-enable Docker image caching using Cache action ([#82](https://github.com/manios/docker-nagios/issues/82))
## Build 22 (2024-08-30)
* Nagios core: v4.5.4
* Nagios plugins: v2.4.12
* NRPE: 4.1.1
### Features
* Upgrade to Nagios Plugins to `2.4.12`. ([#79](https://github.com/manios/docker-nagios/issues/79))
### Bug Fixes
* Fix error shown in Hosts and Services web page when running the container with a user other than nagiosadmin ([#78](https://github.com/manios/docker-nagios/issues/78)) Thanks [@pathia](https://github.com/pathia)!
## Build 21 (2024-08-15)
* Nagios core: v4.5.4
* Nagios plugins: v2.4.11
* NRPE: 4.1.1
### Features
* Upgrade to Nagios Core to `4.5.3`, Nagios Plugins to `2.4.11` and NRPE to `4.1.1` . ([#75](https://github.com/manios/docker-nagios/issues/75))
## Build 20 (2024-07-30)
* Nagios core: v4.5.3
* Nagios plugins: v2.4.10
* NRPE: 4.1.0
### Features
* Upgrade to Nagios Core to `4.5.3`. ([#73](https://github.com/manios/docker-nagios/issues/73))
## Build 19 (2024-05-07)
* Nagios core: v4.5.2
* Nagios plugins: v2.4.10
* NRPE: 4.1.0
### Features
* Upgrade to Nagios Core to `4.5.2`, Nagios plugins to `2.4.19`. ([#69](https://github.com/manios/docker-nagios/issues/69))
## Build 18 (2024-03-10)
* Nagios core: v4.5.1
* Nagios plugins: v2.4.8
* NRPE: 4.1.0
### Features
* Upgrade to Nagios Core to `4.5.1`, Nagios plugins to `2.4.8`. ([#68](https://github.com/manios/docker-nagios/issues/68))
## Build 17 (2023-11-20)
* Nagios core: v4.5.0
* Nagios plugins: v2.4.7
* NRPE: 4.1.0
### Features
* Upgrade to Nagios Core to `4.5.0`, Nagios plugins to `2.4.7`. ([#66](https://github.com/manios/docker-nagios/issues/66))
* Avoid busybox wget `too many redirect` issue. ([#65](https://github.com/manios/docker-nagios/pull/65))
## Build 16 (2023-08-09)
* Nagios core: v4.4.14
* Nagios plugins: v2.4.6
* NRPE: 4.1.0
## Build 15 (2023-06-12)
* Nagios core: v4.4.13
* Nagios plugins: v2.4.5
* NRPE: 4.1.0
### Features
* Upgrade to Nagios Core to `4.4.13`, Nagios plugins to `2.4.5`. ([#61](https://github.com/manios/docker-nagios/issues/61))
## Build 14 (2023-06-01)
* Nagios core: v4.4.12
* Nagios plugins: v2.4.4
* NRPE: 4.1.0
### Features
* Upgrade to Nagios Core to `4.4.12`. ([#60](https://github.com/manios/docker-nagios/issues/60))
## Build 13 (2023-05-10)
* Nagios core: v4.4.11
* Nagios plugins: v2.4.4
* NRPE: 4.1.0
### Features
* Upgrade to Nagios Core to `4.4.11`, Nagios plugins to `2.4.4`. ([#58](https://github.com/manios/docker-nagios/issues/58))
## Build 12 (2023-03-03)
* Nagios core: v4.4.10
@ -285,7 +11,7 @@ This Docker image contains more than one software (Nagios, Nagios plugins, NRPE,
### Features
* Upgrade to Nagios Core to `4.4.10`, Nagios plugins to `2.4.3`. ([#53](https://github.com/manios/docker-nagios/issues/53))
* Upgrade to Nagios Core to `4.4.10`, Nagios plugins to `2.4.3``. ([#53](https://github.com/manios/docker-nagios/issues/53)
## Build 11 (2022-12-12)

View file

@ -4,7 +4,7 @@
# https://www.docker.com/blog/docker-arm-virtual-meetup-multi-arch-with-buildx/
FROM alpine:3.23 AS builder-base
FROM alpine:3.12 as builder-base
ARG TARGETPLATFORM
ARG BUILDPLATFORM
@ -18,9 +18,9 @@ ENV NAGIOS_HOME=/opt/nagios \
NAGIOS_FQDN=nagios.example.com \
NAGIOSADMIN_USER=nagiosadmin \
NAGIOSADMIN_PASS=nagios \
NAGIOS_VERSION=4.5.13 \
NAGIOS_PLUGINS_VERSION=2.5 \
NRPE_VERSION=4.1.3 \
NAGIOS_VERSION=4.4.10 \
NAGIOS_PLUGINS_VERSION=2.4.3 \
NRPE_VERSION=4.1.0 \
APACHE_LOCK_DIR=/var/run \
APACHE_LOG_DIR=/var/log/apache2
@ -29,20 +29,37 @@ RUN addgroup -S ${NAGIOS_GROUP} && \
adduser -S ${NAGIOS_USER} -G ${NAGIOS_CMDGROUP} -g ${NAGIOS_USER} && \
apk update && \
apk add --no-cache git curl unzip apache2 apache2-utils rsyslog \
php83 php83-gd php83-cli runit parallel ssmtp \
libltdl libintl openssl-dev php83-apache2 procps tzdata \
php7 php7-gd php7-cli runit parallel ssmtp \
libltdl libintl openssl-dev php7-apache2 procps tzdata \
libldap mariadb-connector-c freeradius-client-dev libpq libdbi \
lm-sensors perl net-snmp-perl perl-net-snmp perl-crypt-x509 \
perl-timedate perl-libwww perl-text-glob samba-client openssh openssl \
net-snmp-tools bind-tools gd gd-dev bash && \
net-snmp-tools bind-tools gd gd-dev && \
\
: '# For x86 the binary is : gosu-i386' && \
: '# For x64 the binary is : gosu-amd64' && \
: '# For arm-v6 the binary is : gosu-armel' && \
: '# For arm-v7 the binary is : gosu-armhf' && \
: '# For arm64 the binary is : gosu-arm64' && \
: '# For arm64/v8 the binary is : gosu-arm64' && \
: '#######################################' && \
: '# Creating an associative array with the platforms and their respective gosu release DOES NOT WORK in /bin/sh' && \
echo "Arguments TARGETPLATFORM: ${TARGETPLATFORM} and BUILDPLATFORM: ${BUILDPLATFORM}" && \
echo "$TARGETPLATFORM" | awk '{ gosuBinArr["linux/386"]="gosu-i386"; gosuBinArr["linux/amd64"]="gosu-amd64"; gosuBinArr["linux/arm/v6"]="gosu-armel"; gosuBinArr["linux/arm/v7"]="gosu-armhf"; gosuBinArr["linux/arm64"]="gosu-arm64"; gosuBinArr["linux/arm64/v8"]="gosu-arm64"; print gosuBinArr[$0];}' > mygosuver.txt && \
gosuPlatform=$(cat mygosuver.txt) && \
echo "Downloading ${gosuPlatform} for platform $TARGETPLATFORM" &&\
curl -L -o gosu "https://github.com/tianon/gosu/releases/download/1.13/${gosuPlatform}" && \
mv gosu /bin/ && \
chmod 755 /bin/gosu && \
chmod +s /bin/gosu && \
addgroup -S apache ${NAGIOS_CMDGROUP}
### ================================== ###
### STAGE 2 COMPILE NAGIOS SOURCES ###
### ================================== ###
FROM builder-base AS builder-compile
FROM builder-base as builder-compile
ARG TARGETPLATFORM
ARG BUILDPLATFORM
@ -51,21 +68,21 @@ RUN apk update && \
apk add --no-cache build-base automake libtool autoconf py-docutils gnutls \
gnutls-dev g++ make alpine-sdk build-base gcc autoconf \
gettext-dev linux-headers openssl-dev net-snmp net-snmp-tools \
libcrypto3 libpq musl libldap libssl3 libdbi freeradius-client mariadb-connector-c \
libcrypto1.1 libpq musl libldap libssl1.1 libdbi freeradius-client mariadb-connector-c \
openssh-client bind-tools samba-client fping grep rpcbind \
lm-sensors net-snmp-tools \
file freeradius-client-dev libdbi-dev libpq linux-headers mariadb-dev \
mariadb-connector-c-dev perl \
net-snmp-dev openldap-dev openssl-dev postgresql-dev wget
net-snmp-dev openldap-dev openssl-dev postgresql-dev
# Download Nagios core, plugins and nrpe sources
# Download Nagios core, plugins and nrpe sources
RUN cd /tmp && \
echo -n "Downloading Nagios ${NAGIOS_VERSION} source code: " && \
wget -O nagios-core.tar.gz "https://github.com/NagiosEnterprises/nagioscore/archive/refs/tags/nagios-${NAGIOS_VERSION}.tar.gz" && \
wget -O nagios-core.tar.gz "https://github.com/NagiosEnterprises/nagioscore/archive/nagios-${NAGIOS_VERSION}.tar.gz" && \
echo -n -e "OK\nDownloading Nagios plugins ${NAGIOS_PLUGINS_VERSION} source code: " && \
wget -O nagios-plugins.tar.gz "https://github.com/nagios-plugins/nagios-plugins/archive/refs/tags/release-${NAGIOS_PLUGINS_VERSION}.tar.gz" && \
wget -O nagios-plugins.tar.gz "https://github.com/nagios-plugins/nagios-plugins/archive/release-${NAGIOS_PLUGINS_VERSION}.tar.gz" && \
echo -n -e "OK\nDownloading NRPE ${NRPE_VERSION} source code: " && \
wget -O nrpe.tar.gz "https://github.com/NagiosEnterprises/nrpe/archive/refs/tags/nrpe-${NRPE_VERSION}.tar.gz" && \
wget -O nrpe.tar.gz "https://github.com/NagiosEnterprises/nrpe/archive/nrpe-${NRPE_VERSION}.tar.gz" && \
env && \
echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM !! == " && \
echo "OK"
@ -101,16 +118,15 @@ RUN ls -l /tmp && cd /tmp && \
# Compile Nagios Plugins
RUN echo -e "\n\n ===========================\n Configure Nagios Plugins\n ===========================\n" && \
ls -lia /tmp && cd /tmp && \
cd /tmp/nagios-plugins-release-${NAGIOS_PLUGINS_VERSION} && \
./autogen.sh && \
./configure --with-nagios-user=${NAGIOS_USER} \
--with-nagios-group=${NAGIOS_USER} \
--with-openssl \
--prefix=${NAGIOS_HOME} \
--with-ping-command="/bin/ping -n -w %d -c %d %s" \
--with-ping-command="/bin/gosu root /bin/ping -n -w %d -c %d %s" \
--with-ipv6 \
--with-ping6-command="/bin/ping6 -n -w %d -c %d %s" && \
--with-ping6-command="/bin/gosu root /bin/ping6 -n -w %d -c %d %s" && \
echo "Nagios plugins configured: OK" && \
echo -n "Replacing \"<sys\/poll.h>\" with \"<poll.h>\": " && \
egrep -rl "\<sys\/poll.h\>" . | xargs sed -i 's/<sys\/poll.h>/<poll.h>/g' && \
@ -141,7 +157,7 @@ RUN echo -e "\n\n =====================\n Configure NRPE\n =================
cp src/check_nrpe ${NAGIOS_HOME}/libexec/ && \
echo "NRPE installed successfully: OK" && \
echo -n "Final Nagios installed size: " && \
du -h -s ${NAGIOS_HOME}
du -h -s ${NAGIOS_HOME}
# Compile Nagios files
# Create SSMTP configuration
@ -161,11 +177,7 @@ RUN sed -i 's,/bin/mail,/usr/bin/mail,' ${NAGIOS_HOME}/etc/objects/commands.cfg
sed -i 's/^.*command_line.*Host Alert.*$//g' /opt/nagios/etc/objects/commands.cfg && \
sed -i 's/^.*command_line.*Service Alert.*$//g' /opt/nagios/etc/objects/commands.cfg && \
sed -i '/notify-host-by-email/a command_line /usr/bin/printf "%b" "Subject: $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$\\n\\n***** Nagios *****\\n\\nNotification Type: $NOTIFICATIONTYPE$\\nHost: $HOSTNAME$\\nState: $HOSTSTATE$\\nAddress: $HOSTADDRESS$\\nInfo: $HOSTOUTPUT$\\n\\nDate/Time: $LONGDATETIME$\\n" | /usr/sbin/sendmail -v $CONTACTEMAIL$' ${NAGIOS_HOME}/etc/objects/commands.cfg && \
sed -i '/notify-service-by-email/a command_line /usr/bin/printf "%b" "Subject: $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$\\n\\n***** Nagios *****\\n\\nNotification Type: $NOTIFICATIONTYPE$\\n\\nService: $SERVICEDESC$\\nHost: $HOSTALIAS$\\nAddress: $HOSTADDRESS$\\nState: $SERVICESTATE$\\n\\nDate/Time: $LONGDATETIME$\\n\\nAdditional Info:\\n\\n$SERVICEOUTPUT$\\n" | /usr/sbin/sendmail -v $CONTACTEMAIL$' ${NAGIOS_HOME}/etc/objects/commands.cfg && \
\
: '# Modify etc/resource.cfg in order to include custom plugins directory' && \
sed -i 's/^\(.*\)\(Sets .USER2. to be the path to\) event handlers.*$/\1\2 custom plugins directory/g' "${NAGIOS_HOME}"/etc/resource.cfg && \
sed -i 's;^#\([$]USER2[$]=\).*$;\1/opt/Custom-Nagios-Plugins;g' "${NAGIOS_HOME}"/etc/resource.cfg
sed -i '/notify-service-by-email/a command_line /usr/bin/printf "%b" "Subject: $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$\\n\\n***** Nagios *****\\n\\nNotification Type: $NOTIFICATIONTYPE$\\n\\nService: $SERVICEDESC$\\nHost: $HOSTALIAS$\\nAddress: $HOSTADDRESS$\\nState: $SERVICESTATE$\\n\\nDate/Time: $LONGDATETIME$\\n\\nAdditional Info:\\n\\n$SERVICEOUTPUT$\\n" | /usr/sbin/sendmail -v $CONTACTEMAIL$' ${NAGIOS_HOME}/etc/objects/commands.cfg
RUN echo "use_timezone=${NAGIOS_TIMEZONE}" >> ${NAGIOS_HOME}/etc/nagios.cfg && \
sed -i 's/date_format=us/date_format=iso8601/g' ${NAGIOS_HOME}/etc/nagios.cfg
@ -174,7 +186,7 @@ RUN echo "use_timezone=${NAGIOS_TIMEZONE}" >> ${NAGIOS_HOME}/etc/nagios.cfg && \
RUN mkdir -p /orig/apache2 && \
cp -r /etc/apache2/* /orig/apache2 && \
cp -r ${NAGIOS_HOME}/etc /orig/etc && \
cp -r ${NAGIOS_HOME}/var /orig/var
cp -r ${NAGIOS_HOME}/var /orig/var
### ========================== ###
@ -183,6 +195,7 @@ RUN mkdir -p /orig/apache2 && \
FROM builder-base
MAINTAINER Christos Manios <maniopaido@gmail.com>
LABEL name="Nagios" \
nagiosVersion=$NAGIOS_VERSION \
@ -190,16 +203,7 @@ LABEL name="Nagios" \
nrpeVersion=$NRPE_VERSION \
homepage="https://www.nagios.com/" \
maintainer="Christos Manios <maniopaido@gmail.com>" \
build="36" \
org.opencontainers.image.title="Nagios" \
org.opencontainers.image.description="Nagios, the Industry Standard In IT Infrastructure Monitoring" \
org.opencontainers.image.vendor="Nagios" \
org.opencontainers.image.authors="Christos Manios <maniopaido@gmail.com>" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.url="https://hub.docker.com/r/manios/nagios" \
org.opencontainers.image.source="https://github.com/manios/docker-nagios" \
org.opencontainers.image.documentation="https://github.com/manios/docker-nagios/blob/master/README.md" \
org.opencontainers.image.version="36"
build="12"
RUN mkdir -p ${NAGIOS_HOME} && \
mkdir -p /orig/apache2
@ -211,7 +215,7 @@ COPY --from=builder-compile /orig /orig
ADD overlay/ /
# Make
# Make
RUN chmod +x /usr/local/bin/start_nagios \
/etc/sv/apache/run \
/etc/sv/nagios/run \
@ -236,8 +240,8 @@ RUN chmod +x /usr/local/bin/start_nagios \
: '# Add mail symbolic links to ssmtp' && \
ln -s $(which ssmtp) /bin/mail && \
ln -s $(which ssmtp) /usr/sbin/mail
EXPOSE 80
VOLUME "${NAGIOS_HOME}/var" "${NAGIOS_HOME}/etc" "/var/log/apache2" "/opt/Custom-Nagios-Plugins"

View file

@ -1,6 +1,6 @@
MIT License
Copyright 2025 Christos Manios
Copyright 2022 Christos Manios
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@ -10,7 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
MIT License
Copyright 2025 Jason Rivers
Copyright 2017 Jason Rivers
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View file

@ -1,28 +1,21 @@
# Docker Nagios
Docker image for [Nagios](https://www.nagios.org/), the Industry Standard in IT Infrastructure Monitoring. Nagios Core is running on [Alpine Linux](https://alpinelinux.org/), using [Apache HTTP](http://httpd.apache.org/) as a web server and [sSMTP](https://wiki.debian.org/sSMTP) as mail agent for email notifications.
Docker image for [Nagios](https://www.nagios.org/), the Industry Standard In IT Infrastructure Monitoring. Nagios Core is running on [Alpine Linux](https://alpinelinux.org/), using [Apache HTTP](http://httpd.apache.org/) as a web server and [sSMTP](https://wiki.debian.org/sSMTP) as mail agent for email notifications.
The image is inspired by [JasonRivers/Docker-Nagios](https://github.com/JasonRivers/Docker-Nagios) image (Kudos to Jason!) but follows a different approach targetted to lightweight size and basic features.
Build Status:
[![Nagios Build](https://github.com/manios/docker-nagios/actions/workflows/github-build.yml/badge.svg?branch=master)](https://github.com/manios/docker-nagios/actions/workflows/github-build.yml) [![Docker pulls badge](https://img.shields.io/docker/pulls/manios/nagios.svg)](https://hub.docker.com/r/manios/nagios) [![Docker stars badge](https://img.shields.io/docker/stars/manios/nagios.svg)](https://hub.docker.com/r/manios/nagios) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/manios/docker-nagios/blob/master/LICENCE)
![build status badge](https://github.com/manios/docker-nagios/workflows/Nagios%20Build/badge.svg?branch=master) [![](https://images.microbadger.com/badges/image/manios/nagios.svg)](https://microbadger.com/images/manios/nagios) [![Docker pulls badge](https://img.shields.io/docker/pulls/manios/nagios.svg)](https://hub.docker.com/r/manios/nagios) [![Docker stars badge](https://img.shields.io/docker/stars/manios/nagios.svg)](https://hub.docker.com/r/manios/nagios) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/manios/docker-nagios/blob/master/LICENCE)
* **Available architectures**: `x86`, `amd64`, `arm/v6`, `arm/v7`, `arm64`
* **Where to file issues**: https://github.com/manios/docker-nagios/issues
## Supported tags and respective `Dockerfile` links
* `4.5.13`, `4.5`, `latest` [(4.5.13/Dockerfile)](https://github.com/manios/docker-nagios/blob/master/Dockerfile)
* `4.4.10`, `4.4`, `latest` [(4.4.10/Dockerfile)](https://github.com/manios/docker-nagios/blob/master/Dockerfile)
For more information about the image versions you may refer to the [CHANGELOG](https://github.com/manios/docker-nagios/blob/master/CHANGELOG.md)
## Container registries
Since `build-23` ([CHANGELOG](https://github.com/manios/docker-nagios/blob/build-23/CHANGELOG.md#build-23-2024-09-29)), the Nagios Docker image is available in Dockerhub and Github Container Registry (GHCR). You can pull it using one of the following ways:
1. Dockerhub: `docker pull manios/nagios:latest`
1. Github Container Registry: `docker pull ghcr.io/manios/nagios:latest`
## Running
Run with the example configuration with the following:
@ -47,9 +40,9 @@ Notes:
1. The container populates with default configuration files if the configuration directories are empty.
1. The path for the custom plugins will be /opt/Custom-Nagios-Plugins, you will need to reference this directory in your configuration scripts.
1. In order to receive mail notifications, you have to configure SSMTP. You can find example configuration inside the container in the file `/etc/ssmtp/ssmtp.conf` or in the repository in [overlay/etc/ssmtp/ssmtp.conf](https://github.com/manios/docker-nagios/blob/master/overlay/etc/ssmtp/ssmtp.conf).
1. In order to receive mail notifications, you have to configure SSMTP. You can find example configuration in `docker-nagios`.
For best results your Nagios container should have access to both IPv4 & IPv6 networks.
For best results your Nagios container should have access to both IPv4 & IPv6 networks
### Credentials
@ -73,33 +66,6 @@ docker run -e "TZ=Europe/Athens" manios/nagios:latest
This will configure and use globally `"Europe/Athens"` in both container and Nagios process.
### Init scripts
Since tag `build-31` the docker image is able to run custom init scripts at the first time the container runs. This is useful if you want to install extra software and plugins, customise the container or execute any initialisation script of your choice.
This feature has the following characteristics in detail:
* You can run one or more init scripts which have to be present in the `/container-entrypoint-init-scripts` container directory.
* The custom init script(s) run to completion at the first container run.
* Nagios process starts after all init scripts complete successfully.
* If any init script throws an error, the container is restarted.
* When all init scripts run to completion (exit code 0), a special file is written to the container filesystem, in the path `${NAGIOS_HOME}/container_first_run`. This file acts as a flag which verifies that the init scripts will be executed only on the first run.
* If you want your init scripts to run in a specific order, then make sure to name them by using a numeric prefix such as:
1. `0001-install-mongodb.sh`
1. `0002-install-jq.sh`
1. `0003-configure-custom-plugins.sh`
You can also use a volume mount for your init scripts which can survive container deletions:
```sh
docker run -d --name nagios \
-p 8080:80 \
-v "$(pwd)/customscripts:/container-entrypoint-init-scripts" \
manios/nagios:latest
```
For a detailed example you can have a look here: https://github.com/manios/docker-nagios/issues/96.
## Flavours
This Docker image is designed with optimising resources usage in mind and is build for multiple hardware architectures. The following matrix can be used to determine if your hardware architecture is represented in a docker image tag:
@ -122,10 +88,6 @@ To check if your Nagios configuration is OK, you can run the following while you
docker exec -it mynagioscontainer bin/nagios -v etc/nagios.cfg
```
## Custom plugins
This image comes with the official [Nagios Plugins](https://github.com/nagios-plugins/nagios-plugins) preinstalled in order to remain lightweight in size. If you want to use custom plugins, you can install them in the `/opt/Custom-Nagios-Plugins` by using init scripts.
## Troubleshooting
### Nagios keeps restarting or shows a strange behaviour

View file

@ -1,21 +0,0 @@
version: '3.8'
services:
nagios:
image: manios/nagios:latest
volumes:
# you may adjust your folder-mappings here
- /opt/containers/nagios/opt/nagios/etc:/opt/nagios/etc
- /opt/containers/nagios/opt/nagios/var:/opt/nagios/var
- /opt/containers/nagios/ssmtp:/etc/ssmtp
- /opt/containers/nagios/opt/Custom-Nagios-Plugins:/opt/Custom-Nagios-Plugins
ports:
- "9080:80"
environment:
# yo may adjust username and password here or remove it to use the default
NAGIOSADMIN_USER: "godmode"
NAGIOSADMIN_PASS: "secretpass"
# set your timezone below like e.g.
#NAGIOS_TIMEZONE: "Europe/Berlin"
NAGIOS_TIMEZONE: "UTC"

View file

@ -6,70 +6,30 @@ set -eu
# this script becomes PID 1 inside the container, catches termination signals, and stops
# processes managed by runit
# Prints a line by prepending the date in ISO-8601 format
# usage: logDate MESSAGE
# ie: logDate "Spongebob"
logDate() {
mydate=`date +"%Y-%m-%dT%H:%M:%S%z"`
if [ -z "$(ls -A ${NAGIOS_HOME}/etc)" ]; then
echo "Started with empty ETC, copying example data in-place"
cp -Rp /orig/etc/* ${NAGIOS_HOME}/etc/
fi
echo "${mydate} $@"
}
if [ -z "$(ls -A ${NAGIOS_HOME}/var)" ]; then
echo "Started with empty VAR, copying example data in-place"
cp -Rp /orig/var/* ${NAGIOS_HOME}/var/
fi
# Run custom scripts provided by the user
# usage: run_custom_scripts PATH
# ie: run_custom_scripts /container-entrypoint-init-scripts
# This runs *.sh files
# Adapted from: https://github.com/gvenzl/oci-oracle-xe/blob/0cedd27ab04771789f1425639434d33940935f6c/container-entrypoint.sh
run_custom_scripts() {
if [ ! -f "${NAGIOS_HOME}/etc/htpasswd.users" ] ; then
htpasswd -c -b -s "${NAGIOS_HOME}/etc/htpasswd.users" "${NAGIOSADMIN_USER}" "${NAGIOSADMIN_PASS}"
chown -R ${NAGIOS_USER}.${NAGIOS_GROUP} "${NAGIOS_HOME}/etc/htpasswd.users"
fi
SCRIPTS_ROOT="${1}";
# Remove pid files
# Check whether parameter has been passed on
if [ -z "${SCRIPTS_ROOT}" ]; then
echo "No SCRIPTS_ROOT passed on, no scripts will be run.";
return;
fi;
echo -n "Removing Apache HTTPD PID file before starting it ..."
(rm -f /var/run/apache2/httpd.pid || true)
echo "OK"
# Execute custom provided files (only if directory exists and has files in it)
if [ -d "${SCRIPTS_ROOT}" ] && [ -n "$(ls -A "${SCRIPTS_ROOT}")" ]; then
echo -e "\nCONTAINER: Executing user defined scripts..."
run_custom_scripts_recursive ${SCRIPTS_ROOT}
echo -e "CONTAINER: DONE: Executing user defined scripts.\n"
fi;
}
# This recursive function traverses through sub directories by calling itself with them
# usage: run_custom_scripts_recursive PATH
# ie: run_custom_scripts_recursive /container-entrypoint-init-scripts/001_subdir
# This runs *.sh files and traveres in sub directories
# Adapted from: https://github.com/gvenzl/oci-oracle-xe/blob/0cedd27ab04771789f1425639434d33940935f6c/container-entrypoint.sh
run_custom_scripts_recursive() {
local f
for f in "${1}"/*; do
case "${f}" in
*.sh)
if [ -x "${f}" ]; then
echo -e "\nCONTAINER: running ${f} ..."; "${f}"; echo "CONTAINER: DONE: running ${f}"
else
echo -e "\nCONTAINER: sourcing ${f} ..."; . "${f}" echo "CONTAINER: DONE: sourcing ${f}"
fi;
;;
*)
if [ -d "${f}" ]; then
echo -e "\nCONTAINER: descending into ${f} ..."; run_custom_scripts_recursive "${f}"; echo "CONTAINER: DONE: descending into ${f}"
else
echo -e "\nCONTAINER: ignoring ${f}"
fi;
;;
esac
echo "";
done
}
echo -n "Removing rsyslogd PID file before starting it ..."
(rm -f /var/run/rsyslogd.pid || true)
echo "OK"
# This function sets the timezone to Nagios and Apache configuration files
setTimezone() {
@ -130,60 +90,6 @@ shutdown() {
exit
}
### =========== ###
### MAIN METHOD ###
### =========== ###
# If it is the first container startup / initialization,
# execute any custom user scripts
if [ ! -f "${NAGIOS_HOME}/container_first_run" ]; then
run_custom_scripts /container-entrypoint-init-scripts
# After scripts complete, create ${NAGIOS_HOME}/container_first_run
# file to mark the end of first startup
touch "${NAGIOS_HOME}/container_first_run"
fi
# If the $NAGIOS_HOME/etc directory is empty, copy example configuration
if [ -z "$(ls -A ${NAGIOS_HOME}/etc)" ]; then
echo "Started with empty ETC, copying example data in-place"
cp -Rp /orig/etc/* ${NAGIOS_HOME}/etc/
fi
# If the $NAGIOS_HOME/var directory is empty, copy example data
if [ -z "$(ls -A ${NAGIOS_HOME}/var)" ]; then
echo "Started with empty VAR, copying example data in-place"
cp -Rp /orig/var/* ${NAGIOS_HOME}/var/
fi
# If the htpasswd.users file does not exist, create a new one and place NAGIOSADMINUSER as
# its first user
if [ ! -f "${NAGIOS_HOME}/etc/htpasswd.users" ] ; then
htpasswd -c -b -s "${NAGIOS_HOME}/etc/htpasswd.users" "${NAGIOSADMIN_USER}" "${NAGIOSADMIN_PASS}"
chown -R ${NAGIOS_USER}:${NAGIOS_GROUP} "${NAGIOS_HOME}/etc/htpasswd.users"
fi
# Set current $NAGIOSADMIN_USER to the configuration of $NAGIOS_HOME/etc/cgi.cfg
if [ "${NAGIOSADMIN_USER}" != "nagiosadmin" ]; then
echo "Modifying ${NAGIOS_HOME}/etc/cgi.cfg in order to use ${NAGIOSADMIN_USER} as its authorised user"
sed -i "s|\(authorized_for_system_information=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg
sed -i "s|\(authorized_for_configuration_information=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg
sed -i "s|\(authorized_for_system_commands=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg
sed -i "s|\(authorized_for_all_services=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg
sed -i "s|\(authorized_for_all_hosts=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg
sed -i "s|\(authorized_for_all_service_commands=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg
sed -i "s|\(authorized_for_all_host_commands=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg
fi
# Remove pid files
echo -n "Removing Apache HTTPD PID file before starting it ..."
(rm -f /var/run/apache2/httpd.pid || true)
echo "OK"
echo -n "Removing rsyslogd PID file before starting it ..."
(rm -f /var/run/rsyslogd.pid || true)
echo "OK"
# Set timezones before start
setTimezone