Skip to content

SnapDisk — a lightweight Java Swing app that records daily disk-space snapshots to PostgreSQL and visualizes used-space trends.

Notifications You must be signed in to change notification settings

emmanuelekopimo/snapdisk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SnapDisk

SnapDisk is a small Java 21 Swing desktop app that takes one daily snapshot of disk space, stores timestamped records in PostgreSQL, and shows a table + a simple chart of used space over time.

Screenshot

image

Project layout

  • src/ — Java source (packages: com.snapdisk.app, db, dao, model, util, tools)
  • lib/ — third-party jars (Postgres JDBC, optional JFreeChart)
  • bin/ — compiled classes (output)
  • schema.sql — example DB schema

Dependencies

  • Java 21
  • PostgreSQL JDBC driver (place postgresql-*.jar in lib/)
  • JFreeChart jars are optional (put them in lib/ if you want advanced charting)

Build

Compile all sources from the project root (handles spaces in the path):

mapfile -t JAVA_FILES < <(find src -name '*.java' -print0 | xargs -0 -n1 echo)
javac -d bin -sourcepath src -cp "lib/*" "${JAVA_FILES[@]}"

Run

  • Quick launcher (preferred):
java -cp "bin:lib/*" com.snapdisk.app.Launcher
  • Or use the helper script that compiles and runs with --no-db support:
./run.sh --no-db    # shows UI with sample data

DB setup (recommended)

Run these commands as a Postgres superuser to create the role, database and table used by the app. Adjust passwords as needed.

# create role
psql -U postgres -c "CREATE ROLE snapdisk_user LOGIN PASSWORD 'password';" || true

# create database owned by role
psql -U postgres -c "CREATE DATABASE snapdisk OWNER snapdisk_user;" || true

# create table and grant privileges
psql -U postgres -d snapdisk <<'SQL'
CREATE TABLE IF NOT EXISTS public.disk_snapshots (
	id SERIAL PRIMARY KEY,
	snapshot_date DATE NOT NULL UNIQUE,
	snapshot_time TIME NOT NULL,
	total_space BIGINT NOT NULL,
	free_space BIGINT NOT NULL,
	used_space BIGINT NOT NULL
);
ALTER TABLE public.disk_snapshots OWNER TO snapdisk_user;
GRANT USAGE, CREATE ON SCHEMA public TO snapdisk_user;
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE public.disk_snapshots TO snapdisk_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO snapdisk_user;
SQL

Notes:

  • The project currently contains hardcoded DB credentials in src/com/snapdisk/db/Database.java. Change them before production use.

Tools

  • Populate history (backfill recent days):
java -cp "bin:lib/*" com.snapdisk.tools.PopulateHistory 14

Features

  • Automatic one-per-day snapshot on app start (saves total/free/used bytes)
  • Table of snapshots (read-only)
  • Chart plotting used space as percent of total (start & end labels only)
  • Buttons: Clear Data (delete all DB rows) and Export PNG (save chart image)

Troubleshooting

  • If the app reports schema/permission errors, run the DB setup SQL above as a superuser.
  • If you prefer to try the UI without a DB, use ./run.sh --no-db or set SNAPDISK_NO_DB=true.

Next steps

  • Improve persistence config (remove hardcoded credentials)
  • Add scheduled snapshot (OS cron / systemd timer)
  • Add export CSV and unit tests

Enjoy — open an issue or edit files if you want changes.

About

SnapDisk — a lightweight Java Swing app that records daily disk-space snapshots to PostgreSQL and visualizes used-space trends.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages