aboutsummaryrefslogtreecommitdiff
path: root/systems/monitoring-1/monitoring
diff options
context:
space:
mode:
Diffstat (limited to 'systems/monitoring-1/monitoring')
-rw-r--r--systems/monitoring-1/monitoring/Dockerfile35
-rw-r--r--systems/monitoring-1/monitoring/docker-compose.yml15
-rw-r--r--systems/monitoring-1/monitoring/env.example5
-rw-r--r--systems/monitoring-1/monitoring/run.sh47
4 files changed, 102 insertions, 0 deletions
diff --git a/systems/monitoring-1/monitoring/Dockerfile b/systems/monitoring-1/monitoring/Dockerfile
new file mode 100644
index 0000000..4bbf01b
--- /dev/null
+++ b/systems/monitoring-1/monitoring/Dockerfile
@@ -0,0 +1,35 @@
1FROM debian:bookworm
2
3ARG namespace
4
5RUN \
6 apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
7 curl \
8 gnupg
9
10RUN \
11 curl -s "https://build.opensuse.org/projects/home:naemon/signing_keys/download?kind=gpg" | gpg --dearmor > /usr/share/keyrings/naemon.gpg \
12 && echo "deb [signed-by=/usr/share/keyrings/naemon.gpg] https://download.opensuse.org/repositories/home:/naemon/Debian_12/ ./" >> /etc/apt/sources.list.d/naemon-stable.list
13
14# Install the baseline packages for this image. Note, these
15# packages are not version controlled and may change between
16# builds.
17RUN apt-get update && \
18 DEBIAN_FRONTEND=noninteractive \
19 # La liste des packages debian à installer est directement fournie par Immae
20 apt-get install -y $(curl https://status.immae.eu/$namespace/debian-packages)
21
22# Perform the data directory initialization
23RUN mkdir -p /data/var/log/naemon \
24 && rm -rf /var/log/naemon \
25 && ln -s /data/var/log/naemon /var/log/naemon \
26 && find /etc/naemon -type f -not -name "naemon.cfg" -delete
27
28# Add the bootstrap script
29RUN curl https://status.immae.eu/common/run.sh > /run.sh
30RUN chmod 755 /run.sh
31
32# All data is stored on the root data volme
33VOLUME ["/data"]
34
35ENTRYPOINT ["/run.sh"]
diff --git a/systems/monitoring-1/monitoring/docker-compose.yml b/systems/monitoring-1/monitoring/docker-compose.yml
new file mode 100644
index 0000000..b369463
--- /dev/null
+++ b/systems/monitoring-1/monitoring/docker-compose.yml
@@ -0,0 +1,15 @@
1services:
2 naemon:
3 build:
4 context: https://status.immae.eu/common/Dockerfile
5 args:
6 - namespace=${NAMESPACE}
7 container_name: naemon
8 restart: unless-stopped
9 environment:
10 - NOTIFY_REMOTE_TOKEN=${NOTIFY_REMOTE_TOKEN}
11 - NAMESPACE=${NAMESPACE}
12 pid: host
13 network_mode: host
14 volumes:
15 - ./data/log:/data/var/log/naemon
diff --git a/systems/monitoring-1/monitoring/env.example b/systems/monitoring-1/monitoring/env.example
new file mode 100644
index 0000000..bace5a5
--- /dev/null
+++ b/systems/monitoring-1/monitoring/env.example
@@ -0,0 +1,5 @@
1# Les deux variables ci-dessous sont à demander à Immae
2# Token pour notifier le serveur distant (immae)
3NOTIFY_REMOTE_TOKEN=
4# Namespace sur immae.eu
5NAMESPACE=
diff --git a/systems/monitoring-1/monitoring/run.sh b/systems/monitoring-1/monitoring/run.sh
new file mode 100644
index 0000000..9a57990
--- /dev/null
+++ b/systems/monitoring-1/monitoring/run.sh
@@ -0,0 +1,47 @@
1#!/bin/bash
2
3function graceful_exit(){
4 # Note, "service naemon stop" does not work in the phusion image
5 # We just kill the process rather than chase this down.
6 pkill naemon
7 exit $1
8}
9
10# Recup fichiers Ismael
11if [ -n "$NAMESPACE" ]; then
12 echo "Namespace: $NAMESPACE"
13else
14 echo "Le namespace n'a pas été défini dans \$NAMESPACE."
15 exit 1
16fi
17
18curl -o /etc/naemon/conf.d/objects.cfg "https://status.immae.eu/$NAMESPACE/objects.conf"
19curl -o /etc/naemon/module-conf.d/immae.cfg "https://status.immae.eu/common/immae.cfg"
20curl -o /etc/naemon/resource.cfg "https://status.immae.eu/common/resource.cfg"
21
22curl "https://status.immae.eu/$NAMESPACE/plugins.tar" | tar -C /etc/naemon -x
23
24sed -i -e "s|@@COMMON_PLUGINS@@|/usr/lib/naemon/plugins|" \
25 -e "s|@@IMMAE_PLUGINS@@|/etc/naemon/immae_plugins/|" \
26 -e "s|@@TOKEN@@|$NOTIFY_REMOTE_TOKEN|" \
27 /etc/naemon/resource.cfg
28
29# Ensure consistent ownership for the data volume, even if the
30# UID/GID's changes
31chown -R naemon:naemon /etc/naemon /data/var/log/naemon
32
33# Start the services
34service naemon start
35
36# Trap exit signals and do a proper shutdown
37trap "graceful_exit 0;" SIGINT SIGTERM
38
39sleep 5
40while true
41do
42 if ! [ -d "/proc/$(cat /var/run/naemon/naemon.pid)" ]; then
43 echo "Naemon no longer running"
44 graceful_exit 1
45 fi
46 sleep 1
47done