This commit is contained in:
2025-12-07 15:08:16 +01:00
parent 307e75291b
commit 2ce5e320c6
4 changed files with 726 additions and 24 deletions

View File

@@ -143,47 +143,62 @@ parse_args() {
fi
}
# Check and install required tools
# Check dependencies (no automatic installation)
check_dependencies() {
log_info "Checking dependencies..."
local missing_deps=()
local missing_essential=()
local missing_optional=()
# Essential tools
for tool in curl jq lscpu free dmidecode lsblk; do
# Essential tools (required for hardware detection)
for tool in curl jq; do
if ! command -v $tool &> /dev/null; then
missing_deps+=($tool)
missing_essential+=($tool)
fi
done
# Benchmark tools
# Optional hardware detection tools
for tool in lscpu free dmidecode lsblk; do
if ! command -v $tool &> /dev/null; then
missing_optional+=($tool)
fi
done
# Optional benchmark tools
if [[ "$SKIP_CPU" == false ]] && ! command -v sysbench &> /dev/null; then
missing_deps+=(sysbench)
missing_optional+=(sysbench)
SKIP_CPU=true
log_warn "sysbench not found - CPU benchmark will be skipped"
fi
if [[ "$SKIP_DISK" == false ]] && ! command -v fio &> /dev/null; then
missing_deps+=(fio)
missing_optional+=(fio)
SKIP_DISK=true
log_warn "fio not found - Disk benchmark will be skipped"
fi
if [[ "$SKIP_NETWORK" == false && -n "$IPERF_SERVER" ]] && ! command -v iperf3 &> /dev/null; then
missing_deps+=(iperf3)
missing_optional+=(iperf3)
SKIP_NETWORK=true
log_warn "iperf3 not found - Network benchmark will be skipped"
fi
# Try to install missing dependencies
if [[ ${#missing_deps[@]} -gt 0 ]]; then
log_warn "Missing dependencies: ${missing_deps[*]}"
if [[ -f /etc/debian_version ]]; then
log_info "Attempting to install dependencies (requires sudo)..."
sudo apt-get update -qq
sudo apt-get install -y ${missing_deps[@]}
else
log_error "Unable to install dependencies automatically. Please install: ${missing_deps[*]}"
exit 1
fi
# Check essential dependencies
if [[ ${#missing_essential[@]} -gt 0 ]]; then
log_error "Missing essential dependencies: ${missing_essential[*]}"
log_error "Please install them manually. Example (Debian/Ubuntu):"
log_error " sudo apt-get install ${missing_essential[*]}"
exit 1
fi
log_info "All dependencies satisfied"
# Info about optional dependencies
if [[ ${#missing_optional[@]} -gt 0 ]]; then
log_warn "Missing optional tools: ${missing_optional[*]}"
log_info "Some hardware info or benchmarks may be limited"
log_info "To install (Debian/Ubuntu): sudo apt-get install ${missing_optional[*]}"
fi
log_info "Dependency check completed"
}
# Collect CPU information