Created
July 3, 2025 09:55
-
-
Save iketiunn/3e8f81dd6c10d14e1b32d80a8a6d208d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: ./sys_hw_info.sh [-s] | |
show_speed=false | |
while getopts ":s" opt; do | |
[[ $opt == "s" ]] && show_speed=true | |
done | |
cpu=$(lscpu 2>/dev/null | awk -F: '/^CPU\(s\)/ {gsub(/ /,"",$2); c=$2} /^Model name/ {m=$2} END {gsub(/^ +| +$/,"",m); print c "x " m}') | |
ram=$(free -h 2>/dev/null | awk '/^Mem:/ {print $2}') | |
disk=$(lsblk -d -o NAME,SIZE 2>/dev/null | awk 'NR>1 {printf "%s:%s ", $1,$2}') | |
os=$(grep '^PRETTY_NAME=' /etc/os-release 2>/dev/null | cut -d= -f2- | tr -d '"') | |
kernel=$(uname -r) | |
cgroup=$(stat -fc %T /sys/fs/cgroup 2>/dev/null || echo "unknown") | |
swap=$(swapon --noheadings --bytes 2>/dev/null | awk '{s+=$3} END {print s? s/1024/1024 "MB":"0MB"}') | |
load=$(uptime 2>/dev/null | awk -F'load average:' '{print $2}' | xargs) | |
echo "CPU: $cpu" | |
echo "RAM: $ram" | |
echo "Disk: $disk" | |
echo "OS: $os" | |
echo "Kernel: $kernel" | |
echo "Cgroup: $cgroup" | |
echo "Swap: $swap" | |
echo "Load Avg:$load" | |
# Network speeds | |
nets=$(ls /sys/class/net 2>/dev/null | grep -v lo) | |
echo -n "Net: " | |
for i in $nets; do | |
spd="" | |
if command -v ethtool >/dev/null 2>&1 && ethtool $i &>/dev/null; then | |
spd=$(ethtool $i 2>/dev/null | awk -F: '/Speed:/ {print $2}' | xargs) | |
elif command -v iwconfig >/dev/null 2>&1 && iwconfig $i &>/dev/null; then | |
spd=$(iwconfig $i 2>/dev/null | awk -F: '/Bit Rate=/ {print $2}' | awk '{print $1 $2}') | |
fi | |
echo -n "$i($spd) " | |
done | |
echo | |
if $show_speed && command -v curl >/dev/null 2>&1; then | |
echo "Speed Test:" | |
curl -o /dev/null -s -w "Download: %.2f Mbps\n" https://speed.hetzner.de/10MB.bin | awk '{print $1, $2, $3, $4*8/1000000}' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment