Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- command -v smartctl >/dev/null || missing="${missing}smartmontools "; command -v dmidecode >/dev/null || missing="${missing}dmidecode"; echo -e '\n===== System Information =====\nHostname: '"$(hostname)"'\nUptime: '"$(uptime -p)"'\nCPU: '"$(lscpu | awk -F': +' '/Model name/{print $2; exit}')"'\nCPU Cores: '"$(nproc)"' ('"$(lscpu | awk -F': +' '/^CPU\(s\):/{print $2}')"' threads)'; if command -v dmidecode >/dev/null 2>&1; then dmi_mem=$(dmidecode -t memory 2>/dev/null); echo "RAM Size: $(echo "$dmi_mem" | awk '/Size: [0-9]+ GB/{s+=$2} /Size: [0-9]+ MB/{s+=$2/1024} END{printf "%.1f GB", s}')"; echo "RAM Type: $(echo "$dmi_mem" | awk -F': +' '/Type: DDR|Type: SDR/{if($2!="Unknown" && $2!=""){print $2; exit}}')"; echo "RAM Speed: $(echo "$dmi_mem" | awk -F': +' '/Speed: [0-9]+ MT/{print $2; exit}')"; echo "RAM ECC: $(echo "$dmi_mem" | awk -F': +' '/Error Correction Type/{if($2=="None")print "Non-ECC";else print "ECC"; exit}')"; echo "Motherboard: $(dmidecode -t baseboard 2>/dev/null | awk -F': +' '/Manufacturer:/{m=$2} /Product Name:/{p=$2} END{print m" "p}')"; else echo "RAM/Motherboard info: dmidecode not installed"; fi; echo -e '\n===== GPU Information =====\n'"$(lspci | grep -iE 'VGA|Display|3D controller' | grep -iv 'NVMe' | sed 's/^.*: //' || echo "No GPU detected")"'\n\n===== Disk Information =====\n'"$(lsblk -bdno NAME,SIZE,ROTA 2>/dev/null | awk 'BEGIN{printf "%-12s %-10s %-8s\n","DEVICE","SIZE","TYPE"} {type=($3==1?"HDD":"SSD/NVMe"); printf "%-12s %-10s %-8s\n", "/dev/"$1, sprintf("%.1f GB",$2/1000000000), type}')"'\n\n===== Detailed Disk Health & Age ====='; if ! command -v smartctl >/dev/null 2>&1; then echo "smartmontools not installed - disk health data unavailable"; else for d in $(lsblk -dno NAME,TYPE 2>/dev/null | awk '$2~/disk|nvme/{print $1}'); do echo -e "\n--- /dev/$d ---"; full_smart=$(smartctl -a /dev/$d 2>/dev/null); model=$(echo "$full_smart" | awk -F': +' '/Device Model|Model Number/{print $2; exit}'); [ -n "$model" ] && echo "Model: $model"; health=$(echo "$full_smart" | awk -F': +' '/SMART overall-health|SMART Health Status/{print $2; exit}'); echo "Health: ${health:-N/A}"; poh=$(echo "$full_smart" | awk '/Power_On_Hours|Power On Hours/{print $NF; exit}' | sed 's/,//g'); if [[ "$poh" =~ ^[0-9]+$ ]] && [ "$poh" -gt 0 ]; then echo "$poh" | awk '{gsub(/,/,"",$1); days=int($1/24); years=$1/24/365; printf "Power-On: %s hours (%d days / ~%.1f years)\n", $1, days, years}'; fi; pcc=$(echo "$full_smart" | awk '/Power_Cycle_Count|Power Cycles/{print $NF; exit}'); [ -n "$pcc" ] && echo "Power Cycles: $(echo $pcc | sed 's/,//g')"; temp=$(echo "$full_smart" | awk '/Temperature_Celsius/{print $10; exit} /Temperature:/{print $2; exit}'); [ -n "$temp" ] && echo "Temperature: ${temp}°C"; tbw=$(echo "$full_smart" | awk '/Data Units Written/{val=$(NF-1); gsub(/,/,"",val); if(val>0){tb=val*512000/1000000000000; printf "%.2f", tb; exit}}'); if [ -z "$tbw" ] || [ "$tbw" = "0.00" ]; then tbw=$(echo "$full_smart" | awk '/Total_LBAs_Written/{for(i=1;i<=NF;i++){if($i~/^[0-9]+$/ && $i>1000){lba=$i; tb=lba*512/1000000000000; printf "%.2f", tb; exit}}}'); fi; if [ -z "$tbw" ] || [ "$tbw" = "0.00" ]; then tbw=$(echo "$full_smart" | awk '/Host_Writes|Logical Sectors Written/{for(i=1;i<=NF;i++){if($i~/^[0-9,]+$/ && $i>1000){gsub(/,/,"",$i); val=$i; tb=val*512/1000000000000; printf "%.2f", tb; exit}}}'); fi; [ -n "$tbw" ] && [ "$tbw" != "0.00" ] && echo "Total Written: ${tbw} TB"; wear=$(echo "$full_smart" | awk '/Percentage Used/{print $NF; exit}' | sed 's/%//'); [ -n "$wear" ] && echo "Wear Level: ${wear}%"; realloc=$(echo "$full_smart" | awk '$2=="Reallocated_Sector_Ct"{print $NF; exit}'); [ -n "$realloc" ] && echo "Reallocated Sectors: $realloc"; pending=$(echo "$full_smart" | awk '$2=="Current_Pending_Sector"{print $NF; exit}'); [ -n "$pending" ] && echo "Pending Sectors: $pending"; offline=$(echo "$full_smart" | awk '$2=="Offline_Uncorrectable"{print $NF; exit}'); [ -n "$offline" ] && echo "Offline Uncorrectable: $offline"; done; fi; echo -e '\n===== OS Information =====\nOS: '"$(cat /etc/os-release 2>/dev/null | awk -F'=' '/^PRETTY_NAME/{gsub(/"/, "", $2); print $2}')"'\nKernel: '"$(uname -r)"'\nArchitecture: '"$(uname -m)"'\n'; if [ -n "$missing" ]; then echo -e "\n========================================\nWARNING: Missing packages: $missing"; echo "Install with: sudo apt install $missing # Debian/Ubuntu"; echo " or: sudo dnf install $missing # RHEL/Fedora"; fi
Advertisement
Add Comment
Please, Sign In to add comment