Build and push the image to Docker Hub:
docker build --no-cache -t dhml/nagios:$(git rev-parse --short=12 HEAD) .
docker tag dhml/nagios:$(git rev-parse --short=12 HEAD) dhml/nagios:latest
docker push dhml/nagios:$(git rev-parse --short=12 HEAD)
docker push dhml/nagios:latest
Modify the contents of the conf/
directory accordingly. The contents
here are pared down version of those present by default after installing
the nagios
package in the Rocky Linux 8.4
container.
docker run -it --rm \
-v $(pwd)/conf:/etc/nagios \
dhml/nagios:latest \
/usr/sbin/nagios -v /etc/nagios/nagios.cfg
This is handled by msmtp in the container.
Environment variables MSMTP_HOST
(the
host to relay mail to) and
MSMTP_FROM
(the envelope
from address) may be
optionally set when running the container. If both of these are set,
the system-wide configuration file /etc/msmtprc
will be written
allowing alert e-mail to be relayed. See the msmtp
documentation for details. Note
that SMTP authentication is not yet supported.
https://github.com/isaac-galvan/nagios-teams-notify
Configure a command
such as the following:
define command {
command_name notify_teams
command_line /usr/bin/printf "$LONGSERVICEOUTPUT$" | /usr/local/bin/notify-teams.py "$NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" "$SERVICEOUTPUT$" <teams-channel-webhook-url>
}
Then configure this command in host
, service
or contact
definitions.
export MSMTP_HOST=relay.example.com
export [email protected]
docker run \
-d \
--env MSMTP_HOST \
--env MSMTP_FROM \
--name nagios \
-p 8080:80 \
--rm \
-v $(pwd)/conf:/etc/nagios \
-v $(pwd)/logs/httpd:/var/log/httpd \
-v $(pwd)/logs/php-fpm:/var/log/php-fpm \
-v $(pwd)/logs/nagios:/var/log/nagios \
dhml/nagios:latest
Proceed to: http://localhost:8080/nagios/ . The default username and
password are both nagiosadmin
.
export MSMTP_HOST=relay.example.com
export [email protected]
podman run \
--cap-add=CAP_NET_RAW \
-d \
--env MSMTP_HOST \
--env MSMTP_FROM \
--name nagios \
-p 8080:80 \
--rm \
-v $(pwd)/conf:/etc/nagios \
-v $(pwd)/logs/httpd:/var/log/httpd \
-v $(pwd)/logs/php-fpm:/var/log/php-fpm \
-v $(pwd)/logs/nagios:/var/log/nagios \
docker://dhml/nagios
Proceed to: http://localhost:8080/nagios/ . The default username and
password are both nagiosadmin
.
docker exec -it nagios /usr/bin/supervisorctl status
docker exec -it nagios /usr/bin/supervisorctl restart httpd
docker exec -it nagios /usr/bin/supervisorctl restart php-fpm
docker exec -it nagios /usr/bin/supervisorctl restart nagios