Skip to content

Instantly share code, notes, and snippets.

@egulhan
Last active May 3, 2023 19:24
Show Gist options
  • Save egulhan/61c41558fc523a8c7d7fb4603b772f3b to your computer and use it in GitHub Desktop.
Save egulhan/61c41558fc523a8c7d7fb4603b772f3b to your computer and use it in GitHub Desktop.
echos memory, disk and cpu usage
printf "Memory\t\tDisk\t\tCPU\n"
MEMORY=$(free -m | awk 'NR==2{printf "%.2f%%\t\t", $3*100/$2 }')
DISK=$(df -h | awk '$NF=="/"{printf "%s\t\t", $5}')
CPU=$(top -bn1 | grep load | awk '{printf "%.2f%%\t\t\n", $(NF-2)}')
echo "$MEMORY\t$DISK\t$CPU"
watch -n5 stats.sh >> stats.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment