~kris/dots

srice

ref: 9f828eb14bdd54d2c4fd8a3b2c90253021df3152 srice/.local/bin/sysinfo -rwxr-xr-x 882 bytes
9f828eb1 — Kris Yotam mksh: backslash-escape commands in history hook to bypass module aliases (wc=tokei, tr=transmission-remote, cat=bat) 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
# sysinfo -- quick system overview
set -eu

printf "%-12s %s\n" "Hostname:" "$(hostname)"
printf "%-12s %s\n" "Kernel:" "$(uname -r)"
printf "%-12s %s\n" "Uptime:" "$(uptime -p 2>/dev/null || uptime | awk '{print $3,$4}')"
printf "%-12s %s cores\n" "CPU:" "$(nproc)"
printf "%-12s %s\n" "Memory:" "$(free -h | awk '/Mem:/ {print $3 "/" $2}')"
printf "%-12s %s\n" "Disk /:" "$(df -h / | awk 'NR==2 {print $3 "/" $2 " (" $5 ")"}')"
printf "%-12s %s\n" "Load:" "$(cut -d' ' -f1-3 /proc/loadavg 2>/dev/null || sysctl -n vm.loadavg 2>/dev/null || echo 'N/A')"

# Network
if command -v ip >/dev/null 2>&1; then
    printf "%-12s %s\n" "IP:" "$(ip route get 1.1.1.1 2>/dev/null | awk '{print $7; exit}')"
fi

# Tailscale
if command -v tailscale >/dev/null 2>&1; then
    tsip=$(tailscale ip -4 2>/dev/null || echo "not connected")
    printf "%-12s %s\n" "Tailscale:" "$tsip"
fi