Merge branch 'develop'
This commit is contained in:
commit
007d87165d
BIN
Documents/Rapport_mensuelle_PFE_octobre_2025.pdf
Normal file
BIN
Documents/Rapport_mensuelle_PFE_octobre_2025.pdf
Normal file
Binary file not shown.
@ -1,4 +1,3 @@
|
||||
version: "3.8"
|
||||
services:
|
||||
prometheus:
|
||||
image: prom/prometheus:latest
|
||||
@ -47,8 +46,24 @@ services:
|
||||
- /var/log:/var/log:ro
|
||||
command:
|
||||
- -config.file=/etc/promtail/config.yaml
|
||||
#depends_on:
|
||||
# - loki
|
||||
networks:
|
||||
- observability
|
||||
node_exporter:
|
||||
image: prom/node-exporter:latest
|
||||
container_name: node-exporter
|
||||
restart: unless-stopped
|
||||
pid: "host"
|
||||
network_mode: "host"
|
||||
volumes:
|
||||
- /proc:/host/proc:ro
|
||||
- /sys:/host/sys:ro
|
||||
- /:/rootfs:ro
|
||||
command:
|
||||
- '--path.procfs=/host/proc'
|
||||
- '--path.sysfs=/host/sys'
|
||||
- '--collector.filesystem.ignored-mount-points="^/(sys|proc|dev|host|etc)($$|/)"'
|
||||
volumes:
|
||||
grafana-data:
|
||||
networks:
|
||||
|
||||
@ -6,10 +6,19 @@ scrape_configs:
|
||||
static_configs:
|
||||
- targets: ['localhost:9090']
|
||||
|
||||
#- job_name: 'node_exporter_vmservices'
|
||||
# static_configs:
|
||||
# - targets: ['192.168.56.31:9100']
|
||||
- job_name: 'observabilite'
|
||||
static_configs:
|
||||
- targets: ['192.168.56.16:9100'] #ip de la machine observabilite
|
||||
|
||||
- job_name: 'scaphandre'
|
||||
static_configs:
|
||||
- targets: ['192.168.56.16:8080']
|
||||
fallback_scrape_protocol: "PrometheusText1.0.0"
|
||||
|
||||
- job_name: 'apache_vmservices'
|
||||
static_configs:
|
||||
- targets: ['192.168.56.32:9117'] #ip vmService
|
||||
- targets: ['192.168.56.17:9117'] #ip vmService
|
||||
|
||||
- job_name: 'vms'
|
||||
static_configs:
|
||||
- targets: ['192.168.56.18:9100'] #ip vmHardware
|
||||
|
||||
@ -17,3 +17,10 @@ scrape_configs:
|
||||
job: docker
|
||||
__path__: /var/lib/docker/containers/*/*.log
|
||||
|
||||
- job_name: system_logs
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: syslog
|
||||
__path__: /var/log/*.log
|
||||
@ -59,6 +59,7 @@ sudo systemctl status tomcat --no-pager
|
||||
|
||||
echo "=== Déploiement du WAR ArchiWeb ==="
|
||||
sudo cp /vagrant/archiweb-api-1.0.0.war /opt/tomcat/webapps/
|
||||
sudo mv /opt/tomcat/webapps/archiweb-api-1.0.0.war /opt/tomcat/webapps/api.war
|
||||
|
||||
echo "=== Installation PostgreSQL 18 ==="
|
||||
echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
|
||||
@ -72,6 +73,8 @@ DROP DATABASE IF EXISTS archiweb_db;
|
||||
CREATE DATABASE archiweb_db;
|
||||
CREATE USER archiweb_user WITH ENCRYPTED PASSWORD 'archiweb_pass';
|
||||
GRANT ALL PRIVILEGES ON DATABASE archiweb_db TO archiweb_user;
|
||||
\c archiweb_db
|
||||
GRANT ALL ON SCHEMA public TO archiweb_user;
|
||||
\q
|
||||
EOF
|
||||
|
||||
@ -82,9 +85,34 @@ sudo systemctl restart postgresql
|
||||
sudo systemctl status postgresql --no-pager
|
||||
|
||||
echo "=== Import des schémas et données ==="
|
||||
<<<<<<< HEAD
|
||||
#sudo -u archiweb_user psql -U archiweb_user -d archiweb_db -f /vagrant/database/schema.sql -W <<< "archiweb_pass"
|
||||
#sudo -u archiweb_user psql -U archiweb_user -d archiweb_db -f /vagrant/database/data.sql -W <<< "archiweb_pass"
|
||||
PGPASSWORD=archiweb_pass psql -U archiweb_user -d archiweb_db -f /vagrant/database/schema.sql
|
||||
PGPASSWORD=archiweb_pass psql -U archiweb_user -d archiweb_db -f /vagrant/database/data.sql
|
||||
=======
|
||||
# Attendre que PostgreSQL soit complètement redémarré
|
||||
sleep 3
|
||||
>>>>>>> develop
|
||||
|
||||
echo "=== Installation et déploiement terminé ==="
|
||||
# Import avec PGPASSWORD et vérification des fichiers
|
||||
if [ -f /vagrant/database/schema.sql ]; then
|
||||
echo "Import du schéma..."
|
||||
PGPASSWORD=archiweb_pass psql -h localhost -U archiweb_user -d archiweb_db -f /vagrant/database/schema.sql
|
||||
else
|
||||
echo "ERREUR: Fichier schema.sql introuvable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f /vagrant/database/data.sql ]; then
|
||||
echo "Import des données..."
|
||||
PGPASSWORD=archiweb_pass psql -h localhost -U archiweb_user -d archiweb_db -f /vagrant/database/data.sql
|
||||
else
|
||||
echo "ERREUR: Fichier data.sql introuvable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Vérification de l'import ==="
|
||||
PGPASSWORD=archiweb_pass psql -h localhost -U archiweb_user -d archiweb_db -c "\dt"
|
||||
|
||||
echo "=== Installation et déploiement terminé ==="
|
||||
@ -6,7 +6,7 @@ PROMTAIL_VERSION="v3.1.1"
|
||||
PROMTAIL_DIR="/opt/promtail"
|
||||
CONFIG_DIR="/etc/promtail"
|
||||
TOMCAT_LOG_DIR="/opt/tomcat/logs"
|
||||
LOKI_URL="http://192.168.56.20:3100/loki/api/v1/push"
|
||||
LOKI_URL="http://192.168.56.16:3100/loki/api/v1/push"
|
||||
PROMTAIL_USER="promtail"
|
||||
PROMTAIL_GROUP="promtail"
|
||||
TOMCAT_GROUP="tomcatlogs"
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
sudo mv /opt/tomcat/webapps/archiweb-api-1.0.0.war /opt/tomcat/webapps/api.war
|
||||
|
||||
ALTER TABLE utilisateur ADD COLUMN token_reinitialisation VARCHAR(255);
|
||||
|
||||
root@vmApplicatif:/opt/tomcat/webapps# psql -U archiweb_user -d archiweb_db
|
||||
Password for user archiweb_user: archiweb_pass
|
||||
|
||||
archiweb_db=> \dt
|
||||
List of tables
|
||||
Schema | Name | Type | Owner
|
||||
--------+------------------+-------+---------------
|
||||
public | contenu_cours | table | archiweb_user
|
||||
public | cours | table | archiweb_user
|
||||
public | devoir | table | archiweb_user
|
||||
public | enseignement | table | archiweb_user
|
||||
public | inscription | table | archiweb_user
|
||||
public | note | table | archiweb_user
|
||||
public | rendu_devoir | table | archiweb_user
|
||||
public | role | table | archiweb_user
|
||||
public | utilisateur | table | archiweb_user
|
||||
public | utilisateur_role | table | archiweb_user
|
||||
(10 rows)
|
||||
|
||||
archiweb_db=> \d utilisateur
|
||||
Table "public.utilisateur"
|
||||
Column | Type | Collation | Nullable | Default
|
||||
--------------+------------------------+-----------+----------+-----------------------------------------
|
||||
id | bigint | | not null | nextval('utilisateur_id_seq'::regclass)
|
||||
login | character varying(8) | | not null |
|
||||
mot_de_passe | character varying(255) | | not null |
|
||||
nom | character varying(100) | | |
|
||||
prenom | character varying(100) | | |
|
||||
email | character varying(255) | | |
|
||||
|
||||
NB:
|
||||
archiweb_db=> ALTER TABLE utilisateur ADD COLUMN token_reinitialisation VARCHAR(255);
|
||||
ALTER TABLE
|
||||
archiweb_db=> \d utilisateur
|
||||
Table "public.utilisateur"
|
||||
Column | Type | Collation | Nullable | Default
|
||||
------------------------+------------------------+-----------+----------+-----------------------------------------
|
||||
id | bigint | | not null | nextval('utilisateur_id_seq'::regclass)
|
||||
login | character varying(8) | | not null |
|
||||
mot_de_passe | character varying(255) | | not null |
|
||||
nom | character varying(100) | | |
|
||||
prenom | character varying(100) | | |
|
||||
email | character varying(255) | | |
|
||||
token_reinitialisation | character varying(255) | | |
|
||||
|
||||
archiweb_db=> \q
|
||||
|
||||
root@vmApplicatif:/opt/tomcat/webapps# sudo systemctl restart postgresql
|
||||
root@vmApplicatif:/opt/tomcat/webapps# sudo systemctl status postgresql
|
||||
@ -0,0 +1,104 @@
|
||||
#!/bin/bash
|
||||
# ---------------------------------------------------------
|
||||
# Script d'installation automatique de Node Exporter + Promtail
|
||||
# Compatible Debian/Ubuntu
|
||||
# ---------------------------------------------------------
|
||||
|
||||
set -e # Stoppe le script en cas d'erreur
|
||||
|
||||
# --- Variables globales ---
|
||||
NODE_EXPORTER_VERSION="1.7.0"
|
||||
PROMTAIL_VERSION="2.9.2"
|
||||
LOKI_SERVER_IP="192.168.56.16" # à modifier selon ton environnement
|
||||
HOSTNAME_LABEL=$(hostname)
|
||||
|
||||
# --- Vérification utilisateur root ---
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Ce script doit être exécuté en tant que root (sudo)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🚀 Mise à jour du système..."
|
||||
apt update -y && apt install -y wget unzip
|
||||
|
||||
# --- Installation de Node Exporter ---
|
||||
echo "Installation de Node Exporter v${NODE_EXPORTER_VERSION}..."
|
||||
cd /tmp
|
||||
wget -q https://github.com/prometheus/node_exporter/releases/download/v${NODE_EXPORTER_VERSION}/node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz
|
||||
tar xvf node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz
|
||||
mv node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64/node_exporter /usr/local/bin/
|
||||
useradd -rs /bin/false nodeusr || true
|
||||
|
||||
cat >/etc/systemd/system/node_exporter.service <<EOF
|
||||
[Unit]
|
||||
Description=Node Exporter
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=nodeusr
|
||||
ExecStart=/usr/local/bin/node_exporter
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now node_exporter
|
||||
echo "Node Exporter installé et démarré."
|
||||
|
||||
# --- Installation de Promtail ---
|
||||
echo "Installation de Promtail v${PROMTAIL_VERSION}..."
|
||||
cd /tmp
|
||||
wget -q https://github.com/grafana/loki/releases/download/v${PROMTAIL_VERSION}/promtail-linux-amd64.zip
|
||||
unzip -o promtail-linux-amd64.zip
|
||||
mv promtail-linux-amd64 /usr/local/bin/promtail
|
||||
chmod +x /usr/local/bin/promtail
|
||||
|
||||
# --- Configuration de Promtail ---
|
||||
cat >/etc/promtail-config.yml <<EOF
|
||||
server:
|
||||
http_listen_port: 9080
|
||||
grpc_listen_port: 0
|
||||
|
||||
positions:
|
||||
filename: /tmp/positions.yaml
|
||||
|
||||
clients:
|
||||
- url: http://${LOKI_SERVER_IP}:3100/loki/api/v1/push
|
||||
|
||||
scrape_configs:
|
||||
- job_name: system
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: vm-observed
|
||||
host: ${HOSTNAME_LABEL}
|
||||
__path__: /var/log/*.log
|
||||
EOF
|
||||
|
||||
# --- Service Promtail ---
|
||||
cat >/etc/systemd/system/promtail.service <<EOF
|
||||
[Unit]
|
||||
Description=Promtail
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/promtail -config.file=/etc/promtail-config.yml
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now promtail
|
||||
echo "Promtail installé et démarré."
|
||||
|
||||
# --- Résumé ---
|
||||
echo "Installation terminée avec succès !"
|
||||
echo "----------------------------------------"
|
||||
echo "Node Exporter : http://$(hostname -I | awk '{print $1}'):9100/metrics"
|
||||
echo "Promtail : config => /etc/promtail-config.yml"
|
||||
echo "Loki Server IP : ${LOKI_SERVER_IP}:3100"
|
||||
echo "----------------------------------------"
|
||||
@ -0,0 +1,139 @@
|
||||
#!/usr/bin/env bash
|
||||
# Script de stress "fort mais contrôlable" pour VM Linux
|
||||
# - CPU : boucle infinie sur plusieurs cœurs
|
||||
# - RAM : allocation d'un pourcentage de la RAM
|
||||
# - DISK : gros fichier + lectures en boucle
|
||||
#
|
||||
# ⚠️ À adapter AVANT d'exécuter : les variables MEM_PRESSURE_PCT, DISK_FILE_SIZE_MB, etc.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
########## PARAMÈTRES À ADAPTER ##########
|
||||
# Pourcentage de RAM à consommer (50 = 50%)
|
||||
MEM_PRESSURE_PCT=60
|
||||
|
||||
# Nombre de workers CPU
|
||||
# 0 = "autant que de vCPU" (nproc)
|
||||
CPU_WORKERS=0
|
||||
|
||||
# Taille du fichier de stress disque (en MiB)
|
||||
DISK_FILE_SIZE_MB=1024 # 1024 MiB ≈ 1 GiB
|
||||
|
||||
# Répertoire temporaire utilisé pour le test disque
|
||||
TEST_DIR=/tmp/vm_stress_test
|
||||
##########################################
|
||||
|
||||
pids=()
|
||||
|
||||
cleanup() {
|
||||
echo
|
||||
echo "[*] Nettoyage en cours..."
|
||||
# On essaie de tuer proprement tous les jobs de fond
|
||||
for pid in "${pids[@]}"; do
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
kill "$pid" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
|
||||
# On attend un peu qu'ils se terminent
|
||||
sleep 1
|
||||
for pid in "${pids[@]}"; do
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
kill -9 "$pid" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
|
||||
# On supprime les fichiers disque
|
||||
rm -rf "$TEST_DIR" 2>/dev/null || true
|
||||
|
||||
echo "[*] Nettoyage terminé. La charge devrait retomber dans quelques secondes."
|
||||
}
|
||||
|
||||
trap cleanup INT TERM EXIT
|
||||
|
||||
mkdir -p "$TEST_DIR"
|
||||
|
||||
echo "=== Infos de la VM ==="
|
||||
if command -v nproc >/dev/null 2>&1; then
|
||||
echo "CPU : $(nproc) vCPU détectés"
|
||||
fi
|
||||
if [ -r /proc/meminfo ]; then
|
||||
mem_total_kb=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
|
||||
echo "RAM totale : $((mem_total_kb / 1024)) MiB"
|
||||
fi
|
||||
echo
|
||||
|
||||
########## STRESS CPU ##########
|
||||
cpu_workers=${CPU_WORKERS:-0}
|
||||
if [ "$cpu_workers" -le 0 ]; then
|
||||
cpu_workers=$(nproc)
|
||||
fi
|
||||
|
||||
echo "[*] Lancement de $cpu_workers workers CPU…"
|
||||
for ((i=0; i<cpu_workers; i++)); do
|
||||
# Boucle occupée, avec une micro-pause pour éviter un comportement trop violent
|
||||
while :; do
|
||||
: # opération vide
|
||||
: # on fait travailler un peu le CPU
|
||||
: # encore une fois
|
||||
sleep 0.001
|
||||
done &
|
||||
pids+=("$!")
|
||||
done
|
||||
|
||||
########## STRESS RAM ##########
|
||||
if [ -r /proc/meminfo ]; then
|
||||
mem_total_kb=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
|
||||
target_kb=$((mem_total_kb * MEM_PRESSURE_PCT / 100))
|
||||
echo "[*] Allocation d'environ ${MEM_PRESSURE_PCT}% de la RAM (~$((target_kb / 1024)) MiB)…"
|
||||
|
||||
python3 - <<EOF &
|
||||
import time
|
||||
|
||||
target_kb = $target_kb
|
||||
block = b"x" * 1024 # 1 KiB
|
||||
chunks = []
|
||||
|
||||
try:
|
||||
for _ in range(target_kb):
|
||||
chunks.append(block)
|
||||
# On garde la RAM occupée
|
||||
while True:
|
||||
time.sleep(1)
|
||||
except MemoryError:
|
||||
# Si on atteint la limite mémoire, on sort calmement
|
||||
time.sleep(1)
|
||||
EOF
|
||||
pids+=("$!")
|
||||
else
|
||||
echo "[!] /proc/meminfo non disponible, pas de stress RAM."
|
||||
fi
|
||||
|
||||
########## STRESS DISQUE ##########
|
||||
echo "[*] Création d'un fichier de ${DISK_FILE_SIZE_MB} MiB sur le disque et lectures en boucle…"
|
||||
(
|
||||
file="$TEST_DIR/bigfile.bin"
|
||||
# Écriture initiale
|
||||
dd if=/dev/zero of="$file" bs=1M count="$DISK_FILE_SIZE_MB" status=none
|
||||
|
||||
# Boucle de lecture en continu pour stresser le disque
|
||||
while :; do
|
||||
dd if="$file" of=/dev/null bs=1M status=none
|
||||
done
|
||||
) &
|
||||
pids+=("$!")
|
||||
|
||||
echo
|
||||
echo "=== STRESS DÉMARRÉ ==="
|
||||
echo "- CPU : $cpu_workers workers en boucle"
|
||||
echo "- RAM : ~${MEM_PRESSURE_PCT}% de la RAM allouée (si possible)"
|
||||
echo "- DISK : fichier de ${DISK_FILE_SIZE_MB} MiB lu en boucle"
|
||||
echo
|
||||
echo "Surveille l'effet avec :"
|
||||
echo " top / htop / free -h / iotop (si installé)"
|
||||
echo
|
||||
echo "▶ Appuie sur Ctrl+C pour arrêter le script."
|
||||
echo " Tous les processus de stress seront tués et les fichiers temporaires supprimés."
|
||||
|
||||
# On attend tous les jobs de fond (jusqu'à Ctrl+C)
|
||||
wait
|
||||
1
observabilite_hardware/scaphandre
Normal file
1
observabilite_hardware/scaphandre
Normal file
@ -0,0 +1 @@
|
||||
installation de scaphandre
|
||||
Loading…
x
Reference in New Issue
Block a user