diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2024-12-28 15:18:44 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2025-03-14 00:57:49 +0100 |
commit | ee99bd561bcb5cb0d8f18c5290840280018c35db (patch) | |
tree | fda41fcf2628d41d9e51e52efdbaebaba2baca9b /systems/monitoring-1/monitoring/run.sh | |
parent | 31e6906d71fb5e2133dd91d55196048fcc387ea0 (diff) | |
download | Nix-ee99bd561bcb5cb0d8f18c5290840280018c35db.tar.gz Nix-ee99bd561bcb5cb0d8f18c5290840280018c35db.tar.zst Nix-ee99bd561bcb5cb0d8f18c5290840280018c35db.zip |
Add docker monitoring
Diffstat (limited to 'systems/monitoring-1/monitoring/run.sh')
-rw-r--r-- | systems/monitoring-1/monitoring/run.sh | 47 |
1 files changed, 47 insertions, 0 deletions
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 | |||
3 | function 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 | ||
11 | if [ -n "$NAMESPACE" ]; then | ||
12 | echo "Namespace: $NAMESPACE" | ||
13 | else | ||
14 | echo "Le namespace n'a pas été défini dans \$NAMESPACE." | ||
15 | exit 1 | ||
16 | fi | ||
17 | |||
18 | curl -o /etc/naemon/conf.d/objects.cfg "https://status.immae.eu/$NAMESPACE/objects.conf" | ||
19 | curl -o /etc/naemon/module-conf.d/immae.cfg "https://status.immae.eu/common/immae.cfg" | ||
20 | curl -o /etc/naemon/resource.cfg "https://status.immae.eu/common/resource.cfg" | ||
21 | |||
22 | curl "https://status.immae.eu/$NAMESPACE/plugins.tar" | tar -C /etc/naemon -x | ||
23 | |||
24 | sed -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 | ||
31 | chown -R naemon:naemon /etc/naemon /data/var/log/naemon | ||
32 | |||
33 | # Start the services | ||
34 | service naemon start | ||
35 | |||
36 | # Trap exit signals and do a proper shutdown | ||
37 | trap "graceful_exit 0;" SIGINT SIGTERM | ||
38 | |||
39 | sleep 5 | ||
40 | while true | ||
41 | do | ||
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 | ||
47 | done | ||