Disk Space Tracker is a Bash script that checks disk space in bytes, writes the information to an HTML table, and appends the data to the table in an HTML file every time it's run.
No special requirements are needed to run this script, but it is helpful to have git installed to download all the related code for Linux Disk Space Tracker.
Once the software is downloaded or pulled via git, run the script:
sh disk-space-tracker.sh
This Bash script performs the following tasks:
- It defines the path to a CSV file named
disk_space.csv. - It gets the current date and time and stores them in the variables
current_dateandcurrent_time. - It calculates the amount of disk space used in bytes by running the
dfcommand and extracting theusedcolumn value for the root directory (/). The result is stored in thedisk_space_usedvariable. - It checks if the CSV file (
disk_space.csv) exists. If it does not exist, it creates the file and adds a header line with the column names:date,time,andused_disk_space_bytes. - It appends the current date, time, and the calculated disk space usage to the CSV file, creating a new row with this data.
- It logs verbose output to a local
logging.txtfile, including the start time, collected disk space information, and the script's finish time. - Finally, it prints a message to the console indicating that disk space information has been collected and logged to the
disk_space.csvfile.
Overall, this script is designed to collect disk space usage information for the root directory, store it in a CSV file, and create a log file with detailed information about the process. It provides a basic form of system monitoring and record-keeping for disk space usage.
- What is the app for?
- Anyone looking to track and log disk space utilization over time due to system updates, software installations, regular use, and/or data hoarding.
- What was your motivation?
- Working on a gaming project called Crossfire, I was creating docs on how to install the game client. Given the game client can run IoT devices where disk space can be a premium, I wanted to show and track how much disk space is necessary for downloading source code and install dependencies for each step. This way the user can see and plan accordingly for installing the client.
- What problem does it solve?
- I think this helps with planning and avoiding a problem of running out of available disk space, or during the purchase and build process not getting a SSD with enough capacity to run the OS and other desired applications.
No special requirements beyond a working Linux installation is required.
Sample screen output when running the shell command:
$ sh disk-space-tracker.sh
Disk space information collected and logged to disk_space.csv.
$ cat disk_space.csv
date,time,used_disk_space_bytes
2023-11-29,00:38:58,1317849496
$ sh disk-space-tracker.sh
Disk space information collected and logged to disk_space.csv.
$ cat disk_space.csv
date,time,used_disk_space_bytes
2023-11-29,00:38:58,1317849496
2023-11-29,00:50:58,1317850460
- Contributions are welcome.
- Pull requests are welcome.
- Creating a fork on this code base is also welcome.
I can be reached via tannerrj GitHub Profile
MIT License