From 80d8b7aa87b5e1e841cb0dc26663a7a274310649 Mon Sep 17 00:00:00 2001 From: gilles soulier Date: Sun, 7 Dec 2025 15:53:47 +0100 Subject: [PATCH] scrip bench --- .env.example | 2 +- scripts/bench.sh | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index de90f59..eda13fb 100644 --- a/.env.example +++ b/.env.example @@ -2,7 +2,7 @@ # API Token (généré automatiquement par install.sh) # Utilisé pour authentifier les requêtes POST /api/benchmark -API_TOKEN=CHANGE_ME_GENERATE_RANDOM_TOKEN +API_TOKEN=test_hardware_perf # Base de données SQLite DATABASE_URL=sqlite:////app/data/data.db diff --git a/scripts/bench.sh b/scripts/bench.sh index bea92eb..cf54b3d 100755 --- a/scripts/bench.sh +++ b/scripts/bench.sh @@ -31,6 +31,17 @@ GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color +# Function to check and renew sudo timestamp +check_sudo() { + log_info "Requesting sudo permissions for benchmark execution..." + # Ask for password once and keep the timestamp active + sudo -v + if [ $? -ne 0 ]; then + log_error "Sudo authentication failed. Required for some hardware checks (dmidecode, fio) and benchmarks." + exit 1 + fi +} + # Logging functions log_info() { echo -e "${GREEN}[INFO]${NC} $1" @@ -143,6 +154,8 @@ parse_args() { fi } + + # Check dependencies (no automatic installation) check_dependencies() { log_info "Checking dependencies..." @@ -201,6 +214,8 @@ check_dependencies() { log_info "Dependency check completed" } + + # Collect CPU information collect_cpu_info() { local cpu_json="{}" @@ -258,6 +273,19 @@ collect_os_info() { echo "$os_json" } +collect_manufacturer_info() { + # Exécution de dmidecode avec sudo + local manufacturer=$(sudo dmidecode -s system-manufacturer 2>/dev/null || echo 'Unknown') + + local json=$(jq -n \ + --arg manufacturer "$manufacturer" \ + '{ + manufacturer: $manufacturer + }' + ) + echo "$json" +} + # Run CPU benchmark run_cpu_benchmark() { if [[ "$SKIP_CPU" == true ]]; then @@ -474,7 +502,7 @@ send_benchmark() { # Main execution main() { log_info "Linux BenchTools Client v${BENCH_SCRIPT_VERSION}" - + check_sudo # parse_args "$@" check_dependencies send_benchmark