Last active
April 13, 2026 10:14
-
-
Save jjpeleato/99b8b098028b594b0b11f3e22973de60 to your computer and use it in GitHub Desktop.
Monitors and logs disk usage trends into a CSV file.
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 | |
| # | |
| # Monitors and logs disk usage trends into a CSV file. | |
| # Output is converted from KB to GB for better readability. | |
| # | |
| # Ideal for tracking long-term storage growth in VPS environments. | |
| # | |
| LOG_FILE="$HOME/storage-logger.csv" | |
| if [ ! -f $LOG_FILE ]; then | |
| echo "Date,Total (GB),Used (GB),Available (GB),Percentage" > $LOG_FILE | |
| fi | |
| STATS=$(df -k / | tail -1 | awk '{printf "%.2f,%.2f,%.2f,%s", $2/1024/1024, $3/1024/1024, $4/1024/1024, $5}') | |
| DATE=$(date '+%Y-%m-%d %H:%M') | |
| echo "$DATE,$STATS" >> $LOG_FILE | |
| exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment