Skip to content

Commit

Permalink
Added Check-MK monitoring Dockerfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
firecat53 committed May 14, 2016
1 parent 4733e16 commit f293550
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
git submodule update --remote
- Btsync
- Check-MK (Monitoring system based on Nagios. Lighter than OMD)
- Crashplan
- **Couchpotato**
- **Deluge** (with OpenVPN client and privateinternetaccess.com script)
Expand Down
24 changes: 24 additions & 0 deletions check_mk/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Check_MK

FROM ubuntu:16.04
MAINTAINER Scott Hansen, [email protected]

ENV VERSION 1.2.8p1
ENV DEBIAN_FRONTEND noninteractive

COPY start.sh /start.sh
RUN apt-get update -q && \
apt-get install -qy gdebi-core \
wget \
msmtp \
msmtp-mta \
heirloom-mailx && \
wget https://mathias-kettner.de/support/$VERSION/check-mk-raw-${VERSION}_0.xenial_amd64.deb && \
gdebi -nq check-mk-raw-${VERSION}_0.xenial_amd64.deb && \
rm check-mk-raw-${VERSION}_0.xenial_amd64.deb && \
chmod +x /start.sh && \
apt-get autoremove -qy gdebi-core \
wget && \
rm -rf /var/lib/apt/lists/* && \

CMD ["/start.sh"]
53 changes: 53 additions & 0 deletions check_mk/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Docker Check-MK Monitoring
==========================

This is a Dockerfile to set up `Check-MK Monitoring`_ along with
Msmtp send-only mail (using Gmail, Mandrill, etc.) for notifications.

Build
-----

Ensure the correct version from the `downloads page`_ is noted in the
Dockerfile. If your site requires Check-MK to run with tmpfs, remove the line
in start.sh that disables it, then run the container with either `--priviliged`
or `--cap-add SYS_ADMIN`.

Build from Dockerfile::

docker build -t check_mk .

Create data-only volume. Check-MK site configurations will be auto-generated in
/opt/omd/sites. ::

docker run -v /opt/omd/sites -v /config --name check_mk_config ubuntu

Edit the msmtprc and msmtp-aliases files with your email SMTP info. Default
site/user is omd. Then::

docker cp msmtprc check_mk_config:/config/
docker cp msmtp-aliases check_mk_config:/config/

Run
___

Systemd service file is also available. ::

docker run -d --volumes-from check_mk_config -v /etc/localtime:/etc/localtime -p 5000:5000 --name check_mk_run check_mk

Be patient when starting (20-40 seconds). The site has to be generated
initially, then regenerated on subsequent runs to make sure all the permissions
and user/groups are correct. Existing site info will not be overwritten!

Manage
------

The default site name is 'default'. You can use the omd commands to control that
site::

$ docker exec -it check_mk_run /bin/bash
# omd --help
# omd su default
OMD[defatul]:~$ ....

.. _Check-MK Monitoring: http://mathias-kettner.com/check_mk.html
.. _downloads page: http://mathias-kettner.com/check_mk_download.php?HTML=yes
17 changes: 17 additions & 0 deletions check_mk/check_mk.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=Check-MK container
After=docker.service

[Service]
Restart=always
RestartSec=10
ExecStartPre=-/usr/bin/docker rm check_mk_run
ExecStart=/usr/bin/docker run \
--volumes-from check_mk_config \
-p 5000:5000 \
-v /etc/localtime:/etc/localtime:ro \
--name check_mk_run check_mk
ExecStop=/usr/bin/docker stop check_mk_run

[Install]
WantedBy=multi-user.target
2 changes: 2 additions & 0 deletions check_mk/msmtp-aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
root: <email address>
omd: <email address>
21 changes: 21 additions & 0 deletions check_mk/msmtprc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# msmtp config file

# gmail
account gmail
host smtp.gmail.com
port 587
protocol smtp
auth on
from <email address>
user <email address>
password <password>
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

# use gmail as default
account default : gmail

aliases /etc/msmtp-aliases



25 changes: 25 additions & 0 deletions check_mk/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
SITE=default

# Link msmtp data volume to /etc/msmtprc
chgrp omd /config/msmtp*
chmod 640 /config/msmtprc
ln -s /config/* /etc/

if [[ ! -d "/opt/omd/sites/$SITE" ]]; then
# First Run
# Set up a default site "omd"
omd create "$SITE"

# We don't want TMPFS as it requires higher privileges
omd config "$SITE" set TMPFS off

# Accept connections on any IP address, since we get a random one
omd config "$SITE" set APACHE_TCP_ADDR 0.0.0.0
else
# Reinitialize SITE
omd mv "$SITE" temp
omd mv temp "$SITE"
fi
omd start "$SITE"
tail -f "/opt/omd/sites/$SITE/var/log/nagios.log"

0 comments on commit f293550

Please sign in to comment.