-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
102 lines (82 loc) · 3.31 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
FROM centos:centos7
MAINTAINER gardar@ok.is
# - Install basic packages (e.g. python-setuptools is required to have python's easy_install)
# - Install yum-utils so we have yum-config-manager tool available
# - Install inotify, needed to automate daemon restarts after config file changes
# - Install jq, small library for handling JSON files/api from CLI
# - Install supervisord (via python's easy_install - as it has the newest 3.x version)
RUN \
yum update -y && \
yum install -y epel-release && \
yum install -y iproute python-setuptools hostname inotify-tools yum-utils which jq && \
yum clean all && \
easy_install supervisor
ENV ADAGIOS_HOST adagios.local
ENV ADAGIOS_USER thrukadmin
ENV ADAGIOS_PASS thrukadmin
# First install the opensource.is and consol labs repositories
RUN rpm -ihv http://opensource.is/repo/ok-release.rpm
RUN rpm -Uvh https://labs.consol.de/repo/stable/rhel7/x86_64/labs-consol-stable.rhel7.noarch.rpm
RUN yum install -y epel-release
RUN yum update -y ok-release
RUN yum clean all && yum -y update
#
# Install Deps
#
RUN yum install -y git acl libstdc++-static python-setuptools facter mod_wsgi postfix python-pip sudo
# Install Nagios 4
#
RUN yum install -y nagios nagios-plugins-all pnp4nagios
#
# Enable and start services
#
RUN systemctl enable nagios
RUN chkconfig npcd on
RUN systemctl enable httpd
#
# Install Livestatus
#
RUN yum install -y check-mk-livestatus
# Add check_mk livestatus broker module to nagios config
RUN echo "broker_module=/usr/lib64/check_mk/livestatus.o /var/spool/nagios/cmd/livestatus" >> /etc/nagios/nagios.cfg
# Lets make sure adagios can write to nagios configuration files, and that
# it is a valid git repo so we have audit trail
WORKDIR /etc/nagios
RUN git init /etc/nagios/
RUN git config user.name "User"
RUN git config user.email "email@mail.com"
RUN git add *
RUN git commit -m "Initial commit"
# Make sure nagios group will always have write access to the configuration files:
RUN chown -R nagios:nagios /etc/nagios/* /etc/nagios/.git
# Install Pynag from Git
RUN mkdir -p /opt/pynag
WORKDIR /opt/
RUN pip install django==1.6
RUN pip install simplejson
RUN git clone git://github.com/pynag/pynag.git
# Install Adagios from Git
RUN mkdir -p /opt/adagios
WORKDIR /opt
RUN git clone git://github.com/opinkerfi/adagios.git
WORKDIR /opt/adagios/adagios
RUN cp -r etc/adagios /etc/adagios
RUN chown -R nagios:nagios /etc/adagios
RUN chmod g+w -R /etc/adagios
RUN mkdir -p /var/lib/adagios/userdata
RUN chown nagios:nagios /var/lib/adagios
RUN mkdir /etc/nagios/adagios
RUN mkdir -p /etc/nagios/adagios /etc/nagios/commands
RUN echo "cfg_dir=/etc/nagios/adagios" >> /etc/nagios/nagios.cfg
RUN echo "cfg_dir=/etc/nagios/commands" >> /etc/nagios/nagios.cfg
# Add naemon to apache group so it has permissions to pnp4nagios's session files
RUN usermod -G apache nagios
#RUN sed -i 's|^\(nagios_init_script\)=\(.*\)$|\1="sudo /usr/bin/nagios-supervisor-wrapper.sh"|g' /etc/adagios/adagios.conf
#RUN echo "nagios ALL=NOPASSWD: /usr/bin/nagios-supervisor-wrapper.sh" >> /etc/sudoers.d/adagios
# Add supervisord conf, bootstrap.sh files
ADD container-files /
ADD supervisord-nagios.conf /etc/supervisor.d/supervisord-nagios.conf
EXPOSE 80
EXPOSE 8000
VOLUME ["/data", "/etc/nagios", "/var/log/nagios", "/etc/adagios", "/opt/adagios", "/opt/pynag"]
ENTRYPOINT ["/config/bootstrap.sh"]