Skip to content

Commit

Permalink
Merge pull request #1 from opinkerfi/docker-adagios-centos7-systemd
Browse files Browse the repository at this point in the history
Adagios running on Centos7 with systemd
  • Loading branch information
gardart authored Sep 27, 2019
2 parents c5fef6a + 5d16be5 commit a3a84c8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 125 deletions.
51 changes: 21 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Based on appcontainers/nagios
############################################################

FROM centos:latest
FROM centos/systemd
MAINTAINER "Gardar Thorsteinsson" <[email protected]>

ENV ADAGIOS_HOST adagios.local
Expand All @@ -29,11 +29,11 @@ RUN yum --enablerepo=ok-testing install -y naemon naemon-livestatus git adagios
# Lets make sure adagios can write to naemon configuration files, and that
# it is a valid git repo so we have audit trail
WORKDIR /etc/naemon
#RUN git config user.name "admin"
#RUN git config user.email "admin@adagios.local"
#RUN git init /etc/naemon
#UN git add .
#RUN git commit -a -m "Initial commit"
RUN git init /etc/naemon
RUN git config user.name "admin"
RUN git config user.email "[email protected]"
RUN git add .
RUN git commit -a -m "Initial commit"

# Fix permissions for naemon and pnp4nagios
RUN chown -R naemon:naemon /etc/naemon /etc/adagios /var/lib/adagios /var/lib/pnp4nagios /var/log/pnp4nagios /var/spool/pnp4nagios /etc/pnp4nagios/process_perfdata.cfg /var/log/okconfig
Expand Down Expand Up @@ -109,38 +109,29 @@ RUN pynag config --append cfg_dir=/etc/naemon/commands/

RUN mv /etc/httpd/conf.d/thruk_cookie_auth_vhost.conf /etc/httpd/conf.d/thruk_cookie_auth_vhost.conf.disabled

RUN htpasswd -b /etc/thruk/htpasswd "$ADAGIOS_USER" "$ADAGIOS_PASS"
RUN rm -f /etc/nagios/passwd
RUN ln -s /etc/thruk/htpasswd /etc/nagios/passwd

# Redirect root URL to /adagios
RUN echo "RedirectMatch ^/$ /adagios" > /etc/httpd/conf.d/redirect.conf

# Install supervisor and supervisor-quick. Service restarts are painfully slow
# otherwise
RUN pip install supervisor
RUN pip install supervisor-quick

# Remove cache and default passwd files
RUN rm -rf /var/cache/yum /etc/nagios/passwd /etc/thruk/htpasswd

# Copy supervisor config over to the container
COPY supervisord.conf /etc/supervisord.conf

# Copy custom supervisor init.d script (for nagios start|stop)
COPY naemon-supervisor-wrapper.sh /usr/bin/naemon-supervisor-wrapper.sh
RUN sed -i 's|^\(nagios_init_script\)=\(.*\)$|\1="sudo /usr/bin/naemon-supervisor-wrapper.sh"|g' /etc/adagios/adagios.conf
RUN echo "naemon ALL=NOPASSWD: /usr/bin/naemon-supervisor-wrapper.sh" >> /etc/sudoers

# Create childlogdir
RUN mkdir /var/log/supervisor
# Fix permissions for naemon and pnp4nagios
RUN chown -R naemon:naemon /etc/naemon /etc/adagios /var/lib/adagios /var/lib/pnp4nagios /var/log/pnp4nagios /var/spool/pnp4nagios /etc/pnp4nagios/process_perfdata.cfg /var/log/okconfig
# ACL group permissions need g+rwx
RUN chmod g+rwx -R /etc/naemon /etc/adagios /var/lib/adagios /var/lib/pnp4nagios /var/log/pnp4nagios /var/spool/pnp4nagios /etc/pnp4nagios/process_perfdata.cfg /var/log/okconfig
RUN setfacl -R -m group:naemon:rwx -m d:group:naemon:rwx /etc/naemon/ /etc/adagios /var/lib/adagios /var/lib/pnp4nagios /var/log/pnp4nagios /var/spool/pnp4nagios /etc/pnp4nagios/process_perfdata.cfg /var/log/okconfig

# Copy over our custom init script
COPY run.sh /usr/bin/run.sh
# Enable services
RUN systemctl enable httpd
RUN systemctl enable naemon
RUN systemctl enable npcd

# Make run.sh and supervisor wrapper script executable
RUN chmod 755 /usr/bin/run.sh /usr/bin/naemon-supervisor-wrapper.sh
# Remove yum cache
RUN rm -rf /var/cache/yum

WORKDIR /etc/naemon

ENTRYPOINT ["/bin/bash", "/usr/bin/run.sh"]

EXPOSE 80

VOLUME ["/etc/naemon", "/var/log/naemon"]
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ docker create \

Log in with user `thrukadmin` and password `thrukadmin`

## Building

```
git clone https://github.com/opinkerfi/docker-adagios-rpm.git
cd docker-adagios-rpm
docker build -t adagios_systemd_image .
docker run --cap-add=SYS_ADMIN --name adagios -v /sys/fs/cgroup:/sys/fs/cgroup -p 8080:80 -d adagios_systemd_image
```

Then you should be able to access http://localhost:8080
Log in with user `thrukadmin` and password `thrukadmin`

## Parameters

The parameters are split into two halves, separated by a colon, the left hand side representing the host and the right the container side.
Expand Down
11 changes: 0 additions & 11 deletions naemon-supervisor-wrapper.sh

This file was deleted.

50 changes: 0 additions & 50 deletions run.sh

This file was deleted.

34 changes: 0 additions & 34 deletions supervisord.conf

This file was deleted.

0 comments on commit a3a84c8

Please sign in to comment.