Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
bfa5149
Add fichier.txt
MalikCherfi May 28, 2026
88909eb
Add erreur.txt with listed error of server.log
MalikCherfi May 28, 2026
3516a4e
Add rapport.txt file
MalikCherfi May 28, 2026
d65f4f2
Update README.txt
MalikCherfi May 28, 2026
8599f2c
create setting.txt file
MalikCherfi May 28, 2026
a1fade3
create app.log file with log of server.log file
MalikCherfi May 28, 2026
78468f2
create app.log.bak file ( copy of app.log )
MalikCherfi May 28, 2026
adc5550
create app.sh file
MalikCherfi May 28, 2026
d286b0b
create info.sh file
MalikCherfi May 28, 2026
88ff68f
Add env information log script
MalikCherfi May 28, 2026
13e1aaf
Creat check-logs.sh - show log state and show alert
MalikCherfi May 28, 2026
01ba7a4
Add dynamic path for log file and add empty argument verification
MalikCherfi May 28, 2026
a69e2fc
Add level analysis script
MalikCherfi May 28, 2026
ac9f4b5
Add rapport.sh file - script to create report file
MalikCherfi May 28, 2026
135d712
Create report file
MalikCherfi May 28, 2026
5391965
test - Add for loop to handle multiple files
MalikCherfi May 28, 2026
f416e70
Add couleurs.sh file
MalikCherfi May 28, 2026
81c659f
Add check-env.sh file
MalikCherfi May 28, 2026
f6968fa
complete setup script
MalikCherfi May 28, 2026
3ba3ea6
Add .env on gitignore
MalikCherfi May 28, 2026
a91645c
Show port from .env
MalikCherfi May 28, 2026
d22d72c
Add bin bash
MalikCherfi May 28, 2026
9b6a95a
fix syntax errors
MalikCherfi May 28, 2026
5be3a32
fix syntax errors
MalikCherfi May 28, 2026
8aacb21
fix syntax errors in setup.sh file
MalikCherfi May 28, 2026
091dabe
update export
MalikCherfi May 28, 2026
50c8d7c
Add argument
MalikCherfi May 28, 2026
d2855a8
fix export
MalikCherfi May 28, 2026
50002dd
update .env export ( test )
MalikCherfi May 28, 2026
da51eb9
fix export
MalikCherfi May 28, 2026
bd7e58d
replace export
MalikCherfi May 28, 2026
451ddc6
Add ci to gitignore
MalikCherfi May 28, 2026
0e7d49b
remove argument
MalikCherfi May 28, 2026
87ec388
Add default path
MalikCherfi May 28, 2026
63c5321
fix condition
MalikCherfi May 28, 2026
0a29e6c
Add condition to export
MalikCherfi May 28, 2026
3e73829
Add condition
MalikCherfi May 28, 2026
7b8456b
Add environment variables
MalikCherfi May 28, 2026
e9f7e04
remove .env from gitignore
MalikCherfi May 28, 2026
ce38f32
fix export
MalikCherfi May 28, 2026
b5b715e
fix while loop
MalikCherfi May 28, 2026
3fe84c8
Update file name
MalikCherfi May 28, 2026
2fd902b
Update file name
MalikCherfi May 28, 2026
1229405
shellcheck disable=SC2046
MalikCherfi May 28, 2026
44a2400
Add script to login to azure
MalikCherfi May 29, 2026
610238a
place file into src and rename file
MalikCherfi May 29, 2026
d7336b0
Add azure storage script
MalikCherfi May 29, 2026
761887f
Add script to create keyvault
MalikCherfi May 29, 2026
ad98c31
Add script to create vm
MalikCherfi May 29, 2026
87165f3
fix: remove unused variable
MalikCherfi Jun 3, 2026
c2dc936
fix: Add double quote for $IP variable
MalikCherfi Jun 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PORT="5001"
ENV="development"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ terraform.rc

# Ignore MacOS system files
.DS_Store
.ci.yml

# Optional: ignore graph output files generated by `terraform graph`
# *.dot
Expand Down
2 changes: 2 additions & 0 deletions fichier.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Bonjour
Monde
41 changes: 41 additions & 0 deletions mon-projet/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Mon projet Bash

# 1. Combien de lignes contient server.log ?

Le fichier server.log contient 22 lignes.

# 2. Affichez uniquement les 5 premières lignes

2024-01-15 08:00:01 INFO Application started on port 8080
2024-01-15 08:00:05 INFO Connected to Azure SQL Database successfully
2024-01-15 08:01:22 WARNING High memory usage detected: 78%
2024-01-15 08:02:45 ERROR Failed to connect to Azure Storage: connection timeout
2024-01-15 08:03:10 INFO Request processed: GET /api/health [200]

# 3. Affichez uniquement les 3 dernières lignes

2024-01-15 08:19:30 CRITICAL Azure Key Vault unreachable — secrets cannot be retrieved
2024-01-15 08:20:00 INFO Health check passed: all 3 replicas running
2024-01-15 08:21:00 CRITICAL Disk full on /var/log — logging suspended

# 4. Combien de lignes contiennent le mot ERROR ?

5 lignes contiennent le mot "ERROR".

# 5. Affichez toutes les lignes WARNING

2024-01-15 08:01:22 WARNING High memory usage detected: 78%
2024-01-15 08:06:15 WARNING CPU usage spike detected: 92%
2024-01-15 08:10:15 WARNING Disk space below threshold: 15% remaining on /dev/sda1
2024-01-15 08:16:30 WARNING SSL certificate expires in 14 days for api.azuretech.fr

# 6. Affichez toutes les lignes CRITICAL

2024-01-15 08:18:00 CRITICAL Database connection pool exhausted — all 20 connections in use
2024-01-15 08:19:30 CRITICAL Azure Key Vault unreachable — secrets cannot be retrieved
2024-01-15 08:21:00 CRITICAL Disk full on /var/log — logging suspended

# 7. Combien d'erreurs ET de critiques y a-t-il au total ?

Il y'en a 8 au total.

Empty file added mon-projet/config/settings.txt
Empty file.
5 changes: 5 additions & 0 deletions mon-projet/erreur.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
2024-01-15 08:02:45 ERROR Failed to connect to Azure Storage: connection timeout
2024-01-15 08:05:33 ERROR Authentication failed for service account: deploy_svc
2024-01-15 08:07:42 ERROR Database query timeout after 30s on table: audit_logs
2024-01-15 08:09:00 ERROR Max retries exceeded - Azure Storage service unavailable
2024-01-15 08:12:45 ERROR Backup failed: insufficient permissions on /var/backup/azure
22 changes: 22 additions & 0 deletions mon-projet/logs/app.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
2024-01-15 08:00:01 INFO Application started on port 8080
2024-01-15 08:00:05 INFO Connected to Azure SQL Database successfully
2024-01-15 08:01:22 WARNING High memory usage detected: 78%
2024-01-15 08:02:45 ERROR Failed to connect to Azure Storage: connection timeout
2024-01-15 08:03:10 INFO Request processed: GET /api/health [200]
2024-01-15 08:05:33 ERROR Authentication failed for service account: deploy_svc
2024-01-15 08:06:15 WARNING CPU usage spike detected: 92%
2024-01-15 08:07:42 ERROR Database query timeout after 30s on table: audit_logs
2024-01-15 08:08:00 INFO Retry attempt 1/3 for Azure Storage connection
2024-01-15 08:08:30 INFO Retry attempt 2/3 for Azure Storage connection
2024-01-15 08:09:00 ERROR Max retries exceeded - Azure Storage service unavailable
2024-01-15 08:10:15 WARNING Disk space below threshold: 15% remaining on /dev/sda1
2024-01-15 08:11:22 INFO Backup job started: daily-backup-2024-01-15
2024-01-15 08:12:45 ERROR Backup failed: insufficient permissions on /var/backup/azure
2024-01-15 08:14:03 INFO Alert sent to monitoring team via Azure Monitor
2024-01-15 08:15:00 INFO Scheduled maintenance check completed
2024-01-15 08:16:30 WARNING SSL certificate expires in 14 days for api.azuretech.fr
2024-01-15 08:18:00 CRITICAL Database connection pool exhausted — all 20 connections in use
2024-01-15 08:18:55 INFO Kubernetes pod restarted: api-deployment-7d9f8b-xkp2m
2024-01-15 08:19:30 CRITICAL Azure Key Vault unreachable — secrets cannot be retrieved
2024-01-15 08:20:00 INFO Health check passed: all 3 replicas running
2024-01-15 08:21:00 CRITICAL Disk full on /var/log — logging suspended
22 changes: 22 additions & 0 deletions mon-projet/logs/app.log.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
2024-01-15 08:00:01 INFO Application started on port 8080
2024-01-15 08:00:05 INFO Connected to Azure SQL Database successfully
2024-01-15 08:01:22 WARNING High memory usage detected: 78%
2024-01-15 08:02:45 ERROR Failed to connect to Azure Storage: connection timeout
2024-01-15 08:03:10 INFO Request processed: GET /api/health [200]
2024-01-15 08:05:33 ERROR Authentication failed for service account: deploy_svc
2024-01-15 08:06:15 WARNING CPU usage spike detected: 92%
2024-01-15 08:07:42 ERROR Database query timeout after 30s on table: audit_logs
2024-01-15 08:08:00 INFO Retry attempt 1/3 for Azure Storage connection
2024-01-15 08:08:30 INFO Retry attempt 2/3 for Azure Storage connection
2024-01-15 08:09:00 ERROR Max retries exceeded - Azure Storage service unavailable
2024-01-15 08:10:15 WARNING Disk space below threshold: 15% remaining on /dev/sda1
2024-01-15 08:11:22 INFO Backup job started: daily-backup-2024-01-15
2024-01-15 08:12:45 ERROR Backup failed: insufficient permissions on /var/backup/azure
2024-01-15 08:14:03 INFO Alert sent to monitoring team via Azure Monitor
2024-01-15 08:15:00 INFO Scheduled maintenance check completed
2024-01-15 08:16:30 WARNING SSL certificate expires in 14 days for api.azuretech.fr
2024-01-15 08:18:00 CRITICAL Database connection pool exhausted — all 20 connections in use
2024-01-15 08:18:55 INFO Kubernetes pod restarted: api-deployment-7d9f8b-xkp2m
2024-01-15 08:19:30 CRITICAL Azure Key Vault unreachable — secrets cannot be retrieved
2024-01-15 08:20:00 INFO Health check passed: all 3 replicas running
2024-01-15 08:21:00 CRITICAL Disk full on /var/log — logging suspended
16 changes: 16 additions & 0 deletions mon-projet/logs/rapport-20260528-120402.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
RAPPORT D'ANALYSE — 28/05/2026 12:04

--- Compteurs ---
INFO=10 WARNING=4 ERROR=5 CRITICAL=3

--- Incidents critiques ---
2024-01-15 08:18:00 CRITICAL Database connection pool exhausted — all 20 connections in use
2024-01-15 08:19:30 CRITICAL Azure Key Vault unreachable — secrets cannot be retrieved
2024-01-15 08:21:00 CRITICAL Disk full on /var/log — logging suspended

--- Erreurs ---
2024-01-15 08:02:45 ERROR Failed to connect to Azure Storage: connection timeout
2024-01-15 08:05:33 ERROR Authentication failed for service account: deploy_svc
2024-01-15 08:07:42 ERROR Database query timeout after 30s on table: audit_logs
2024-01-15 08:09:00 ERROR Max retries exceeded - Azure Storage service unavailable
2024-01-15 08:12:45 ERROR Backup failed: insufficient permissions on /var/backup/azure
5 changes: 5 additions & 0 deletions mon-projet/rapport.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=== RAPPORT DE LOGS ===
22 lignes au total
5 ERROR
4 WARNING
3 CRITICAL
14 changes: 14 additions & 0 deletions mon-projet/src/analyse-niveaux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# analyse-niveaux.sh — Compte chaque niveau de log

LOG_FILE="ressources/server.log"

echo "=== Analyse par niveau ==="

for NIVEAU in INFO WARNING ERROR CRITICAL; do
NB=$(grep -c "$NIVEAU" "$LOG_FILE")
echo " $NIVEAU : $NB occurrence(s)"
done

echo "=========================="
echo " TOTAL : $(wc -l < "$LOG_FILE") lignes"
1 change: 1 addition & 0 deletions mon-projet/src/app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/bash
32 changes: 32 additions & 0 deletions mon-projet/src/azure-keyvault.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# azure-keyvault.sh — Crée un Key Vault et ajoute un secret

KEYVAULT_NAME="kv-nexacloud-$RANDOM"
RESOURCE_GROUP="mcherfiRG"
LOCATION="francecentral"

# Créer le Key Vault
az keyvault create \
--name "$KEYVAULT_NAME" \
--resource-group "$RESOURCE_GROUP" \
--location "$LOCATION"

# Ajouter un secret
az keyvault secret set \
--vault-name "$KEYVAULT_NAME" \
--name "db-password" \
--value "MonMotDePasse123!"

# Récupérer un secret dans un script
SECRET=$(az keyvault secret show \
--vault-name "$KEYVAULT_NAME" \
--name "db-password" \
--query "value" \
--output tsv)

echo "Secret récupéré (longueur : ${#SECRET} caractères)"

# Lister tous les secrets
az keyvault secret list \
--vault-name "$KEYVAULT_NAME" \
--output table
49 changes: 49 additions & 0 deletions mon-projet/src/azure-login.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
# azure.sh — Azure CLI et automatisation cloud

RESOURCE_GROUP="mcherfiRG"

VERT="\033[0;32m"
ROUGE="\033[0;31m"
CYAN="\033[0;36m"
RESET="\033[0m"

info() { echo -e "${CYAN}[INFO]${RESET} $1"; }
ok() { echo -e "${VERT}[OK]${RESET} $1"; }
warn() { echo -e "${JAUNE}[WARN]${RESET} $1"; }
err() {
echo -e "${ROUGE}[ERR]${RESET} $1"
exit 1
}

# Vérifier que Azure CLI est installé
if az --version &>/dev/null; then
ok "Azure CLI installé"
else
err "Azure CLI non trouvé. Veuillez l'installer pour continuer."
fi

# Se connecter à Azure
if az login; then
ok "Connexion réussie à Azure"
else
err "Erreur de connexion"
fi

# Vérifier le compte actif
info "Vérification du compte Azure actif..."
echo ""
if az account show &>/dev/null; then
ok "Compte Azure actif : $(az account show --query 'user.name' -o tsv)"
else
err "Aucun compte Azure actif. Veuillez vous connecter avec 'az login'."
fi

echo ""

# Vérifier que le groupe a été créé
if az group show --name "$RESOURCE_GROUP" --query "properties.provisioningState" -o tsv &>/dev/null; then
ok "Groupe de ressources '$RESOURCE_GROUP' trouvé"
else
err "Groupe de ressources '$RESOURCE_GROUP' non trouvé. Veuillez le créer avec 'az group create'."
fi
60 changes: 60 additions & 0 deletions mon-projet/src/azure-storage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
# azure-storage.sh — Crée un compte de stockage et uploade server.log

set -e

RESOURCE_GROUP="mcherfiRG"
LOCATION="francecentral"
STORAGE_ACCOUNT="stnexacloud$RANDOM"
CONTAINER="logs"
FICHIER_LOCAL="ressources/server.log"
FICHIER_BLOB="server.log"

echo "=== Création du compte de stockage Azure ==="

# Créer le compte de stockage
az storage account create \
--name "$STORAGE_ACCOUNT" \
--resource-group "$RESOURCE_GROUP" \
--location "$LOCATION" \
--sku Standard_LRS \
--kind StorageV2 \
--output none

echo "Compte créé : $STORAGE_ACCOUNT"

# Récupérer la clé de connexion
CLE=$(az storage account keys list \
--resource-group "$RESOURCE_GROUP" \
--account-name "$STORAGE_ACCOUNT" \
--query "[0].value" \
--output tsv)

# Créer un conteneur
az storage container create \
--name "$CONTAINER" \
--account-name "$STORAGE_ACCOUNT" \
--account-key "$CLE" \
--output none

echo "Conteneur créé : $CONTAINER"

# Uploader server.log
az storage blob upload \
--container-name "$CONTAINER" \
--file "$FICHIER_LOCAL" \
--name "$FICHIER_BLOB" \
--account-name "$STORAGE_ACCOUNT" \
--account-key "$CLE" \
--output none

echo "Fichier uploadé : $FICHIER_BLOB"

# Lister les blobs du conteneur
echo ""
echo "=== Contenu du conteneur ==="
az storage blob list \
--container-name "$CONTAINER" \
--account-name "$STORAGE_ACCOUNT" \
--account-key "$CLE" \
--output table
31 changes: 31 additions & 0 deletions mon-projet/src/azure-vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# azure-vm.sh — Crée une machine virtuelle et se connecte en SSH

RESOURCE_GROUP="mcherfiRG"

VM_NAME="vm-nexacloud-tp"
VM_IMAGE="Ubuntu2204"
VM_SIZE="Standard_D2s_v3"

# Créer une VM avec clé SSH générée automatiquement
az vm create \
--resource-group "$RESOURCE_GROUP" \
--name "$VM_NAME" \
--image "$VM_IMAGE" \
--size "$VM_SIZE" \
--admin-username "malikcherfi" \
--ssh-key-values ~/.ssh/id_ed25519.pub \
--output json

# Récupérer l'IP publique
IP=$(az vm show \
--resource-group "$RESOURCE_GROUP" \
--name "$VM_NAME" \
--show-details \
--query "publicIps" \
--output tsv)

echo "IP de la VM : $IP"

# Se connecter en SSH
ssh -i ~/.ssh/id_ed25519 malikcherfi@"$IP"
58 changes: 58 additions & 0 deletions mon-projet/src/check-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
# check-env.sh — Vérifie que l'environnement est prêt pour NexaCloud

set -e

VERT="\033[0;32m"
ROUGE="\033[0;31m"
JAUNE="\033[0;33m"
RESET="\033[0m"

ok() { echo -e "${VERT} [OK]${RESET} $1"; }
warn() { echo -e "${JAUNE} [WARN]${RESET} $1"; }
err() { echo -e "${ROUGE} [ERR]${RESET} $1"; }

# Cette fonction vérifie si une commande est installée
# $1 = nom de la commande | $2 = nom à afficher (optionnel)
verifier_commande() {
local cmd="$1"
local nom="${2:-$1}"
# La commande "command -v" vérifie si un programme existe
# &>/dev/null redirige la sortie pour ne rien afficher
if command -v "$cmd" &>/dev/null; then
ok "$nom installé"
else
err "$nom non trouvé"
fi
}

echo ""
echo "=== Vérification de l'environnement NexaCloud ==="
echo ""

# TODO: appelez verifier_commande pour tester python3, node, npm et git
# Exemple : verifier_commande "python3" "Python"

for cmd in python3 node npm git; do
verifier_commande "$cmd"
done

echo ""

# TODO: vérifiez que ces deux fichiers existent avec [ -f ]
# et affichez ok ou warn selon le résultat
# Fichiers à vérifier : "config.json" et "ressources/server.log"

for file in "$@"; do
if [ -f "$file" ]; then
ok "Fichier $file trouvé"
else
warn "Fichier $file manquant"
fi
done



echo ""
echo "=== Vérification terminée ==="
echo ""
Loading
Loading