Merge pull request #289 from Icinga/287

Remove demo Dockerfile
This commit is contained in:
Eric Lippmann 2022-10-26 15:04:52 +02:00 committed by GitHub
commit ff6e3c5003
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 16 additions and 246 deletions

View file

@ -1,28 +0,0 @@
WSGIPythonHome /opt/graphite
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog /dev/stderr
CustomLog /dev/stdout combined
<Location "/">
Require all granted
</Location>
WSGIDaemonProcess graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120 user=graphite group=graphite
WSGIProcessGroup graphite
WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite application-group=%{GLOBAL}
WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi
Alias /static/ /opt/graphite/webapp/content/
<Location "/static/">
Require all granted
SetHandler None
</Location>
</VirtualHost>
<Directory "/usr/share/icingaweb2/public">
SetEnv REMOTE_USER icingaadmin
</Directory>

View file

@ -1 +0,0 @@
deb https://packages.icinga.com/debian icinga-stretch main

View file

@ -1,7 +0,0 @@
library "db_ido_mysql"
object IdoMysqlConnection "ido-mysql" {
host = "localhost"
user = "nagios"
database = "icinga2"
}

View file

@ -1,3 +0,0 @@
[icingaweb2]
strip_username_regexp = ""
backend = "external"

View file

@ -1,7 +0,0 @@
[global]
show_stacktraces = "1"
config_backend = "ini"
[logging]
log = "php"
level = "INFO"

View file

@ -1,3 +0,0 @@
[graphite]
url = "http://127.0.0.1"
insecure = "0"

View file

@ -1,3 +0,0 @@
[icinga]
type = "ido"
resource = "icinga_ido"

View file

@ -1,3 +0,0 @@
[icinga2]
transport = "local"
path = "/var/run/icinga2/cmd/icinga2.cmd"

View file

@ -1,2 +0,0 @@
[security]
protected_customvars = "*pw*,*pass*,community"

View file

@ -1,11 +0,0 @@
[icinga_ido]
type = "db"
db = "mysql"
host = "localhost"
port = ""
dbname = "icinga2"
username = "www-data"
password = ""
charset = "utf8"
persistent = "0"
use_ssl = "0"

View file

@ -1,3 +0,0 @@
[Administrators]
users = "icingaadmin"
permissions = "*"

View file

@ -1,2 +0,0 @@
[Date]
date.timezone = UTC

View file

@ -1,60 +0,0 @@
[supervisord]
nodaemon = true
logfile = /dev/stdout
loglevel = info
[unix_http_server]
file = /run/supervisord.s
[supervisorctl]
serverurl = unix:///run/supervisord.s
[program:icinga2]
command = /bin/bash -exo pipefail -c 'set -a; . /etc/default/icinga2; set +a; exec icinga2 daemon -e "$ICINGA2_ERROR_LOG"'
depends_on = carbon-cache, mariadb
stdout_logfile = /dev/stdout
redirect_stderr = true
autostart = true
autorestart = true
startsecs = 10
startretries = 3
exitcodes = 0
stopsignal = TERM
stopwaitsecs = 5
[program:apache2]
command = /bin/bash -exo pipefail -c 'set -a; . /etc/apache2/envvars; set +a; exec apache2 -k start -DFOREGROUND'
depends_on = mariadb
stdout_logfile = /dev/stdout
redirect_stderr = true
autostart = true
autorestart = true
startsecs = 10
startretries = 3
exitcodes = 0
stopsignal = TERM
stopwaitsecs = 5
[program:mariadb]
command = /usr/sbin/mysqld -u mysql
stdout_logfile = /dev/stdout
redirect_stderr = true
autostart = true
autorestart = true
startsecs = 10
startretries = 3
exitcodes = 0
stopsignal = TERM
stopwaitsecs = 5
[program:carbon-cache]
command = nosu graphite graphite /opt/graphite/bin/carbon-cache.py --config=/opt/graphite/conf/carbon.conf --nodaemon start
stdout_logfile = /dev/stdout
redirect_stderr = true
autostart = true
autorestart = true
startsecs = 10
startretries = 3
exitcodes = 0
stopsignal = TERM
stopwaitsecs = 5

View file

@ -1,75 +0,0 @@
FROM debian:9 as icingaweb2-module-graphite
SHELL ["/bin/bash", "-exo", "pipefail", "-c"]
ADD . /icingaweb2-module-graphite
RUN rm -rf /icingaweb2-module-graphite/.* || true
FROM debian:9
SHELL ["/bin/bash", "-exo", "pipefail", "-c"]
RUN apt-get update ;\
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-{recommends,suggests} -y \
apt-transport-https gnupg2 dirmngr ca-certificates ;\
apt-get clean ;\
rm -vrf /var/lib/apt/lists/* ;\
apt-key adv --fetch-keys 'https://packages.icinga.com/icinga.key' ;\
DEBIAN_FRONTEND=noninteractive apt-get purge -y gnupg2 dirmngr ;\
DEBIAN_FRONTEND=noninteractive apt-get autoremove --purge -y
ADD .docker/apt-ext.list /etc/apt/sources.list.d/ext.list
RUN apt-get update ;\
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --no-install-suggests -y \
icinga2-{bin,ido-mysql} dbconfig-no-thanks mariadb-server \
apache2 icingaweb2{,-module-monitoring} icingacli php7.0-{intl,imagick,mysql,curl} locales \
gcc libapache2-mod-wsgi libcairo2 libffi-dev python{,-dev} virtualenv ;\
apt-get clean ;\
rm -vrf /var/lib/apt/lists/* /etc/icinga2/conf.d/* /etc/icingaweb2/* ;\
a2dissite 000-default ;\
perl -pi -e 's~//~~ if /const NodeName/' /etc/icinga2/constants.conf ;\
perl -pi -e 'if (!%locales) { %locales = (); for my $d ("", "/modules/monitoring") { for my $f (glob "/usr/share/icingaweb2${d}/application/locale/*_*") { if ($f =~ m~/(\w+)$~) { $locales{$1} = undef } } } } s/^# ?// if (/ UTF-8$/ && /^# (\w+)/ && exists $locales{$1})' /etc/locale.gen ;\
perl -e 'print "object GraphiteWriter \"graphite\" {\n enable_send_thresholds = true\n enable_send_metadata = true\n}\n"' > /etc/icinga2/features-available/graphite.conf
RUN adduser --system --group --home /opt/graphite/home graphite ;\
chown graphite:graphite /opt/graphite ;\
su -ls /bin/bash -c 'set -exo pipefail; /usr/bin/virtualenv /opt/graphite; . /opt/graphite/bin/activate; export PYTHONPATH=/opt/graphite/lib/:/opt/graphite/webapp/; /opt/graphite/bin/pip install --no-binary=:all: https://github.com/graphite-project/whisper/tarball/87ae6def1bece7e079d49a61ac8d09c6ebfe4e96; /opt/graphite/bin/pip install --no-binary=:all: https://github.com/graphite-project/carbon/tarball/f36da0f77aaf83a61f9880dec7abbf5c14a7d2bb; /opt/graphite/bin/pip install --no-binary=:all: https://github.com/graphite-project/graphite-web/tarball/53d96432b6ba1c30797405dff97ba01af009cb25; for f in /opt/graphite/conf/*.example; do ln -vs "$f" "/opt/graphite/conf/$(basename "$f" .example)"; done; /opt/graphite/bin/django-admin migrate --settings=graphite.settings' graphite
COPY --from=grandmaster/nosu:latest /usr/local/bin/nosu /usr/local/bin/nosu
COPY --from=icingaweb2-module-graphite /icingaweb2-module-graphite /usr/share/icingaweb2/modules/graphite
RUN set -a; . /etc/default/icinga2; set +a ;\
/usr/lib/icinga2/prepare-dirs /etc/default/icinga2
RUN install -m 755 -o mysql -g root -d /var/run/mysqld
RUN mysqld -u mysql & \
MYSQLD_PID="$!" ;\
while ! mysql <<<''; do sleep 1; done ;\
mysql <<<"CREATE DATABASE icinga2; USE icinga2; $(< /usr/share/icinga2-ido-mysql/schema/mysql.sql) GRANT ALL ON icinga2.* TO nagios@localhost IDENTIFIED VIA unix_socket; GRANT SELECT ON icinga2.* TO 'www-data'@localhost IDENTIFIED VIA unix_socket;" ;\
kill "$MYSQLD_PID" ;\
while test -e "/proc/$MYSQLD_PID"; do sleep 1; done
COPY .docker/icinga2-ido.conf /etc/icinga2/features-available/ido-mysql.conf
RUN set -a; . /etc/default/icinga2; set +a ;\
for f in command graphite ido-mysql; do icinga2 feature enable $f; done
COPY .docker/php-icingaweb2.ini /etc/php/7.0/apache2/conf.d/99-icingaweb2.ini
ADD --chown=www-data:icingaweb2 .docker/icingaweb2 /etc/icingaweb2
RUN install -o www-data -g icingaweb2 -m 02770 -d /etc/icingaweb2/enabledModules ;\
ln -vs /usr/share/icingaweb2/modules/monitoring /etc/icingaweb2/enabledModules/monitoring ;\
ln -vs /usr/share/icingaweb2/modules/graphite /etc/icingaweb2/enabledModules/graphite ;\
locale-gen -j 4
COPY .docker/apache2-site.conf /etc/apache2/sites-available/icingaweb2.conf
RUN a2enmod proxy; a2enmod proxy_http; a2ensite icingaweb2
COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord /usr/local/bin/supervisord
COPY .docker/supervisord.conf /etc/
CMD icingacli graphite icinga2 config >/etc/icinga2/conf.d/graphite.conf ;\
exec supervisord -c /etc/supervisord.conf

View file

@ -22,4 +22,4 @@ the monitoring module.
* [Installation](doc/02-Installation.md)
* [Configuration](doc/03-Configuration.md)
* [Templates](doc/04-Templates.md)
* [Demonstration](doc/06-Demonstration.md)
* [Development](doc/06-Development.md)

View file

@ -1,37 +0,0 @@
# <a id="Demonstration"></a>Demonstration
This repository ships a [Dockerfile](../Dockerfile.demo) for demonstrating
and/or developing this module (but not for using it in production).
Build:
```bash
docker build -t icingaweb2-module-graphite-demo -f Dockerfile.demo .
```
Run:
```bash
docker run -itp 8080:80 icingaweb2-module-graphite-demo
```
The container serves an Icinga Web 2 with this module and all dependencies
at http://localhost:8080/icingaweb2 and Graphite Web at http://localhost:8080.
Icinga monitors dummy services yielding random perfdata
as expected by the shipped graph templates.
Use the container for development without re-building:
```bash
docker run -itp 8080:80 -v "$(pwd):/usr/share/icingaweb2/modules/graphite" icingaweb2-module-graphite-demo
```
Code changes are visible immediately, but graph template changes
require a container restart.
Preserve graphs:
```bash
docker run -itp 8080:80 -v "$(pwd)/.whisper:/opt/graphite/storage/whisper" icingaweb2-module-graphite-demo
```

15
doc/06-Development.md Normal file
View file

@ -0,0 +1,15 @@
# Development
This module provides a CLI command for demonstrating
graph templates (useful for developing them):
```bash
icingacli graphite icinga2 config
```
It generates Icinga 2 config based on the present graph templates.
With this config Icinga will (also) "monitor" dummy services yielding random
perfdata as expected by the graph templates.
I. e.: If that Icinga is also writing to the Graphite that is
read by this module, you'll get dummy graphs for all templates.