mirror of
https://github.com/manios/docker-nagios.git
synced 2026-07-18 08:55:35 +00:00
Compare commits
56 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2a266a0b8 | ||
|
|
6c680597aa | ||
|
|
832f18de01 | ||
|
|
b0164053a3 | ||
|
|
1ccea2191c | ||
|
|
952e22f7ac | ||
|
|
a4227c8de4 | ||
|
|
5acca58978 | ||
|
|
78dff4a2d0 | ||
|
|
29a8acf349 | ||
|
|
2e618492a2 | ||
|
|
196a449b4b | ||
|
|
5a00b37375 | ||
|
|
a98132f871 | ||
|
|
d098e3782a | ||
|
|
f86d932bb4 | ||
|
|
79232ba6ae | ||
|
|
d3c5fa1a8a | ||
|
|
f8680f8e8d | ||
|
|
85434f57dc | ||
|
|
3ed23b25cc | ||
|
|
b6f28ebd98 | ||
|
|
9c4873d9c1 | ||
|
|
002dacf965 | ||
|
|
155722ddbd | ||
|
|
47c30fc38d | ||
|
|
8045ac4399 | ||
|
|
4920d98619 | ||
|
|
b9aab3b10d | ||
|
|
45cf3347e3 | ||
|
|
6a4bd9d524 | ||
|
|
0a90f75035 | ||
|
|
77e8550ce5 | ||
|
|
6964113262 | ||
|
|
786a3d6aa4 | ||
|
|
4977b79690 | ||
|
|
8482b61938 | ||
|
|
2bdffc955a | ||
|
|
64a4da80a7 | ||
|
|
7507283f05 | ||
|
|
6b550aa657 | ||
|
|
224e43183d | ||
|
|
1a74ebaa5d | ||
|
|
f45e49cce3 | ||
|
|
e4adfa6728 | ||
|
|
164ef4d6ad | ||
|
|
2ef4638652 | ||
|
|
d6e574e7d7 | ||
|
|
39a727f7da | ||
|
|
a5276ab07f | ||
|
|
909d1092f0 | ||
|
|
edaddfe36d | ||
|
|
ca16cc0c97 | ||
|
|
0ae4402364 | ||
|
|
a85c199666 | ||
|
|
c081de3f90 |
7 changed files with 536 additions and 85 deletions
50
.github/workflows/github-build.yml
vendored
50
.github/workflows/github-build.yml
vendored
|
|
@ -6,6 +6,7 @@ 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:
|
||||
|
|
@ -19,7 +20,7 @@ jobs:
|
|||
echo "github.action_path : ${{ github.action_path }}"
|
||||
echo "github.actor : ${{ github.actor }}"
|
||||
echo "github.base_ref : ${{ github.base_ref }}"
|
||||
echo "github.event : ${{ toJson(github.event) }}"
|
||||
echo 'github.event : ${{ toJson(github.event) }}'
|
||||
echo "github.event_name : ${{ github.event_name }}"
|
||||
echo "github.event_path : ${{ github.event_path }}"
|
||||
echo "github.head_ref : ${{ github.head_ref }}"
|
||||
|
|
@ -54,33 +55,38 @@ jobs:
|
|||
run: |
|
||||
echo "My docker tag will be: ${{ env.action_mytag }}"
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
uses: docker/login-action@v3
|
||||
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@v3
|
||||
uses: actions/checkout@v4
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
uses: docker/setup-qemu-action@v3
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
uses: docker/setup-buildx-action@v3
|
||||
-
|
||||
name: Available platforms
|
||||
run: echo ${{ steps.buildx.outputs.platforms }}
|
||||
-
|
||||
name: Cache Docker layers for this Git branch
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
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 \
|
||||
|
|
@ -88,21 +94,33 @@ 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 }}" \
|
||||
--tag manios/nagios:${{ env.action_mytag }} \
|
||||
--label "org.opencontainers.image.revision=${{ github.sha }}" \
|
||||
--tag ${GITHUB_ACTOR}/nagios:${{ env.action_mytag }} \
|
||||
--output "type=image,push=false" .
|
||||
-
|
||||
name: Docker Buildx (push)
|
||||
- name: 'Docker Buildx: Push to Dockerhub'
|
||||
run: |
|
||||
echo "== This branch is : ${GITHUB_REF}"
|
||||
echo "Will push image manios/nagios:${{ env.action_mytag }} to DockerHub"
|
||||
echo "Will push image ${GITHUB_ACTOR}/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 }}" \
|
||||
--tag manios/nagios:${{ env.action_mytag }} \
|
||||
--label "org.opencontainers.image.revision=${{ github.sha }}" \
|
||||
--tag ${GITHUB_ACTOR}/nagios:${{ env.action_mytag }} \
|
||||
--output "type=image,push=true" .
|
||||
-
|
||||
name: Inspect image
|
||||
- name: 'Docker Buildx: Push to GitHub Container Registry'
|
||||
run: |
|
||||
docker buildx imagetools inspect manios/nagios:${{ env.action_mytag }}
|
||||
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 }}
|
||||
|
|
|
|||
284
CHANGELOG.md
284
CHANGELOG.md
|
|
@ -3,6 +3,290 @@
|
|||
|
||||
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
|
||||
* Nagios plugins: v2.4.3
|
||||
* NRPE: 4.1.0
|
||||
|
||||
### Features
|
||||
|
||||
* 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)
|
||||
|
||||
* Nagios core: v4.4.9
|
||||
|
|
|
|||
82
Dockerfile
82
Dockerfile
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
# https://www.docker.com/blog/docker-arm-virtual-meetup-multi-arch-with-buildx/
|
||||
|
||||
FROM alpine:3.12 as builder-base
|
||||
FROM alpine:3.23 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.4.9 \
|
||||
NAGIOS_PLUGINS_VERSION=2.4.2 \
|
||||
NRPE_VERSION=4.1.0 \
|
||||
NAGIOS_VERSION=4.5.13 \
|
||||
NAGIOS_PLUGINS_VERSION=2.5 \
|
||||
NRPE_VERSION=4.1.3 \
|
||||
APACHE_LOCK_DIR=/var/run \
|
||||
APACHE_LOG_DIR=/var/log/apache2
|
||||
|
||||
|
|
@ -29,37 +29,20 @@ 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 \
|
||||
php7 php7-gd php7-cli runit parallel ssmtp \
|
||||
libltdl libintl openssl-dev php7-apache2 procps tzdata \
|
||||
php83 php83-gd php83-cli runit parallel ssmtp \
|
||||
libltdl libintl openssl-dev php83-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 && \
|
||||
\
|
||||
: '# 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 && \
|
||||
net-snmp-tools bind-tools gd gd-dev bash && \
|
||||
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
|
||||
|
||||
|
|
@ -68,21 +51,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 \
|
||||
libcrypto1.1 libpq musl libldap libssl1.1 libdbi freeradius-client mariadb-connector-c \
|
||||
libcrypto3 libpq musl libldap libssl3 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
|
||||
net-snmp-dev openldap-dev openssl-dev postgresql-dev wget
|
||||
|
||||
# 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/nagios-${NAGIOS_VERSION}.tar.gz" && \
|
||||
wget -O nagios-core.tar.gz "https://github.com/NagiosEnterprises/nagioscore/archive/refs/tags/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/release-${NAGIOS_PLUGINS_VERSION}.tar.gz" && \
|
||||
wget -O nagios-plugins.tar.gz "https://github.com/nagios-plugins/nagios-plugins/archive/refs/tags/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/nrpe-${NRPE_VERSION}.tar.gz" && \
|
||||
wget -O nrpe.tar.gz "https://github.com/NagiosEnterprises/nrpe/archive/refs/tags/nrpe-${NRPE_VERSION}.tar.gz" && \
|
||||
env && \
|
||||
echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM !! == " && \
|
||||
echo "OK"
|
||||
|
|
@ -118,15 +101,16 @@ 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/gosu root /bin/ping -n -w %d -c %d %s" \
|
||||
--with-ping-command="/bin/ping -n -w %d -c %d %s" \
|
||||
--with-ipv6 \
|
||||
--with-ping6-command="/bin/gosu root /bin/ping6 -n -w %d -c %d %s" && \
|
||||
--with-ping6-command="/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' && \
|
||||
|
|
@ -157,7 +141,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
|
||||
|
|
@ -177,7 +161,11 @@ 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
|
||||
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
|
||||
|
||||
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
|
||||
|
|
@ -186,7 +174,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
|
||||
|
||||
|
||||
### ========================== ###
|
||||
|
|
@ -195,7 +183,6 @@ RUN mkdir -p /orig/apache2 && \
|
|||
|
||||
FROM builder-base
|
||||
|
||||
MAINTAINER Christos Manios <maniopaido@gmail.com>
|
||||
|
||||
LABEL name="Nagios" \
|
||||
nagiosVersion=$NAGIOS_VERSION \
|
||||
|
|
@ -203,7 +190,16 @@ LABEL name="Nagios" \
|
|||
nrpeVersion=$NRPE_VERSION \
|
||||
homepage="https://www.nagios.com/" \
|
||||
maintainer="Christos Manios <maniopaido@gmail.com>" \
|
||||
build="11"
|
||||
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"
|
||||
|
||||
RUN mkdir -p ${NAGIOS_HOME} && \
|
||||
mkdir -p /orig/apache2
|
||||
|
|
@ -215,7 +211,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 \
|
||||
|
|
@ -240,8 +236,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"
|
||||
|
|
|
|||
4
LICENCE
4
LICENCE
|
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright 2022 Christos Manios
|
||||
Copyright 2025 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 2017 Jason Rivers
|
||||
Copyright 2025 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:
|
||||
|
||||
|
|
|
|||
48
README.md
48
README.md
|
|
@ -1,21 +1,28 @@
|
|||
# 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:
|
||||
 [](https://microbadger.com/images/manios/nagios) [](https://hub.docker.com/r/manios/nagios) [](https://hub.docker.com/r/manios/nagios) [](https://github.com/manios/docker-nagios/blob/master/LICENCE)
|
||||
[](https://github.com/manios/docker-nagios/actions/workflows/github-build.yml) [](https://hub.docker.com/r/manios/nagios) [](https://hub.docker.com/r/manios/nagios) [](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.4.9`, `4.4`, `latest` [(4.4.9/Dockerfile)](https://github.com/manios/docker-nagios/blob/master/Dockerfile)
|
||||
* `4.5.13`, `4.5`, `latest` [(4.5.13/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:
|
||||
|
|
@ -40,9 +47,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 in `docker-nagios`.
|
||||
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).
|
||||
|
||||
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
|
||||
|
||||
|
|
@ -66,6 +73,33 @@ 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:
|
||||
|
|
@ -88,6 +122,10 @@ 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
|
||||
|
|
|
|||
21
docker-compose-portainer.yaml
Normal file
21
docker-compose-portainer.yaml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
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"
|
||||
|
|
@ -6,30 +6,70 @@ set -eu
|
|||
# this script becomes PID 1 inside the container, catches termination signals, and stops
|
||||
# processes managed by runit
|
||||
|
||||
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
|
||||
# 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}/var)" ]; then
|
||||
echo "Started with empty VAR, copying example data in-place"
|
||||
cp -Rp /orig/var/* ${NAGIOS_HOME}/var/
|
||||
fi
|
||||
echo "${mydate} $@"
|
||||
}
|
||||
|
||||
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
|
||||
# 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() {
|
||||
|
||||
# Remove pid files
|
||||
SCRIPTS_ROOT="${1}";
|
||||
|
||||
echo -n "Removing Apache HTTPD PID file before starting it ..."
|
||||
(rm -f /var/run/apache2/httpd.pid || true)
|
||||
echo "OK"
|
||||
# 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 rsyslogd PID file before starting it ..."
|
||||
(rm -f /var/run/rsyslogd.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
|
||||
}
|
||||
|
||||
# This function sets the timezone to Nagios and Apache configuration files
|
||||
setTimezone() {
|
||||
|
|
@ -90,6 +130,60 @@ 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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue