Sign inSign up

instantlinux/nagios

By instantlinux

Updated 17 days ago

Nagios Core monitoring service built under Alpine for multiple platforms

Image
Monitoring & observability
4

9.6K

instantlinux/nagios repository overview

nagios

Nagios Core monitoring service built under Alpine for multiple platforms

Usage

This is Nagios Core 4.x and the primary plugins, served by nginx in an efficient Alpine image. Here in this codebase find an example docker-compose.yml which will launch 3 services: this instantlinux/nagios image, the NagiosQL image and another nginx server which provides SSL termination. To round out the monitoring solution, this setup is compatible with the free easyNag mobile app.

To support plugins that you might want to add as a volume-mount, the image includes bash, the mariadb client, perl, python3, samba client, and sudo.

Steps:

  • Set up NagiosQL as defined in its README, or import your existing Nagios configuration to a mountable volume.
  • Copy the docker-compose.yml from this repo and define any environment-var overrides you might need (as defined below)
  • Set up the nagios-htpasswd secret for basic-auth using the htpasswd command and place it in /var/adm/secrets/nagios-htpasswd
  • Bring up Nagios4 and NagiosQL using docker-compose up

This will generate a nagios.cfg.proto; it will be copied to /etc/nagios/nagios.cfg only the first time the volume is mounted, after which you will have to edit it manually.

If version 4.4.7 won't start due to segfault, see note below for nagios.cfg workaround.

Note: if using NagiosQL for the first time, manual edits of nagios.cfg plus cleaning up distributed files (e.g. printer.cfg, windows.cfg) will most likely be required before nagios configuration check passes.

This will run under docker-compose or kubernetes using the bridge network; if you need to use certain plugins like check_dhcp which require direct host network, use the NGINX_PORT parameter to override the default port 80 to specify port (or ip:port if desired).

This repo has complete instructions for building a kubernetes cluster where you can deploy kubernetes.yaml using make and customizing Makefile.vars after cloning this repo:

git clone https://github.com/instantlinux/docker-tools.git
cd docker-tools/k8s
make nagios

Tips:

  • Nagios v4 requires that each service be attached to at least one host or hostgroups. If you're migrating from an old installation, deactivate any service definitions that are no longer in use
Variables
VariableDefaultDescription
ADMIN_PATH/optPath on localhost (for adding local plugins, etc)
AUTHORIZED_USERSnagiosadminList of users
CONFIG_CHECKyesWhether to halt on startup if config-check fails
HTPASSWD_SECRETNAMEnagios-htpasswdSecret holding basic-auth user/passwords
MAIL_RELAY_HOSTsmtp:25FQDN and port of SMTP relay
MAIL_RELAY_SECRETNAMEnagios-mail-secretName of secret containing mail password
MAIL_RELAY_USERAuth for SMTP relay provider
MAIL_USE_TLSyesWhether to encrypt with TLS and STARTTLS
NAGIOS_MAIL_RELAYsmtpDNS name for nagios email sending
NAGIOS_FQDNnagios.dockerserver_name for nginx
NGINX_PORT80listen port (or ip:port) for nginx
PERF_ENABLEyesWhether to generate performance logs
TZUTClocal timezone
Volumes

Mount these path names to persistent storage:

PathDescription
/etc/nagiosConfiguration, as managed by NagiosQL
/opt/nagios/pluginsAny custom ($USER2$) plugins you want to add
/var/nagiosLogs and status

Some other important path names are:

PathDescription
/usr/lib/nagios/pluginsSystem plugins ($USER1$)

Note for version 4.4.7: there is a bug (issue #861) which causes segfault on startup. Make sure to set check_for_updates=0 in the nagios.cfg file mounted to /etc/nagios.

Secrets
SecretDescription
nagios-htpasswdWeb UI basic-auth passwords
nagios-mail-secretAuth secret for smtp provider
Migrating from jasonrivers/nagios

This is almost-but-not-quite compatible (minus nagiosgraph) with the jasonriver/nagios image previously used by the services here. Here's what you need to know if you want to use this in place of that image:

  • Since this is based on alpine rather than ubuntu, before starting this image look for your nagios.cfg and do these replacements in that and cgi.cfg:
sed -i -e 's:/opt/nagios/etc:/etc/nagios:' \
    -e 's:/opt/nagios/var:/var/nagios:' nagios.cfg
sed -i -e 's:/opt/nagios/etc:/etc/nagios:' cgi.cfg
  • Update value of $USER1$ in resource.cfg:
sed -i -e 's:/opt/nagios/libexec:/usr/lib/nagios/plugins:' resource.cfg
  • Set the environment variable NAGIOS_ETC to the new pathname /etc/nagios in your docker-compose or kubernetes container startup
  • Change volume mounts to /etc/nagios and /var/nagios
Contributing

If you want to make improvements to this image, see CONTRIBUTING.

If you want nagiosgraph or other features added, please submit an issue with suggestions on implementation.

Tag summary

Content type

Image

Digest

sha256:a1eaa1621

Size

85 MB

Last updated

17 days ago

docker pull instantlinux/nagios