Skip to content

Instantly share code, notes, and snippets.

@lpradovera
Created February 24, 2022 20:27
Show Gist options
  • Save lpradovera/08c3779bdd9696a80a04888ca6e12434 to your computer and use it in GitHub Desktop.
Save lpradovera/08c3779bdd9696a80a04888ca6e12434 to your computer and use it in GitHub Desktop.
Simple monitoring script
end=$((SECONDS+3600))
while [ $SECONDS -lt $end ]; do
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$DISK$CPU"
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment