scrip bench
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# API Token (généré automatiquement par install.sh)
|
# API Token (généré automatiquement par install.sh)
|
||||||
# Utilisé pour authentifier les requêtes POST /api/benchmark
|
# 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
|
# Base de données SQLite
|
||||||
DATABASE_URL=sqlite:////app/data/data.db
|
DATABASE_URL=sqlite:////app/data/data.db
|
||||||
|
|||||||
@@ -31,6 +31,17 @@ GREEN='\033[0;32m'
|
|||||||
YELLOW='\033[1;33m'
|
YELLOW='\033[1;33m'
|
||||||
NC='\033[0m' # No Color
|
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
|
# Logging functions
|
||||||
log_info() {
|
log_info() {
|
||||||
echo -e "${GREEN}[INFO]${NC} $1"
|
echo -e "${GREEN}[INFO]${NC} $1"
|
||||||
@@ -143,6 +154,8 @@ parse_args() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check dependencies (no automatic installation)
|
# Check dependencies (no automatic installation)
|
||||||
check_dependencies() {
|
check_dependencies() {
|
||||||
log_info "Checking dependencies..."
|
log_info "Checking dependencies..."
|
||||||
@@ -201,6 +214,8 @@ check_dependencies() {
|
|||||||
log_info "Dependency check completed"
|
log_info "Dependency check completed"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Collect CPU information
|
# Collect CPU information
|
||||||
collect_cpu_info() {
|
collect_cpu_info() {
|
||||||
local cpu_json="{}"
|
local cpu_json="{}"
|
||||||
@@ -258,6 +273,19 @@ collect_os_info() {
|
|||||||
echo "$os_json"
|
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
|
||||||
run_cpu_benchmark() {
|
run_cpu_benchmark() {
|
||||||
if [[ "$SKIP_CPU" == true ]]; then
|
if [[ "$SKIP_CPU" == true ]]; then
|
||||||
@@ -474,7 +502,7 @@ send_benchmark() {
|
|||||||
# Main execution
|
# Main execution
|
||||||
main() {
|
main() {
|
||||||
log_info "Linux BenchTools Client v${BENCH_SCRIPT_VERSION}"
|
log_info "Linux BenchTools Client v${BENCH_SCRIPT_VERSION}"
|
||||||
|
check_sudo #
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
check_dependencies
|
check_dependencies
|
||||||
send_benchmark
|
send_benchmark
|
||||||
|
|||||||
Reference in New Issue
Block a user