Use fig for docker env

Change-Id: Ic4a330b7655f47a16f7c3a6afc709b6bb06513cf
This commit is contained in:
aviau 2014-12-13 20:03:29 -05:00
parent c86d70fbb1
commit dfa8b4a4f5
13 changed files with 52 additions and 79 deletions

View File

@ -13,11 +13,11 @@ 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 riemann-client && shinken install mod-riemann
RUN pip install pymongo && shinken install mod-mongodb
## plugins
@ -39,12 +39,6 @@ RUN useradd influxdb # We should remove this when issue is fixed (https://github
RUN dpkg -i influxdb_latest_amd64.deb
RUN service influxdb start && until curl -X POST 'http://localhost:8086/db?u=root&p=root' -d '{"name": "grafana"}'; do echo "Try again"; sleep 2; done && curl -X POST 'http://localhost:8086/db?u=root&p=root' -d '{"name": "db"}' # We should remove the sleep when this issue is fixed: https://github.com/influxdb/influxdb/issues/805
### Riemann
RUN wget http://aphyr.com/riemann/riemann_0.2.6_all.deb
RUN sudo dpkg -i riemann_0.2.6_all.deb
RUN sudo apt-get install -y openjdk-7-jre
ADD tools/docker/etc/riemann/riemann.config /etc/riemann/riemann.config
### Grafana
RUN apt-get install -y apache2
RUN wget http://grafanarel.s3.amazonaws.com/grafana-1.7.0-rc1.tar.gz
@ -58,15 +52,6 @@ RUN apt-get install -y libapache2-mod-proxy-html
RUN a2enmod proxy_http
ADD tools/docker/etc/apache2/conf-enabled/influxdb.conf /etc/apache2/conf-enabled/influxdb.conf
### Mongodb
RUN apt-get install -y mongodb
ADD tools/docker/etc/mongodb.conf /etc/mongodb.conf
## Import sample config
## TODO: Use the python client or curl instead.
ADD tools/docker/mongoimport /mongoimport
RUN service mongodb start && until mongoimport --db shinken --host localhost --collection hosts < /mongoimport/hosts.json; do echo "Try again"; sleep 2; done && mongoimport --db shinken --host localhost --collection services < /mongoimport/services.json && service mongodb stop
### Surveil
## Copy files
ADD surveil /surveil/surveil
@ -97,13 +82,7 @@ EXPOSE 8086
# Grafana
EXPOSE 80
# Riemann
EXPOSE 5555
# Mongodb
EXPOSE 27017
# Surveil
EXPOSE 8080
CMD ["/usr/bin/supervisord"]
CMD surveil-init && /usr/bin/supervisord

6
fig.yml Normal file
View File

@ -0,0 +1,6 @@
surveil:
build: .
links:
- mongo
mongo:
image: mongo

View File

@ -12,6 +12,7 @@ packages =
[entry_points]
console_scripts =
surveil-api = surveil.cmd.api:main
surveil-init = surveil.cmd.init:main
[build_sphinx]
source-dir = doc/source

View File

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

40
surveil/cmd/init.py Normal file
View File

@ -0,0 +1,40 @@
# Copyright 2014 - Savoir-Faire Linux inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Script to initialize Surveil dependencies."""
from surveil.api import config
def main():
# Create a basic config in mongodb
mongo = config.app_hooks[0].mongo_connection
mongo_shinken = mongo.shinken
mongo_hosts = mongo_shinken.hosts
mongo_services = mongo_shinken.services
mongo_hosts.insert(
{"use": "generic-host", "contact_groups": "admins",
"host_name": "surveil", "address": "localhost"}
)
mongo_services.insert(
{"check_command": "check_tcp!8080", "check_interval": "5",
"check_period": "24x7", "contact_groups": "admins",
"contacts": "admin", "host_name": "surveil",
"max_check_attempts": "5", "notification_interval": "30",
"notification_period": "24x7", "retry_interval": "3",
"service_description": "check-surveil-api"}
)

View File

@ -1,16 +0,0 @@
# mongodb.conf
# Where to store the data.
dbpath=/var/lib/mongodb
#where to log
logpath=/var/log/mongodb/mongodb.log
logappend=true
bind_ip = 0.0.0.0
#port = 27017
# Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
journal=true

View File

@ -1,21 +0,0 @@
; -*- mode: clojure; -*-
; vim: filetype=clojure
(logging/init {:file "/var/log/riemann/riemann.log"})
; Listen on the local interface over TCP (5555), UDP (5555), and websockets
; (5556)
(let [host "0.0.0.0"]
(tcp-server {:host host})
(udp-server {:host host})
(ws-server {:host host}))
; Expire old events from the index every 5 seconds.
(periodically-expire 5)
(let [index (index)]
(streams
(expired #(prn "Expired" %))
(where (not (service #"^riemann "))
index
#(info "received event" %))))

View File

@ -37,7 +37,7 @@ define broker {
# - graphite = Use a Graphite time series DB for perfdata
# - webui = Shinken Web interface
# - glpidb = Save data in GLPI MySQL database
modules WebUI,mod-influxdb,mod-riemann
modules WebUI,mod-influxdb
# Enable https or not
use_ssl 0

View File

@ -5,7 +5,7 @@
define module {
module_name mongodb
module_type mongodb
uri mongodb://localhost/?safe=false
uri mongodb://mongo/?safe=false
database shinken
#username username ;optional
#password password ;optional

View File

@ -1,11 +0,0 @@
## Module: mod-riemann
## Loaded by: Broker
# Export host and service performance data and events to Riemann.
define module {
module_name mod-riemann
module_type riemann_perfdata
host localhost
port 5555
#use_udp 1 ; default value is 0, 1 to use udp
#tick_limit 300 ; Default value 300
}

View File

@ -10,9 +10,6 @@ command=/bin/sh -c "service influxdb start"
[program:apache2]
command=/bin/sh -c "service apache2 start"
[program:riemann]
command=/bin/sh -c "service riemann start"
[program:mongodb]
command=/bin/sh -c "service mongodb start"

View File

@ -1 +0,0 @@
{"use": "generic-host", "contact_groups": "admins", "host_name": "surveil", "address": "localhost"}

View File

@ -1 +0,0 @@
{ "check_command": "check_tcp!8080", "check_interval": "5", "check_period": "24x7", "contact_groups": "admins", "contacts": "admin", "host_name": "surveil", "max_check_attempts": "5", "notification_interval": "30", "notification_period": "24x7", "retry_interval": "3", "service_description": "check-surveil-api" }