├── overlay ├── etc │ ├── sv │ │ ├── rsyslog │ │ │ └── run │ │ ├── apache │ │ │ └── run │ │ └── nagios │ │ │ └── run │ ├── rsyslog.conf │ └── ssmtp │ │ └── ssmtp.conf └── usr │ └── local │ └── bin │ └── start_nagios ├── docker-compose-portainer.yaml ├── LICENCE ├── .github ├── ISSUE_TEMPLATE │ └── bug-report.yaml └── workflows │ └── github-build.yml ├── README.md ├── CHANGELOG.md └── Dockerfile /overlay/etc/sv/rsyslog/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | exec rsyslogd -n -f /etc/rsyslog.conf 6 | -------------------------------------------------------------------------------- /overlay/etc/sv/apache/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . /usr/sbin/envvars 4 | 5 | # TODO Check about cache 6 | # . /usr/sbin/htcacheclean 7 | 8 | export TZ="${NAGIOS_TIMEZONE}" 9 | 10 | exec /usr/sbin/httpd -D NO_DETACH 11 | -------------------------------------------------------------------------------- /overlay/etc/sv/nagios/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "checking permissions for nagios" 4 | find /opt/nagios -not -user ${NAGIOS_USER} -exec chown ${NAGIOS_USER}:${NAGIOS_GROUP} {} \; 5 | 6 | 7 | exec "${NAGIOS_HOME}/bin/nagios" "${NAGIOS_HOME}/etc/nagios.cfg" 8 | -------------------------------------------------------------------------------- /overlay/etc/rsyslog.conf: -------------------------------------------------------------------------------- 1 | # redirect /var/log/syslog to stdout 2 | $ModLoad imuxsock 3 | 4 | # Template which logs only tag and message 5 | # https://unix.stackexchange.com/questions/302972/how-to-stop-rsyslog-output-timestamp 6 | $template noTimestampFormat,"%syslogtag%%msg%\n" 7 | 8 | # Set default file format 9 | # https://www.rsyslog.com/doc/v8-stable/configuration/templates.html 10 | $ActionFileDefaultTemplate RSYSLOG_FileFormat 11 | 12 | $WorkDirectory /var/spool/rsyslog 13 | *.*;auth,authpriv.none /dev/stdout 14 | -------------------------------------------------------------------------------- /docker-compose-portainer.yaml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | services: 3 | nagios: 4 | image: manios/nagios:latest 5 | volumes: 6 | # you may adjust your folder-mappings here 7 | - /opt/containers/nagios/opt/nagios/etc:/opt/nagios/etc 8 | - /opt/containers/nagios/opt/nagios/var:/opt/nagios/var 9 | - /opt/containers/nagios/ssmtp:/etc/ssmtp 10 | - /opt/containers/nagios/opt/Custom-Nagios-Plugins:/opt/Custom-Nagios-Plugins 11 | 12 | ports: 13 | - "9080:80" 14 | 15 | environment: 16 | # yo may adjust username and password here or remove it to use the default 17 | NAGIOSADMIN_USER: "godmode" 18 | NAGIOSADMIN_PASS: "secretpass" 19 | # set your timezone below like e.g. 20 | #NAGIOS_TIMEZONE: "Europe/Berlin" 21 | NAGIOS_TIMEZONE: "UTC" 22 | -------------------------------------------------------------------------------- /overlay/etc/ssmtp/ssmtp.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Config file for sSMTP sendmail 3 | # 4 | # Gmail configuration with help from 5 | # http://askubuntu.com/questions/155248/how-can-i-have-nagios-alerts-emailed-to-my-gmail 6 | # 7 | # The person who gets all mail for userids < 1000 8 | # Make this empty to disable rewriting. 9 | root=mygmailaccount@gmail.com 10 | 11 | # The place where the mail goes. The actual machine name is required no 12 | # MX records are consulted. Commonly mailhosts are named mail.domain.com 13 | # For Gmail use the following 14 | mailhub=smtp.gmail.com:587 15 | 16 | # Where will the mail seem to come from? 17 | #rewriteDomain= 18 | 19 | # The full hostname 20 | hostname=raspberrypi 21 | 22 | # Are users allowed to set their own From: address? 23 | # YES - Allow the user to specify their own From: address 24 | # NO - Use the system generated From: address 25 | #FromLineOverride=YES 26 | 27 | UseTLS=YES 28 | UseSTARTTLS=YES 29 | AuthMethod=LOGIN 30 | AuthUser=mygmailaccount@gmail.com 31 | AuthPass=passw 32 | 33 | 34 | # TEMPLATE FOR GMAIL 35 | # UseTLS=YES 36 | # UseSTARTTLS=YES 37 | # AuthMethod=LOGIN 38 | # AuthUser=mygmailaccount@gmail.com 39 | # AuthPass=passw 40 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright 2025 Christos Manios 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | MIT License 12 | 13 | Copyright 2025 Jason Rivers 14 | 15 | 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: 16 | 17 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.yaml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: File a bug report 3 | title: "[Bug]: " 4 | labels: [bug, triage] 5 | assignees: 6 | - octocat 7 | body: 8 | - type: markdown 9 | attributes: 10 | value: | 11 | Thanks for taking the time to fill out this bug report! 12 | - type: textarea 13 | id: what-happened 14 | attributes: 15 | label: What happened? 16 | description: Also tell us, what did you expect to happen? 17 | placeholder: Tell us what you see! 18 | value: "A bug happened!" 19 | validations: 20 | required: true 21 | - type: textarea 22 | id: image-info 23 | attributes: 24 | label: Image information 25 | description: | 26 | Can you please give us some information about the image you are using? In order to achieve this, please post here the output of the command: 27 | 28 | ```shell 29 | docker inspect --format='{{range $k,$v := .Config.Labels}}{{printf "* %s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v}}{{end}}{{"\n"}}{{end}}' manios/nagios:[TAG] 30 | ``` 31 | Example output: 32 | 33 | ``` 34 | * build: 5 35 | * gitCommit: c34e48cb6866b1a2bb77adf4d69feeab534ecc84 36 | * homepage: https://www.nagios.com/ 37 | * maintainer: Christos Manios 38 | * nagiosPluginsVersion: 2.3.3 39 | * nagiosVersion: 4.4.6 40 | * name: Nagios 41 | * nrpeVersion: 4.0.3 42 | ``` 43 | validations: 44 | required: true 45 | - type: dropdown 46 | id: image-architercture 47 | attributes: 48 | label: Image architecture 49 | description: | 50 | What is the architecture your docker image is using? You can easily find out by executing this 51 | 52 | ```shell 53 | docker exec -it [container-name] /bin/sh -c 'apk --print-arch' 54 | ``` 55 | in your running container. 56 | 57 | Example output: 58 | 59 | ``` 60 | amd64 61 | ``` 62 | multiple: true 63 | options: 64 | - x86 65 | - amd64 66 | - arm/v6 67 | - arm/v7 68 | - arm64 69 | validations: 70 | required: true 71 | - type: textarea 72 | id: logs 73 | attributes: 74 | label: Relevant log output 75 | description: | 76 | Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for markdown backticks. 77 | 78 | For example, in order to view the last 200 log lines from the container you can run: 79 | 80 | ```shell 81 | docker logs --tail 200 [container-name] 82 | ``` 83 | 84 | You can also append the Apache error or access logs by issuing the commands: 85 | 86 | ```shell 87 | docker exec -it [container-name] /bin/sh -c 'cat /var/log/apache2/error.log' 88 | 89 | # AND 90 | 91 | docker exec -it [container-name] /bin/sh -c 'cat /var/log/apache2/access.log 92 | ``` 93 | render: shell 94 | 95 | -------------------------------------------------------------------------------- /.github/workflows/github-build.yml: -------------------------------------------------------------------------------- 1 | name: Nagios Build 2 | # This workflow is triggered on pushes to the repository. 3 | # Taken from tutorial 4 | # https://github.com/gitschooldude/hello 5 | # https://www.youtube.com/watch?v=-xIXFxuZCMI 6 | # https://github.com/marketplace/actions/docker-setup-buildx 7 | # https://github.com/marketplace/actions/docker-login 8 | # https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions/58034787 9 | 10 | on: [push] 11 | 12 | jobs: 13 | nagios-build: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Print all github.* variables 17 | id: step_one_print_all 18 | run: | 19 | echo "github.action : ${{ github.action }}" 20 | echo "github.action_path : ${{ github.action_path }}" 21 | echo "github.actor : ${{ github.actor }}" 22 | echo "github.base_ref : ${{ github.base_ref }}" 23 | echo 'github.event : ${{ toJson(github.event) }}' 24 | echo "github.event_name : ${{ github.event_name }}" 25 | echo "github.event_path : ${{ github.event_path }}" 26 | echo "github.head_ref : ${{ github.head_ref }}" 27 | echo "github.job : ${{ github.job }}" 28 | echo "github.ref : ${{ github.ref }}" 29 | echo "github.repository : ${{ github.repository }}" 30 | echo "github.repository_owner : ${{ github.repository_owner }}" 31 | echo "github.run_id : ${{ github.run_id }}" 32 | echo "github.run_number : ${{ github.run_number }}" 33 | echo "github.sha : ${{ github.sha }}" 34 | echo "github.token : ${{ github.token }}" 35 | echo "github.workflow : ${{ github.workflow }}" 36 | echo "github.workspace : ${{ github.workspace }}" 37 | echo "my docker tag: ${{ env.action_mytag }}" 38 | - name: Set the value of a the Docker tag for branches other than master 39 | id: step_two_branches_all 40 | if: ${{ (startsWith( github.ref, 'refs/heads') == true) && (github.ref != 'refs/heads/master') }} 41 | run: | 42 | echo "action_mytag=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV 43 | - name: Set the value of the Docker tag for git tags 44 | id: step_set_docker_tag_for_git_tags 45 | if: ${{ startsWith( github.ref, 'refs/tags') == true}} 46 | run: | 47 | echo "action_mytag=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV 48 | - name: Set the value of the Docker tag for master branch 49 | id: step_branch_master 50 | if: ${{ github.ref == 'refs/heads/master' }} 51 | run: | 52 | echo "action_mytag=latest" >> $GITHUB_ENV 53 | - name: Print the Docker tag value which will be used 54 | id: step_print_docker_tag 55 | run: | 56 | echo "My docker tag will be: ${{ env.action_mytag }}" 57 | - name: Login to DockerHub 58 | uses: docker/login-action@v3 59 | with: 60 | username: ${{ secrets.DOCKERHUB_USERNAME }} 61 | password: ${{ secrets.DOCKERHUB_TOKEN }} 62 | - name: Login to GitHub Container Registry 63 | uses: docker/login-action@v3 64 | with: 65 | registry: ghcr.io 66 | username: ${{ github.actor }} 67 | password: ${{ secrets.GITHUB_TOKEN }} 68 | - 69 | name: Checkout 70 | uses: actions/checkout@v4 71 | - 72 | name: Set up QEMU 73 | uses: docker/setup-qemu-action@v3 74 | - 75 | name: Set up Docker Buildx 76 | uses: docker/setup-buildx-action@v3 77 | - 78 | name: Available platforms 79 | run: echo ${{ steps.buildx.outputs.platforms }} 80 | - 81 | name: Cache Docker layers for this Git branch 82 | uses: actions/cache@v4 83 | id: cache 84 | with: 85 | path: /tmp/.buildx-cache 86 | key: ${{ runner.os }}-buildx-${{ github.ref }} 87 | restore-keys: | 88 | ${{ runner.os }}-buildx-${{ github.ref }} 89 | - name: Docker Buildx (build and cache) 90 | run: | 91 | docker buildx build \ 92 | --progress plain \ 93 | --cache-from "type=local,src=/tmp/.buildx-cache" \ 94 | --cache-to "type=local,dest=/tmp/.buildx-cache" \ 95 | --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \ 96 | --label "gitCommit=${{ github.sha }}" \ 97 | --label "org.opencontainers.image.revision=${{ github.sha }}" \ 98 | --tag ${GITHUB_ACTOR}/nagios:${{ env.action_mytag }} \ 99 | --output "type=image,push=false" . 100 | - name: 'Docker Buildx: Push to Dockerhub' 101 | run: | 102 | echo "== This branch is : ${GITHUB_REF}" 103 | echo "Will push image ${GITHUB_ACTOR}/nagios:${{ env.action_mytag }} to DockerHub" 104 | docker buildx build \ 105 | --progress plain \ 106 | --cache-from "type=local,src=/tmp/.buildx-cache" \ 107 | --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \ 108 | --label "gitCommit=${{ github.sha }}" \ 109 | --label "org.opencontainers.image.revision=${{ github.sha }}" \ 110 | --tag ${GITHUB_ACTOR}/nagios:${{ env.action_mytag }} \ 111 | --output "type=image,push=true" . 112 | - name: 'Docker Buildx: Push to GitHub Container Registry' 113 | run: | 114 | echo "== This branch is : ${GITHUB_REF}" 115 | echo "Will push image ghcr.io/${GITHUB_ACTOR}/nagios:${{ env.action_mytag }} to GitHub Container Registry" 116 | docker buildx build \ 117 | --progress plain \ 118 | --cache-from "type=local,src=/tmp/.buildx-cache" \ 119 | --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \ 120 | --label "gitCommit=${{ github.sha }}" \ 121 | --label "org.opencontainers.image.revision=${{ github.sha }}" \ 122 | --tag ghcr.io/${GITHUB_ACTOR}/nagios:${{ env.action_mytag }} \ 123 | --output "type=image,push=true" . 124 | - name: Inspect image 125 | run: | 126 | docker buildx imagetools inspect ${GITHUB_ACTOR}/nagios:${{ env.action_mytag }} 127 | -------------------------------------------------------------------------------- /overlay/usr/local/bin/start_nagios: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | # adapted from https://github.com/discourse/discourse_docker/blob/master/image/base/boot 6 | # this script becomes PID 1 inside the container, catches termination signals, and stops 7 | # processes managed by runit 8 | 9 | # Prints a line by prepending the date in ISO-8601 format 10 | # usage: logDate MESSAGE 11 | # ie: logDate "Spongebob" 12 | logDate() { 13 | mydate=`date +"%Y-%m-%dT%H:%M:%S%z"` 14 | 15 | echo "${mydate} $@" 16 | } 17 | 18 | # Run custom scripts provided by the user 19 | # usage: run_custom_scripts PATH 20 | # ie: run_custom_scripts /container-entrypoint-init-scripts 21 | # This runs *.sh files 22 | # Adapted from: https://github.com/gvenzl/oci-oracle-xe/blob/0cedd27ab04771789f1425639434d33940935f6c/container-entrypoint.sh 23 | run_custom_scripts() { 24 | 25 | SCRIPTS_ROOT="${1}"; 26 | 27 | # Check whether parameter has been passed on 28 | if [ -z "${SCRIPTS_ROOT}" ]; then 29 | echo "No SCRIPTS_ROOT passed on, no scripts will be run."; 30 | return; 31 | fi; 32 | 33 | # Execute custom provided files (only if directory exists and has files in it) 34 | if [ -d "${SCRIPTS_ROOT}" ] && [ -n "$(ls -A "${SCRIPTS_ROOT}")" ]; then 35 | 36 | echo -e "\nCONTAINER: Executing user defined scripts..." 37 | 38 | run_custom_scripts_recursive ${SCRIPTS_ROOT} 39 | 40 | echo -e "CONTAINER: DONE: Executing user defined scripts.\n" 41 | 42 | fi; 43 | } 44 | 45 | # This recursive function traverses through sub directories by calling itself with them 46 | # usage: run_custom_scripts_recursive PATH 47 | # ie: run_custom_scripts_recursive /container-entrypoint-init-scripts/001_subdir 48 | # This runs *.sh files and traveres in sub directories 49 | # Adapted from: https://github.com/gvenzl/oci-oracle-xe/blob/0cedd27ab04771789f1425639434d33940935f6c/container-entrypoint.sh 50 | run_custom_scripts_recursive() { 51 | local f 52 | for f in "${1}"/*; do 53 | case "${f}" in 54 | *.sh) 55 | if [ -x "${f}" ]; then 56 | echo -e "\nCONTAINER: running ${f} ..."; "${f}"; echo "CONTAINER: DONE: running ${f}" 57 | else 58 | echo -e "\nCONTAINER: sourcing ${f} ..."; . "${f}" echo "CONTAINER: DONE: sourcing ${f}" 59 | fi; 60 | ;; 61 | 62 | *) 63 | if [ -d "${f}" ]; then 64 | echo -e "\nCONTAINER: descending into ${f} ..."; run_custom_scripts_recursive "${f}"; echo "CONTAINER: DONE: descending into ${f}" 65 | else 66 | echo -e "\nCONTAINER: ignoring ${f}" 67 | fi; 68 | ;; 69 | esac 70 | echo ""; 71 | done 72 | } 73 | 74 | # This function sets the timezone to Nagios and Apache configuration files 75 | setTimezone() { 76 | 77 | # If TZ env is not set, continue 78 | # https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash 79 | if [ -z "${TZ+x}" ]; then 80 | echo "TZ env variable is not set. Continue." 81 | return 0 82 | fi 83 | 84 | # Check if timezone is set in nagios.cfg 85 | NAGIOS_CFG="${NAGIOS_HOME}/etc/nagios.cfg" 86 | NAGIOS_HTTPD_CFG="/etc/apache2/conf.d/nagios.conf" 87 | 88 | TZ_EXIST_NAGIOS_CFG=$(egrep -q "^use_timezone" ${NAGIOS_CFG} ; echo $?) 89 | TZ_EXIST_APACHE_CFG=$(egrep -q "SetEnv *TZ *" ${NAGIOS_HTTPD_CFG} ; echo $?) 90 | 91 | #echo "Exists in Nagios conf: $TZ_EXIST_NAGIOS_CFG or Apache conf: $TZ_EXIST_APACHE_CFG" 92 | 93 | # Set timezone to Nagios config 94 | if [ ${TZ_EXIST_NAGIOS_CFG} -eq 0 ]; then 95 | echo -n "Timezone setting exists in ${NAGIOS_CFG}. Modifying it ..." 96 | sed -i "s|^use_timezone.*$|use_timezone=$TZ|g" "${NAGIOS_CFG}" 97 | echo " OK" 98 | else 99 | echo -n "No timezone setting in ${NAGIOS_CFG} ..." 100 | echo "use_timezone=$TZ" >> ${NAGIOS_CFG} 101 | echo " OK" 102 | fi 103 | 104 | # Set timezone to Apache httpd Nagios config 105 | if [ ${TZ_EXIST_APACHE_CFG} -eq 0 ]; then 106 | echo -n "Timezone setting exists in ${NAGIOS_HTTPD_CFG}. Modifying it ..." 107 | sed -i "s|^ *SetEnv *TZ.*$| SetEnv TZ \"${TZ}\"|g" "${NAGIOS_HTTPD_CFG}" 108 | echo " OK" 109 | else 110 | echo -n "No timezone setting in ${NAGIOS_HTTPD_CFG} ..." 111 | sed -i "s|# *SSLRequireSSL|# SSLRequireSSL\n SetEnv TZ \"${TZ}\"|g" "${NAGIOS_HTTPD_CFG}" 112 | echo " OK" 113 | fi 114 | 115 | } 116 | 117 | shutdown() { 118 | echo Shutting Down 119 | ls /etc/service | SHELL=/bin/sh parallel --no-notice sv force-stop {} 120 | if [ -e "/proc/${RUNSVDIR}" ]; then 121 | kill -HUP "${RUNSVDIR}" 122 | wait "${RUNSVDIR}" 123 | fi 124 | 125 | # give stuff a bit of time to finish 126 | sleep 1 127 | 128 | ORPHANS=$(ps -eo pid= | tr -d ' ' | grep -Fxv 1) 129 | SHELL=/bin/bash parallel --no-notice 'timeout 5 /bin/bash -c "kill {} && wait {}" || kill -9 {}' ::: "${ORPHANS}" 2> /dev/null 130 | exit 131 | } 132 | 133 | ### =========== ### 134 | ### MAIN METHOD ### 135 | ### =========== ### 136 | 137 | # If it is the first container startup / initialization, 138 | # execute any custom user scripts 139 | if [ ! -f "${NAGIOS_HOME}/container_first_run" ]; then 140 | run_custom_scripts /container-entrypoint-init-scripts 141 | 142 | # After scripts complete, create ${NAGIOS_HOME}/container_first_run 143 | # file to mark the end of first startup 144 | touch "${NAGIOS_HOME}/container_first_run" 145 | fi 146 | 147 | # If the $NAGIOS_HOME/etc directory is empty, copy example configuration 148 | if [ -z "$(ls -A ${NAGIOS_HOME}/etc)" ]; then 149 | echo "Started with empty ETC, copying example data in-place" 150 | cp -Rp /orig/etc/* ${NAGIOS_HOME}/etc/ 151 | fi 152 | 153 | # If the $NAGIOS_HOME/var directory is empty, copy example data 154 | if [ -z "$(ls -A ${NAGIOS_HOME}/var)" ]; then 155 | echo "Started with empty VAR, copying example data in-place" 156 | cp -Rp /orig/var/* ${NAGIOS_HOME}/var/ 157 | fi 158 | 159 | # If the htpasswd.users file does not exist, create a new one and place NAGIOSADMINUSER as 160 | # its first user 161 | if [ ! -f "${NAGIOS_HOME}/etc/htpasswd.users" ] ; then 162 | htpasswd -c -b -s "${NAGIOS_HOME}/etc/htpasswd.users" "${NAGIOSADMIN_USER}" "${NAGIOSADMIN_PASS}" 163 | chown -R ${NAGIOS_USER}:${NAGIOS_GROUP} "${NAGIOS_HOME}/etc/htpasswd.users" 164 | fi 165 | 166 | # Set current $NAGIOSADMIN_USER to the configuration of $NAGIOS_HOME/etc/cgi.cfg 167 | if [ "${NAGIOSADMIN_USER}" != "nagiosadmin" ]; then 168 | echo "Modifying ${NAGIOS_HOME}/etc/cgi.cfg in order to use ${NAGIOSADMIN_USER} as its authorised user" 169 | sed -i "s|\(authorized_for_system_information=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg 170 | sed -i "s|\(authorized_for_configuration_information=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg 171 | sed -i "s|\(authorized_for_system_commands=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg 172 | sed -i "s|\(authorized_for_all_services=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg 173 | sed -i "s|\(authorized_for_all_hosts=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg 174 | sed -i "s|\(authorized_for_all_service_commands=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg 175 | sed -i "s|\(authorized_for_all_host_commands=\).*|\1${NAGIOSADMIN_USER}|g" /opt/nagios/etc/cgi.cfg 176 | fi 177 | 178 | # Remove pid files 179 | echo -n "Removing Apache HTTPD PID file before starting it ..." 180 | (rm -f /var/run/apache2/httpd.pid || true) 181 | echo "OK" 182 | 183 | echo -n "Removing rsyslogd PID file before starting it ..." 184 | (rm -f /var/run/rsyslogd.pid || true) 185 | echo "OK" 186 | 187 | # Set timezones before start 188 | setTimezone 189 | 190 | exec runsvdir -P /etc/service & 191 | RUNSVDIR=$! 192 | echo "Started runsvdir, PID is ${RUNSVDIR}" 193 | 194 | trap shutdown SIGTERM SIGHUP SIGINT 195 | wait "${RUNSVDIR}" 196 | 197 | shutdown 198 | 199 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker Nagios 2 | 3 | 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. 4 | 5 | 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. 6 | 7 | Build Status: 8 | [![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) 9 | 10 | * **Available architectures**: `x86`, `amd64`, `arm/v6`, `arm/v7`, `arm64` 11 | * **Where to file issues**: https://github.com/manios/docker-nagios/issues 12 | 13 | ## Supported tags and respective `Dockerfile` links 14 | 15 | * `4.5.10`, `4.5`, `latest` [(4.5.10/Dockerfile)](https://github.com/manios/docker-nagios/blob/master/Dockerfile) 16 | 17 | For more information about the image versions you may refer to the [CHANGELOG](https://github.com/manios/docker-nagios/blob/master/CHANGELOG.md) 18 | 19 | ## Container registries 20 | 21 | 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: 22 | 23 | 1. Dockerhub: `docker pull manios/nagios:latest` 24 | 1. Github Container Registry: `docker pull ghcr.io/manios/nagios:latest` 25 | 26 | ## Running 27 | 28 | Run with the example configuration with the following: 29 | 30 | ```sh 31 | docker run --name nagios -p 0.0.0.0:8080:80 manios/nagios:latest 32 | ``` 33 | 34 | alternatively you can use external Nagios configuration & log data with the following: 35 | 36 | ```sh 37 | docker run --name nagios \ 38 | -v /path-to-nagios/etc/:/opt/nagios/etc/ \ 39 | -v /path-to-nagios/var:/opt/nagios/var/ \ 40 | -v /path-to-nagios/ssmtp.conf:/etc/ssmtp/ssmtp.conf \ 41 | -v /path-to-custom-plugins:/opt/Custom-Nagios-Plugins \ 42 | -p 0.0.0.0:8080:80 \ 43 | manios/nagios:latest 44 | ``` 45 | 46 | Notes: 47 | 48 | 1. The container populates with default configuration files if the configuration directories are empty. 49 | 1. The path for the custom plugins will be /opt/Custom-Nagios-Plugins, you will need to reference this directory in your configuration scripts. 50 | 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). 51 | 52 | For best results your Nagios container should have access to both IPv4 & IPv6 networks. 53 | 54 | ### Credentials 55 | 56 | The default credentials for the web interface is `nagiosadmin` / `nagios`. However you can define your own credentials by overriding `NAGIOSADMIN_USER` and `NAGIOSADMIN_PASS` when you run the container. For example: 57 | 58 | ```sh 59 | docker run --name nagios \ 60 | -e NAGIOSADMIN_USER="godmode" \ 61 | -e NAGIOSADMIN_PASS="super-Duper-Secret!" \ 62 | -p 0.0.0.0:8080:80 \ 63 | manios/nagios:latest 64 | ``` 65 | 66 | ### Timezones 67 | 68 | By default the Alpine container and Nagios both use `UTC`. In order to change the timezone we can pass the [tz timezone database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) as an environmental variable in `docker run` such as: 69 | 70 | ```bash 71 | docker run -e "TZ=Europe/Athens" manios/nagios:latest 72 | ``` 73 | 74 | This will configure and use globally `"Europe/Athens"` in both container and Nagios process. 75 | 76 | ### Init scripts 77 | 78 | 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. 79 | 80 | This feature has the following characteristics in detail: 81 | 82 | * You can run one or more init scripts which have to be present in the `/container-entrypoint-init-scripts` container directory. 83 | * The custom init script(s) run to completion at the first container run. 84 | * Nagios process starts after all init scripts complete successfully. 85 | * If any init script throws an error, the container is restarted. 86 | * 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. 87 | * 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: 88 | 1. `0001-install-mongodb.sh` 89 | 1. `0002-install-jq.sh` 90 | 1. `0003-configure-custom-plugins.sh` 91 | 92 | You can also use a volume mount for your init scripts which can survive container deletions: 93 | 94 | ```sh 95 | docker run -d --name nagios \ 96 | -p 8080:80 \ 97 | -v "$(pwd)/customscripts:/container-entrypoint-init-scripts" \ 98 | manios/nagios:latest 99 | ``` 100 | 101 | For a detailed example you can have a look here: https://github.com/manios/docker-nagios/issues/96. 102 | 103 | ## Flavours 104 | 105 | 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: 106 | 107 | |Hardware|Image OS/Arch| 108 | |-|-| 109 | |PC (32bit)|linux/i386| 110 | |PC (64bit)|linux/amd64 111 | |Raspberry Pi 1|linux/arm/v6| 112 | |Raspberry Pi 2|linux/arm/v7| 113 | |Raspberry Pi 3|linux/arm/v7 or linux/arm64| 114 | |Raspberry Pi 4|linux/arm/v7 or linux/arm64| 115 | |Apple Silicon M1|linux/arm64| 116 | 117 | ## Test configuration 118 | 119 | To check if your Nagios configuration is OK, you can run the following while your container is running. We assume that you use `/opt/nagios/etc/nagios.cfg` as your main configuration file. 120 | 121 | ```bash 122 | docker exec -it mynagioscontainer bin/nagios -v etc/nagios.cfg 123 | ``` 124 | 125 | ## Custom plugins 126 | 127 | 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. 128 | 129 | ## Troubleshooting 130 | 131 | ### Nagios keeps restarting or shows a strange behaviour 132 | 133 | In docker tag `build-5`, `build-6`, `build-7` we have used Alpine 3.14 as our base image. This comes with security updates which may cause trouble as described in [Release Notes forAlpine 3.14.0 > faccessat2](https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.14.0#faccessat2). 134 | 135 | In order to resolve this issue you should use docker tag `build-8` or you can follow the workarounds provided here: [#32 (comment)](https://github.com/manios/docker-nagios/issues/32#issuecomment-940355201). 136 | 137 | ### My image does not run on Raspberry Pi 138 | 139 | As already mentioned in [#17](https://github.com/manios/docker-nagios/issues/17), sometimes, because docker manifest related features are still experimental (after 2+ years of their introduction) it has happened when we tested in Raspberry Pi 1 (`arm-v6`) and Raspberry Pi 3 (`arm-v7`) that it does not download the `arm` image but the `amd64`. 140 | 141 | Thus you can define explicitly which architecture to pull: 142 | 143 | ```bash 144 | docker pull --platform=linux/arm/v6 manios/nagios 145 | # or 146 | docker pull --platform=linux/arm/v7 manios/nagios 147 | ``` 148 | 149 | and it works. Be advised that the `--platform` switch requires that you enable the [Docker Experimental Features](https://github.com/docker/cli/blob/master/experimental/README.md). 150 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # Changelog 3 | 4 | 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 - ` which will have an incremental unsigned integer. In this document we will describe the contents of every image in every build. 5 | 6 | ## Build 32 (2025-12-04) 7 | 8 | * Nagios core: v4.5.10 9 | * Nagios plugins: v2.4.12 10 | * NRPE: 4.1.3 11 | * Alpine: 12 | * 3.23.0: `amd64`, `i386`, `arm64`,`arm/v6`, `arm/v7` 13 | 14 | ### Features 15 | 16 | * 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)) 17 | 18 | ## Build 31 (2025-12-01) 19 | 20 | * Nagios core: v4.5.10 21 | * Nagios plugins: v2.4.12 22 | * NRPE: 4.1.3 23 | * Alpine: 24 | * 3.22.2: `amd64`, `i386`, `arm64` 25 | * 3.12.12: `arm/v6`, `arm/v7` 26 | 27 | ### Features 28 | 29 | * Upgrade to Nagios Core `4.5.10`. ([#95](https://github.com/manios/docker-nagios/issues/95)) 30 | * Add init script functionality. ([#96](https://github.com/manios/docker-nagios/issues/96)) 31 | * 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)) 32 | 33 | ### Bug Fixes 34 | 35 | * Modify `etc/resource.cfg` in order to include custom plugins directory. 36 | 37 | ## Build 30 (2025-04-10) 38 | 39 | * Nagios core: v4.5.9 40 | * Nagios plugins: v2.4.12 41 | * NRPE: 4.1.3 42 | * Alpine: 43 | * 3.21.3: `amd64`, `i386`, `arm64` 44 | * 3.12.12: `arm/v6`, `arm/v7` 45 | 46 | ### Features 47 | 48 | * 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)) 49 | 50 | ## Build 29 (2025-02-23) 51 | 52 | * Nagios core: v4.5.9 53 | * Nagios plugins: v2.4.12 54 | * NRPE: 4.1.3 55 | * Alpine: 56 | * 3.12.12: `amd64`, `i386`, `arm64`, `arm/v6`, `arm/v7` 57 | 58 | ### Bug Fixes 59 | 60 | * 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)) 61 | 62 | ## Build 28 (2025-02-22) 63 | 64 | * Nagios core: v4.5.9 65 | * Nagios plugins: v2.4.12 66 | * NRPE: 4.1.3 67 | * Alpine: 68 | * 3.12.12: `amd64`, `i386`, `arm64`, `arm/v6`, `arm/v7` 69 | 70 | ### Features 71 | 72 | * Upgrade NRPE to `4.1.3` and gosu to `v1.13`. ([#90](https://github.com/manios/docker-nagios/issues/90)) 73 | 74 | ## Build 27 (2024-12-29) 75 | 76 | * Nagios core: v4.5.9 77 | * Nagios plugins: v2.4.12 78 | * NRPE: 4.1.1 79 | * Alpine: 80 | * 3.12.12: `amd64`, `i386`, `arm64`, `arm/v6`, `arm/v7` 81 | 82 | ### Features 83 | 84 | * Upgrade to Nagios Core `4.5.9`. ([#88](https://github.com/manios/docker-nagios/issues/88)) 85 | 86 | ## Build 26 (2024-11-22) 87 | 88 | * Nagios core: v4.5.8 89 | * Nagios plugins: v2.4.12 90 | * NRPE: 4.1.1 91 | * Alpine: 92 | * 3.12.12: `amd64`, `i386`, `arm64`, `arm/v6`, `arm/v7` 93 | 94 | ### Features 95 | 96 | * Upgrade to Nagios Core `4.5.8`. ([#87](https://github.com/manios/docker-nagios/issues/87)) 97 | 98 | ## Build 25 (2024-10-27) 99 | 100 | * Nagios core: v4.5.7 101 | * Nagios plugins: v2.4.12 102 | * NRPE: 4.1.1 103 | 104 | ### Features 105 | 106 | * Upgrade to Nagios Core `4.5.7`. ([#86](https://github.com/manios/docker-nagios/issues/86)) 107 | 108 | ## Build 24 (2024-10-11) 109 | 110 | * Nagios core: v4.5.6 111 | * Nagios plugins: v2.4.12 112 | * NRPE: 4.1.1 113 | 114 | ### Features 115 | 116 | * Upgrade to Nagios Core `4.5.6`. ([#84](https://github.com/manios/docker-nagios/issues/84)) 117 | 118 | ## Build 23 (2024-09-29) 119 | 120 | * Nagios core: v4.5.5 121 | * Nagios plugins: v2.4.12 122 | * NRPE: 4.1.1 123 | 124 | ### Features 125 | 126 | * Upgrade to Nagios Core `4.5.5`. ([#81](https://github.com/manios/docker-nagios/issues/81)) 127 | * Push container images to Github Container Registry ([#83](https://github.com/manios/docker-nagios/issues/83)) 128 | * Re-enable Docker image caching using Cache action ([#82](https://github.com/manios/docker-nagios/issues/82)) 129 | 130 | ## Build 22 (2024-08-30) 131 | 132 | * Nagios core: v4.5.4 133 | * Nagios plugins: v2.4.12 134 | * NRPE: 4.1.1 135 | 136 | ### Features 137 | 138 | * Upgrade to Nagios Plugins to `2.4.12`. ([#79](https://github.com/manios/docker-nagios/issues/79)) 139 | 140 | ### Bug Fixes 141 | 142 | * 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)! 143 | 144 | ## Build 21 (2024-08-15) 145 | 146 | * Nagios core: v4.5.4 147 | * Nagios plugins: v2.4.11 148 | * NRPE: 4.1.1 149 | 150 | ### Features 151 | 152 | * 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)) 153 | 154 | ## Build 20 (2024-07-30) 155 | 156 | * Nagios core: v4.5.3 157 | * Nagios plugins: v2.4.10 158 | * NRPE: 4.1.0 159 | 160 | ### Features 161 | 162 | * Upgrade to Nagios Core to `4.5.3`. ([#73](https://github.com/manios/docker-nagios/issues/73)) 163 | 164 | 165 | ## Build 19 (2024-05-07) 166 | 167 | * Nagios core: v4.5.2 168 | * Nagios plugins: v2.4.10 169 | * NRPE: 4.1.0 170 | 171 | ### Features 172 | 173 | * Upgrade to Nagios Core to `4.5.2`, Nagios plugins to `2.4.19`. ([#69](https://github.com/manios/docker-nagios/issues/69)) 174 | 175 | ## Build 18 (2024-03-10) 176 | 177 | * Nagios core: v4.5.1 178 | * Nagios plugins: v2.4.8 179 | * NRPE: 4.1.0 180 | 181 | ### Features 182 | 183 | * Upgrade to Nagios Core to `4.5.1`, Nagios plugins to `2.4.8`. ([#68](https://github.com/manios/docker-nagios/issues/68)) 184 | 185 | ## Build 17 (2023-11-20) 186 | 187 | * Nagios core: v4.5.0 188 | * Nagios plugins: v2.4.7 189 | * NRPE: 4.1.0 190 | 191 | ### Features 192 | 193 | * Upgrade to Nagios Core to `4.5.0`, Nagios plugins to `2.4.7`. ([#66](https://github.com/manios/docker-nagios/issues/66)) 194 | * Avoid busybox wget `too many redirect` issue. ([#65](https://github.com/manios/docker-nagios/pull/65)) 195 | 196 | ## Build 16 (2023-08-09) 197 | 198 | * Nagios core: v4.4.14 199 | * Nagios plugins: v2.4.6 200 | * NRPE: 4.1.0 201 | 202 | ## Build 15 (2023-06-12) 203 | 204 | * Nagios core: v4.4.13 205 | * Nagios plugins: v2.4.5 206 | * NRPE: 4.1.0 207 | 208 | ### Features 209 | 210 | * Upgrade to Nagios Core to `4.4.13`, Nagios plugins to `2.4.5`. ([#61](https://github.com/manios/docker-nagios/issues/61)) 211 | 212 | ## Build 14 (2023-06-01) 213 | 214 | * Nagios core: v4.4.12 215 | * Nagios plugins: v2.4.4 216 | * NRPE: 4.1.0 217 | 218 | ### Features 219 | 220 | * Upgrade to Nagios Core to `4.4.12`. ([#60](https://github.com/manios/docker-nagios/issues/60)) 221 | 222 | ## Build 13 (2023-05-10) 223 | 224 | * Nagios core: v4.4.11 225 | * Nagios plugins: v2.4.4 226 | * NRPE: 4.1.0 227 | 228 | ### Features 229 | 230 | * Upgrade to Nagios Core to `4.4.11`, Nagios plugins to `2.4.4`. ([#58](https://github.com/manios/docker-nagios/issues/58)) 231 | 232 | ## Build 12 (2023-03-03) 233 | 234 | * Nagios core: v4.4.10 235 | * Nagios plugins: v2.4.3 236 | * NRPE: 4.1.0 237 | 238 | ### Features 239 | 240 | * Upgrade to Nagios Core to `4.4.10`, Nagios plugins to `2.4.3`. ([#53](https://github.com/manios/docker-nagios/issues/53)) 241 | 242 | ## Build 11 (2022-12-12) 243 | 244 | * Nagios core: v4.4.9 245 | * Nagios plugins: v2.4.2 246 | * NRPE: 4.1.0 247 | 248 | ### Features 249 | 250 | * Upgrade to Nagios Core to `4.4.9`. 251 | 252 | ## Build 10 (2022-11-17) 253 | 254 | * Nagios core: v4.4.8 255 | * Nagios plugins: v2.4.2 256 | * NRPE: 4.1.0 257 | 258 | ### Features 259 | 260 | * Upgrade to Nagios Core to `4.4.8`, Nagios plugins to `2.4.2` and NRPE to `4.1.0`. ([#49](https://github.com/manios/docker-nagios/issues/42), [#50](https://github.com/manios/docker-nagios/issues/50), [#51](https://github.com/manios/docker-nagios/issues/51)) 261 | * Enable again automatic update checks as they are fixed in Nagios 4.4.8. ([nagioscore/#861](https://github.com/NagiosEnterprises/nagioscore/issues/861)) 262 | * Updating adduser options to include username. ([#44](https://github.com/manios/docker-nagios/pull/44)) 263 | 264 | ## Build 9 (2022-05-08) 265 | 266 | * Nagios core: v4.4.7 267 | * Nagios plugins: v2.4.0 268 | * NRPE: 4.0.3 269 | 270 | ### Bug Fixes 271 | 272 | * Add missing dependencies to build legacy map cgi. ([#36](https://github.com/manios/docker-nagios/issues/36)) 273 | * Add missing `bind-tools` package. ([#37](https://github.com/manios/docker-nagios/issues/37)) 274 | 275 | ### Features 276 | 277 | * Upgrade to Nagios Core to `4.4.7` and Nagios plugins to `2.4.0`. ([#42](https://github.com/manios/docker-nagios/issues/42)) 278 | * Add mail client symbolic links to [sSMTP](https://wiki.debian.org/sSMTP). ([#39](https://github.com/manios/docker-nagios/issues/39)) 279 | 280 | ## Build 8 (2021-10-21) 281 | 282 | * Nagios core: v4.4.6 283 | * Nagios plugins: v2.3.3 284 | * NRPE: 4.0.3 285 | 286 | ### Bug Fixes 287 | 288 | * Rollback to Alpine 3.12 as base image as Alpine 3.14 causes multiple issues in ARM devices. ([#32](https://github.com/manios/docker-nagios/issues/32), [#35](https://github.com/manios/docker-nagios/issues/35)) 289 | 290 | ## Build 7 (2021-08-24) 291 | 292 | * Nagios core: v4.4.6 293 | * Nagios plugins: v2.3.3 294 | * NRPE: 4.0.3 295 | 296 | ### Bug Fixes 297 | 298 | * Fix HTTP 500 Internal Server Error due to getcgi.c bug. ([#34](https://github.com/manios/docker-nagios/issues/34)) 299 | 300 | ## Build 6 (2021-08-20) 301 | 302 | * Nagios core: v4.4.6 303 | * Nagios plugins: v2.3.3 304 | * NRPE: 4.0.3 305 | 306 | ### Bug Fixes 307 | 308 | * Fix `check_mysql_query` plugin segmentation fault error. ([#33](https://github.com/manios/docker-nagios/issues/33)) 309 | 310 | ## Build 5 (2021-08-14) 311 | 312 | * Nagios core: v4.4.6 313 | * Nagios plugins: v2.3.3 314 | * NRPE: 4.0.3 315 | 316 | ### Bug Fixes 317 | 318 | * Add missing `net-snmp-tools` package. ([#31](https://github.com/manios/docker-nagios/issues/31)) 319 | * Add missing missing `gosu` for `amd64` architecture. ([#30](https://github.com/manios/docker-nagios/issues/30)) 320 | * Add missing `openssl` package. ([#28](https://github.com/manios/docker-nagios/issues/28)) 321 | * Add missing `openssh` package. ([#27](https://github.com/manios/docker-nagios/issues/27)) 322 | 323 | ### Features 324 | 325 | * Update to `alpine:3.14` as base image. 326 | * Build and tag the docker image automatically according to git branch and tag information. 327 | 328 | ## Build 4 (2021-04-20) 329 | 330 | * Nagios core: v4.4.6 331 | * Nagios plugins: v2.3.3 332 | * NRPE: 4.0.3 333 | 334 | ### Bug Fixes 335 | 336 | * Use `alpine:3.11` as base image as musl libc 1.2.2-r0 causes multiple issues. ([#3](https://github.com/manios/docker-nagios/issues/3) ,[#24](https://github.com/manios/docker-nagios/issues/24)) 337 | 338 | ### Features 339 | 340 | * Add a new build flavour for `arm64`. ([#25](https://github.com/manios/docker-nagios/issues/25)) 341 | 342 | ## Build 3 (2021-04-08) 343 | 344 | * Nagios core: v4.4.6 345 | * Nagios plugins: v2.3.3 346 | * NRPE: 4.0.3 347 | 348 | ### Bug Fixes 349 | 350 | * Fix `ldap`,`snmp`,`check_pgsql`,`dbi`,`radius`,`mysql` plugins build failing. Compilation was failing due to unmet dependencies. ([#3](https://github.com/manios/docker-nagios/issues/3) ,[#22](https://github.com/manios/docker-nagios/issues/22)) 351 | 352 | ## Build 2 (2020-12-24) 353 | 354 | * Nagios core: v4.4.6 355 | * Nagios plugins: v2.3.3 356 | * NRPE: 4.0.3 357 | 358 | ### Bug Fixes 359 | 360 | * Fix rsyslog runsv loop ([#8](https://github.com/manios/docker-nagios/issues/8)) 361 | * Fix httpd runsv loop ([#13](https://github.com/manios/docker-nagios/issues/13), [#17](https://github.com/manios/docker-nagios/issues/17), [#18](https://github.com/manios/docker-nagios/issues/18)) 362 | * Fix check_ping version 2.2.1 Plugin Timeout ([#12](https://github.com/manios/docker-nagios/issues/12)) 363 | 364 | ### Features 365 | 366 | * Add the ability to override default timezone inside the container and Nagios ([#11](https://github.com/manios/docker-nagios/issues/11)) 367 | * Build the Docker images using Github Actions ([#19](https://github.com/manios/docker-nagios/issues/19)) 368 | 369 | ## Build 1 (2020-11-24) 370 | 371 | * Nagios core: v4.4.5 372 | * Nagios plugins: v2.2.1 373 | * NRPE: 4.0.0 374 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ### ================================== ### 2 | ### STAGE 1 CREATE PARENT IMAGE ### 3 | ### ================================== ### 4 | 5 | # https://www.docker.com/blog/docker-arm-virtual-meetup-multi-arch-with-buildx/ 6 | 7 | FROM alpine:3.23 AS builder-base 8 | 9 | ARG TARGETPLATFORM 10 | ARG BUILDPLATFORM 11 | 12 | ENV NAGIOS_HOME=/opt/nagios \ 13 | NAGIOS_USER=nagios \ 14 | NAGIOS_GROUP=nagios \ 15 | NAGIOS_CMDUSER=nagios \ 16 | NAGIOS_CMDGROUP=nagios \ 17 | NAGIOS_TIMEZONE=UTC \ 18 | NAGIOS_FQDN=nagios.example.com \ 19 | NAGIOSADMIN_USER=nagiosadmin \ 20 | NAGIOSADMIN_PASS=nagios \ 21 | NAGIOS_VERSION=4.5.10 \ 22 | NAGIOS_PLUGINS_VERSION=2.4.12 \ 23 | NRPE_VERSION=4.1.3 \ 24 | APACHE_LOCK_DIR=/var/run \ 25 | APACHE_LOG_DIR=/var/log/apache2 26 | 27 | 28 | RUN addgroup -S ${NAGIOS_GROUP} && \ 29 | adduser -S ${NAGIOS_USER} -G ${NAGIOS_CMDGROUP} -g ${NAGIOS_USER} && \ 30 | apk update && \ 31 | apk add --no-cache git curl unzip apache2 apache2-utils rsyslog \ 32 | php83 php83-gd php83-cli runit parallel ssmtp \ 33 | libltdl libintl openssl-dev php83-apache2 procps tzdata \ 34 | libldap mariadb-connector-c freeradius-client-dev libpq libdbi \ 35 | lm-sensors perl net-snmp-perl perl-net-snmp perl-crypt-x509 \ 36 | perl-timedate perl-libwww perl-text-glob samba-client openssh openssl \ 37 | net-snmp-tools bind-tools gd gd-dev bash && \ 38 | addgroup -S apache ${NAGIOS_CMDGROUP} 39 | 40 | 41 | ### ================================== ### 42 | ### STAGE 2 COMPILE NAGIOS SOURCES ### 43 | ### ================================== ### 44 | 45 | FROM builder-base AS builder-compile 46 | ARG TARGETPLATFORM 47 | ARG BUILDPLATFORM 48 | 49 | # Add dependencies required to build Nagios 50 | RUN apk update && \ 51 | apk add --no-cache build-base automake libtool autoconf py-docutils gnutls \ 52 | gnutls-dev g++ make alpine-sdk build-base gcc autoconf \ 53 | gettext-dev linux-headers openssl-dev net-snmp net-snmp-tools \ 54 | libcrypto3 libpq musl libldap libssl3 libdbi freeradius-client mariadb-connector-c \ 55 | openssh-client bind-tools samba-client fping grep rpcbind \ 56 | lm-sensors net-snmp-tools \ 57 | file freeradius-client-dev libdbi-dev libpq linux-headers mariadb-dev \ 58 | mariadb-connector-c-dev perl \ 59 | net-snmp-dev openldap-dev openssl-dev postgresql-dev wget 60 | 61 | # Download Nagios core, plugins and nrpe sources 62 | RUN cd /tmp && \ 63 | echo -n "Downloading Nagios ${NAGIOS_VERSION} source code: " && \ 64 | wget -O nagios-core.tar.gz "https://github.com/NagiosEnterprises/nagioscore/archive/refs/tags/nagios-${NAGIOS_VERSION}.tar.gz" && \ 65 | echo -n -e "OK\nDownloading Nagios plugins ${NAGIOS_PLUGINS_VERSION} source code: " && \ 66 | wget -O nagios-plugins.tar.gz "https://github.com/nagios-plugins/nagios-plugins/archive/refs/tags/release-${NAGIOS_PLUGINS_VERSION}.tar.gz" && \ 67 | echo -n -e "OK\nDownloading NRPE ${NRPE_VERSION} source code: " && \ 68 | wget -O nrpe.tar.gz "https://github.com/NagiosEnterprises/nrpe/archive/refs/tags/nrpe-${NRPE_VERSION}.tar.gz" && \ 69 | env && \ 70 | echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM !! == " && \ 71 | echo "OK" 72 | 73 | # Compile Nagios Core 74 | RUN ls -l /tmp && cd /tmp && \ 75 | tar zxf nagios-core.tar.gz && \ 76 | tar zxf nagios-plugins.tar.gz && \ 77 | tar zxf nrpe.tar.gz && \ 78 | cd "/tmp/nagioscore-nagios-${NAGIOS_VERSION}" && \ 79 | echo -e "\n ===========================\n Configure Nagios Core\n ===========================\n" && \ 80 | ./configure \ 81 | --prefix=${NAGIOS_HOME} \ 82 | --exec-prefix=${NAGIOS_HOME} \ 83 | --enable-event-broker \ 84 | --with-command-user=${NAGIOS_CMDUSER} \ 85 | --with-command-group=${NAGIOS_CMDGROUP} \ 86 | --with-nagios-user=${NAGIOS_USER} \ 87 | --with-nagios-group=${NAGIOS_GROUP} && \ 88 | : 'Apply patches to Nagios Core sources:' && \ 89 | echo -n "Replacing \"\" with \"\": " && \ 90 | sed -i 's///g' ./include/config.h && \ 91 | echo "OK" && \ 92 | echo -e "\n\n ===========================\n Compile Nagios Core\n ===========================\n" && \ 93 | make all && \ 94 | echo -e "\n\n ===========================\n Install Nagios Core\n ===========================\n" && \ 95 | make install && \ 96 | make install-commandmode && \ 97 | make install-config && \ 98 | make install-webconf && \ 99 | echo -n "Nagios installed size: " && \ 100 | du -h -s ${NAGIOS_HOME} 101 | 102 | # Compile Nagios Plugins 103 | RUN echo -e "\n\n ===========================\n Configure Nagios Plugins\n ===========================\n" && \ 104 | ls -lia /tmp && cd /tmp && \ 105 | cd /tmp/nagios-plugins-release-${NAGIOS_PLUGINS_VERSION} && \ 106 | ./autogen.sh && \ 107 | ./configure --with-nagios-user=${NAGIOS_USER} \ 108 | --with-nagios-group=${NAGIOS_USER} \ 109 | --with-openssl \ 110 | --prefix=${NAGIOS_HOME} \ 111 | --with-ping-command="/bin/ping -n -w %d -c %d %s" \ 112 | --with-ipv6 \ 113 | --with-ping6-command="/bin/ping6 -n -w %d -c %d %s" && \ 114 | echo "Nagios plugins configured: OK" && \ 115 | echo -n "Replacing \"\" with \"\": " && \ 116 | egrep -rl "\" . | xargs sed -i 's///g' && \ 117 | egrep -rl "\"sys\/poll.h\"" . | xargs sed -i 's/"sys\/poll.h"/"poll.h"/g' && \ 118 | echo "OK" && \ 119 | echo -e "\n\n ===========================\n Compile Nagios Plugins\n ===========================\n" && \ 120 | make && \ 121 | echo "Nagios plugins compile successfully: OK" && \ 122 | echo -e "\n\n ===========================\nInstall Nagios Plugins\n ===========================\n" && \ 123 | make install && \ 124 | echo "Nagios plugins installed successfully: OK" 125 | 126 | # Compile NRPE 127 | RUN echo -e "\n\n =====================\n Configure NRPE\n =====================\n" && \ 128 | cd /tmp/nrpe-nrpe-${NRPE_VERSION} && \ 129 | ./configure --enable-command-args \ 130 | --with-nagios-user=${NAGIOS_USER} \ 131 | --with-nagios-group=${NAGIOS_USER} \ 132 | --with-ssl=/usr/bin/openssl \ 133 | --with-ssl-lib=/usr/lib && \ 134 | echo "NRPE client configured: OK" && \ 135 | echo -e "\n\n ===========================\n Compile NRPE\n ===========================\n" && \ 136 | # make all && \ 137 | make check_nrpe && \ 138 | echo "NRPE compiled successfully: OK" && \ 139 | echo -e "\n\n ===========================\n Install NRPE\n ===========================\n" && \ 140 | # make install && \ 141 | cp src/check_nrpe ${NAGIOS_HOME}/libexec/ && \ 142 | echo "NRPE installed successfully: OK" && \ 143 | echo -n "Final Nagios installed size: " && \ 144 | du -h -s ${NAGIOS_HOME} 145 | 146 | # Compile Nagios files 147 | # Create SSMTP configuration 148 | 149 | 150 | # RUN sed -i.bak 's/.*\=www\-data//g' /etc/apache2/envvars 151 | RUN export DOC_ROOT="DocumentRoot $(echo $NAGIOS_HOME/share)" && \ 152 | sed -i "s,DocumentRoot.*,$DOC_ROOT," /etc/apache2/httpd.conf && \ 153 | sed -i "s|^ *ScriptAlias.*$|ScriptAlias /cgi-bin $NAGIOS_HOME/sbin|g" /etc/apache2/httpd.conf && \ 154 | sed -i 's/^\(.*\)#\(LoadModule cgi_module\)\(.*\)/\1\2\3/' /etc/apache2/httpd.conf && \ 155 | echo "ServerName ${NAGIOS_FQDN}" >> /etc/apache2/httpd.conf 156 | 157 | RUN sed -i 's,/bin/mail,/usr/bin/mail,' ${NAGIOS_HOME}/etc/objects/commands.cfg && \ 158 | sed -i 's,/usr/usr,/usr,' ${NAGIOS_HOME}/etc/objects/commands.cfg && \ 159 | \ 160 | : '# Modify Nagios mail commands in order to work with SSMTP' && \ 161 | sed -i 's/^.*command_line.*Host Alert.*$//g' /opt/nagios/etc/objects/commands.cfg && \ 162 | sed -i 's/^.*command_line.*Service Alert.*$//g' /opt/nagios/etc/objects/commands.cfg && \ 163 | 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 && \ 164 | 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 && \ 165 | \ 166 | : '# Modify etc/resource.cfg in order to include custom plugins directory' && \ 167 | sed -i 's/^\(.*\)\(Sets .USER2. to be the path to\) event handlers.*$/\1\2 custom plugins directory/g' "${NAGIOS_HOME}"/etc/resource.cfg && \ 168 | sed -i 's;^#\([$]USER2[$]=\).*$;\1/opt/Custom-Nagios-Plugins;g' "${NAGIOS_HOME}"/etc/resource.cfg 169 | 170 | RUN echo "use_timezone=${NAGIOS_TIMEZONE}" >> ${NAGIOS_HOME}/etc/nagios.cfg && \ 171 | sed -i 's/date_format=us/date_format=iso8601/g' ${NAGIOS_HOME}/etc/nagios.cfg 172 | 173 | # Copy original configuration to /orig directory 174 | RUN mkdir -p /orig/apache2 && \ 175 | cp -r /etc/apache2/* /orig/apache2 && \ 176 | cp -r ${NAGIOS_HOME}/etc /orig/etc && \ 177 | cp -r ${NAGIOS_HOME}/var /orig/var 178 | 179 | 180 | ### ========================== ### 181 | ### START OF ACTUAL DOCKERFILE ### 182 | ### ========================== ### 183 | 184 | FROM builder-base 185 | 186 | 187 | LABEL name="Nagios" \ 188 | nagiosVersion=$NAGIOS_VERSION \ 189 | nagiosPluginsVersion=$NAGIOS_PLUGINS_VERSION \ 190 | nrpeVersion=$NRPE_VERSION \ 191 | homepage="https://www.nagios.com/" \ 192 | maintainer="Christos Manios " \ 193 | build="32" \ 194 | org.opencontainers.image.title="Nagios" \ 195 | org.opencontainers.image.description="Nagios, the Industry Standard In IT Infrastructure Monitoring" \ 196 | org.opencontainers.image.vendor="Nagios" \ 197 | org.opencontainers.image.authors="Christos Manios " \ 198 | org.opencontainers.image.licenses="MIT" \ 199 | org.opencontainers.image.url="https://hub.docker.com/r/manios/nagios" \ 200 | org.opencontainers.image.source="https://github.com/manios/docker-nagios" \ 201 | org.opencontainers.image.documentation="https://github.com/manios/docker-nagios/blob/master/README.md" \ 202 | org.opencontainers.image.version="32" 203 | 204 | RUN mkdir -p ${NAGIOS_HOME} && \ 205 | mkdir -p /orig/apache2 206 | 207 | WORKDIR ${NAGIOS_HOME} 208 | COPY --from=builder-compile ${NAGIOS_HOME} ${NAGIOS_HOME} 209 | 210 | COPY --from=builder-compile /orig /orig 211 | 212 | ADD overlay/ / 213 | 214 | # Make 215 | RUN chmod +x /usr/local/bin/start_nagios \ 216 | /etc/sv/apache/run \ 217 | /etc/sv/nagios/run \ 218 | /etc/sv/rsyslog/run && \ 219 | rm -rf /etc/sv/getty-5 && \ 220 | \ 221 | : '# enable all runit services' && \ 222 | ln -s /etc/sv/* /etc/service && \ 223 | \ 224 | : '# Copy initial settings files' && \ 225 | chown -R nagios:nagios ${NAGIOS_HOME} && \ 226 | : '# Create special dirs' && \ 227 | (mkdir /run/apache2 || true) && \ 228 | mkdir -p /var/spool/rsyslog && \ 229 | : '# Copy Apache configuration' && \ 230 | cp -Rp /orig/apache2/* /etc/apache2 && \ 231 | : '# Convert files to Unix format' && \ 232 | dos2unix /etc/rsyslog.conf && \ 233 | dos2unix /usr/local/bin/start_nagios && \ 234 | dos2unix /etc/sv/**/run && \ 235 | dos2unix /etc/ssmtp/ssmtp.conf && \ 236 | : '# Add mail symbolic links to ssmtp' && \ 237 | ln -s $(which ssmtp) /bin/mail && \ 238 | ln -s $(which ssmtp) /usr/sbin/mail 239 | 240 | 241 | EXPOSE 80 242 | 243 | VOLUME "${NAGIOS_HOME}/var" "${NAGIOS_HOME}/etc" "/var/log/apache2" "/opt/Custom-Nagios-Plugins" 244 | 245 | CMD [ "/usr/local/bin/start_nagios" ] 246 | --------------------------------------------------------------------------------