Skip to content
This repository was archived by the owner on Sep 17, 2021. It is now read-only.

Feature/22 supervisord #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

FROM centos:centos6
MAINTAINER Bernardo Gomez Palacio <bernardo.gomezpalacio@gmail.com>
ENV REFRESHED_AT 2015-03-19
ENV REFRESHED_AT 2015-07-27_00.05

# Install EPEL to have MySQL packages.
RUN yum install -y http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Expand All @@ -12,7 +12,7 @@ RUN yum install -y http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-releas
RUN yum makecache
# Installing Tools.
RUN yum -y -q install \
monit \
supervisor \
nmap \
traceroute \
wget \
Expand Down Expand Up @@ -62,7 +62,7 @@ RUN yum -y -q install zabbix-agent \
zabbix22-dbfiles-mysql

# YUM Cleanup
yum clean all && rm -rf /tmp/*
RUN yum clean all && rm -rf /tmp/*

# MySQL
COPY ./mysql/my.cnf /etc/mysql/conf.d/my.cnf
Expand All @@ -83,12 +83,12 @@ COPY ./zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf
RUN chmod 640 /etc/zabbix/zabbix_server.conf
RUN chown root:zabbix /etc/zabbix/zabbix_server.conf

# Monit
ADD ./monitrc /etc/monitrc
RUN chmod 600 /etc/monitrc
# Supervisord
ADD supervisord.conf /etc/supervisord.conf
RUN chmod 600 /etc/supervisord.conf

# https://github.com/dotcloud/docker/issues/1240#issuecomment-21807183
RUN echo "NETWORKING=yes" > /etc/sysconfig/network
# RUN echo "NETWORKING=yes" > /etc/sysconfig/network

# Add the script that will start the repo.
ADD ./scripts/entrypoint.sh /bin/docker-zabbix
Expand All @@ -100,7 +100,7 @@ RUN chmod 755 /bin/docker-zabbix
# * Monit
EXPOSE 10051 10052 80 2812

VOLUME ["/var/lib/mysql", "/usr/lib/zabbix/alertscripts", "/usr/lib/zabbix/externalscripts", "/etc/zabbix/zabbix_agentd.d"]
VOLUME ["/var/lib/mysql", "/usr/lib/zabbix/alertscripts", "/usr/lib/zabbix/externalscripts", "/etc/zabbix/zabbix_agentd.d", "/var/log/supervisor"]

ENTRYPOINT ["/bin/docker-zabbix"]
CMD ["run"]
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
REPORTER = dot

name = "docker-zabbix"
image_name = "berngp/$(name)"


build:
@docker build -t $(image_name) .


run:
@docker run --rm -it \
--hostname=$(name) \
--name=$(name) \
-P \
$(image_name)

run-shell:
@docker run --rm -it \
--hostname=$(name) \
--name=$(name) \
-P \
$(image_name) \
shell

exec:
@docker exec -it $(name) /bin/bash

rmi:
-@docker rmi $(image_name)

rm:
-@docker rm $(name)

clean: rm rmi

tag: build
-@docker tag $(image_name) $(image_name)

push: tag
docker push $(image_name)

.PHONY: build run exec rmi rm clean tag push
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The container provides the following *Zabbix Services*, please refer to the [Zab
* A *Zabbix Web UI* at port 80 (e.g. `http://$container_ip/zabbix` )
* A *Zabbix Agent*.
* A MySQL instance supporting *Zabbix*, user is `zabbix` and password is `zabbix`.
* A Monit deamon managing the processes (http://$container_ip:2812, user 'myuser' and password 'mypassword').
* Supervisord managing the processes (`http://$container_ip:2812`, user `'myuser'` and password `'mypassword'`).


## Usage
Expand Down
70 changes: 0 additions & 70 deletions Vagrantfile

This file was deleted.

33 changes: 0 additions & 33 deletions monitrc

This file was deleted.

19 changes: 10 additions & 9 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source /etc/profile.d/java.sh

_file_marker="/var/lib/mysql/.mysql-configured"
readonly _file_marker="/var/lib/mysql/.mysql-configured"

if [ ! -f "$_file_marker" ]; then
/sbin/service mysqld restart
Expand Down Expand Up @@ -46,32 +46,33 @@ if [ ! -f "$_file_marker" ]; then
touch "$_file_marker"
fi

_cmd="/usr/bin/monit -d 10 -Ic /etc/monitrc"
_shell="/bin/bash"
readonly _cmd="/usr/bin/supervisord -c /etc/supervisord.conf --nodaemon"
readonly _cmd_ctrl="/usr/bin/supervisorctl -c /etc/supervisord.conf"
readonly _shell="/bin/bash"

case "$1" in
run)
echo "Running Monit... "
exec /usr/bin/monit -d 10 -Ic /etc/monitrc
echo "Running Supervisor ..."
exec $_cmd
;;
stop)
$_cmd stop all
$_cmd_ctrl stop all
RETVAL=$?
;;
restart)
$_cmd restart all
$_cmd_ctrl restart all
RETVAL=$?
;;
shell)
$_shell
RETVAL=$?
;;
status)
$_cmd status all
$_cmd_ctrl status all
RETVAL=$?
;;
summary)
$_cmd summary
$_cmd_ctrl summary
RETVAL=$?
;;
*)
Expand Down
82 changes: 82 additions & 0 deletions supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
[unix_http_server]
file = /var/run/supervisor.sock
chmod = 0777
chown = nobody:nogroup
username = myuser
password = mypassword


[supervisorctl]
serverurl = unix:///var/run/supervisor.sock
username = myuser
password = mypassword
prompt = supervisor


[inet_http_server]
port = 0.0.0.0:2812
username = myuser
password = mypassword


[supervisord]
logfile = /var/log/supervisor/supervisord.log
logfile_maxbytes = 10MB
logfile_backups = 10
loglevel = info
pidfile = /var/run/supervisord.pid
nodaemon = true
minfds = 1024
minprocs = 200
umask = 022
identifier = supervisor
nocleanup = true
childlogdir = /var/log/supervisor/


[program:mysqld]
command=/usr/bin/mysqld_safe
redirect_stderr=true
autostart=true
autorestart=true


[program:httpd]
command=/usr/sbin/apachectl -D "FOREGROUND" -k start
redirect_stderr=true
autostart=true
autorestart=true


[program:zabbix-server]
command=/usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
redirect_stderr=true
autostart=true
autorestart=true
stopasgroup=true


[program:zabbix-agentd]
command=/usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
redirect_stderr=true
autostart=true
autorestart=true
stopasgroup=true


[program:zabbix-java-gateway]
command=/etc/init.d/zabbix-java-gateway start
redirect_stderr=true
autostart=true
autorestart=true
stopasgroup=true


[group:base]
programs=mysqld,httpd
priority=100


[group:zabbix]
programs=zabbix-server,zabbix-agentd,zabbix-java-gateway
priority=999
2 changes: 0 additions & 2 deletions zabbix/zabbix_agentd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
# Default:
# PidFile=/tmp/zabbix_agentd.pid

PidFile=/var/run/zabbix/zabbix_agentd.pid

### Option: LogFile
# Name of log file.
# If not set, syslog is used.
Expand Down
2 changes: 0 additions & 2 deletions zabbix/zabbix_java_gateway.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ LISTEN_IP="0.0.0.0"
# Default:
# PID_FILE=

PID_FILE="/var/run/zabbix/zabbix_java.pid"

### Option: zabbix.startPollers
# Number of worker threads to start.
#
Expand Down
2 changes: 0 additions & 2 deletions zabbix/zabbix_server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ LogFileSize=0
# Default:
# PidFile=/tmp/zabbix_server.pid

PidFile=/var/run/zabbix/zabbix_server.pid

### Option: DBHost
# Database host name.
# If set to localhost, socket is used for MySQL.
Expand Down