Containers: separated shinken from surveil

Change-Id: I4e54d1a64f8a368e1b2328423a0a86f4455d1161
This commit is contained in:
aviau 2015-02-13 15:43:47 -05:00
parent c3102fed7b
commit bbdc2a5202
103 changed files with 130 additions and 64 deletions

View File

@ -2,52 +2,23 @@ FROM ubuntu:trusty
MAINTAINER Alexandre Viau <alexandre.viau@savoirfairelinux.com>
RUN apt-get update && apt-get install -y vim supervisor python-pip python3-pip python-dev libffi-dev libssl-dev git python-pycurl
RUN apt-get update
RUN apt-get install -y vim supervisor
### Shinken
RUN apt-get install -y python-pip
# Surveil needs shinken (as a lib)
RUN useradd shinken && pip install https://github.com/naparuba/shinken/archive/2.2-RC1.zip
RUN apt-get install -y python-pycurl
RUN shinken --init
## modules
#RUN mkdir /var/lib/shinken/share
RUN shinken install webui
RUN shinken install auth-cfg-password
RUN pip install influxdb && shinken install mod-influxdb
RUN shinken install ws-arbiter
RUN pip install pymongo && shinken install mod-mongodb
# python-surveilclient (used by surveil-init)
RUN pip install python-surveilclient
## plugins
RUN apt-get install -y nagios-plugins
# run permissions for user `shinken`
RUN chmod u+s /usr/lib/nagios/plugins/check_icmp
RUN chmod u+s /bin/ping
RUN chmod u+s /bin/ping6
## Packs
ADD shinken-tools/packs /packs
## Plugins
ADD shinken-tools/plugins/*/check_* /usr/lib/shinken/plugins/
# Download packs from savoirfairelinux/monitoring-tools
# Download packs
RUN apt-get install -y subversion && \
## Packs
svn checkout https://github.com/savoirfairelinux/monitoring-tools/trunk/packs/generic-host /packs/generic-host && \
svn checkout https://github.com/stackforge/surveil/trunk/shinken-tools/packs/linux-glance /packs/linux-glance && \
svn checkout https://github.com/stackforge/surveil/trunk/shinken-tools/packs/linux-keystone /packs/linux-keystone && \
apt-get remove -y subversion
## configuration
RUN rm -rf /etc/shinken
ADD tools/docker/etc/shinken /etc/shinken
RUN chown -R root:shinken /etc/shinken
### Surveil
## Package deps
RUN apt-get install -y python3-pip python-dev libffi-dev libssl-dev
## Copy files
# Copy files
ADD surveil /surveil/surveil
ADD setup.cfg /surveil/setup.cfg
ADD requirements.txt surveil/requirements.txt
@ -55,22 +26,15 @@ ADD setup.py /surveil/setup.py
ADD .git /surveil/.git
ADD README.rst surveil/README.rst
## Install
# Install
RUN pip install -r /surveil/requirements.txt
RUN apt-get install -y git
RUN cd surveil && python setup.py install
### Supervisor
ADD tools/docker/etc/supervisor /etc/supervisor
# Supervisor
ADD tools/docker/surveil_container/etc/supervisor /etc/supervisor
# Shinken WEBUI
EXPOSE 7767
# Surveil
# Surveil API
EXPOSE 8080
CMD surveil-init && \
surveil-pack-upload --mongo-url=mongo --mongo-port=27017 /packs/linux-keystone/ && \
surveil-pack-upload --mongo-url=mongo --mongo-port=27017 /packs/linux-glance/ && \
surveil-pack-upload --mongo-url=mongo --mongo-port=27017 /packs/generic-host/ && \
CMD sleep 20 && \
/usr/bin/supervisord

10
fig.yml
View File

@ -3,9 +3,17 @@ surveil:
links:
- mongo
- influxdb
- shinken
ports:
- "8080:8080"
- "7767:7767"
shinken:
build: tools/docker/shinken_container/
links:
- mongo
- influxdb
ports:
- "7767:7767"
mongo:
image: mongo

View File

@ -2,8 +2,3 @@ pecan>=0.5.0
pymongo>=2.7.2
wsme
requests
# Plugins dependencies
shinkenplugins
python-keystoneclient
python-glanceclient

View File

@ -25,7 +25,7 @@ server = {
app_hooks = [
hooks.DBHook(
pymongo.MongoClient('mongo', 27017),
"http://127.0.0.1:7760"
"http://shinken:7760"
)
]

View File

@ -14,6 +14,10 @@
"""Script to reinitialize surveil."""
import subprocess
import surveilclient.client as sc
from surveil.api import config
@ -28,16 +32,48 @@ def main():
mongo_hosts = mongo_shinken.hosts
mongo_services = mongo_shinken.services
# Load the shinken packs
subprocess.call(
[
"surveil-pack-upload",
"--mongo-url=mongo",
"--mongo-port=27017",
"/packs/linux-keystone/",
]
)
subprocess.call(
[
"surveil-pack-upload",
"--mongo-url=mongo",
"--mongo-port=27017",
"/packs/linux-glance/",
]
)
subprocess.call(
[
"surveil-pack-upload",
"--mongo-url=mongo",
"--mongo-port=27017",
"/packs/generic-host/",
]
)
mongo_hosts.insert(
{"use": "generic-host", "contact_groups": "admins",
"host_name": "surveil", "address": "localhost"}
"host_name": "ws-arbiter", "address": "localhost"}
)
mongo_services.insert(
{"check_command": "check_tcp!8080", "check_interval": "5",
{"check_command": "check_tcp!7760", "check_interval": "5",
"check_period": "24x7", "contact_groups": "admins",
"contacts": "admin", "host_name": "surveil",
"contacts": "admin", "host_name": "ws-arbiter",
"max_check_attempts": "5", "notification_interval": "30",
"notification_period": "24x7", "retry_interval": "3",
"service_description": "check-surveil-api"}
"service_description": "check-ws-arbiter"}
)
# Reload the surveil config
cli_surveil = sc.Client('http://localhost:8080/v1')
cli_surveil.reload_config()

View File

@ -0,0 +1,58 @@
FROM ubuntu:trusty
MAINTAINER Alexandre Viau <alexandre.viau@savoirfairelinux.com>
RUN apt-get update
RUN apt-get install -y vim supervisor python-dev libffi-dev libssl-dev
# libffi-devand libssl-dev are for python-cryptography
### Shinken
RUN apt-get install -y python-pip
RUN useradd shinken && pip install https://github.com/naparuba/shinken/archive/2.2-RC1.zip
RUN apt-get install -y python-pycurl
RUN shinken --init
## modules
#RUN mkdir /var/lib/shinken/share
RUN shinken install webui
RUN shinken install auth-cfg-password
RUN pip install influxdb && shinken install mod-influxdb
RUN shinken install ws-arbiter
RUN pip install pymongo && shinken install mod-mongodb
## plugins
RUN apt-get install -y nagios-plugins
# run permissions for user `shinken`
RUN chmod u+s /usr/lib/nagios/plugins/check_icmp
RUN chmod u+s /bin/ping
RUN chmod u+s /bin/ping6
# Download plugins
RUN apt-get install -y subversion && \
svn checkout https://github.com/stackforge/surveil/trunk/shinken-tools/plugins/plugin-check-glance /plugins/check_glance && \
svn checkout https://github.com/stackforge/surveil/trunk/shinken-tools/plugins/plugin-check-keystone /plugins/check_keystone && \
apt-get remove -y subversion
## Install plugins dependencies
RUN pip install shinkenplugins python-keystoneclient python-glanceclient
## Install Plugins
RUN mkdir -p /usr/lib/shinken/plugins && \
cp /plugins/*/check_* /usr/lib/shinken/plugins/
## configuration
RUN rm -rf /etc/shinken
ADD etc/shinken /etc/shinken
RUN chown -R root:shinken /etc/shinken
### Supervisor
ADD etc/supervisor /etc/supervisor
# Shinken WEBUI
EXPOSE 7767
# ws-arbiter
EXPOSE 7760
CMD /usr/bin/supervisord

Some files were not shown because too many files have changed in this diff Show More