From ea28005bc937b36c34a825053160c95df371eabd Mon Sep 17 00:00:00 2001
From: anima
Date: Sat, 1 Feb 2025 14:59:43 +0100
Subject: [PATCH] add grafana module
---
Dockerfile | 11 +++++++++++
README.md | 11 ++++++-----
conf_icingaweb2.py | 9 +++++++++
init.sh | 4 +++-
4 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 0da35fb..e86df9b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -35,6 +35,17 @@ RUN ["bash", "-exo", "pipefail", "-c", "\
apt clean all ; \
rm -vrf /var/lib/apt/lists/* "]
+## install module grafana
+ARG MODULE_VERSION="3.0.0"
+ARG ICINGAWEB_MODULEPATH="/usr/share/icingaweb2/modules"
+ARG REPO_URL="https://github.com/NETWAYS/icingaweb2-module-grafana"
+ARG TARGET_DIR="${ICINGAWEB_MODULEPATH}/grafana"
+ARG URL="${REPO_URL}/archive/v${MODULE_VERSION}.tar.gz"
+RUN ["bash", "-exo", "pipefail", "-c", "\
+ install -d -m 0755 ${TARGET_DIR} ; \
+ wget -q -O - $URL | tar xfz - -C ${TARGET_DIR} --strip-components 1 ; \
+"]
+
## create persistend data store
RUN ["bash", "-exo", "pipefail", "-c", "\
mkdir -p /data ; \
diff --git a/README.md b/README.md
index 7cc32f3..5e6da77 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,7 @@ docker compose up -d
For a full deployment see: [comming soon ...]()
+If you run the setup without any environment vars the setup token will be printet in docker log!
## understand environment
For the configuration (primarily the initial setup) I use a similar method as: https://hub.docker.com/r/icinga/icingaweb2
@@ -66,16 +67,16 @@ ICINGAWEB2_GRAFANA_GRAPH | grafana | /etc/icingaweb2/modules/grafana/graphs.ini
### static vars
var | description
--- | ---
-ICINGAWEB2_CONF_ONCE | if true: all configuration setups (above) run only on fist setup.
-ICINGAWEB2_DB_RESOURCE_NAME | needed for setup scrip to know witch database is used for users
-ICINGAWEB2_DEFAULT_ADMIN_USER | default admin username
+ICINGAWEB2_CONF_ONCE | if var exists: all configuration setups (above) run only on fist setup.
+ICINGAWEB2_DB_RESOURCE_NAME | needed for setup script to know witch database is used for users
+ICINGAWEB2_DEFAULT_ADMIN_USER | default admin username addidional this var is primary identifier to run auto config
ICINGAWEB2_DEFAULT_ADMIN_PASS | default admin password
### easy setup
-If you use the example, than you kan setup the `env.sample`.
+If you use the example, than you can setup the `env.sample`.
All required variables are included and insert the values in the correct places.
-Hint: in this file all vars dont have the `2` behind icingaweb2 or icinga.
+Hint: in this file all vars dont have the `2` behind icingaweb2 or icinga2.
Vars for the container have the `2`
## example
diff --git a/conf_icingaweb2.py b/conf_icingaweb2.py
index 803efe4..0faa54a 100644
--- a/conf_icingaweb2.py
+++ b/conf_icingaweb2.py
@@ -133,6 +133,15 @@ def main():
### commandtransports.ini : https://icinga.com/docs/icinga-db-web/latest/doc/03-Configuration/#command-transport-configuration
IniFile(ICINGADB_WEB_CONFDIR + 'commandtransports.ini', 'ICINGAWEB2_ICINGADB_API__')
+ ## icingaweb2 modul: grafana
+ ICINGAWEB_GRAFANA_DIR = ICINGAWEB_CONFDIR + 'modules/grafana/'
+ ### config.ini : https://github.com/NETWAYS/icingaweb2-module-grafana/blob/main/doc/03-module-configuration.md
+ IniFile(ICINGADB_WEB_CONFDIR + 'config.ini', 'ICINGAWEB2_GRAFANA_CONF__')
+ ### grafana.ini : https://github.com/NETWAYS/icingaweb2-module-grafana/blob/main/doc/02-installation.md
+ IniFile(ICINGADB_WEB_CONFDIR + 'grafana.ini', 'ICINGAWEB2_GRAFANA_AUTH__')
+ ### graphs.ini : https://github.com/NETWAYS/icingaweb2-module-grafana/blob/main/doc/04-graph-configuration.md
+ IniFile(ICINGADB_WEB_CONFDIR + 'graph.ini', 'ICINGAWEB2_GRAFANA_GRAPH__')
+
## run db init
InitDB()
diff --git a/init.sh b/init.sh
index 3be73ae..3aa3cd6 100644
--- a/init.sh
+++ b/init.sh
@@ -21,7 +21,9 @@ if [ -z "$(ls -A /data)" ]; then
## enable modules
icingacli module enable icingadb
mkdir -p /etc/icingaweb2/modules/icingadb/
-
+
+ icingacli module enable grafana
+ mkdir -p /etc/icingaweb2/modules/grafana/
else
## print setup token because no auto deployment will run
icingacli setup token create;