This commit is contained in:
Gilles Soulier
2026-01-05 16:08:01 +01:00
parent dcba044cd6
commit c67befc549
2215 changed files with 26743 additions and 329 deletions

View File

@@ -14,7 +14,7 @@ set -e
# Version / variables globales
#=========================================================
BENCH_SCRIPT_VERSION="1.3.1"
BENCH_SCRIPT_VERSION="1.3.2"
# Couleurs
GREEN='\033[0;32m'
@@ -27,9 +27,9 @@ TOTAL_STEPS=8
CURRENT_STEP=0
# Paramètres réseau / API (peuvent être surchargés par variables d'environnement)
SERVER_URL="${SERVER_URL:-10.0.1.97:8007}" # ajouter le port ou le schéma dans send_benchmark_payload si besoin
SERVER_URL="${SERVER_URL:-10.0.0.50:8007}" # ajouter le port ou le schéma dans send_benchmark_payload si besoin
API_TOKEN="${API_TOKEN:-29855796dacf5cfe75ff9b02d6adf3dd0f9c52db5b53e7abfb4c0df7ece1be0a}"
IPERF_SERVER="${IPERF_SERVER:-10.0.1.97}"
IPERF_SERVER="${IPERF_SERVER:-10.0.0.50}"
# Mode DEBUG
# Mettre à 1 pour afficher le payload JSON complet avant envoi
@@ -171,12 +171,19 @@ check_dependencies() {
echo -e "${BLUE}Installation automatique des paquets manquants...${NC}"
echo " Paquets: ${to_install[*]}"
echo ""
# Pre-configure iperf3 to not install daemon
if printf '%s\n' "${to_install[@]}" | grep -q "^iperf3$"; then
echo "► Configuration iperf3 (désactivation du daemon)..."
echo "iperf3 iperf3/start_daemon boolean false" | sudo debconf-set-selections
fi
echo "► apt-get update..."
if ! sudo apt-get update -qq 2>&1 | grep -v "Policy will reject signature"; then
log_warn "Warning durant apt-get update (on continue)"
fi
echo "► apt-get install..."
if sudo apt-get install -y "${to_install[@]}"; then
if sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "${to_install[@]}"; then
log_info "Installation des dépendances OK"
else
log_error "Échec de l'installation des dépendances"
@@ -942,11 +949,15 @@ collect_network_shares() {
collect_network_info() {
log_step "Collecte des informations réseau"
echo " → Début de collect_network_info()"
local network_array="[]"
local iface
echo " → Début de la boucle sur les interfaces réseau"
for iface in $(ip -br link show | awk '$2 ~ /UP|UNKNOWN/ {print $1}'); do
[[ "$iface" =~ ^(lo|docker|br-|veth) ]] && continue
# Filtrer les interfaces virtuelles (loopback, docker, bridges, veth, tap, fw*, vmbr)
[[ "$iface" =~ ^(lo|docker|br-|veth|tap|fw|vmbr) ]] && continue
local mac
mac=$(ip link show "$iface" | awk '/link\/ether/ {print $2}')
@@ -1021,7 +1032,11 @@ collect_network_info() {
wol_json="false"
fi
local net_json
# Debug: afficher les variables avant la création du JSON
echo " → DEBUG Interface: $iface"
echo " type='$type' mac='$mac' ip='${ip_addr:-}' speed='$speed' wol='$wol_json'"
local net_json jq_error
net_json=$(jq -n \
--arg name "$iface" \
--arg type "$type" \
@@ -1035,17 +1050,28 @@ collect_network_info() {
name: $name,
type: $type,
mac: $mac,
ip_address: ( $ip | select(. != "") ),
speed_mbps: ( ( $speed | tonumber? ) // null ),
driver: ( $driver | select(. != "") ),
ssid: ( $ssid | select(. != "") ),
ip_address: (if $ip != "" then $ip else null end),
speed_mbps: (if $speed != "" then ($speed | tonumber) else null end),
driver: (if $driver != "" then $driver else null end),
ssid: (if $ssid != "" then $ssid else null end),
wake_on_lan: $wol
}' 2>/dev/null || echo '{}')
}' 2>&1)
local jq_exit=$?
if [[ $jq_exit -ne 0 ]]; then
echo " ✗ jq ERREUR (code: $jq_exit): $net_json"
log_warn "Interface $iface: erreur jq, ignorée"
continue
fi
echo " net_json result: '$net_json'"
# Vérifier que net_json est valide avant de l'ajouter
if [[ "$net_json" != "{}" ]] && echo "$net_json" | jq empty 2>/dev/null; then
if echo "$net_json" | jq empty 2>/dev/null; then
echo " ✓ JSON valide, ajout à network_array"
network_array=$(echo "$network_array" | jq --argjson net "$net_json" '. + [$net]')
else
echo " ✗ JSON invalide, interface ignorée"
log_warn "Interface $iface: JSON invalide, ignorée"
fi
@@ -1083,7 +1109,7 @@ run_benchmarks() {
eps_single=$(echo "$cpu_single" | awk '/events per second/ {print $4}')
[[ -z "$eps_single" ]] && eps_single=0
local cpu_score_single
cpu_score_single=$(safe_bc "scale=2; $eps_single / 100")
cpu_score_single=$(safe_bc "scale=2; $eps_single")
log_info " Single-core: ${eps_single} events/sec (score: ${cpu_score_single})"
# Test multi-core (tous les threads)
@@ -1096,7 +1122,7 @@ run_benchmarks() {
[[ -z "$eps_multi" ]] && eps_multi=0
[[ -z "$time_s" ]] && time_s=0
local cpu_score_multi
cpu_score_multi=$(safe_bc "scale=2; $eps_multi / 100")
cpu_score_multi=$(safe_bc "scale=2; $eps_multi")
log_info " Multi-core: ${eps_multi} events/sec (score: ${cpu_score_multi})"
# Score global = moyenne des deux
@@ -1138,7 +1164,7 @@ run_benchmarks() {
[[ -z "$thr" ]] && thr=$(echo "$mem_res" | awk '/transferred/ {print $(NF-1)}' | head -1)
[[ -z "$thr" ]] && thr=0
local mem_score
mem_score=$(safe_bc "scale=2; $thr / 100")
mem_score=$(safe_bc "scale=2; $thr")
mem_bench=$(jq -n \
--arg thr "$thr" \
@@ -1179,7 +1205,7 @@ run_benchmarks() {
lat_ms=$(safe_bc "scale=3; $lat_ns / 1000000")
local disk_score
disk_score=$(safe_bc "scale=2; ($rmb + $wmb) / 20")
disk_score=$(safe_bc "scale=2; $rmb + $wmb")
disk_bench=$(jq -n \
--arg rmb "$rmb" \
@@ -1209,7 +1235,7 @@ run_benchmarks() {
local net_bench="null"
if command -v iperf3 &>/dev/null; then
local target="$IPERF_SERVER"
[[ -z "$target" ]] && target="10.0.1.97"
[[ -z "$target" ]] && target="10.0.0.50"
log_info "Benchmark Réseau en cours (vers $target)..."
@@ -1237,7 +1263,7 @@ run_benchmarks() {
fi
# Score réseau
local net_score=$(safe_bc "scale=2; ($upload_mbps + $download_mbps) / 20" | tr -d '\n')
local net_score=$(safe_bc "scale=2; $upload_mbps + $download_mbps" | tr -d '\n')
# S'assurer que les valeurs sont valides pour jq
[[ -z "$upload_mbps" || "$upload_mbps" == "null" ]] && upload_mbps="0"
@@ -1270,15 +1296,15 @@ run_benchmarks() {
local gpu_bench="null"
log_warn "GPU bench non implémenté - ignoré"
# Score global selon pondérations recommandées :
# CPU 30%, RAM 20%, Disque 25%, Réseau 15%, GPU 10%
# Score global selon pondérations :
# CPU 40% (double du reste), RAM 20%, Disque 20%, Réseau 10%, GPU 10%
local scores="" total_weight=0
if [[ "$cpu_bench" != "null" ]]; then
local cs
cs=$(echo "$cpu_bench" | jq '.score // 0')
scores="$scores + $cs * 0.30"
total_weight=$(safe_bc "$total_weight + 0.30")
scores="$scores + $cs * 0.40"
total_weight=$(safe_bc "$total_weight + 0.40")
fi
if [[ "$mem_bench" != "null" ]]; then
@@ -1291,15 +1317,15 @@ run_benchmarks() {
if [[ "$disk_bench" != "null" ]]; then
local ds
ds=$(echo "$disk_bench" | jq '.score // 0')
scores="$scores + $ds * 0.25"
total_weight=$(safe_bc "$total_weight + 0.25")
scores="$scores + $ds * 0.20"
total_weight=$(safe_bc "$total_weight + 0.20")
fi
if [[ "$net_bench" != "null" ]]; then
local ns
ns=$(echo "$net_bench" | jq '.score // 0')
scores="$scores + $ns * 0.15"
total_weight=$(safe_bc "$total_weight + 0.15")
scores="$scores + $ns * 0.10"
total_weight=$(safe_bc "$total_weight + 0.10")
fi
if [[ "$gpu_bench" != "null" ]]; then

View File

@@ -358,7 +358,7 @@ DEBUG: Payload JSON complet
✓ Payload sauvegardé dans: /tmp/bench_payload_20251214_092836.json
Appuyez sur Entrée pour continuer l'envoi ou Ctrl+C pour annuler...
✓ Envoi du payload vers: http://10.0.1.97:8007/api/benchmark
✓ Envoi du payload vers: http://10.0.0.50:8007/api/benchmark
✓ Payload envoyé avec succès (HTTP 200)
════════════════════════════════════════════════════════